import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart';

// 微信导师
class WechatTeacherPage extends StatefulWidget {
  @override
  _WechatTeacherPageState createState() => _WechatTeacherPageState();
}

class _WechatTeacherPageState extends State<WechatTeacherPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: _createNav(),
      body: SafeArea(
        child: SingleChildScrollView(
          child: Column(
            children: <Widget>[
              _createHeader(),
              _createWechat(),
            ],
          ),
        ),
      ),
    );
  }

  // 导航栏
  Widget _createNav() {
    return CupertinoNavigationBar(
      border: Border(
        bottom: BorderSide(
          width: 0.0, // One physical pixel.
          style: BorderStyle.none,
        ),
      ),
      backgroundColor: Colors.white,
      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),
        ),
      ),
    );
  }

  Widget _createHeader() {
    return Container(
      width: double.infinity,
      height: 283,
      child: Stack(
        children: <Widget>[
          Container(
            width: double.infinity,
            height: 185,
            color: Colors.redAccent,
          ),
          Align(
            alignment: Alignment.bottomCenter,
            child: Container(
              width: double.infinity,
              height: 138,
              margin: EdgeInsets.only(left: 10, right: 10),
              padding: EdgeInsets.all(12),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(10),
              ),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '我的导师',
                    style: TextStyle(
                      fontWeight: FontWeight.bold,
                      fontSize: 15,
                      color: Color(0xff333333),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.only(top: 8, bottom: 2),
                    child: CupertinoTextField(
                      placeholder: '请填写邀请人邀请码/手机号码',
                      placeholderStyle: TextStyle(fontSize: 14),
                      decoration: BoxDecoration(),
                    ),
                  ),
                  Container(
                    height: 0.5,
                    color: Color(0xffd5d5d5),
                  ),
                  Center(
                    child: Container(
                      margin: EdgeInsets.only(top: 10),
                      width: 130,
                      height: 30,
                      decoration: BoxDecoration(
                          color: Colors.redAccent,
                          borderRadius: BorderRadius.circular(15)),
                      child: Center(
                        child: Text(
                          '绑定邀请人',
                          style: TextStyle(color: Colors.white, fontSize: 14),
                        ),
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }

  Widget _createWechat() {
    return Container(
      width: double.infinity,
      margin: EdgeInsets.only(left: 10, right: 10, top: 15),
      padding: EdgeInsets.all(12),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(10),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text(
            '官方微信',
            style: TextStyle(
              fontSize: 15,
              fontWeight: FontWeight.bold,
            ),
          ),
          WechatTeachetItem(),
          Container(
            margin: EdgeInsets.only(top: 4, bottom: 4),
            width: double.infinity,
            height: 0.5,
            color: Color(0xffebebeb),
          ),
          WechatTeachetItem(),
        ],
      ),
    );
  }
}
