mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
adds syncing
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../providers/settings_provider.dart';
|
||||
import '../providers/supplement_provider.dart';
|
||||
import '../services/notification_service.dart';
|
||||
import 'pending_notifications_screen.dart';
|
||||
import 'sync_settings_screen.dart';
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
const SettingsScreen({super.key});
|
||||
@@ -68,6 +70,22 @@ class SettingsScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.cloud_sync),
|
||||
title: const Text('Cloud Sync'),
|
||||
subtitle: const Text('Configure WebDAV sync settings'),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () {
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const SyncSettingsScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -365,7 +383,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Pending Notifications'),
|
||||
content: pending.isEmpty
|
||||
content: pending.isEmpty
|
||||
? const Text('No pending notifications')
|
||||
: SizedBox(
|
||||
width: double.maxFinite,
|
||||
@@ -376,7 +394,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
itemCount: pending.length,
|
||||
itemBuilder: (context, index) {
|
||||
final notification = pending[index];
|
||||
|
||||
|
||||
// Calculate scheduled time inline
|
||||
String scheduledTime = '';
|
||||
try {
|
||||
@@ -389,22 +407,22 @@ class SettingsScreen extends StatelessWidget {
|
||||
} else {
|
||||
final supplementId = notificationId ~/ 100;
|
||||
final reminderIndex = notificationId % 100;
|
||||
|
||||
|
||||
final supplement = provider.supplements.firstWhere(
|
||||
(s) => s.id == supplementId,
|
||||
orElse: () => provider.supplements.first,
|
||||
);
|
||||
|
||||
|
||||
if (reminderIndex < supplement.reminderTimes.length) {
|
||||
final reminderTime = supplement.reminderTimes[reminderIndex];
|
||||
final now = DateTime.now();
|
||||
final timeParts = reminderTime.split(':');
|
||||
final hour = int.parse(timeParts[0]);
|
||||
final minute = int.parse(timeParts[1]);
|
||||
|
||||
|
||||
final today = DateTime(now.year, now.month, now.day, hour, minute);
|
||||
final isToday = today.isAfter(now);
|
||||
|
||||
|
||||
scheduledTime = '${isToday ? 'Today' : 'Tomorrow'} at $reminderTime';
|
||||
} else {
|
||||
scheduledTime = 'Unknown time';
|
||||
@@ -413,7 +431,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
} catch (e) {
|
||||
scheduledTime = 'ID: ${notification.id}';
|
||||
}
|
||||
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: ListTile(
|
||||
|
Reference in New Issue
Block a user