-
Notifications
You must be signed in to change notification settings - Fork 32
/
home_page.dart
142 lines (135 loc) · 4.76 KB
/
home_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
130
131
132
133
134
135
136
137
138
139
140
141
142
import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';
import 'package:yaru_example/main.dart';
import 'package:yaru_example/view/color_disk.dart';
import 'package:yaru_example/view/colors_view.dart';
import 'package:yaru_example/view/controls_view.dart';
import 'package:yaru_example/view/fonts_view.dart';
import 'package:yaru_example/view/inputs_view.dart';
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
_HomePageState();
int _counter = 0;
void incrementCounter() {
setState(() {
_counter++;
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('Yay! $_counter ❤️ for Yaru')));
});
}
final textController = TextEditingController(
text:
'My code fails, I do not know why.\nMy code works, I do not know why.\nText in other scripts: Tamaziɣt Taqbaylit, 中文(简体), Čeština, Беларуская, Ελληνικά, עברית, Русский, བོད་ཡིག, Norsk bokmål.');
int _selectedIndex = 0;
final List<Widget> _views = <Widget>[
FontsView(),
ControlsView(),
InputsView(),
ColorsView()
];
@override
Widget build(BuildContext context) {
final theme = YaruTheme.of(context);
return Scaffold(
appBar: AppBar(
leading: SizedBox(
width: 50,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: TextButton(
style: TextButton.styleFrom(
padding: const EdgeInsets.all(0),
shape: const CircleBorder()),
onPressed: () => AppTheme.apply(context,
themeMode: theme.themeMode == ThemeMode.light
? ThemeMode.dark
: ThemeMode.light),
child: Icon(theme.themeMode == ThemeMode.light
? Icons.dark_mode
: Icons.light_mode)),
),
),
actions: [
PopupMenuButton<Color>(
onSelected: (value) {},
child: SizedBox(
width: 40,
child: Icon(
Icons.color_lens,
color: Theme.of(context).primaryColor,
),
),
itemBuilder: (context) {
return [
PopupMenuItem(
onTap: () => AppTheme.apply(context, highContrast: true),
child: ColorDisk(
color: theme.themeMode == ThemeMode.light
? Colors.black
: Colors.white,
selected: theme.highContrast == true,
onPressed: () {},
),
),
for (final variant
in YaruVariant.values.take(10)) // skip flavors
PopupMenuItem(
onTap: () => AppTheme.apply(context,
variant: variant, highContrast: false),
child: ColorDisk(
color: variant.color,
selected: variant == theme.variant &&
theme.highContrast != true,
onPressed: () {},
),
)
];
},
),
],
),
body: Column(
children: <Widget>[
Expanded(
child: Center(
child: _views[_selectedIndex],
),
),
],
),
bottomNavigationBar: BottomNavigationBar(
landscapeLayout: BottomNavigationBarLandscapeLayout.spread,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.font_download_outlined),
activeIcon: Icon(Icons.font_download),
label: 'Fonts'),
BottomNavigationBarItem(
icon: Icon(Icons.radio_button_checked_outlined),
activeIcon: Icon(Icons.radio_button_checked),
label: 'Controls'),
BottomNavigationBarItem(
icon: Icon(Icons.text_fields),
activeIcon: Icon(Icons.text_fields_outlined),
label: 'Text Fields'),
BottomNavigationBarItem(
icon: Icon(Icons.color_lens_outlined),
activeIcon: Icon(Icons.color_lens),
label: 'Palette')
],
currentIndex: _selectedIndex,
onTap: (index) => setState(() => _selectedIndex = index),
),
floatingActionButton: FloatingActionButton(
onPressed: () => {incrementCounter()},
child: Icon(Icons.plus_one),
),
floatingActionButtonLocation:
FloatingActionButtonLocation.miniCenterDocked,
);
}
}