normal_dialog.dart
4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../common/colors.dart';
import '../../utils/text_style_ms.dart';
class NormalDialog extends StatelessWidget {
final String title;
final String content;
final String cancelBtnText;
final String okBtnText;
final VoidCallback? okOnClick;
final VoidCallback? cancelOnClick;
final bool showCancelBtn;
final bool showOkBtn;
const NormalDialog({
Key? key,
this.title = 'hint',
this.content = '',
this.okOnClick,
this.cancelOnClick,
this.showCancelBtn = true,
this.showOkBtn = true,
this.cancelBtnText = 'cancel',
this.okBtnText = 'sure',
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Dialog(
insetPadding: EdgeInsets.zero,
backgroundColor: ColorConfig.red.withOpacity(0),
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 34),
padding: const EdgeInsets.only(top: 30),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: ColorConfig.white,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Text(
title,
style: const TextStyle(
color: ColorConfig.color33,
fontSize: 18,
fontWeight: FontWeight.w500,
),
),
),
Container(
padding: const EdgeInsets.only(
top: 27, bottom: 44, left: 10, right: 10),
alignment: Alignment.center,
width: double.infinity,
child: Text(
content,
textAlign: TextAlign.center,
style: TextStyleMs.color33_14_400.copyWith(height: 2.0),
),
),
Container(
height: 52,
width: double.infinity,
margin: const EdgeInsets.symmetric(horizontal: 12),
decoration: const BoxDecoration(
border: Border(
top: BorderSide(color: ColorConfig.colorF7F7F7, width: 1),
),
),
child: Row(
children: [
showCancelBtn
? Expanded(
child: InkWell(
onTap: () {
Get.back(result: false);
if (cancelOnClick != null) {
cancelOnClick!();
}
},
child: Container(
child: Text(
cancelBtnText.tr,
style: TextStyleMs.color33_14_400,
),
alignment: Alignment.center,
margin: const EdgeInsets.symmetric(vertical: 6),
decoration: showOkBtn
? const BoxDecoration(
border: Border(
right: BorderSide(
color: ColorConfig.colorF7F7F7,
width: 1,
),
),
)
: const BoxDecoration(),
),
),
)
: Container(),
showOkBtn
? Expanded(
child: InkWell(
onTap: () {
Get.back(result: true);
if (okOnClick != null) {
okOnClick!();
}
},
child: Container(
alignment: Alignment.center,
child: Text(
okBtnText.tr,
style: TextStyleMs.colorFF761E_14_400,
),
),
),
)
: Container(),
],
),
),
],
),
),
);
}
}