- Add 10-second periodic auto-sync to CycleEntriesNotifier - Fix husband_devotional_screen: use partnerId for isConnected check, navigate to SharingSettingsScreen instead of legacy mock dialog - Remove obsolete _showConnectDialog method and mock data import - Update husband_settings_screen: show 'Partner Settings' with linked partner name when connected - Add SharingSettingsScreen: Pad Supplies toggle (disabled when pad tracking off), Intimacy always enabled - Add CORS OPTIONS handler to backend server - Add _ensureServerRegistration for reliable partner linking - Add copy button to Invite Partner dialog - Dynamic base URL for web (uses window.location.hostname)
40 lines
1.1 KiB
Dart
40 lines
1.1 KiB
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
|
import '../models/teaching_plan.dart';
|
|
|
|
final teachingPlansProvider =
|
|
StateNotifierProvider<TeachingPlansNotifier, List<TeachingPlan>>((ref) {
|
|
return TeachingPlansNotifier();
|
|
});
|
|
|
|
class TeachingPlansNotifier extends StateNotifier<List<TeachingPlan>> {
|
|
TeachingPlansNotifier() : super([]) {
|
|
_loadPlans();
|
|
}
|
|
|
|
void _loadPlans() {
|
|
if (Hive.isBoxOpen('teaching_plans_v2')) {
|
|
final box = Hive.box<TeachingPlan>('teaching_plans_v2');
|
|
state = box.values.toList()..sort((a, b) => b.date.compareTo(a.date));
|
|
}
|
|
}
|
|
|
|
Future<void> addPlan(TeachingPlan plan) async {
|
|
final box = Hive.box<TeachingPlan>('teaching_plans_v2');
|
|
await box.put(plan.id, plan);
|
|
_loadPlans();
|
|
}
|
|
|
|
Future<void> updatePlan(TeachingPlan plan) async {
|
|
final box = Hive.box<TeachingPlan>('teaching_plans_v2');
|
|
await box.put(plan.id, plan);
|
|
_loadPlans();
|
|
}
|
|
|
|
Future<void> deletePlan(String id) async {
|
|
final box = Hive.box<TeachingPlan>('teaching_plans_v2');
|
|
await box.delete(id);
|
|
_loadPlans();
|
|
}
|
|
}
|