Skip to content

Commit 37ca0f4

Browse files
committed
Save current calendar view, closes #97
1 parent 797d972 commit 37ca0f4

File tree

10 files changed

+857
-746
lines changed

10 files changed

+857
-746
lines changed

api/pubspec.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ packages:
5353
dependency: transitive
5454
description:
5555
name: build
56-
sha256: "6439a9c71a4e6eca8d9490c1b380a25b02675aa688137dfbe66d2062884a23ac"
56+
sha256: ce76b1d48875e3233fde17717c23d1f60a91cc631597e49a400c89b475395b1d
5757
url: "https://pub.dev"
5858
source: hosted
59-
version: "3.0.2"
59+
version: "3.1.0"
6060
build_config:
6161
dependency: transitive
6262
description:
@@ -77,26 +77,26 @@ packages:
7777
dependency: transitive
7878
description:
7979
name: build_resolvers
80-
sha256: "2b21a125d66a86b9511cc3fb6c668c42e9a1185083922bf60e46d483a81a9712"
80+
sha256: d1d57f7807debd7349b4726a19fd32ec8bc177c71ad0febf91a20f84cd2d4b46
8181
url: "https://pub.dev"
8282
source: hosted
83-
version: "3.0.2"
83+
version: "3.0.3"
8484
build_runner:
8585
dependency: "direct dev"
8686
description:
8787
name: build_runner
88-
sha256: fd3c09f4bbff7fa6e8d8ef688a0b2e8a6384e6483a25af0dac75fef362bcfe6f
88+
sha256: b24597fceb695969d47025c958f3837f9f0122e237c6a22cb082a5ac66c3ca30
8989
url: "https://pub.dev"
9090
source: hosted
91-
version: "2.7.0"
91+
version: "2.7.1"
9292
build_runner_core:
9393
dependency: transitive
9494
description:
9595
name: build_runner_core
96-
sha256: ab27e46c8aa233e610cf6084ee6d8a22c6f873a0a9929241d8855b7a72978ae7
96+
sha256: "066dda7f73d8eb48ba630a55acb50c4a84a2e6b453b1cb4567f581729e794f7b"
9797
url: "https://pub.dev"
9898
source: hosted
99-
version: "9.3.0"
99+
version: "9.3.1"
100100
built_collection:
101101
dependency: transitive
102102
description:
@@ -109,10 +109,10 @@ packages:
109109
dependency: transitive
110110
description:
111111
name: built_value
112-
sha256: ba95c961bafcd8686d1cf63be864eb59447e795e124d98d6a27d91fcd13602fb
112+
sha256: a30f0a0e38671e89a492c44d005b5545b830a961575bbd8336d42869ff71066d
113113
url: "https://pub.dev"
114114
source: hosted
115-
version: "8.11.1"
115+
version: "8.12.0"
116116
checked_yaml:
117117
dependency: transitive
118118
description:

app/android/Gemfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ GEM
1111
artifactory (3.0.17)
1212
atomos (0.1.3)
1313
aws-eventstream (1.4.0)
14-
aws-partitions (1.1152.0)
15-
aws-sdk-core (3.231.0)
14+
aws-partitions (1.1156.0)
15+
aws-sdk-core (3.232.0)
1616
aws-eventstream (~> 1, >= 1.3.0)
1717
aws-partitions (~> 1, >= 1.992.0)
1818
aws-sigv4 (~> 1.9)
@@ -23,15 +23,15 @@ GEM
2323
aws-sdk-kms (1.112.0)
2424
aws-sdk-core (~> 3, >= 3.231.0)
2525
aws-sigv4 (~> 1.5)
26-
aws-sdk-s3 (1.198.0)
26+
aws-sdk-s3 (1.199.0)
2727
aws-sdk-core (~> 3, >= 3.231.0)
2828
aws-sdk-kms (~> 1)
2929
aws-sigv4 (~> 1.5)
3030
aws-sigv4 (1.12.1)
3131
aws-eventstream (~> 1, >= 1.0.2)
3232
babosa (1.0.4)
3333
base64 (0.3.0)
34-
bigdecimal (3.2.2)
34+
bigdecimal (3.2.3)
3535
claide (1.1.0)
3636
colored (1.2)
3737
colored2 (3.1.2)
@@ -182,7 +182,7 @@ GEM
182182
trailblazer-option (>= 0.1.1, < 0.2.0)
183183
uber (< 0.2.0)
184184
retriable (3.1.2)
185-
rexml (3.4.2)
185+
rexml (3.4.3)
186186
rouge (3.28.0)
187187
ruby2_keywords (0.0.5)
188188
rubyzip (2.4.1)
@@ -233,4 +233,4 @@ DEPENDENCIES
233233
screengrab
234234

