forked from bdlukaa/fluent_ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolors.dart
114 lines (109 loc) · 3.48 KB
/
colors.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
import 'package:fluent_ui/fluent_ui.dart';
class ColorsPage extends StatelessWidget {
const ColorsPage({Key? key, this.controller}) : super(key: key);
final ScrollController? controller;
Widget buildColorBlock(String name, Color color) {
return Container(
constraints: const BoxConstraints(
minHeight: 65,
minWidth: 65,
),
padding: const EdgeInsets.all(2.0),
color: color,
child: Column(mainAxisAlignment: MainAxisAlignment.end, children: [
Text(name, style: TextStyle(color: color.basedOnLuminance())),
]),
);
}
@override
Widget build(BuildContext context) {
const Divider divider = Divider(
style: DividerThemeData(
verticalMargin: EdgeInsets.all(10),
horizontalMargin: EdgeInsets.all(10),
),
);
return ScaffoldPage(
header: const PageHeader(title: Text('Colors Showcase')),
content: ListView(
padding: EdgeInsets.only(
bottom: kPageDefaultVerticalPadding,
left: PageHeader.horizontalPadding(context),
right: PageHeader.horizontalPadding(context),
),
controller: controller,
children: [
InfoLabel(
label: 'Primary Colors',
child: Wrap(
spacing: 10,
runSpacing: 10,
children: Colors.accentColors.map<Widget>((color) {
return buildColorBlock('', color);
}).toList(),
),
),
divider,
InfoLabel(
label: 'Info Colors',
child: Wrap(
spacing: 10,
runSpacing: 10,
children: [
buildColorBlock('Warning 1', Colors.warningPrimaryColor),
buildColorBlock('Warning 2', Colors.warningSecondaryColor),
buildColorBlock('Error 1', Colors.errorPrimaryColor),
buildColorBlock('Error 2', Colors.errorSecondaryColor),
buildColorBlock('Success 1', Colors.successPrimaryColor),
buildColorBlock(
'Success 2', Colors.successSecondaryColor.toAccentColor()),
],
),
),
divider,
InfoLabel(
label: 'All Shades',
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Row(children: [
buildColorBlock('Black', Colors.black),
buildColorBlock('White', Colors.white),
]),
const SizedBox(height: 10),
Wrap(
children: List.generate(22, (index) {
return buildColorBlock(
'Grey#${(index + 1) * 10}',
Colors.grey[(index + 1) * 10],
);
}),
),
const SizedBox(height: 10),
Wrap(
children: accent,
runSpacing: 10,
spacing: 10,
),
]),
),
],
),
);
}
List<Widget> get accent {
List<Widget> children = [];
for (final accent in Colors.accentColors) {
children.add(
Wrap(
// mainAxisSize: MainAxisSize.min,
children: List.generate(accent.swatch.length, (index) {
final name = accent.swatch.keys.toList()[index];
final color = accent.swatch[name];
return buildColorBlock(name, color!);
}),
),
);
}
return children;
}
}