summaryrefslogtreecommitdiffstats
path: root/lib/presentation/screens
diff options
context:
space:
mode:
Diffstat (limited to 'lib/presentation/screens')
-rw-r--r--lib/presentation/screens/clock/clock.dart45
-rw-r--r--lib/presentation/screens/settings/settings_screens/date_time/date/date_screen.dart198
-rw-r--r--lib/presentation/screens/settings/settings_screens/date_time/date/select_year.dart121
-rw-r--r--lib/presentation/screens/settings/settings_screens/date_time/date_time_screen.dart9
-rw-r--r--lib/presentation/screens/settings/settings_screens/date_time/time/time_screen.dart9
5 files changed, 285 insertions, 97 deletions
diff --git a/lib/presentation/screens/clock/clock.dart b/lib/presentation/screens/clock/clock.dart
index f0858e7..ec419d6 100644
--- a/lib/presentation/screens/clock/clock.dart
+++ b/lib/presentation/screens/clock/clock.dart
@@ -1,6 +1,5 @@
-import 'dart:async';
-
import 'package:flutter_ics_homescreen/export.dart';
+import 'package:intl/intl.dart';
class ClockPage extends ConsumerWidget {
const ClockPage({super.key});
@@ -10,6 +9,7 @@ class ClockPage extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
double clockSize = MediaQuery.sizeOf(context).width * 0.51;
+ final currentTime = ref.watch(currentTimeProvider);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -66,8 +66,9 @@ class ClockPage extends ConsumerWidget {
),
),
),
- child: const AnalogClock(
+ child: AnalogClock(
dialColor: null,
+ dateTime: currentTime,
markingColor: null,
hourNumberColor: null,
secondHandColor: AGLDemoColors.jordyBlueColor,
@@ -96,47 +97,21 @@ class ClockPage extends ConsumerWidget {
}
}
-class RealTimeClock extends StatefulWidget {
+class RealTimeClock extends ConsumerStatefulWidget {
const RealTimeClock({super.key});
@override
- State<RealTimeClock> createState() => _RealTimeClockState();
+ RealTimeClockState createState() => RealTimeClockState();
}
-class _RealTimeClockState extends State<RealTimeClock> {
+class RealTimeClockState extends ConsumerState<RealTimeClock> {
late String _timeString;
- late Timer _timer;
-
- @override
- void initState() {
- _timeString = _formatDateTime(DateTime.now());
- _timer =
- Timer.periodic(const Duration(seconds: 1), (Timer t) => _getTime());
- super.initState();
- }
-
- @override
- void dispose() {
- _timer.cancel();
- super.dispose();
- }
-
- void _getTime() {
- final DateTime now = DateTime.now();
- final String formattedDateTime = _formatDateTime(now);
- if (mounted) {
- setState(() {
- _timeString = formattedDateTime;
- });
- }
- }
-
- String _formatDateTime(DateTime dateTime) {
- return "${dateTime.hour}:${dateTime.minute.toString().padLeft(2, '0')}";
- }
+ DateFormat dateFormat = DateFormat('hh:mm a');
@override
Widget build(BuildContext context) {
+ final currentTime = ref.watch(currentTimeProvider);
+ _timeString = dateFormat.format(currentTime);
return Text(
_timeString,
style: GoogleFonts.brunoAce(color: Colors.white, fontSize: 128),
diff --git a/lib/presentation/screens/settings/settings_screens/date_time/date/date_screen.dart b/lib/presentation/screens/settings/settings_screens/date_time/date/date_screen.dart
index 6802ed0..9f40a76 100644
--- a/lib/presentation/screens/settings/settings_screens/date_time/date/date_screen.dart
+++ b/lib/presentation/screens/settings/settings_screens/date_time/date/date_screen.dart
@@ -1,5 +1,6 @@
+import 'package:flutter_calendar_carousel/classes/event.dart';
+import 'package:flutter_calendar_carousel/flutter_calendar_carousel.dart';
import 'package:flutter_ics_homescreen/export.dart';
-import 'package:calendar_date_picker2/calendar_date_picker2.dart';
import 'package:intl/intl.dart';
class DatePage extends ConsumerWidget {
@@ -14,6 +15,7 @@ class DatePage extends ConsumerWidget {
title: 'Date',
hasBackButton: true,
onPressed: () {
+ ref.read(currentTimeProvider.notifier).isYearChanged = false;
context.flow<AppState>().update((state) => AppState.dateTime);
},
),
@@ -36,84 +38,170 @@ class DateScreenWidget extends ConsumerStatefulWidget {
}
class DateScreenWidgetState extends ConsumerState<DateScreenWidget> {
- late String selectedDate;
+ late DateTime _currentDate;
+ late DateTime _currentDate2;
+ late String _currentMonth;
+ late DateTime _targetDateTime;
onPressed({required String type}) {
if (type == "confirm") {
- ref.read(dateTimeStateProvider.notifier).setDate(selectedDate);
+ DateTime selectedeDate = _currentDate.copyWith(
+ day: _currentDate2.day,
+ year: _currentDate2.year,
+ month: _currentDate2.month);
+
+ ref.read(currentTimeProvider.notifier).setCurrentTime(selectedeDate);
context.flow<AppState>().update((state) => AppState.dateTime);
} else if (type == "cancel") {
+ ref.read(currentTimeProvider.notifier).isYearChanged = false;
context.flow<AppState>().update((state) => AppState.dateTime);
}
}
@override
void initState() {
- selectedDate = ref.read(dateTimeStateProvider).date;
-
+ _currentDate = ref.read(currentTimeProvider);
+ int? selectedYear = ref.read(currentTimeProvider.notifier).selectedYear;
+ if (selectedYear != null &&
+ ref.read(currentTimeProvider.notifier).isYearChanged) {
+ _currentDate = _currentDate.copyWith(year: selectedYear);
+ }
+ _currentDate2 = _currentDate;
+ _currentMonth = DateFormat.yMMM().format(_currentDate);
+ _targetDateTime = _currentDate;
super.initState();
}
@override
Widget build(BuildContext context) {
Size size = MediaQuery.sizeOf(context);
+
+ final calendarCarouselNoHeader = CalendarCarousel<Event>(
+ onDayPressed: (date, events) {
+ setState(() => _currentDate2 = date);
+ },
+ daysHaveCircularBorder: true,
+ showOnlyCurrentMonthDate: false,
+ weekendTextStyle:
+ const TextStyle(color: AGLDemoColors.periwinkleColor, fontSize: 40),
+ daysTextStyle:
+ const TextStyle(color: AGLDemoColors.periwinkleColor, fontSize: 40),
+ thisMonthDayBorderColor: Colors.transparent,
+ weekFormat: false,
+ height: 720.0,
+ selectedDateTime: _currentDate2,
+ targetDateTime: _targetDateTime,
+ selectedDayButtonColor: AGLDemoColors.buttonFillEnabledColor,
+ customGridViewPhysics: const NeverScrollableScrollPhysics(),
+ showHeader: false,
+ todayTextStyle:
+ const TextStyle(color: AGLDemoColors.periwinkleColor, fontSize: 40),
+ nextDaysTextStyle: const TextStyle(color: Colors.transparent),
+ todayButtonColor: Colors.transparent,
+ selectedDayTextStyle: const TextStyle(color: Colors.white, fontSize: 40),
+ minSelectedDate: _currentDate.subtract(const Duration(days: 10958)),
+ maxSelectedDate: _currentDate.add(const Duration(days: 10958)),
+ prevDaysTextStyle: const TextStyle(
+ color: Colors.transparent,
+ ),
+ weekdayTextStyle: const TextStyle(color: Colors.white, fontSize: 26),
+ todayBorderColor: AGLDemoColors.buttonFillEnabledColor,
+ onCalendarChanged: (DateTime date) {
+ setState(() {
+ _targetDateTime = date;
+ _currentMonth = DateFormat.yMMM().format(_targetDateTime);
+ });
+ },
+ onDayLongPressed: (DateTime date) {},
+ );
+
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- CalendarDatePicker2(
- config: CalendarDatePicker2Config(
- calendarType: CalendarDatePicker2Type.single,
- dayBuilder: (
- {required date,
- decoration,
- isDisabled,
- isSelected,
- isToday,
- textStyle}) {
- Widget? dayWidget;
- dayWidget = Container(
- decoration: decoration,
- child: Center(
- child: Stack(
- alignment: AlignmentDirectional.center,
- children: [
- Text(
- MaterialLocalizations.of(context)
- .formatDecimal(date.day),
- style: textStyle,
- ),
- ],
+ Container(
+ margin: const EdgeInsets.only(
+ top: 30.0,
+ bottom: 16.0,
+ left: 16.0,
+ right: 16.0,
+ ),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: <Widget>[
+ Flexible(
+ child: TextButton(
+ onPressed: () {
+ context.flow<AppState>().update((state) => AppState.year);
+ },
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ _currentMonth,
+ style: const TextStyle(
+ color: AGLDemoColors.periwinkleColor,
+ fontSize: 40.0,
+ ),
),
+ const Padding(
+ padding: EdgeInsets.only(left: 8.0),
+ child: Icon(
+ Icons.keyboard_arrow_down,
+ size: 40,
+ color: AGLDemoColors.periwinkleColor,
+ ),
+ )
+ ],
+ ),
+ )),
+ Row(
+ children: [
+ TextButton(
+ child: const Padding(
+ padding: EdgeInsets.all(15.0),
+ child: Icon(
+ Icons.arrow_back_ios,
+ size: 30,
+ color: AGLDemoColors.periwinkleColor,
+ ),
+ ),
+ onPressed: () {
+ setState(() {
+ _targetDateTime = DateTime(
+ _targetDateTime.year, _targetDateTime.month - 1);
+ _currentMonth =
+ DateFormat.yMMM().format(_targetDateTime);
+ });
+ },
),
- );
-
- return dayWidget;
- },
- dayTextStyle: const TextStyle(
- color: AGLDemoColors.periwinkleColor, fontSize: 40),
- selectedDayHighlightColor: AGLDemoColors.neonBlueColor,
- controlsTextStyle: const TextStyle(
- color: AGLDemoColors.periwinkleColor, fontSize: 40),
- weekdayLabelTextStyle: const TextStyle(
- color: AGLDemoColors.periwinkleColor, fontSize: 40),
- controlsHeight: 40,
- dayTextStylePredicate: ({required date}) {
- return const TextStyle(
- color: AGLDemoColors.periwinkleColor, fontSize: 40);
- },
- selectedDayTextStyle:
- const TextStyle(color: Colors.white, fontSize: 40)),
- value: selectedDate == "mm/dd/yyyy"
- ? []
- : [DateFormat().add_yMMMMd().parse(selectedDate)],
- onValueChanged: (dates) {
- setState(() {
- selectedDate = DateFormat().add_yMMMMd().format(dates.first!);
- });
- },
+ TextButton(
+ child: const Padding(
+ padding: EdgeInsets.all(15.0),
+ child: Icon(
+ Icons.arrow_forward_ios,
+ size: 30,
+ color: AGLDemoColors.periwinkleColor,
+ ),
+ ),
+ onPressed: () {
+ setState(() {
+ _targetDateTime = DateTime(
+ _targetDateTime.year, _targetDateTime.month + 1);
+ _currentMonth =
+ DateFormat.yMMM().format(_targetDateTime);
+ });
+ },
+ ),
+ ],
+ )
+ ],
+ ),
+ ),
+ Container(
+ child: calendarCarouselNoHeader,
),
const SizedBox(
- height: 120,
+ height: 180,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
diff --git a/lib/presentation/screens/settings/settings_screens/date_time/date/select_year.dart b/lib/presentation/screens/settings/settings_screens/date_time/date/select_year.dart
new file mode 100644
index 0000000..f41a60e
--- /dev/null
+++ b/lib/presentation/screens/settings/settings_screens/date_time/date/select_year.dart
@@ -0,0 +1,121 @@
+import 'package:flutter_ics_homescreen/export.dart';
+
+class SelectYearPage extends ConsumerWidget {
+ const SelectYearPage({super.key});
+ static Page<void> page() => const MaterialPage<void>(child: SelectYearPage());
+
+ @override
+ Widget build(BuildContext context, WidgetRef ref) {
+ return Scaffold(
+ body: Column(children: [
+ CommonTitle(
+ title: 'Select Year',
+ hasBackButton: true,
+ onPressed: () {
+ context.flow<AppState>().update((state) => AppState.date);
+ },
+ ),
+ const Expanded(
+ child: Padding(
+ padding:
+ EdgeInsets.only(top: 50, left: 144, right: 144, bottom: 200),
+ child: SelectYearWidget()),
+ ),
+ ]),
+ );
+ }
+}
+
+class SelectYearWidget extends ConsumerStatefulWidget {
+ const SelectYearWidget({super.key});
+ Page<void> page() => const MaterialPage<void>(child: SelectYearWidget());
+
+ @override
+ SelectYearWidgetState createState() => SelectYearWidgetState();
+}
+
+class SelectYearWidgetState extends ConsumerState<SelectYearWidget> {
+ late int selectedYear;
+ late ScrollController controller;
+
+ onPressed({required int year}) {
+ setState(() {
+ selectedYear = year;
+ });
+ ref.read(currentTimeProvider.notifier).selectedYear = selectedYear;
+ ref.read(currentTimeProvider.notifier).isYearChanged = true;
+ context.flow<AppState>().update((state) => AppState.date);
+ }
+
+ @override
+ void initState() {
+ DateTime currentDate = ref.read(currentTimeProvider);
+ int? selYear = ref.read(currentTimeProvider.notifier).selectedYear;
+
+ if (selYear != null &&
+ ref.read(currentTimeProvider.notifier).isYearChanged) {
+ selectedYear = selYear;
+ } else {
+ selectedYear = currentDate.year;
+ }
+ controller = ScrollController();
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ final position = controller.position.maxScrollExtent / 2;
+ controller.jumpTo(position);
+ });
+ super.initState();
+ }
+
+ @override
+ void dispose() {
+ controller.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Padding(
+ padding: const EdgeInsets.only(top: 20, bottom: 150),
+ child: SingleChildScrollView(
+ controller: controller,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ for (var i = selectedYear - 30; i < selectedYear + 30; i++)
+ Column(
+ children: [
+ ListTile(
+ contentPadding: const EdgeInsets.symmetric(
+ vertical: 30, horizontal: 30),
+ onTap: () {
+ onPressed(year: i);
+ },
+ title: Text(
+ i.toString(),
+ style: TextStyle(
+ color: selectedYear == i
+ ? Colors.white
+ : AGLDemoColors.periwinkleColor,
+ fontSize: 40),
+ ),
+ trailing: selectedYear == i
+ ? const Icon(
+ Icons.check,
+ color: AGLDemoColors.neonBlueColor,
+ size: 40,
+ )
+ : null,
+ ),
+ const Divider(
+ color: AGLDemoColors.buttonFillEnabledColor,
+ height: 1,
+ thickness: 1,
+ )
+ ],
+ )
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/presentation/screens/settings/settings_screens/date_time/date_time_screen.dart b/lib/presentation/screens/settings/settings_screens/date_time/date_time_screen.dart
index c9a3abf..caf56a1 100644
--- a/lib/presentation/screens/settings/settings_screens/date_time/date_time_screen.dart
+++ b/lib/presentation/screens/settings/settings_screens/date_time/date_time_screen.dart
@@ -7,8 +7,9 @@ class DateTimePage extends ConsumerWidget {
static Page<void> page() => const MaterialPage<void>(child: DateTimePage());
@override
Widget build(BuildContext context, WidgetRef ref) {
- final dateTime = ref.watch(dateTimeStateProvider.select((val) => val));
- DateFormat dateFormat = DateFormat('hh:mm a');
+ DateFormat dateFormat = DateFormat().add_yMMMMd();
+ DateFormat timeFormat = DateFormat('hh:mm a');
+
final currentime = ref.watch(currentTimeProvider);
return Scaffold(
@@ -29,7 +30,7 @@ class DateTimePage extends ConsumerWidget {
UnitsTile(
image: "assets/Calendar.svg",
title: 'Date',
- unitName: dateTime.date,
+ unitName: dateFormat.format(currentime),
hasSwich: false,
voidCallback: () async {
context
@@ -39,7 +40,7 @@ class DateTimePage extends ConsumerWidget {
UnitsTile(
image: "assets/Time.svg",
title: 'Time',
- unitName: dateFormat.format(currentime),
+ unitName: timeFormat.format(currentime),
hasSwich: true,
voidCallback: () {
context
diff --git a/lib/presentation/screens/settings/settings_screens/date_time/time/time_screen.dart b/lib/presentation/screens/settings/settings_screens/date_time/time/time_screen.dart
index de8adb4..8d0a228 100644
--- a/lib/presentation/screens/settings/settings_screens/date_time/time/time_screen.dart
+++ b/lib/presentation/screens/settings/settings_screens/date_time/time/time_screen.dart
@@ -43,14 +43,17 @@ class TimeScreenWidgetState extends ConsumerState<TimeScreenWidget> {
TextEditingController hourController = TextEditingController();
TextEditingController minuteController = TextEditingController();
-
+ late DateTime currentTime;
onPressed({required String type}) {
if (type == "confirm") {
if (hourController.text.isNotEmpty && minuteController.text.isNotEmpty) {
String input =
'${hourController.text}:${minuteController.text} $selectedMeridien';
DateTime selectedeDatetime = DateFormat.jm().parse(input);
-
+ selectedeDatetime = selectedeDatetime.copyWith(
+ day: currentTime.day,
+ year: currentTime.year,
+ month: currentTime.month);
ref
.read(currentTimeProvider.notifier)
.setCurrentTime(selectedeDatetime);
@@ -69,7 +72,7 @@ class TimeScreenWidgetState extends ConsumerState<TimeScreenWidget> {
@override
void initState() {
- DateTime currentTime = ref.read(currentTimeProvider);
+ currentTime = ref.read(currentTimeProvider);
String time = DateFormat('hh:mm a').format(currentTime);
List<String> split = time.split(":");