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

class VipCenterTipDialog extends StatelessWidget {
  /// 点击了关闭
  void _onClickClose(BuildContext context) {
    Navigator.pop(context);
  }

  /// 点击了继续完成任务
  void _onClickContinue(){
    Logger.log('continue  ....');
  }

  /// 我再想想
  void _onClickGuess(){
    Logger.log('我再想想');
  }

  /// 立即成为会员
  void _onClickBecome(){
    Logger.log('立即成为');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Container(
            width: double.infinity,
            margin: const EdgeInsets.only(left: 22.5, right: 22.5),
            padding: const EdgeInsets.only(top: 15, right: 15, left: 15, bottom: 20),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(10),
              color: HexColor.fromHex('#FFFFFF'),
            ),
            child: Column(
              children: <Widget>[
                /// 关闭按钮
                Align(
                    alignment: Alignment.topRight,
                    child: GestureDetector(behavior: HitTestBehavior.opaque, onTap: () => _onClickClose(context), child: Container(height: 22, width: 22, color: Colors.red))),
                const SizedBox(height: 3),
                Text('升级会员提示', style: TextStyle(color: HexColor.fromHex('#333333'), fontSize: 18, fontWeight: FontWeight.bold)),
                const SizedBox(height: 15),
                Padding(
                  padding: const EdgeInsets.only(left: 55 - 15.0, right: 55 - 15.0),
                  child: Text(
                    '由于您还未达到成免费条件,可以选择缴费成为会员,立即享受会员权益.',
                    maxLines: 5,
                    style: TextStyle(
                      color: HexColor.fromHex('#666666'),
                      fontSize: 16,
                    ),
                  ),
                ),
                const SizedBox(height: 30),

                /// 继续完成的按钮
                Visibility(
                  visible: false,
                  replacement: Row(
                    children: <Widget>[
                      Flexible(
                        flex: 1,
                        child: _buildGuessButtonWidget(),
                      ),
                      const SizedBox(width: 11),
                      Flexible(
                        flex: 1,
                        child: _buildBecomeButtonWidget(),
                      ),
                    ],
                  ),
                  child: _buildContinueButtonWidget(),
                ),

              ],
            ),
          ),
        ],
      ),
    );
  }

  /// 我再想想按钮
  Widget _buildGuessButtonWidget(){
    return _buildButtonWidget(
      text: '我再想想',
      textColor: '#999999',
      bgColor: null,
      marginLeft: 45.5-15,
      onTap:_onClickGuess,
    );
  }

  /// 立即成为会员按钮
  Widget _buildBecomeButtonWidget(){
    return _buildButtonWidget(
      text: '立即成为会员',
      textColor: '#FFFFFF',
      bgColor: null,
      marginRight: 36.5-15,
      onTap:_onClickBecome,
    );
  }

  /// 继续完成的按钮
  Widget _buildContinueButtonWidget(){
    return  _buildButtonWidget(
        text: '继续完成任务',
        textColor: '#FFFFFF',
        bgColor: null,
        marginLeft: 42.5 - 15,
        marginRight: 34 - 15.0,
        onTap: _onClickContinue
    );
  }



  Widget _buildButtonWidget({String text, String textColor, String bgColor, GestureTapCallback onTap,final double marginLeft,final double marginRight}){
   return GestureDetector(
     onTap: onTap,
     behavior: HitTestBehavior.opaque,
     child: Container(
       decoration: BoxDecoration(
           color: HexColor.fromHex(bgColor ??  '#FF4242'),
           borderRadius: BorderRadius.circular(45/2)
       ),
       alignment: Alignment.center,
       width: double.infinity,
       height: 44.5,
       margin: EdgeInsets.only(left: marginLeft ?? 0 , right: marginRight ?? 0 ),
       child: Text(text ?? '', style: TextStyle(color: HexColor.fromHex(textColor ?? '#FFFFFF'), fontSize: 14,),),
     ),
   );
  }

}
