import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/withdraw_page/bloc/withdraw_bloc.dart';
import 'package:zhiying_comm/util/base_bloc.dart';

/*提现页面*/
class WithdrawPage extends StatefulWidget {
  final Map<String, dynamic> data;

  const WithdrawPage(this.data, {Key key}) : super(key: key);

  @override
  _WithdrawPageState createState() => _WithdrawPageState();
}

class _WithdrawPageState extends State<WithdrawPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: _createNav(),
      body: SafeArea(
        child: BlocProvider<WithdrawBloc>(
          bloc: WithdrawBloc(),
          child: _WithdrawContainer(widget.data),
        ),
      ),
    );
  }

  // 导航栏
  Widget _createNav() {
    return CupertinoNavigationBar(
      leading: Navigator.canPop(context)
          ? GestureDetector(
              child: Container(
                padding: EdgeInsets.zero,
                child: Icon(
                  Icons.arrow_back_ios,
                  size: 20,
                ),
              ),
              onTap: () {
                if (Navigator.canPop(context)) {
                  Navigator.pop(context);
                }
              },
            )
          : Container(),
      middle: Text(
        '提现',
        style: TextStyle(
          fontSize: 15,
          color: Color(0xff333333),
        ),
      ),
      trailing: GestureDetector(
        child: Text(
          '明细',
          style: TextStyle(fontSize: 13, color: Color(0xff333333)),
        ),
        onTap: () {},
      ),
    );
  }
}

class _WithdrawContainer extends StatefulWidget {
  final Map<String, dynamic> data;

  const _WithdrawContainer(this.data, {Key key}) : super(key: key);

  @override
  _WithdrawContainerState createState() => _WithdrawContainerState();
}

class _WithdrawContainerState extends State<_WithdrawContainer> {
  WithdrawBloc _bloc;

  @override
  void initState() {
    _bloc = BlocProvider.of<WithdrawBloc>(context);
    if (widget.data.containsKey('skip_identifier')) {
      _bloc.loadData(widget.data['skip_identifier']);
    }
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      child: Column(
        children: <Widget>[],
      ),
    );
  }
}