import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/favorites_page/model/favorites_style_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class FavoritesDialogWidget extends StatelessWidget {
  ConfirmDialog styleModel;

  FavoritesDialogWidget({@required this.styleModel});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Container(
            width: double.infinity,
            padding: const EdgeInsets.only(top: 30, left: 17, right: 17, bottom: 12.5),
            decoration: BoxDecoration(color: HexColor.fromHex(styleModel?.bgColor ?? '#FFFFFF'), borderRadius: BorderRadius.circular(8)),
            margin: EdgeInsets.only(left: 46, right: 46),
            child: Column(
              children: <Widget>[
                /// 标题
                Text(styleModel?.bgText ?? '', style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold, color: HexColor.fromHex(styleModel?.bgTextColor ?? '#333333'))),
                const SizedBox(height: 44),
                Row(
                  children: <Widget>[
                    Flexible(flex: 1, child: _buildCustomerButtonWidget(
                      text: styleModel?.leftText ?? '我在想想',
                      textColor:styleModel?.leftTextColor ?? '#FF4242',
                      bgColor: styleModel?.leftBtnBgColor ?? '#FFFFFF',
                      borderColor: styleModel?.leftTextColor ?? '#FF4242',
                      callback: ()=> Navigator.maybePop(context, 0),
                    )),
                    const SizedBox(width: 14),
                    Flexible(flex: 1, child: _buildCustomerButtonWidget(
                      text: styleModel?.rightText ?? '确认删除',
                      textColor: styleModel?.rightTextColor ?? '#FFFFFF',
                      borderColor: styleModel?.rightTextColor ?? '#FFFFFF',
                      bgColor: styleModel?.rightBtnBgColor ?? '#FF4242',
                      callback: ()=> Navigator.maybePop(context, 1),
                    )),
                  ],
                )
              ],
            ),
          )
        ],
      ),
    );
  }

  Widget _buildCustomerButtonWidget({String text, String textColor, String bgColor, String borderColor,GestureTapCallback callback, double height = 30}) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: callback,
      child: Container(
        alignment: Alignment.center,
        height: height,
        width: double.infinity,
        decoration: BoxDecoration(
          color: HexColor.fromHex(bgColor),
          borderRadius: BorderRadius.circular(height / 2),
          border: Border.all(color: HexColor.fromHex(borderColor), width: 0.5),
        ),
        child: Text(
          text ?? '',
          style: TextStyle(color: HexColor.fromHex(textColor), fontSize: 13),
        ),
      ),
    );
  }
}
