Newer
Older
flutterBaseApp / lib / ui / widgets / common / dialog / select_item_dialog_widget.dart
StephanieGitHub on 9 Feb 2021 2 KB first commit
import 'package:base_app/res/index.dart';
import 'package:base_app/ui/widgets/common/button/round_button_widget.dart';
import 'package:flutter/material.dart';

// 两个选择弹窗(选择事件类型,选择查询类型用)
class SelectItemDialog extends Dialog {
  final String title; // 标题
  final String btn1Text; // 第一个按钮文字
  final String btn2Text; // 第二个按钮文字
  final VoidCallback btn1OnPressed; // 第一个按钮点击回调
  final VoidCallback btn2OnPressed; // 第二个按钮点击回调

  SelectItemDialog(this.title,
      {Key key,
      @required this.btn1Text,
      @required this.btn2Text,
      @required this.btn1OnPressed,
      @required this.btn2OnPressed})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return new GestureDetector(
        onTap: () {
          Navigator.pop(context);
        },
        child: Material(
          type: MaterialType.transparency,
          child: new Center(
            child: new SizedBox(
              width: 220.0,
              height: 220.0,
              child: new Container(
                padding: EdgeInsets.symmetric(horizontal: 30, vertical: 10),
                decoration: ShapeDecoration(
                  color: Color(0xffffffff),
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.all(
                      Radius.circular(8.0),
                    ),
                  ),
                ),
                child: new Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Text(
                      title,
                      style:
                          TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                    ),
                    Gaps.vGap15,
                    new RoundButton(
                        radius: 8.0,
                        text: "$btn1Text",
                        onPressed: () => btn1OnPressed()),
                    Gaps.vGap10,
                    new RoundButton(
                        radius: 8.0,
                        text: "$btn2Text",
                        onPressed: () => btn2OnPressed()),
                  ],
                ),
              ),
            ),
          ),
        ));
  }
}