-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
notification_realm_currency_form.dart
126 lines (119 loc) · 4.31 KB
/
notification_realm_currency_form.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
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:shiori/application/bloc.dart';
import 'package:shiori/domain/app_constants.dart';
import 'package:shiori/domain/enums/enums.dart';
import 'package:shiori/domain/models/models.dart';
import 'package:shiori/generated/l10n.dart';
import 'package:shiori/presentation/shared/dialogs/number_picker_dialog.dart';
import 'package:shiori/presentation/shared/dropdown_button_with_title.dart';
import 'package:shiori/presentation/shared/extensions/i18n_extensions.dart';
import 'package:shiori/presentation/shared/utils/enum_utils.dart';
import 'notification_circle_item.dart';
import 'notification_dropdown_type.dart';
import 'notification_note.dart';
import 'notification_switch.dart';
import 'notification_title_body.dart';
const _type = AppNotificationType.realmCurrency;
class NotificationRealmCurrency extends StatelessWidget {
final String title;
final String body;
final int currentRealmCurrency;
final String note;
final bool showNotification;
final bool isInEditMode;
final List<NotificationItemImage> images;
final bool showOtherImages;
final RealmRankType currentRankType;
final int currentTrustRank;
const NotificationRealmCurrency({
Key? key,
required this.title,
required this.body,
required this.currentRealmCurrency,
required this.note,
required this.showNotification,
required this.isInEditMode,
required this.images,
required this.showOtherImages,
required this.currentRankType,
required this.currentTrustRank,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
NotificationCircleItem(type: _type, images: images, showOtherImages: showOtherImages),
Row(
children: [
Flexible(
fit: FlexFit.tight,
flex: 60,
child: NotificationDropdownType(selectedValue: _type, isInEditMode: isInEditMode),
),
const Spacer(flex: 10),
Flexible(
fit: FlexFit.tight,
flex: 30,
child: OutlinedButton(
onPressed: () => _showRealmRankLevelPickerDialog(context),
child: Text(s.currentX(currentRealmCurrency)),
),
),
],
),
Row(
children: [
Expanded(
flex: 40,
child: DropdownButtonWithTitle<RealmRankType>(
title: s.realmRank,
currentValue: currentRankType,
items: EnumUtils.getTranslatedAndSortedEnum(
RealmRankType.values,
(val, index) => '# ${index + 1} - ${s.translateRealRankType(val)}',
sort: false,
),
onChanged: (v) => context.read<NotificationBloc>().add(NotificationEvent.realmRankTypeChanged(newValue: v)),
),
),
const Spacer(flex: 10),
Expanded(
flex: 40,
child: DropdownButtonWithTitle<int>(
title: s.trustRank,
currentValue: currentTrustRank,
items: realmTrustRank.keys.map((level) => TranslatedEnum<int>(level, '$level')).toList(),
onChanged: (v) => context.read<NotificationBloc>().add(NotificationEvent.realmTrustRankLevelChanged(newValue: v)),
),
),
],
),
NotificationTitleBody(title: title, body: body),
NotificationNote(note: note),
NotificationSwitch(showNotification: showNotification),
],
);
}
Future<void> _showRealmRankLevelPickerDialog(BuildContext context) async {
final s = S.of(context);
final max = getRealmMaxCurrency(currentTrustRank);
await showDialog<int>(
context: context,
builder: (_) => NumberPickerDialog(
maxItemLevel: max - 1,
minItemLevel: 0,
value: currentRealmCurrency,
title: s.realmCurrency,
),
).then((newValue) {
if (newValue == null) {
return;
}
context.read<NotificationBloc>().add(NotificationEvent.realmCurrencyChanged(newValue: newValue));
});
}
}