diff options
Diffstat (limited to 'lib/data')
-rw-r--r-- | lib/data/data_providers/app_provider.dart | 9 | ||||
-rw-r--r-- | lib/data/data_providers/datetime_notifier.dart | 14 | ||||
-rw-r--r-- | lib/data/data_providers/time_notifier.dart | 3 | ||||
-rw-r--r-- | lib/data/models/date_time.dart | 59 |
4 files changed, 5 insertions, 80 deletions
diff --git a/lib/data/data_providers/app_provider.dart b/lib/data/data_providers/app_provider.dart index 80416a4..f6fb1ad 100644 --- a/lib/data/data_providers/app_provider.dart +++ b/lib/data/data_providers/app_provider.dart @@ -1,11 +1,9 @@ -import 'package:flutter_ics_homescreen/data/data_providers/datetime_notifier.dart'; import 'package:flutter_ics_homescreen/data/data_providers/hybrid_notifier.dart'; import 'package:flutter_ics_homescreen/data/data_providers/signal_notifier.dart'; import 'package:flutter_ics_homescreen/data/data_providers/time_notifier.dart'; import 'package:flutter_ics_homescreen/data/data_providers/units_notifier.dart'; import 'package:flutter_ics_homescreen/data/data_providers/audio_notifier.dart'; import 'package:flutter_ics_homescreen/data/data_providers/users_notifier.dart'; -import 'package:flutter_ics_homescreen/data/models/date_time.dart'; import 'package:flutter_ics_homescreen/export.dart'; import '../models/users.dart'; @@ -33,7 +31,8 @@ enum AppState { tempUnit, clock, date, - time + time, + year } final appProvider = StateProvider<AppState>((ref) => AppState.splash); @@ -55,10 +54,6 @@ final usersProvider = StateNotifierProvider<UsersNotifier, Users>((ref) { return UsersNotifier(Users.initial()); }); -final dateTimeStateProvider = - StateNotifierProvider<DateTimeNotifier, DateAndTime>((ref) { - return DateTimeNotifier(DateAndTime.initial()); -}); final hybridtateProvider = StateNotifierProvider<HybridNotifier, Hybrid>((ref) { return HybridNotifier(const Hybrid.initial()); }); diff --git a/lib/data/data_providers/datetime_notifier.dart b/lib/data/data_providers/datetime_notifier.dart deleted file mode 100644 index 6947a34..0000000 --- a/lib/data/data_providers/datetime_notifier.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:flutter_ics_homescreen/data/models/date_time.dart'; -import 'package:flutter_ics_homescreen/export.dart'; - -class DateTimeNotifier extends StateNotifier<DateAndTime> { - DateTimeNotifier(super.state); - - void setDate(String newVal) { - state = state.copyWith(date: newVal); - } - - void setTime(String newVal) { - state = state.copyWith(time: newVal); - } -} diff --git a/lib/data/data_providers/time_notifier.dart b/lib/data/data_providers/time_notifier.dart index 9737b2b..c290526 100644 --- a/lib/data/data_providers/time_notifier.dart +++ b/lib/data/data_providers/time_notifier.dart @@ -11,6 +11,8 @@ class CurrentTimeNotifier extends StateNotifier<DateTime> { } bool _hasInitialized = false; + int? selectedYear; + bool isYearChanged = false; void _initializeTimer() { Timer.periodic(const Duration(seconds: 1), (timer) { @@ -20,5 +22,6 @@ class CurrentTimeNotifier extends StateNotifier<DateTime> { void setCurrentTime(DateTime newTime) { state = newTime; + selectedYear = newTime.year; } } diff --git a/lib/data/models/date_time.dart b/lib/data/models/date_time.dart deleted file mode 100644 index 62d7743..0000000 --- a/lib/data/models/date_time.dart +++ /dev/null @@ -1,59 +0,0 @@ -import 'dart:convert'; - -import 'package:flutter_ics_homescreen/export.dart'; -import 'package:intl/intl.dart'; - -@immutable -class DateAndTime { - final String date; - final String time; - const DateAndTime({ - required this.date, - required this.time, - }); - - DateAndTime.initial() - : date = DateFormat().add_yMMMMd().format(DateTime.now()), - time = DateFormat('hh:mm a').format(DateTime.now()); - DateAndTime copyWith({ - String? date, - String? time, - }) { - return DateAndTime( - date: date ?? this.date, - time: time ?? this.time, - ); - } - - Map<String, dynamic> toMap() { - return { - 'date': date, - 'time': time, - }; - } - - factory DateAndTime.fromMap(Map<String, dynamic> map) { - return DateAndTime( - date: map['date'], - time: map['time'], - ); - } - - String toJson() => json.encode(toMap()); - - factory DateAndTime.fromJson(String source) => - DateAndTime.fromMap(json.decode(source)); - - @override - String toString() => 'DateAndTime(date: $date, time: $time)'; - - @override - bool operator ==(Object other) { - if (identical(this, other)) return true; - - return other is DateAndTime && other.date == date && other.time == time; - } - - @override - int get hashCode => date.hashCode ^ time.hashCode; -} |