-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbutton_page.dart
129 lines (124 loc) · 3.7 KB
/
button_page.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
import 'package:example/helpers.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:platty/platty.dart';
class ButtonPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return PScaffold(
appBar: navBarFor(title: "Buttons"),
backgroundColor: Colors.white,
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
buildTitleLabel("Android"),
buildTitleLabel("iOS"),
],
),
buildButtonRow(
androidButtonText: "Normal", iosButtonText: "Normal"),
buildButtonRow(
androidButtonText: "Disabled",
iosButtonText: "Disabled",
disabledColor: Colors.red.withAlpha(150),
),
buildFlatButtonRow(
iosButtonText: "Flat",
androidButtonText: "Flat",
),
buildFlatButtonRow(
androidButtonText: "Flat Disabled",
iosButtonText: "Flat Disabled",
isDisabled: true,
)
],
),
),
);
}
Row buildFlatButtonRow(
{String androidButtonText,
String iosButtonText,
bool isDisabled = false}) =>
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
buildExpandedButton(
child: PTheme.android(
PFlatButton(
padding: EdgeInsets.all(8.0),
child: Text(androidButtonText),
onPressed: !isDisabled ? () {} : null,
),
),
),
buildExpandedButton(
isLeft: false,
child: PTheme.ios(
PFlatButton(
padding: EdgeInsets.all(8.0),
child: Text(iosButtonText),
onPressed: !isDisabled ? () {} : null,
),
),
),
],
);
buildTitleLabel(String text) => Expanded(
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
text,
style: TextStyle(fontSize: 16.0),
),
),
),
);
buildButtonRow(
{String iosButtonText,
String androidButtonText,
Color disabledColor}) =>
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
buildExpandedButton(
child: PButton(
color: Colors.red,
padding: EdgeInsets.all(8.0),
child: Text(
androidButtonText,
style: TextStyle(color: Colors.white),
),
renderPlatform: TargetPlatform.android,
onPressed: disabledColor == null ? () {} : null,
)),
buildExpandedButton(
isLeft: false,
child: PButton(
color: Colors.red,
padding: EdgeInsets.all(8.0),
child: Text(
iosButtonText,
style: TextStyle(color: Colors.white),
),
renderPlatform: TargetPlatform.iOS,
onPressed: disabledColor == null ? () {} : null,
),
),
],
);
Expanded buildExpandedButton({Widget child, bool isLeft = true}) {
return Expanded(
child: Padding(
padding: EdgeInsets.only(
left: isLeft ? 8.0 : 4.0, right: isLeft ? 4.0 : 8.0),
child: child,
),
);
}
}