forked from bdlukaa/fluent_ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypography.dart
150 lines (144 loc) · 5.03 KB
/
typography.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
import 'package:fluent_ui/fluent_ui.dart';
import 'settings.dart';
class TypographyPage extends StatefulWidget {
const TypographyPage({Key? key}) : super(key: key);
@override
_TypographyPageState createState() => _TypographyPageState();
}
class _TypographyPageState extends State<TypographyPage> {
Color? color;
double scale = 1.0;
Widget buildColorBox(Color color) {
const double boxSize = 25.0;
return Container(
height: boxSize,
width: boxSize,
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(4.0),
),
);
}
@override
Widget build(BuildContext context) {
assert(debugCheckHasFluentTheme(context));
Typography typography = FluentTheme.of(context).typography;
color ??= typography.display!.color;
typography = typography.apply(displayColor: color!);
const Widget spacer = SizedBox(height: 4.0);
return ScaffoldPage(
header: PageHeader(
title: const Text('Typography showcase'),
commandBar: SizedBox(
width: 180.0,
child: Tooltip(
message: 'Pick a text color',
child: Combobox<Color>(
placeholder: const Text('Text Color'),
onChanged: (c) => setState(() => color = c),
value: color,
items: [
ComboboxItem(
child: Row(children: [
buildColorBox(Colors.white),
const SizedBox(width: 10.0),
const Text('White'),
]),
value: Colors.white,
),
ComboboxItem(
child: Row(children: [
buildColorBox(Colors.black),
const SizedBox(width: 10.0),
const Text('Black'),
]),
value: Colors.black,
),
...List.generate(Colors.accentColors.length, (index) {
final color = Colors.accentColors[index];
return ComboboxItem(
child: Row(children: [
buildColorBox(color),
const SizedBox(width: 10.0),
Text(accentColorNames[index + 1]),
]),
value: color,
);
}),
],
),
),
),
),
content: Padding(
padding: EdgeInsets.symmetric(
horizontal: PageHeader.horizontalPadding(context),
),
child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
const Divider(
style: DividerThemeData(horizontalMargin: EdgeInsets.zero),
),
Expanded(
child: ListView(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
children: [
Text('Display',
style:
typography.display?.apply(fontSizeFactor: scale)),
spacer,
Text('Title Large',
style: typography.titleLarge
?.apply(fontSizeFactor: scale)),
spacer,
Text('Title',
style:
typography.title?.apply(fontSizeFactor: scale)),
spacer,
Text('Subtitle',
style: typography.subtitle
?.apply(fontSizeFactor: scale)),
spacer,
Text('Body Large',
style: typography.bodyLarge
?.apply(fontSizeFactor: scale)),
spacer,
Text('Body Strong',
style: typography.bodyStrong
?.apply(fontSizeFactor: scale)),
spacer,
Text('Body',
style: typography.body?.apply(fontSizeFactor: scale)),
spacer,
Text('Caption',
style:
typography.caption?.apply(fontSizeFactor: scale)),
spacer,
],
),
),
],
),
),
Semantics(
label: 'Scale',
child: Slider(
vertical: true,
value: scale,
onChanged: (v) => setState(() => scale = v),
label: scale.toStringAsFixed(2),
max: 2,
min: 0.5,
// style: SliderThemeData(useThumbBall: false),
),
),
]),
),
);
}
}