Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAllGroups function & things in settings #21

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/services/yahrtzeits_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ class YahrtzeitsManager {
return _yahrtzeits;
}

Future<List<String>> getAllGroups() async {
await syncWithCalendar(); // Ensure the Yahrtzeits are up-to-date
Set<String> uniqueGroups = {};
for (var yahrtzeit in _yahrtzeits) {
if (yahrtzeit.group != null && yahrtzeit.group!.isNotEmpty) {
uniqueGroups.add(yahrtzeit.group!);
}
}
return uniqueGroups.toList();
}

Future<List<Yahrtzeit>> getUpcomingYahrtzeits({int days = 1000}) async {
final allYahrtzeits = await getAllYahrtzeits();
final now = tz.TZDateTime.now(tz.local);
Expand Down
25 changes: 15 additions & 10 deletions lib/settings/settings.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../localizations/app_localizations.dart';
Expand Down Expand Up @@ -63,7 +62,8 @@ class _SettingsPageState extends State<SettingsPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.translate('settings'), style: TextStyle(color: Colors.white)),
title: Text(AppLocalizations.of(context)!.translate('settings'),
style: TextStyle(color: Colors.white)),
backgroundColor: Color.fromARGB(255, 50, 4, 129),
centerTitle: true,
),
Expand All @@ -85,13 +85,15 @@ class _SettingsPageState extends State<SettingsPage> {
],
onChanged: (Locale? newValue) {
if (newValue != null) {
Provider.of<LocaleProvider>(context, listen: false).setLocale(newValue);
Provider.of<LocaleProvider>(context, listen: false)
.setLocale(newValue);
}
},
),
),
ListTile(
title: Text(AppLocalizations.of(context)!.translate('jewish_language')),
title: Text(
AppLocalizations.of(context)!.translate('jewish_language')),
trailing: DropdownButton<String>(
value: _jewishLanguage,
items: [
Expand Down Expand Up @@ -119,7 +121,7 @@ class _SettingsPageState extends State<SettingsPage> {
),
),
ListTile(
title: Text(AppLocalizations.of(context)!.translate('sync_settings')),
title: Text('Sync: ${widget.syncSettings ? 'on' : 'off'}'),
trailing: Switch(
value: widget.syncSettings,
onChanged: (value) {
Expand Down Expand Up @@ -152,7 +154,7 @@ class _SettingsPageState extends State<SettingsPage> {
),
),
ListTile(
title: Text(AppLocalizations.of(context)!.translate('notifications')),
title: Text('Notifications: ${widget.notifications ? 'on' : 'off'}'),
trailing: Switch(
value: widget.notifications,
onChanged: (value) {
Expand Down Expand Up @@ -185,17 +187,20 @@ class _SettingsPageState extends State<SettingsPage> {
),
),
ListTile(
title: Text(AppLocalizations.of(context)!.translate('calendar_settings')),
title: Text(
AppLocalizations.of(context)!.translate('calendar_settings')),
trailing: DropdownButton<String>(
value: _calendar,
items: [
DropdownMenuItem(
value: 'google',
child: Text(AppLocalizations.of(context)!.translate('Google Calendar')),
child: Text(AppLocalizations.of(context)!
.translate('Google Calendar')),
),
DropdownMenuItem(
value: 'device',
child: Text(AppLocalizations.of(context)!.translate('Device Calendar')),
child: Text(AppLocalizations.of(context)!
.translate('Device Calendar')),
),
],
onChanged: (value) {
Expand All @@ -212,4 +217,4 @@ class _SettingsPageState extends State<SettingsPage> {
),
);
}
}
}