-
Notifications
You must be signed in to change notification settings - Fork 82
/
default_style.dart
170 lines (148 loc) · 6.07 KB
/
default_style.dart
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
import 'package:flutter/material.dart';
import 'package:flutter_pickers/style/picker_style.dart';
// 日间圆角
final headDecorationLight = BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)));
/// 无标题样式
class NoTitleStyle extends PickerStyle {
NoTitleStyle() {
this.showTitleBar = false;
}
/// 夜间
NoTitleStyle.dark() {
this.showTitleBar = false;
this.backgroundColor = Colors.grey[800]!;
this.textColor = Colors.white;
}
}
/// 默认样式
class DefaultPickerStyle extends PickerStyle {
DefaultPickerStyle({bool haveRadius: false, String? title}) {
if (haveRadius) {
this.headDecoration = BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)));
}
if (title != null && title != '') {
this.title = Center(child: Text(title, style: TextStyle(color: Colors.grey, fontSize: 14)));
}
}
/// 夜间
DefaultPickerStyle.dark({bool haveRadius: false, String? title}) {
this.commitButton = Container(
alignment: Alignment.center,
padding: const EdgeInsets.only(left: 12, right: 22),
child: Text('确定', style: TextStyle(color: Colors.white, fontSize: 16.0)),
);
this.cancelButton = Container(
alignment: Alignment.center,
padding: const EdgeInsets.only(left: 22, right: 12),
child: Text('取消', style: TextStyle(color: Colors.white, fontSize: 16.0)),
);
this.headDecoration = BoxDecoration(
color: Colors.grey[800],
borderRadius:
!haveRadius ? null : BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)));
if (title != null && title != '') {
this.title = Center(child: Text(title, style: TextStyle(color: Colors.white, fontSize: 14)));
}
this.backgroundColor = Colors.grey[800]!;
this.textColor = Colors.white;
}
}
/// 关闭按钮样式
class ClosePickerStyle extends PickerStyle {
/// 日间
ClosePickerStyle({bool haveRadius: false, String? title}) {
if (haveRadius) {
this.headDecoration = BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)));
}
this.cancelButton = SizedBox();
if (title != null && title != '') {
this.title = Padding(
padding: const EdgeInsets.only(left: 16),
child: Align(
alignment: Alignment.centerLeft, child: Text(title, style: TextStyle(color: Colors.grey, fontSize: 14))),
);
}
this.commitButton = Container(
// padding: const EdgeInsets.all(4),
margin: const EdgeInsets.only(right: 12),
child: Icon(Icons.close, color: Colors.grey, size: 28),
);
}
/// 夜间
ClosePickerStyle.dark({bool haveRadius: false, String? title}) {
this.headDecoration = BoxDecoration(
color: Colors.grey[800],
borderRadius:
!haveRadius ? null : BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)));
this.cancelButton = SizedBox();
this.commitButton = Container(
margin: const EdgeInsets.only(right: 12),
child: Icon(Icons.close, color: Colors.white, size: 28),
);
if (title != null && title != '') {
this.title = Padding(
padding: const EdgeInsets.only(left: 16),
child: Align(
alignment: Alignment.centerLeft, child: Text(title, style: TextStyle(color: Colors.white, fontSize: 14))),
);
}
this.backgroundColor = Colors.grey[800]!;
this.textColor = Colors.white;
}
}
/// 圆角按钮样式
class RaisedPickerStyle extends PickerStyle {
RaisedPickerStyle({bool haveRadius: false, String? title, Color color: Colors.blue}) {
if (haveRadius) {
this.headDecoration = BoxDecoration(
color: Colors.white,
borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)));
}
this.commitButton = Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
margin: const EdgeInsets.only(right: 22),
decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(4)),
child: Text('确定', style: TextStyle(color: Colors.white, fontSize: 15.0)),
);
this.cancelButton = Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
margin: const EdgeInsets.only(left: 22),
decoration: BoxDecoration(border: Border.all(color: color, width: 1), borderRadius: BorderRadius.circular(4)),
child: Text('取消', style: TextStyle(color: color, fontSize: 15.0)),
);
if (title != null && title != '') {
this.title = Center(child: Text(title, style: TextStyle(color: Colors.grey, fontSize: 14)));
}
}
/// 夜间
RaisedPickerStyle.dark({bool haveRadius: false, String? title, Color? color}) {
this.headDecoration = BoxDecoration(
color: Colors.grey[800],
borderRadius:
!haveRadius ? null : BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)));
this.commitButton = Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
margin: const EdgeInsets.only(right: 22),
decoration: BoxDecoration(color: color ?? Colors.blue, borderRadius: BorderRadius.circular(4)),
child: Text('确定', style: TextStyle(color: Colors.white, fontSize: 15.0)),
);
this.cancelButton = Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 3),
margin: const EdgeInsets.only(left: 22),
decoration:
BoxDecoration(border: Border.all(color: Colors.white, width: 1), borderRadius: BorderRadius.circular(4)),
child: Text('取消', style: TextStyle(color: Colors.white, fontSize: 15.0)),
);
if (title != null && title != '') {
this.title = Center(child: Text(title, style: TextStyle(color: Colors.white, fontSize: 14)));
}
this.backgroundColor = Colors.grey[800]!;
this.textColor = Colors.white;
}
}