235235
BUNDLED WITH
236-
2.7.1
236+
2.6.9

app/lib/cubits/settings.dart

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import 'dart:convert';
22

33
import 'package:collection/collection.dart';
44
import 'package:dart_mappable/dart_mappable.dart';
5+
import 'package:flow/src/generated/i18n/app_localizations.dart';
56
import 'package:flutter/material.dart';
67
import 'package:flutter_bloc/flutter_bloc.dart';
78
import 'package:material_leap/material_leap.dart';
9+
import 'package:phosphor_flutter/phosphor_flutter.dart';
810
import 'package:shared_preferences/shared_preferences.dart';
911
import 'package:timezone/timezone.dart' as tz;
1012
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
@@ -61,6 +63,35 @@ final class ThemeModeMapper extends SimpleMapper<ThemeMode> {
6163
}
6264
}
6365

66+
@MappableEnum()
67+
enum CalendarView {
68+
list,
69+
day,
70+
week,
71+
month,
72+
pending;
73+
74+
String getLocalizedName(BuildContext context) {
75+
return switch (this) {
76+
CalendarView.list => AppLocalizations.of(context).list,
77+
CalendarView.day => AppLocalizations.of(context).day,
78+
CalendarView.week => AppLocalizations.of(context).week,
79+
CalendarView.month => AppLocalizations.of(context).month,
80+
CalendarView.pending => AppLocalizations.of(context).pending,
81+
};
82+
}
83+
84+
IconGetter get icon {
85+
return switch (this) {
86+
CalendarView.list => PhosphorIcons.list,
87+
CalendarView.day => PhosphorIcons.calendar,
88+
CalendarView.week => PhosphorIcons.columns,
89+
CalendarView.month => PhosphorIcons.gridNine,
90+
CalendarView.pending => PhosphorIcons.clock,
91+
};
92+
}
93+
}
94+
6495
@MappableClass(includeCustomMappers: [ThemeModeMapper()])
6596
class FlowSettings with FlowSettingsMappable, LeapSettings {
6697
static const String localeKey = 'locale';
@@ -84,6 +115,8 @@ class FlowSettings with FlowSettingsMappable, LeapSettings {
84115
final bool highContrast;
85116
static const String alarmsKey = 'alarms';
86117
final List<Alarm> alarms;
118+
static const String calendarViewKey = 'calendarView';
119+
final CalendarView calendarView;
87120

88121
const FlowSettings({
89122
this.locale = '',
@@ -96,6 +129,7 @@ class FlowSettings with FlowSettingsMappable, LeapSettings {
96129
this.density = ThemeDensity.system,
97130
this.highContrast = false,
98131
this.alarms = const [],
132+
this.calendarView = CalendarView.list,
99133
});
100134

101135
factory FlowSettings.fromPrefs(SharedPreferences prefs) => FlowSettings(
@@ -125,6 +159,9 @@ class FlowSettings with FlowSettingsMappable, LeapSettings {
125159
?.map((e) => AlarmMapper.fromJson(e))
126160
.toList() ??
127161
[],
162+
calendarView: CalendarView.values.byName(
163+
prefs.getString(calendarViewKey) ?? 'list',
164+
),
128165
);
129166
Future<void> saveThemeMode(SharedPreferences prefs) =>
130167
prefs.setString(themeModeKey, themeMode.name);
@@ -148,6 +185,8 @@ class FlowSettings with FlowSettingsMappable, LeapSettings {
148185
prefs.setBool(highContrastKey, highContrast);
149186
Future<void> saveAlarms(SharedPreferences prefs) =>
150187
prefs.setStringList(alarmsKey, alarms.map((e) => e.toJson()).toList());
188+
Future<void> saveCalendarView(SharedPreferences prefs) =>
189+
prefs.setString(calendarViewKey, calendarView.name);
151190

152191
Future<void> save(SharedPreferences prefs) async {
153192
await saveThemeMode(prefs);
@@ -160,6 +199,7 @@ class FlowSettings with FlowSettingsMappable, LeapSettings {
160199
await saveDensity(prefs);
161200
await saveHighContrast(prefs);
162201
await saveAlarms(prefs);
202+
await saveCalendarView(prefs);
163203
}
164204
}
165205

@@ -271,6 +311,12 @@ class SettingsCubit extends Cubit<FlowSettings>
271311
return _runSave(newState.saveAlarms);
272312
}
273313

314+
Future<void> changeCalendarView(CalendarView view) {
315+
final newState = state.copyWith(calendarView: view);
316+
emit(newState);
317+
return _runSave(newState.saveCalendarView);
318+
}
319+
274320
Future<void> importSettings(String data) {
275321
final settings = FlowSettingsMapper.fromJson(
276322
data,

app/lib/cubits/settings.mapper.dart

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)