forked from canonical/ubuntu-desktop-installer
/
choose_your_look_page.dart
94 lines (87 loc) · 2.78 KB
/
choose_your_look_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
import 'package:flutter/material.dart';
import 'package:ubuntu_wizard/settings.dart';
import 'package:ubuntu_wizard/widgets.dart';
import 'package:yaru_widgets/yaru_widgets.dart';
import '../../l10n.dart';
class ChooseYourLookPage extends StatelessWidget {
const ChooseYourLookPage({Key? key}) : super(key: key);
static Widget create(BuildContext context) => const ChooseYourLookPage();
@override
Widget build(BuildContext context) {
final lang = AppLocalizations.of(context);
final width = MediaQuery.of(context).size.width;
final settings = Settings.of(context, listen: false);
return WizardPage(
header: Text(lang.chooseYourLookPageHeader),
actions: <WizardAction>[
WizardAction.back(context),
WizardAction.next(context),
],
title: Text(lang.chooseYourLookPageTitle),
content: Center(
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
_ThemeOptionCard(
width: width / 3,
assetName: 'assets/choose_your_look/light-theme.png',
selected: Theme.of(context).brightness == Brightness.light,
onTap: () {
settings.applyTheme(Brightness.light);
},
preferenceName: lang.chooseYourLookPageLightSetting,
),
SizedBox(
width: width / 20,
),
_ThemeOptionCard(
width: width / 3,
assetName: 'assets/choose_your_look/dark-theme.png',
selected: Theme.of(context).brightness == Brightness.dark,
onTap: () {
settings.applyTheme(Brightness.dark);
},
preferenceName: lang.chooseYourLookPageDarkSetting,
),
]),
),
);
}
}
class _ThemeOptionCard extends StatelessWidget {
const _ThemeOptionCard({
Key? key,
required this.width,
required this.assetName,
required this.selected,
required this.onTap,
required this.preferenceName,
}) : super(key: key);
final double width;
final String assetName;
final bool selected;
final Function() onTap;
final String preferenceName;
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: width,
child: YaruSelectableContainer(
child: FlavorImage.asset(assetName),
selected: selected,
onTap: onTap,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(preferenceName,
style: Theme.of(context).textTheme.headline6),
)
],
);
}
}