import 'package:flutter/material.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

///
/// 我的团队 - 粉丝信息
///
class TeamFansItem extends StatefulWidget {
  @override
  _TeamFansItemState createState() => _TeamFansItemState();
}

class _TeamFansItemState extends State<TeamFansItem> {
  @override
  Widget build(BuildContext context) {
    return _getMainWidget();
  }

  /// 主体视图
  Widget _getMainWidget() {
    return Container(
      decoration: BoxDecoration(color: HexColor.fromHex('#FFFFFF'), borderRadius: BorderRadius.circular(10)),
      margin: const EdgeInsets.only(left: 12.5, right: 12.5),
      padding: const EdgeInsets.only(left: 20, right: 20, top: 17.5, bottom: 15),
      child: Column(
        children: <Widget>[
          // 粉丝头像信息等
          _getFansInfoWidget(),
          // 微信号码
          _getWXNumberInfoWidget(),
          // 数据信息
          _getDataWidget(),
        ],
      ),
    );
  }

  /// 粉丝头像信息等
  Widget _getFansInfoWidget() {
    return Row(
      children: <Widget>[
        /// 头像
        Container(width: 50, height: 50, color: Colors.red),
        const SizedBox(width: 10),

        /// 信息
        Column(
          children: <Widget>[
            /// 会员等级 关系 昵称
            RichText(
              text: TextSpan(text: '', children: [
                /// 等级
                WidgetSpan(child: Container(width: 37, height: 13, color: Colors.red)),

                /// 会员关系
                WidgetSpan(child: Container(width: 13, height: 13, color: Colors.red, margin: const EdgeInsets.only(left: 3, right: 3))),

                /// 会员名称
                TextSpan(text: '温***哥', style: TextStyle(color: HexColor.fromHex('#333333'), fontSize: 12, fontWeight: FontWeight.bold))
              ]),
            ),

            /// 手机号码
            RichText(
              text: TextSpan(text: '', children: [
                /// 手机号码
                TextSpan(text: '手机号：', style: TextStyle(color: HexColor.fromHex('#333333'), fontSize: 11)),
                TextSpan(text: '124****6124', style: TextStyle(color: HexColor.fromHex('#333333'), fontSize: 11, fontFamily: 'Din', package: 'zhiying_base_widget')),

                /// 复制按钮
                WidgetSpan(child: Container(width: 11, height: 11, color: Colors.red, margin: const EdgeInsets.only(left: 3)))
              ]),
            ),
          ],
        )
      ],
    );
  }

  /// 微信号码信息
  Widget _getWXNumberInfoWidget() {
    return Container(
      padding: const EdgeInsets.only(left: 9, right: 10, bottom: 6.5, top: 6.5),
      decoration: BoxDecoration(
        color: HexColor.fromHex('#F7F7F7'),
        borderRadius: BorderRadius.circular(10),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          /// 微信号码
          RichText(
            text: TextSpan(text: '微信号:', style: TextStyle(color: HexColor.fromHex('#999999'), fontSize: 11, fontWeight: FontWeight.bold), children: [
              TextSpan(
                  text: '54A78',
                  style: TextStyle(fontWeight: FontWeight.bold, color: HexColor.fromHex('#333333'), fontSize: 11, fontFamily: 'Din', package: 'zhiying_base_widget')),
              WidgetSpan(child: Container(margin: const EdgeInsets.only(left: 5.5), color: Colors.red, width: 11, height: 11))
            ]),
          ),

          /// 最近登陆时间
          Text('最近登陆 2019-06-28', style: TextStyle(color: HexColor.fromHex('#909090'), fontSize: 11, fontFamily: 'Din', package: 'zhiying_base_widget'))
        ],
      ),
    );
  }

  /// 数据信息
  Widget _getDataWidget() {
    return Row(
      children: <Widget>[
        /// 左边数据
        Column(
          children: <Widget>[
            /// 邀请人数(人)
            _getCustomWidget(
              text: '邀请人数(人)',
              textColor: '#333333',
              textSize: 10,
              number: '1578',
              numberColor: '#FF4242',
              numberSize: 20,
            ),

            /// 今日邀请 & 本月邀请
            Row(
              children: <Widget>[
                /// 今日邀请
                _getCustomWidget(
                  text: '今日邀请',
                  textColor: '#909090',
                  textSize: 10,
                  number: '3258',
                  numberColor: '#333333',
                  numberSize: 15,
                ),

                /// 本月邀请
                _getCustomWidget(
                  text: '本月邀请',
                  textColor: '#909090',
                  textSize: 10,
                  number: '3258',
                  numberColor: '#333333',
                  numberSize: 15,
                ),
              ],
            )
          ],
        ),

        /// 分割线
        VerticalDivider(width: 65.5, thickness: 0.5),

        /// 右边数据
        Column(
          children: <Widget>[
            /// 累计收益(¥)
            _getCustomWidget(
              text: '累计收益(¥)',
              textColor: '#333333',
              textSize: 10,
              number: '157.54',
              numberColor: '#FF4242',
              numberSize: 20,
            ),

            /// 近7天收益 & 本月收益
            Row(
              children: <Widget>[
                /// 今日邀请
                _getCustomWidget(
                  text: '近7天收益',
                  textColor: '#909090',
                  textSize: 10,
                  number: '4.12',
                  numberColor: '#333333',
                  numberSize: 15,
                ),

                /// 本月邀请
                _getCustomWidget(
                  text: '本月收益',
                  textColor: '#909090',
                  textSize: 10,
                  number: '528.14',
                  numberColor: '#333333',
                  numberSize: 15,
                ),
              ],
            )
          ],
        )
      ],
    );
  }

  /// 自定义Widget(数字加粗)
  Widget _getCustomWidget({String text, String textColor, double textSize, String number, String numberColor, double numberSize, String icon}) {
    return Column(
      children: <Widget>[
        /// Number
        Row(
          children: <Widget>[
            /// nummber\
            Text(number,
                style: TextStyle(color: HexColor.fromHex(numberColor), fontSize: numberSize, fontWeight: FontWeight.bold, fontFamily: 'Din', package: 'zhiying_base_widget')),
            const SizedBox(width: 3),

            /// icon
            Visibility(visible: !EmptyUtil.isEmpty(icon), child: Container(height: 7, width: 5, color: Colors.red))
          ],
        ),

        /// Text
        Text(text, style: TextStyle(color: HexColor.fromHex(textColor), fontSize: textSize))
      ],
    );
  }
}
