-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsettings_view.dart
124 lines (120 loc) · 4.86 KB
/
settings_view.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
// Flutter imports:
import 'package:flutter/material.dart';
// Package imports:
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:stacked/stacked.dart';
// Project imports:
import 'package:notredame/core/viewmodels/settings_viewmodel.dart';
import 'package:notredame/ui/utils/app_theme.dart';
import 'package:notredame/ui/widgets/base_scaffold.dart';
class SettingsView extends StatefulWidget {
@override
_SettingsViewState createState() => _SettingsViewState();
}
class _SettingsViewState extends State<SettingsView> {
@override
Widget build(BuildContext context) =>
ViewModelBuilder<SettingsViewModel>.reactive(
viewModelBuilder: () => SettingsViewModel(intl: AppIntl.of(context)!),
builder: (context, model, child) => BaseScaffold(
appBar: AppBar(
title: Text(AppIntl.of(context)!.settings_title),
),
body: ListView(
children: [
ListTile(
title: Text(
AppIntl.of(context)!.settings_display_pref_category,
style: const TextStyle(color: AppTheme.etsLightRed),
),
),
PopupMenuButton(
offset: Offset(MediaQuery.of(context).size.width, 20),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
onSelected: (ThemeMode value) {
setState(() {
model.selectedTheme = value;
});
},
itemBuilder: (BuildContext context) =>
<PopupMenuEntry<ThemeMode>>[
PopupMenuItem(
value: ThemeMode.light,
child: ListTile(
title: Text(AppIntl.of(context)!.light_theme),
leading: const Icon(Icons.wb_sunny),
),
),
PopupMenuItem(
value: ThemeMode.dark,
child: ListTile(
title: Text(AppIntl.of(context)!.dark_theme),
leading: const Icon(Icons.nightlight_round),
),
),
PopupMenuItem(
value: ThemeMode.system,
child: ListTile(
title: Text(AppIntl.of(context)!.system_theme),
leading: const Icon(Icons.brightness_auto),
),
),
],
child: ListTile(
leading: Icon(model.selectedTheme == ThemeMode.light
? Icons.wb_sunny
: model.selectedTheme == ThemeMode.dark
? Icons.nightlight_round
: Icons.brightness_auto),
title: Text(AppIntl.of(context)!.settings_dark_theme_pref),
subtitle: Text(model.selectedTheme == ThemeMode.light
? AppIntl.of(context)!.light_theme
: model.selectedTheme == ThemeMode.dark
? AppIntl.of(context)!.dark_theme
: AppIntl.of(context)!.system_theme),
trailing: const Icon(Icons.arrow_drop_down),
),
),
const Divider(
thickness: 2,
indent: 10,
endIndent: 10,
),
ListTile(
title: Text(
AppIntl.of(context)!.settings_miscellaneous_category,
style: const TextStyle(color: AppTheme.etsLightRed),
),
),
PopupMenuButton(
offset: Offset(MediaQuery.of(context).size.width, 20),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
onSelected: (String value) {
setState(() {
model.currentLocale = value;
});
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
PopupMenuItem<String>(
value: AppIntl.supportedLocales.first.languageCode,
child: Text(AppIntl.of(context)!.settings_english),
),
PopupMenuItem<String>(
value: AppIntl.supportedLocales.last.languageCode,
child: Text(AppIntl.of(context)!.settings_french),
),
],
child: ListTile(
leading: const Icon(Icons.language),
title: Text(AppIntl.of(context)!.settings_language_pref),
subtitle: Text(model.currentLocale),
trailing: const Icon(Icons.arrow_drop_down),
),
),
],
),
),
);
}