import 'package:flutter/material.dart';
import 'package:netrain_flutter_app/common/AppColors.dart';
import 'package:netrain_flutter_app/common/Images.dart';

/**
 * @author xuehao
 * on 2021/7/14
 */
class BottomNavPage extends StatefulWidget {
  BottomNavPage({Key key}) : super(key: key);

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

class _BottomNavPageState extends State<BottomNavPage> {
  int _index = 0;

  @override
  Widget build(BuildContext context) {
    List<BottomNavigationBarItem> _bottomNavigationbar = [
      BottomNavigationBarItem(
        title: Text("工作站"),
        icon: Image.asset(Images.ic_bottom_01),
      ),
      BottomNavigationBarItem(
        title: Text("消息"),
        icon: Image.asset(Images.ic_bottom_02),
      ),
      BottomNavigationBarItem(
        //显示的字样
        title: Text("我的"),
        //未选中时的图片
        icon: Image.asset(Images.ic_bottom_03),
        //选中后的图片
        activeIcon: Image.asset(Images.ic_bottom_03_true),
      ),
    ];

    List<Widget> _widgetItems = [
      HomePage(),
      MsgPage(),
      UserCenter(),
    ];

    return new MaterialApp(
      title: "bottom_page",
      home: Scaffold(
          bottomNavigationBar: BottomNavigationBar(
            items: _bottomNavigationbar,
            type: BottomNavigationBarType.fixed,
            currentIndex: _index,
            onTap: (index) {
              _changePage(index);
            },
          ),
          body: _widgetItems[_index]),
    );
  }

  _changePage(int index) {
    setState(() {
      _index = index;
    });
  }
}

class HomePage extends StatefulWidget {
  HomePage({Key key}) : super(key: key);

  @override
  _HomePageState createState() {
    return _HomePageState();
  }
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        backgroundColor: Color(AppColors.blue_bg_color),
        title: Text(
          "基本信息",
          style: TextStyle(
            fontSize: 16,
          ),
        ),
        centerTitle: true,
        leading: GestureDetector(
          onTap: () {
            Navigator.pop(context);
          },
          child: Icon(Icons.arrow_back_ios),
        ),
        actions: [
          Container(
            margin: EdgeInsets.fromLTRB(0, 0, 10, 0),
            alignment: Alignment.centerRight,
            child: Text(
              "稍后提交",
              textAlign: TextAlign.center,
            ),
          )
        ],
      ),
      body: new Column(children: [
        Container(
          height: 80,
          color: Color(AppColors.blue_bg_color),
          child: Column(
            children: [
              Spacer(),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  SizedBox(width: 54),
                  Container(
                    alignment: Alignment.center,
                    height: 22,
                    width: 22,
                    child: Text(
                      "1",
                      style: TextStyle(color: Color(AppColors.blue_bg_color)),
                    ),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(11.0),
                      color: Colors.white,
                    ),
                  ),
                  Spacer(),
                  Container(
                    alignment: Alignment.center,
                    height: 22,
                    width: 22,
                    child: Text(
                      "2",
                      style: TextStyle(color: Color(AppColors.blue_bg_color)),
                    ),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(11.0),
                      color: Color(AppColors.white_transparent_50),
                    ),
                  ),
                  Spacer(),
                  Container(
                    alignment: Alignment.center,
                    height: 22,
                    width: 22,
                    child: Text(
                      "3",
                      style: TextStyle(color: Color(AppColors.blue_bg_color)),
                    ),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(11.0),
                      color: Color(AppColors.white_transparent_50),
                    ),
                  ),
                  SizedBox(width: 54),
                ],
              ),
              SizedBox(height: 8),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  SizedBox(width: 41),
                  Text(
                    "基本信息",
                    style: TextStyle(color: Colors.white, fontSize: 12),
                  ),
                  Spacer(),
                  Text(
                    "提交证件",
                    style: TextStyle(
                        color: Color(AppColors.white_transparent_50),
                        fontSize: 12),
                  ),
                  Spacer(),
                  Text(
                    "审核完毕",
                    style: TextStyle(
                        color: Color(AppColors.white_transparent_50),
                        fontSize: 12),
                  ),
                  SizedBox(width: 41),
                ],
              ),
              Spacer(),
            ],
          ),
        ),
        Container(
          margin: EdgeInsets.all(16),
          padding: EdgeInsets.fromLTRB(0, 0, 0, 16),
          decoration: BoxDecoration(
            color: Color(AppColors.blue_bg_color2),
            borderRadius: BorderRadius.circular(4.0),
          ),
          child: Column(
            children: [
              Container(
                child: Text(
                  "您完成所有认证资料，并完成互联网医院认证备案后，杏联医生工作室将为您提供以下功能:",
                  style: TextStyle(
                      fontSize: 12, color: Color(AppColors.text_default_color)),
                ),
                margin: EdgeInsets.all(10),
              ),
              Row(
                children: <Widget>[
                  Expanded(
                    child: Container(
                      padding: EdgeInsets.fromLTRB(20, 0, 20, 0),
                      child: Row(
                        children: [
                          Column(
                            children: [
                              Text(
                                "邀请患者",
                                style: TextStyle(
                                    fontSize: 16,
                                    color: Color(AppColors.EditTextColor),
                                    fontWeight: FontWeight.bold),
                              ),
                              Text(
                                "专属二维码",
                                style: TextStyle(
                                    color: Color(AppColors.text_default_color),
                                    fontSize: 12
                                ),
                              )
                            ],
                          ),
                          SizedBox(width: 16),
                          Image.asset(Images.ic_friend)
                        ],
                      ),
                    ),
                    flex: 1,
                  ),
                  Expanded(
                    child: Container(
                      child: Row(
                        children: [
                          Column(
                            children: [
                              Text(
                                "电子处方权",
                                style: TextStyle(
                                    fontSize: 16,
                                    color: Color(AppColors.EditTextColor),
                                    fontWeight: FontWeight.bold),
                              ),
                              Text(
                                "建立自己的诊室",
                                style: TextStyle(
                                    color: Color(AppColors.text_default_color),
                                    fontSize: 12
                                ),
                              )
                            ],
                          ),
                          SizedBox(width: 16),
                          Image.asset(Images.ic_prescription_home)
                        ],
                      ),
                    ),
                    flex: 1,
                  ),
                ],
              ),
            ],
          ),
        )
      ]),
    );
  }
}

class MsgPage extends StatefulWidget {
  MsgPage({Key key}) : super(key: key);

  @override
  _MsgPageState createState() {
    return _MsgPageState();
  }
}

class _MsgPageState extends State<MsgPage> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text("消息"),
    );
  }
}

class UserCenter extends StatefulWidget {
  UserCenter({Key key}) : super(key: key);

  @override
  _UserCenterState createState() {
    return _UserCenterState();
  }
}

class _UserCenterState extends State<UserCenter> {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text("个人中心"),
    );
  }
}
