-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
other_settings.dart
116 lines (113 loc) · 4.81 KB
/
other_settings.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
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:genshindb/application/bloc.dart';
import 'package:genshindb/application/settings/settings_bloc.dart';
import 'package:genshindb/domain/enums/enums.dart';
import 'package:genshindb/generated/l10n.dart';
import 'package:genshindb/presentation/game_codes/game_codes_page.dart';
import 'package:genshindb/presentation/shared/extensions/i18n_extensions.dart';
import 'package:genshindb/presentation/shared/loading.dart';
import 'package:genshindb/presentation/shared/styles.dart';
import 'settings_card.dart';
class OtherSettings extends StatelessWidget {
@override
Widget build(BuildContext context) {
final s = S.of(context);
final theme = Theme.of(context);
return SettingsCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Row(
children: <Widget>[
const Icon(Icons.build),
Container(
margin: const EdgeInsets.only(left: 5),
child: Text(s.others, style: Theme.of(context).textTheme.headline6),
),
],
),
Padding(
padding: const EdgeInsets.only(top: 5),
child: Text(
s.generalSettings,
style: const TextStyle(color: Colors.grey),
),
),
BlocBuilder<SettingsBloc, SettingsState>(
builder: (context, state) {
return state.map(
loading: (_) => const Loading(useScaffold: false),
loaded: (settingsState) => Column(
children: [
SwitchListTile(
activeColor: theme.accentColor,
title: Text(s.showCharacterDetails),
value: settingsState.showCharacterDetails,
onChanged: (newVal) => context.read<SettingsBloc>().add(SettingsEvent.showCharacterDetailsChanged(newValue: newVal)),
),
SwitchListTile(
activeColor: theme.accentColor,
title: Text(s.showWeaponDetails),
value: settingsState.showWeaponDetails,
onChanged: (newVal) => context.read<SettingsBloc>().add(SettingsEvent.showWeaponDetailsChanged(newValue: newVal)),
),
ListTile(
dense: true,
contentPadding: EdgeInsets.zero,
title: Padding(
padding: Styles.edgeInsetHorizontal16,
child: DropdownButton<AppServerResetTimeType>(
isExpanded: true,
hint: Text(s.chooseServer),
value: settingsState.serverResetTime,
underline: Container(height: 0, color: Colors.transparent),
onChanged: (v) => context.read<SettingsBloc>().add(SettingsEvent.serverResetTimeChanged(newValue: v)),
items: AppServerResetTimeType.values
.map((type) => DropdownMenuItem<AppServerResetTimeType>(value: type, child: Text(s.translateServerResetTimeType(type))))
.toList(),
),
),
subtitle: Container(
margin: const EdgeInsets.only(left: 25),
child: Transform.translate(
offset: const Offset(0, -10),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
s.serverWhereYouPlay,
style: const TextStyle(color: Colors.grey),
),
),
),
),
),
],
),
);
},
),
ListTile(
dense: false,
title: Text(s.gameCodes),
subtitle: Container(
margin: const EdgeInsets.only(left: 10),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
s.seeAllInGameGameCodes,
style: const TextStyle(color: Colors.grey, fontSize: 11),
),
),
),
onTap: () => _showGameCodesDialog(context),
)
],
),
);
}
Future<void> _showGameCodesDialog(BuildContext context) async {
context.read<GameCodesBloc>().add(const GameCodesEvent.opened());
await Navigator.push(context, MaterialPageRoute(fullscreenDialog: true, builder: (ctx) => const GameCodesPage()));
}
}