From f0447913c14deeec2a26af9e46a5ca914ab560f2 Mon Sep 17 00:00:00 2001 From: StarProxima Date: Tue, 25 Apr 2023 20:18:09 +0300 Subject: [PATCH 1/6] Title, size and AppName for desktop --- lib/core/utils.dart | 2 ++ .../settings/ui/widgets/settings_page_app_info.dart | 2 +- .../settings_page_lesson_card_lesson_type_position.dart | 2 +- lib/main.dart | 7 +++++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/core/utils.dart b/lib/core/utils.dart index 3d59fef..a8367de 100644 --- a/lib/core/utils.dart +++ b/lib/core/utils.dart @@ -3,3 +3,5 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; final kIsMobile = !kIsWeb && Platform.isAndroid || Platform.isIOS; +final kIsDesktop = + !kIsWeb && Platform.isWindows || Platform.isMacOS || Platform.isLinux; diff --git a/lib/features/settings/ui/widgets/settings_page_app_info.dart b/lib/features/settings/ui/widgets/settings_page_app_info.dart index 5eed0ae..e0e43a0 100644 --- a/lib/features/settings/ui/widgets/settings_page_app_info.dart +++ b/lib/features/settings/ui/widgets/settings_page_app_info.dart @@ -12,7 +12,7 @@ class _SettingsPageAppInfo extends ConsumerWidget { final packageInfo = ref.watch(packageInfoStateHolder); return packageInfo.when( data: (packageInfo) => Text( - "${packageInfo.appName} v${packageInfo.version}+${packageInfo.buildNumber}", + "Куб.Расписание v${packageInfo.version}+${packageInfo.buildNumber}", style: context.textStyles.smallSubTitle.copyWith( color: context.colors.subduedText, ), diff --git a/lib/features/settings/ui/widgets/settings_page_lesson_card_lesson_type_position.dart b/lib/features/settings/ui/widgets/settings_page_lesson_card_lesson_type_position.dart index 2a58b77..8bd607d 100644 --- a/lib/features/settings/ui/widgets/settings_page_lesson_card_lesson_type_position.dart +++ b/lib/features/settings/ui/widgets/settings_page_lesson_card_lesson_type_position.dart @@ -14,7 +14,7 @@ class _SettingsPageLessonCardLessonTypePosition extends ConsumerWidget { return AppRadioSelector( label: const Text( - 'Расположение типа занятия в карточке \n(1000 и 1 способ - pre-release overview)', + 'Расположение типа занятия в карточке', ), value: lessonCardLessonTypePosition, onSelect: (value) => diff --git a/lib/main.dart b/lib/main.dart index 947da52..8d9dac7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,11 +11,18 @@ import 'package:cube_system/core/hive_initializer.dart'; import 'package:cube_system/features/analytics/logger.dart'; import 'package:cube_system/core/utils.dart'; +import 'package:window_size/window_size.dart'; void main() async { final widgetConfiguration = WidgetConfiguration( child: AppBuilder( preInitialize: (binding) async { + if (kIsDesktop) { + setWindowTitle('Куб.Расписание'); + setWindowMinSize(const Size(460, 380)); + setWindowMaxSize(const Size.fromWidth(700)); + } + await dotenv.load(); await Future.wait([ if (kIsMobile) From e039efcb0871f473fefdd1695ffcedee4a05a202 Mon Sep 17 00:00:00 2001 From: StarProxima Date: Tue, 25 Apr 2023 20:47:12 +0300 Subject: [PATCH 2/6] Separate LesonFullTimings --- lib/core/hive_initializer.dart | 4 +- .../models/app_settings/app_settings.g.dart | 16 +- .../current_lesson_time_to_end_provider.dart | 2 +- ...time_to_start_progress_value_provider.dart | 8 +- ...time_to_start_progress_value_provider.dart | 4 +- .../next_lesson_time_to_start_provider.dart | 2 +- .../ui/widgets/lesson_card_indicator.dart | 3 +- .../lesson_card/ui/widgets/recess_card.dart | 49 ++-- .../managers/lesson_convertor.dart | 9 +- .../managers/timetable_lessons_manager.dart | 6 +- lib/models/lesson/lesson.dart | 29 +-- lib/models/lesson/lesson.freezed.dart | 210 ++++++++++------- lib/models/lesson/lesson.g.dart | 49 ++-- .../lesson_timings/lesson_date_timings.dart | 14 ++ .../lesson_date_timings.freezed.dart | 167 ++++++++++++++ ...ings.g.dart => lesson_date_timings.g.dart} | 26 +-- .../lesson_timings/lesson_full_timings.dart | 17 -- .../lesson_full_timings.freezed.dart | 214 ------------------ 18 files changed, 415 insertions(+), 414 deletions(-) create mode 100644 lib/models/lesson_timings/lesson_date_timings.dart create mode 100644 lib/models/lesson_timings/lesson_date_timings.freezed.dart rename lib/models/lesson_timings/{lesson_full_timings.g.dart => lesson_date_timings.g.dart} (59%) delete mode 100644 lib/models/lesson_timings/lesson_full_timings.dart delete mode 100644 lib/models/lesson_timings/lesson_full_timings.freezed.dart diff --git a/lib/core/hive_initializer.dart b/lib/core/hive_initializer.dart index 18dafe6..1818949 100644 --- a/lib/core/hive_initializer.dart +++ b/lib/core/hive_initializer.dart @@ -10,7 +10,7 @@ import 'package:cube_system/features/settings/models/app_theme_mode/app_theme_mo import 'package:cube_system/features/settings/models/lesson_card_recess_display_condition/lesson_card_recess_display_condition.dart'; import 'package:cube_system/models/adapters/time_of_day_adapter.dart'; import 'package:cube_system/models/lesson/lesson.dart'; -import 'package:cube_system/models/lesson_timings/lesson_full_timings.dart'; +import 'package:cube_system/models/lesson_timings/lesson_date_timings.dart'; import 'package:cube_system/models/lesson_timings/lesson_timings.dart'; import 'package:cube_system/models/lesson_type/lesson_type.dart'; import 'package:cube_system/models/timetable/timetable_type.dart'; @@ -30,7 +30,7 @@ abstract class HiveInitializer { _reg(LessonCardRecessDisplayConditionAdapter()); _reg(TimeOfDayAdapter()); _reg(LessonAdapter()); - _reg(LessonFullTimingsAdapter()); + _reg(LessonDateTimingsAdapter()); _reg(LessonTimingsAdapter()); _reg(LessonTypeAdapter()); _reg(TimetableInfoAdapter()); diff --git a/lib/features/settings/models/app_settings/app_settings.g.dart b/lib/features/settings/models/app_settings/app_settings.g.dart index dd0c9ae..42a4efd 100644 --- a/lib/features/settings/models/app_settings/app_settings.g.dart +++ b/lib/features/settings/models/app_settings/app_settings.g.dart @@ -63,19 +63,15 @@ _$_AppSettings _$$_AppSettingsFromJson(Map json) => $enumDecodeNullable(_$AppThemeModeEnumMap, json['appThemeMode']) ?? AppThemeMode.system, lessonColorsMode: $enumDecodeNullable( - _$AppLessonColorsModeEnumMap, - json['lessonColorsMode'], - ) ?? + _$AppLessonColorsModeEnumMap, json['lessonColorsMode']) ?? AppLessonColorsMode.cube, lessonCardLessonTypePosition: $enumDecodeNullable( - _$LessonCardLessonTypePositionEnumMap, - json['lessonCardLessonTypePosition'], - ) ?? + _$LessonCardLessonTypePositionEnumMap, + json['lessonCardLessonTypePosition']) ?? LessonCardLessonTypePosition.bottomRight, lessonCardRecessDisplayCondition: $enumDecodeNullable( - _$LessonCardRecessDisplayConditionEnumMap, - json['lessonCardRecessDisplayCondition'], - ) ?? + _$LessonCardRecessDisplayConditionEnumMap, + json['lessonCardRecessDisplayCondition']) ?? LessonCardRecessDisplayCondition.always, landingPassed: json['landingPassed'] as bool? ?? false, ); @@ -101,7 +97,7 @@ const _$AppThemeModeEnumMap = { const _$AppLessonColorsModeEnumMap = { AppLessonColorsMode.cube: 'cube', - AppLessonColorsMode.accent: 'proxima', + AppLessonColorsMode.accent: 'accent', }; const _$LessonCardLessonTypePositionEnumMap = { diff --git a/lib/features/timetable_page/features/lesson_card/providers/current_lesson_time_to_end_provider.dart b/lib/features/timetable_page/features/lesson_card/providers/current_lesson_time_to_end_provider.dart index ac49c45..787fec1 100644 --- a/lib/features/timetable_page/features/lesson_card/providers/current_lesson_time_to_end_provider.dart +++ b/lib/features/timetable_page/features/lesson_card/providers/current_lesson_time_to_end_provider.dart @@ -10,7 +10,7 @@ final currentLessonTimeToEndProvider = Provider((ref) { if (activeLesson == null) return null; - final endLessonDateTime = activeLesson.timings.endDateTime; + final endLessonDateTime = activeLesson.dateTimings.endDateTime; final duration = endLessonDateTime.difference(currentDateTime); return DateTimeDuration(duration); diff --git a/lib/features/timetable_page/features/lesson_card/providers/lesson_time_to_start_progress_value_provider.dart b/lib/features/timetable_page/features/lesson_card/providers/lesson_time_to_start_progress_value_provider.dart index dd6a1b1..f326b7f 100644 --- a/lib/features/timetable_page/features/lesson_card/providers/lesson_time_to_start_progress_value_provider.dart +++ b/lib/features/timetable_page/features/lesson_card/providers/lesson_time_to_start_progress_value_provider.dart @@ -1,13 +1,13 @@ -import 'package:cube_system/models/lesson/lesson.dart'; import 'package:cube_system/features/date_time_contol/state_holders/current_date_time_state_holders.dart'; +import 'package:cube_system/models/lesson_timings/lesson_date_timings.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; final lessonTimeToEndProgressValueProvider = - Provider.family.autoDispose((ref, lesson) { + Provider.family.autoDispose((ref, timings) { final currentDateTime = ref.watch(currentDateTimeLazy); - final lessonStart = lesson.timings.startDateTime; - final lessonEnd = lesson.timings.endDateTime; + final lessonStart = timings.startDateTime; + final lessonEnd = timings.endDateTime; final lessonIsOver = currentDateTime.isAfter(lessonEnd); final lessonNotStarted = currentDateTime.isBefore(lessonStart); diff --git a/lib/features/timetable_page/features/lesson_card/providers/next_lesson_time_to_start_progress_value_provider.dart b/lib/features/timetable_page/features/lesson_card/providers/next_lesson_time_to_start_progress_value_provider.dart index 237371a..61dff2e 100644 --- a/lib/features/timetable_page/features/lesson_card/providers/next_lesson_time_to_start_progress_value_provider.dart +++ b/lib/features/timetable_page/features/lesson_card/providers/next_lesson_time_to_start_progress_value_provider.dart @@ -22,8 +22,8 @@ final nextLessonTimeToStartProgressValueProvider = Provider((ref) { if (lessonNext == null || lessonLast == null) return 1; - final startInterval = lessonLast.timings.endDateTime; - final endInterval = lessonNext.timings.startDateTime; + final startInterval = lessonLast.dateTimings.endDateTime; + final endInterval = lessonNext.dateTimings.startDateTime; final recessTime = endInterval.difference(startInterval); diff --git a/lib/features/timetable_page/features/lesson_card/providers/next_lesson_time_to_start_provider.dart b/lib/features/timetable_page/features/lesson_card/providers/next_lesson_time_to_start_provider.dart index 5fa0f60..9c8592d 100644 --- a/lib/features/timetable_page/features/lesson_card/providers/next_lesson_time_to_start_provider.dart +++ b/lib/features/timetable_page/features/lesson_card/providers/next_lesson_time_to_start_provider.dart @@ -28,7 +28,7 @@ final nextLessonTimeToStartProvider = Provider((ref) { final dateTime = ref.watch(currentDateTimeQuick); - final startDateTime = next.timings.startDateTime; + final startDateTime = next.dateTimings.startDateTime; final duration = startDateTime.difference(dateTime); return DateTimeDuration(duration); diff --git a/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_indicator.dart b/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_indicator.dart index 2a07d78..df4cdfa 100644 --- a/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_indicator.dart +++ b/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_indicator.dart @@ -7,7 +7,8 @@ class LessonCardIndicator extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final lesson = ref.watch(_lessonInLessonCard); - double value = ref.watch(lessonTimeToEndProgressValueProvider(lesson)); + double value = + ref.watch(lessonTimeToEndProgressValueProvider(lesson.dateTimings)); final color = ref.watch(appLessonColorByLesson(lesson)); diff --git a/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart b/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart index 4434003..603d1d4 100644 --- a/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart +++ b/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart @@ -1,3 +1,4 @@ +import 'package:cube_system/features/settings/state_holders/app_settings_state_holder.dart'; import 'package:cube_system/styles/app_theme_context_extension.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -31,6 +32,7 @@ class RecessCard extends ConsumerWidget { final numberStr = numberStart != numberEnd ? '$numberStart - $numberEnd' : '$numberStart'; + return Container( height: 40, decoration: BoxDecoration( @@ -47,23 +49,40 @@ class RecessCard extends ConsumerWidget { clipBehavior: Clip.antiAlias, child: Row( children: [ - Container( - width: 6, - decoration: BoxDecoration( - color: color?.toAppFadedColor(), - ), - child: Align( - alignment: Alignment.bottomCenter, - child: FractionallySizedBox( - heightFactor: 1.cutNumberEdgesZeroToOne(), - child: Container( - width: 6, - decoration: BoxDecoration( - color: color, + Consumer( + builder: (context, ref, _) { + final isOnIndicator = ref.watch( + appSettingsStateHolder.select( + (value) => + value.lessonCardLessonTypePosition.isOnIndicator, + ), + ); + double width = isOnIndicator ? 20 : 6; + + return Container( + width: width, + decoration: BoxDecoration( + color: color?.toAppFadedColor(), + ), + child: Align( + alignment: Alignment.bottomCenter, + child: Consumer( + child: Container( + width: width, + decoration: BoxDecoration( + color: color, + ), + ), + builder: (context, ref, child) { + return FractionallySizedBox( + heightFactor: 1.cutNumberEdgesZeroToOne(), + child: child, + ); + }, ), ), - ), - ), + ); + }, ), const SizedBox(width: 12), Container( diff --git a/lib/features/timetable_page/managers/lesson_convertor.dart b/lib/features/timetable_page/managers/lesson_convertor.dart index 761a915..6af5143 100644 --- a/lib/features/timetable_page/managers/lesson_convertor.dart +++ b/lib/features/timetable_page/managers/lesson_convertor.dart @@ -1,7 +1,7 @@ import 'dart:ui'; import 'package:cube_system/gen/api/cube_api.swagger.dart'; -import 'package:cube_system/models/lesson_timings/lesson_full_timings.dart'; +import 'package:cube_system/models/lesson_timings/lesson_date_timings.dart'; import 'package:cube_system/models/lesson_type/lesson_type.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -67,9 +67,7 @@ class LessonConvertor { final timings = lessonTimings.state[number]!; - final fullTiminigs = LessonFullTimings( - start: timings.start, - end: timings.end, + final dateTiminigs = LessonDateTimings( startDateTime: date.add( Duration(hours: timings.start.hour, minutes: timings.start.minute), ), @@ -80,7 +78,8 @@ class LessonConvertor { final newLesson = Lesson( number: lesson.number, - timings: fullTiminigs, + timings: timings, + dateTimings: dateTiminigs, type: type, typeShortName: lesson.type.shortName, disciplineName: lesson.discipline?.name, diff --git a/lib/features/timetable_page/managers/timetable_lessons_manager.dart b/lib/features/timetable_page/managers/timetable_lessons_manager.dart index 6cb8df3..58e85c4 100644 --- a/lib/features/timetable_page/managers/timetable_lessons_manager.dart +++ b/lib/features/timetable_page/managers/timetable_lessons_manager.dart @@ -173,10 +173,10 @@ class TimetableLessonsManager { for (final lesson in lessons) { if (lesson.isEvent) continue; - if (currentDate.isAfter(lesson.timings.startDateTime) && - currentDate.isBefore(lesson.timings.endDateTime)) { + if (currentDate.isAfter(lesson.dateTimings.startDateTime) && + currentDate.isBefore(lesson.dateTimings.endDateTime)) { lessonCurrent = lesson; - } else if (currentDate.isBefore(lesson.timings.startDateTime)) { + } else if (currentDate.isBefore(lesson.dateTimings.startDateTime)) { nextLesson.state = lesson; currentLesson.state = lessonCurrent; lastLesson.state = lessonLast; diff --git a/lib/models/lesson/lesson.dart b/lib/models/lesson/lesson.dart index 15a3689..bdfbd1d 100644 --- a/lib/models/lesson/lesson.dart +++ b/lib/models/lesson/lesson.dart @@ -1,9 +1,11 @@ import 'dart:ui'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:cube_system/models/lesson_timings/lesson_full_timings.dart'; +import 'package:cube_system/models/lesson_timings/lesson_date_timings.dart'; import 'package:cube_system/models/lesson_type/lesson_type.dart'; import 'package:hive/hive.dart'; +import 'package:cube_system/models/lesson_timings/lesson_timings.dart'; + part 'lesson.freezed.dart'; part 'lesson.g.dart'; @@ -12,17 +14,18 @@ class Lesson with _$Lesson { @HiveType(typeId: 0) factory Lesson({ @HiveField(0) required int number, - @HiveField(1) required LessonFullTimings timings, - @HiveField(2) required LessonType type, - @HiveField(3) required String typeShortName, - @HiveField(4) required String? disciplineName, - @HiveField(5) required String? place, - @HiveField(6) required List groupNames, - @HiveField(7) required List teacherNames, - @HiveField(8) required bool isRemotely, - @HiveField(9) required bool isElective, - @HiveField(10) required bool isEvent, - @HiveField(11) required Color defaultColor, - @HiveField(12) required int emptyLessonsBefore, + @HiveField(1) required LessonTimings timings, + @HiveField(2) required LessonDateTimings dateTimings, + @HiveField(3) required LessonType type, + @HiveField(4) required String typeShortName, + @HiveField(5) required String? disciplineName, + @HiveField(6) required String? place, + @HiveField(7) required List groupNames, + @HiveField(8) required List teacherNames, + @HiveField(9) required bool isRemotely, + @HiveField(10) required bool isElective, + @HiveField(11) required bool isEvent, + @HiveField(12) required Color defaultColor, + @HiveField(13) required int emptyLessonsBefore, }) = _Lesson; } diff --git a/lib/models/lesson/lesson.freezed.dart b/lib/models/lesson/lesson.freezed.dart index 2862cff..1aeb7fb 100644 --- a/lib/models/lesson/lesson.freezed.dart +++ b/lib/models/lesson/lesson.freezed.dart @@ -19,28 +19,30 @@ mixin _$Lesson { @HiveField(0) int get number => throw _privateConstructorUsedError; @HiveField(1) - LessonFullTimings get timings => throw _privateConstructorUsedError; + LessonTimings get timings => throw _privateConstructorUsedError; @HiveField(2) - LessonType get type => throw _privateConstructorUsedError; + LessonDateTimings get dateTimings => throw _privateConstructorUsedError; @HiveField(3) - String get typeShortName => throw _privateConstructorUsedError; + LessonType get type => throw _privateConstructorUsedError; @HiveField(4) - String? get disciplineName => throw _privateConstructorUsedError; + String get typeShortName => throw _privateConstructorUsedError; @HiveField(5) - String? get place => throw _privateConstructorUsedError; + String? get disciplineName => throw _privateConstructorUsedError; @HiveField(6) - List get groupNames => throw _privateConstructorUsedError; + String? get place => throw _privateConstructorUsedError; @HiveField(7) - List get teacherNames => throw _privateConstructorUsedError; + List get groupNames => throw _privateConstructorUsedError; @HiveField(8) - bool get isRemotely => throw _privateConstructorUsedError; + List get teacherNames => throw _privateConstructorUsedError; @HiveField(9) - bool get isElective => throw _privateConstructorUsedError; + bool get isRemotely => throw _privateConstructorUsedError; @HiveField(10) - bool get isEvent => throw _privateConstructorUsedError; + bool get isElective => throw _privateConstructorUsedError; @HiveField(11) - Color get defaultColor => throw _privateConstructorUsedError; + bool get isEvent => throw _privateConstructorUsedError; @HiveField(12) + Color get defaultColor => throw _privateConstructorUsedError; + @HiveField(13) int get emptyLessonsBefore => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -54,20 +56,22 @@ abstract class $LessonCopyWith<$Res> { @useResult $Res call( {@HiveField(0) int number, - @HiveField(1) LessonFullTimings timings, - @HiveField(2) LessonType type, - @HiveField(3) String typeShortName, - @HiveField(4) String? disciplineName, - @HiveField(5) String? place, - @HiveField(6) List groupNames, - @HiveField(7) List teacherNames, - @HiveField(8) bool isRemotely, - @HiveField(9) bool isElective, - @HiveField(10) bool isEvent, - @HiveField(11) Color defaultColor, - @HiveField(12) int emptyLessonsBefore}); + @HiveField(1) LessonTimings timings, + @HiveField(2) LessonDateTimings dateTimings, + @HiveField(3) LessonType type, + @HiveField(4) String typeShortName, + @HiveField(5) String? disciplineName, + @HiveField(6) String? place, + @HiveField(7) List groupNames, + @HiveField(8) List teacherNames, + @HiveField(9) bool isRemotely, + @HiveField(10) bool isElective, + @HiveField(11) bool isEvent, + @HiveField(12) Color defaultColor, + @HiveField(13) int emptyLessonsBefore}); - $LessonFullTimingsCopyWith<$Res> get timings; + $LessonTimingsCopyWith<$Res> get timings; + $LessonDateTimingsCopyWith<$Res> get dateTimings; } /// @nodoc @@ -85,6 +89,7 @@ class _$LessonCopyWithImpl<$Res, $Val extends Lesson> $Res call({ Object? number = null, Object? timings = null, + Object? dateTimings = null, Object? type = null, Object? typeShortName = null, Object? disciplineName = freezed, @@ -105,7 +110,11 @@ class _$LessonCopyWithImpl<$Res, $Val extends Lesson> timings: null == timings ? _value.timings : timings // ignore: cast_nullable_to_non_nullable - as LessonFullTimings, + as LessonTimings, + dateTimings: null == dateTimings + ? _value.dateTimings + : dateTimings // ignore: cast_nullable_to_non_nullable + as LessonDateTimings, type: null == type ? _value.type : type // ignore: cast_nullable_to_non_nullable @@ -155,11 +164,19 @@ class _$LessonCopyWithImpl<$Res, $Val extends Lesson> @override @pragma('vm:prefer-inline') - $LessonFullTimingsCopyWith<$Res> get timings { - return $LessonFullTimingsCopyWith<$Res>(_value.timings, (value) { + $LessonTimingsCopyWith<$Res> get timings { + return $LessonTimingsCopyWith<$Res>(_value.timings, (value) { return _then(_value.copyWith(timings: value) as $Val); }); } + + @override + @pragma('vm:prefer-inline') + $LessonDateTimingsCopyWith<$Res> get dateTimings { + return $LessonDateTimingsCopyWith<$Res>(_value.dateTimings, (value) { + return _then(_value.copyWith(dateTimings: value) as $Val); + }); + } } /// @nodoc @@ -170,21 +187,24 @@ abstract class _$$_LessonCopyWith<$Res> implements $LessonCopyWith<$Res> { @useResult $Res call( {@HiveField(0) int number, - @HiveField(1) LessonFullTimings timings, - @HiveField(2) LessonType type, - @HiveField(3) String typeShortName, - @HiveField(4) String? disciplineName, - @HiveField(5) String? place, - @HiveField(6) List groupNames, - @HiveField(7) List teacherNames, - @HiveField(8) bool isRemotely, - @HiveField(9) bool isElective, - @HiveField(10) bool isEvent, - @HiveField(11) Color defaultColor, - @HiveField(12) int emptyLessonsBefore}); + @HiveField(1) LessonTimings timings, + @HiveField(2) LessonDateTimings dateTimings, + @HiveField(3) LessonType type, + @HiveField(4) String typeShortName, + @HiveField(5) String? disciplineName, + @HiveField(6) String? place, + @HiveField(7) List groupNames, + @HiveField(8) List teacherNames, + @HiveField(9) bool isRemotely, + @HiveField(10) bool isElective, + @HiveField(11) bool isEvent, + @HiveField(12) Color defaultColor, + @HiveField(13) int emptyLessonsBefore}); @override - $LessonFullTimingsCopyWith<$Res> get timings; + $LessonTimingsCopyWith<$Res> get timings; + @override + $LessonDateTimingsCopyWith<$Res> get dateTimings; } /// @nodoc @@ -199,6 +219,7 @@ class __$$_LessonCopyWithImpl<$Res> $Res call({ Object? number = null, Object? timings = null, + Object? dateTimings = null, Object? type = null, Object? typeShortName = null, Object? disciplineName = freezed, @@ -219,7 +240,11 @@ class __$$_LessonCopyWithImpl<$Res> timings: null == timings ? _value.timings : timings // ignore: cast_nullable_to_non_nullable - as LessonFullTimings, + as LessonTimings, + dateTimings: null == dateTimings + ? _value.dateTimings + : dateTimings // ignore: cast_nullable_to_non_nullable + as LessonDateTimings, type: null == type ? _value.type : type // ignore: cast_nullable_to_non_nullable @@ -275,17 +300,18 @@ class _$_Lesson implements _Lesson { _$_Lesson( {@HiveField(0) required this.number, @HiveField(1) required this.timings, - @HiveField(2) required this.type, - @HiveField(3) required this.typeShortName, - @HiveField(4) required this.disciplineName, - @HiveField(5) required this.place, - @HiveField(6) required final List groupNames, - @HiveField(7) required final List teacherNames, - @HiveField(8) required this.isRemotely, - @HiveField(9) required this.isElective, - @HiveField(10) required this.isEvent, - @HiveField(11) required this.defaultColor, - @HiveField(12) required this.emptyLessonsBefore}) + @HiveField(2) required this.dateTimings, + @HiveField(3) required this.type, + @HiveField(4) required this.typeShortName, + @HiveField(5) required this.disciplineName, + @HiveField(6) required this.place, + @HiveField(7) required final List groupNames, + @HiveField(8) required final List teacherNames, + @HiveField(9) required this.isRemotely, + @HiveField(10) required this.isElective, + @HiveField(11) required this.isEvent, + @HiveField(12) required this.defaultColor, + @HiveField(13) required this.emptyLessonsBefore}) : _groupNames = groupNames, _teacherNames = teacherNames; @@ -294,22 +320,25 @@ class _$_Lesson implements _Lesson { final int number; @override @HiveField(1) - final LessonFullTimings timings; + final LessonTimings timings; @override @HiveField(2) - final LessonType type; + final LessonDateTimings dateTimings; @override @HiveField(3) - final String typeShortName; + final LessonType type; @override @HiveField(4) - final String? disciplineName; + final String typeShortName; @override @HiveField(5) + final String? disciplineName; + @override + @HiveField(6) final String? place; final List _groupNames; @override - @HiveField(6) + @HiveField(7) List get groupNames { if (_groupNames is EqualUnmodifiableListView) return _groupNames; // ignore: implicit_dynamic_type @@ -318,7 +347,7 @@ class _$_Lesson implements _Lesson { final List _teacherNames; @override - @HiveField(7) + @HiveField(8) List get teacherNames { if (_teacherNames is EqualUnmodifiableListView) return _teacherNames; // ignore: implicit_dynamic_type @@ -326,24 +355,24 @@ class _$_Lesson implements _Lesson { } @override - @HiveField(8) + @HiveField(9) final bool isRemotely; @override - @HiveField(9) + @HiveField(10) final bool isElective; @override - @HiveField(10) + @HiveField(11) final bool isEvent; @override - @HiveField(11) + @HiveField(12) final Color defaultColor; @override - @HiveField(12) + @HiveField(13) final int emptyLessonsBefore; @override String toString() { - return 'Lesson(number: $number, timings: $timings, type: $type, typeShortName: $typeShortName, disciplineName: $disciplineName, place: $place, groupNames: $groupNames, teacherNames: $teacherNames, isRemotely: $isRemotely, isElective: $isElective, isEvent: $isEvent, defaultColor: $defaultColor, emptyLessonsBefore: $emptyLessonsBefore)'; + return 'Lesson(number: $number, timings: $timings, dateTimings: $dateTimings, type: $type, typeShortName: $typeShortName, disciplineName: $disciplineName, place: $place, groupNames: $groupNames, teacherNames: $teacherNames, isRemotely: $isRemotely, isElective: $isElective, isEvent: $isEvent, defaultColor: $defaultColor, emptyLessonsBefore: $emptyLessonsBefore)'; } @override @@ -353,6 +382,8 @@ class _$_Lesson implements _Lesson { other is _$_Lesson && (identical(other.number, number) || other.number == number) && (identical(other.timings, timings) || other.timings == timings) && + (identical(other.dateTimings, dateTimings) || + other.dateTimings == dateTimings) && (identical(other.type, type) || other.type == type) && (identical(other.typeShortName, typeShortName) || other.typeShortName == typeShortName) && @@ -379,6 +410,7 @@ class _$_Lesson implements _Lesson { runtimeType, number, timings, + dateTimings, type, typeShortName, disciplineName, @@ -401,57 +433,61 @@ class _$_Lesson implements _Lesson { abstract class _Lesson implements Lesson { factory _Lesson( {@HiveField(0) required final int number, - @HiveField(1) required final LessonFullTimings timings, - @HiveField(2) required final LessonType type, - @HiveField(3) required final String typeShortName, - @HiveField(4) required final String? disciplineName, - @HiveField(5) required final String? place, - @HiveField(6) required final List groupNames, - @HiveField(7) required final List teacherNames, - @HiveField(8) required final bool isRemotely, - @HiveField(9) required final bool isElective, - @HiveField(10) required final bool isEvent, - @HiveField(11) required final Color defaultColor, - @HiveField(12) required final int emptyLessonsBefore}) = _$_Lesson; + @HiveField(1) required final LessonTimings timings, + @HiveField(2) required final LessonDateTimings dateTimings, + @HiveField(3) required final LessonType type, + @HiveField(4) required final String typeShortName, + @HiveField(5) required final String? disciplineName, + @HiveField(6) required final String? place, + @HiveField(7) required final List groupNames, + @HiveField(8) required final List teacherNames, + @HiveField(9) required final bool isRemotely, + @HiveField(10) required final bool isElective, + @HiveField(11) required final bool isEvent, + @HiveField(12) required final Color defaultColor, + @HiveField(13) required final int emptyLessonsBefore}) = _$_Lesson; @override @HiveField(0) int get number; @override @HiveField(1) - LessonFullTimings get timings; + LessonTimings get timings; @override @HiveField(2) - LessonType get type; + LessonDateTimings get dateTimings; @override @HiveField(3) - String get typeShortName; + LessonType get type; @override @HiveField(4) - String? get disciplineName; + String get typeShortName; @override @HiveField(5) - String? get place; + String? get disciplineName; @override @HiveField(6) - List get groupNames; + String? get place; @override @HiveField(7) - List get teacherNames; + List get groupNames; @override @HiveField(8) - bool get isRemotely; + List get teacherNames; @override @HiveField(9) - bool get isElective; + bool get isRemotely; @override @HiveField(10) - bool get isEvent; + bool get isElective; @override @HiveField(11) - Color get defaultColor; + bool get isEvent; @override @HiveField(12) + Color get defaultColor; + @override + @HiveField(13) int get emptyLessonsBefore; @override @JsonKey(ignore: true) diff --git a/lib/models/lesson/lesson.g.dart b/lib/models/lesson/lesson.g.dart index 22998ff..2b66e9a 100644 --- a/lib/models/lesson/lesson.g.dart +++ b/lib/models/lesson/lesson.g.dart @@ -18,50 +18,53 @@ class LessonAdapter extends TypeAdapter<_$_Lesson> { }; return _$_Lesson( number: fields[0] as int, - timings: fields[1] as LessonFullTimings, - type: fields[2] as LessonType, - typeShortName: fields[3] as String, - disciplineName: fields[4] as String?, - place: fields[5] as String?, - groupNames: (fields[6] as List).cast(), - teacherNames: (fields[7] as List).cast(), - isRemotely: fields[8] as bool, - isElective: fields[9] as bool, - isEvent: fields[10] as bool, - defaultColor: fields[11] as Color, - emptyLessonsBefore: fields[12] as int, + timings: fields[1] as LessonTimings, + dateTimings: fields[2] as LessonDateTimings, + type: fields[3] as LessonType, + typeShortName: fields[4] as String, + disciplineName: fields[5] as String?, + place: fields[6] as String?, + groupNames: (fields[7] as List).cast(), + teacherNames: (fields[8] as List).cast(), + isRemotely: fields[9] as bool, + isElective: fields[10] as bool, + isEvent: fields[11] as bool, + defaultColor: fields[12] as Color, + emptyLessonsBefore: fields[13] as int, ); } @override void write(BinaryWriter writer, _$_Lesson obj) { writer - ..writeByte(13) + ..writeByte(14) ..writeByte(0) ..write(obj.number) ..writeByte(1) ..write(obj.timings) ..writeByte(2) - ..write(obj.type) + ..write(obj.dateTimings) ..writeByte(3) - ..write(obj.typeShortName) + ..write(obj.type) ..writeByte(4) - ..write(obj.disciplineName) + ..write(obj.typeShortName) ..writeByte(5) + ..write(obj.disciplineName) + ..writeByte(6) ..write(obj.place) - ..writeByte(8) - ..write(obj.isRemotely) ..writeByte(9) - ..write(obj.isElective) + ..write(obj.isRemotely) ..writeByte(10) - ..write(obj.isEvent) + ..write(obj.isElective) ..writeByte(11) - ..write(obj.defaultColor) + ..write(obj.isEvent) ..writeByte(12) + ..write(obj.defaultColor) + ..writeByte(13) ..write(obj.emptyLessonsBefore) - ..writeByte(6) - ..write(obj.groupNames) ..writeByte(7) + ..write(obj.groupNames) + ..writeByte(8) ..write(obj.teacherNames); } diff --git a/lib/models/lesson_timings/lesson_date_timings.dart b/lib/models/lesson_timings/lesson_date_timings.dart new file mode 100644 index 0000000..1a3772f --- /dev/null +++ b/lib/models/lesson_timings/lesson_date_timings.dart @@ -0,0 +1,14 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:hive/hive.dart'; + +part 'lesson_date_timings.freezed.dart'; +part 'lesson_date_timings.g.dart'; + +@freezed +class LessonDateTimings with _$LessonDateTimings { + @HiveType(typeId: 1) + factory LessonDateTimings({ + @HiveField(0) required DateTime startDateTime, + @HiveField(1) required DateTime endDateTime, + }) = _LessonDateTimings; +} diff --git a/lib/models/lesson_timings/lesson_date_timings.freezed.dart b/lib/models/lesson_timings/lesson_date_timings.freezed.dart new file mode 100644 index 0000000..9562628 --- /dev/null +++ b/lib/models/lesson_timings/lesson_date_timings.freezed.dart @@ -0,0 +1,167 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'lesson_date_timings.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +/// @nodoc +mixin _$LessonDateTimings { + @HiveField(0) + DateTime get startDateTime => throw _privateConstructorUsedError; + @HiveField(1) + DateTime get endDateTime => throw _privateConstructorUsedError; + + @JsonKey(ignore: true) + $LessonDateTimingsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $LessonDateTimingsCopyWith<$Res> { + factory $LessonDateTimingsCopyWith( + LessonDateTimings value, $Res Function(LessonDateTimings) then) = + _$LessonDateTimingsCopyWithImpl<$Res, LessonDateTimings>; + @useResult + $Res call( + {@HiveField(0) DateTime startDateTime, + @HiveField(1) DateTime endDateTime}); +} + +/// @nodoc +class _$LessonDateTimingsCopyWithImpl<$Res, $Val extends LessonDateTimings> + implements $LessonDateTimingsCopyWith<$Res> { + _$LessonDateTimingsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? startDateTime = null, + Object? endDateTime = null, + }) { + return _then(_value.copyWith( + startDateTime: null == startDateTime + ? _value.startDateTime + : startDateTime // ignore: cast_nullable_to_non_nullable + as DateTime, + endDateTime: null == endDateTime + ? _value.endDateTime + : endDateTime // ignore: cast_nullable_to_non_nullable + as DateTime, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$_LessonDateTimingsCopyWith<$Res> + implements $LessonDateTimingsCopyWith<$Res> { + factory _$$_LessonDateTimingsCopyWith(_$_LessonDateTimings value, + $Res Function(_$_LessonDateTimings) then) = + __$$_LessonDateTimingsCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@HiveField(0) DateTime startDateTime, + @HiveField(1) DateTime endDateTime}); +} + +/// @nodoc +class __$$_LessonDateTimingsCopyWithImpl<$Res> + extends _$LessonDateTimingsCopyWithImpl<$Res, _$_LessonDateTimings> + implements _$$_LessonDateTimingsCopyWith<$Res> { + __$$_LessonDateTimingsCopyWithImpl( + _$_LessonDateTimings _value, $Res Function(_$_LessonDateTimings) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? startDateTime = null, + Object? endDateTime = null, + }) { + return _then(_$_LessonDateTimings( + startDateTime: null == startDateTime + ? _value.startDateTime + : startDateTime // ignore: cast_nullable_to_non_nullable + as DateTime, + endDateTime: null == endDateTime + ? _value.endDateTime + : endDateTime // ignore: cast_nullable_to_non_nullable + as DateTime, + )); + } +} + +/// @nodoc + +@HiveType(typeId: 1) +class _$_LessonDateTimings implements _LessonDateTimings { + _$_LessonDateTimings( + {@HiveField(0) required this.startDateTime, + @HiveField(1) required this.endDateTime}); + + @override + @HiveField(0) + final DateTime startDateTime; + @override + @HiveField(1) + final DateTime endDateTime; + + @override + String toString() { + return 'LessonDateTimings(startDateTime: $startDateTime, endDateTime: $endDateTime)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$_LessonDateTimings && + (identical(other.startDateTime, startDateTime) || + other.startDateTime == startDateTime) && + (identical(other.endDateTime, endDateTime) || + other.endDateTime == endDateTime)); + } + + @override + int get hashCode => Object.hash(runtimeType, startDateTime, endDateTime); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$_LessonDateTimingsCopyWith<_$_LessonDateTimings> get copyWith => + __$$_LessonDateTimingsCopyWithImpl<_$_LessonDateTimings>( + this, _$identity); +} + +abstract class _LessonDateTimings implements LessonDateTimings { + factory _LessonDateTimings( + {@HiveField(0) required final DateTime startDateTime, + @HiveField(1) required final DateTime endDateTime}) = + _$_LessonDateTimings; + + @override + @HiveField(0) + DateTime get startDateTime; + @override + @HiveField(1) + DateTime get endDateTime; + @override + @JsonKey(ignore: true) + _$$_LessonDateTimingsCopyWith<_$_LessonDateTimings> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/lesson_timings/lesson_full_timings.g.dart b/lib/models/lesson_timings/lesson_date_timings.g.dart similarity index 59% rename from lib/models/lesson_timings/lesson_full_timings.g.dart rename to lib/models/lesson_timings/lesson_date_timings.g.dart index fa617c7..d10f6a8 100644 --- a/lib/models/lesson_timings/lesson_full_timings.g.dart +++ b/lib/models/lesson_timings/lesson_date_timings.g.dart @@ -1,40 +1,34 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'lesson_full_timings.dart'; +part of 'lesson_date_timings.dart'; // ************************************************************************** // TypeAdapterGenerator // ************************************************************************** -class LessonFullTimingsAdapter extends TypeAdapter<_$_LessonFullTimings> { +class LessonDateTimingsAdapter extends TypeAdapter<_$_LessonDateTimings> { @override final int typeId = 1; @override - _$_LessonFullTimings read(BinaryReader reader) { + _$_LessonDateTimings read(BinaryReader reader) { final numOfFields = reader.readByte(); final fields = { for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(), }; - return _$_LessonFullTimings( - start: fields[0] as TimeOfDay, - end: fields[2] as TimeOfDay, - startDateTime: fields[3] as DateTime, - endDateTime: fields[4] as DateTime, + return _$_LessonDateTimings( + startDateTime: fields[0] as DateTime, + endDateTime: fields[1] as DateTime, ); } @override - void write(BinaryWriter writer, _$_LessonFullTimings obj) { + void write(BinaryWriter writer, _$_LessonDateTimings obj) { writer - ..writeByte(4) - ..writeByte(0) - ..write(obj.start) ..writeByte(2) - ..write(obj.end) - ..writeByte(3) + ..writeByte(0) ..write(obj.startDateTime) - ..writeByte(4) + ..writeByte(1) ..write(obj.endDateTime); } @@ -44,7 +38,7 @@ class LessonFullTimingsAdapter extends TypeAdapter<_$_LessonFullTimings> { @override bool operator ==(Object other) => identical(this, other) || - other is LessonFullTimingsAdapter && + other is LessonDateTimingsAdapter && runtimeType == other.runtimeType && typeId == other.typeId; } diff --git a/lib/models/lesson_timings/lesson_full_timings.dart b/lib/models/lesson_timings/lesson_full_timings.dart deleted file mode 100644 index 24ca9b1..0000000 --- a/lib/models/lesson_timings/lesson_full_timings.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:hive/hive.dart'; - -part 'lesson_full_timings.freezed.dart'; -part 'lesson_full_timings.g.dart'; - -@freezed -class LessonFullTimings with _$LessonFullTimings { - @HiveType(typeId: 1) - factory LessonFullTimings({ - @HiveField(0) required TimeOfDay start, - @HiveField(2) required TimeOfDay end, - @HiveField(3) required DateTime startDateTime, - @HiveField(4) required DateTime endDateTime, - }) = _LessonFullTimings; -} diff --git a/lib/models/lesson_timings/lesson_full_timings.freezed.dart b/lib/models/lesson_timings/lesson_full_timings.freezed.dart deleted file mode 100644 index 90d6f05..0000000 --- a/lib/models/lesson_timings/lesson_full_timings.freezed.dart +++ /dev/null @@ -1,214 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'lesson_full_timings.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); - -/// @nodoc -mixin _$LessonFullTimings { - @HiveField(0) - TimeOfDay get start => throw _privateConstructorUsedError; - @HiveField(2) - TimeOfDay get end => throw _privateConstructorUsedError; - @HiveField(3) - DateTime get startDateTime => throw _privateConstructorUsedError; - @HiveField(4) - DateTime get endDateTime => throw _privateConstructorUsedError; - - @JsonKey(ignore: true) - $LessonFullTimingsCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $LessonFullTimingsCopyWith<$Res> { - factory $LessonFullTimingsCopyWith( - LessonFullTimings value, $Res Function(LessonFullTimings) then) = - _$LessonFullTimingsCopyWithImpl<$Res, LessonFullTimings>; - @useResult - $Res call( - {@HiveField(0) TimeOfDay start, - @HiveField(2) TimeOfDay end, - @HiveField(3) DateTime startDateTime, - @HiveField(4) DateTime endDateTime}); -} - -/// @nodoc -class _$LessonFullTimingsCopyWithImpl<$Res, $Val extends LessonFullTimings> - implements $LessonFullTimingsCopyWith<$Res> { - _$LessonFullTimingsCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? start = null, - Object? end = null, - Object? startDateTime = null, - Object? endDateTime = null, - }) { - return _then(_value.copyWith( - start: null == start - ? _value.start - : start // ignore: cast_nullable_to_non_nullable - as TimeOfDay, - end: null == end - ? _value.end - : end // ignore: cast_nullable_to_non_nullable - as TimeOfDay, - startDateTime: null == startDateTime - ? _value.startDateTime - : startDateTime // ignore: cast_nullable_to_non_nullable - as DateTime, - endDateTime: null == endDateTime - ? _value.endDateTime - : endDateTime // ignore: cast_nullable_to_non_nullable - as DateTime, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$_LessonFullTimingsCopyWith<$Res> - implements $LessonFullTimingsCopyWith<$Res> { - factory _$$_LessonFullTimingsCopyWith(_$_LessonFullTimings value, - $Res Function(_$_LessonFullTimings) then) = - __$$_LessonFullTimingsCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {@HiveField(0) TimeOfDay start, - @HiveField(2) TimeOfDay end, - @HiveField(3) DateTime startDateTime, - @HiveField(4) DateTime endDateTime}); -} - -/// @nodoc -class __$$_LessonFullTimingsCopyWithImpl<$Res> - extends _$LessonFullTimingsCopyWithImpl<$Res, _$_LessonFullTimings> - implements _$$_LessonFullTimingsCopyWith<$Res> { - __$$_LessonFullTimingsCopyWithImpl( - _$_LessonFullTimings _value, $Res Function(_$_LessonFullTimings) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? start = null, - Object? end = null, - Object? startDateTime = null, - Object? endDateTime = null, - }) { - return _then(_$_LessonFullTimings( - start: null == start - ? _value.start - : start // ignore: cast_nullable_to_non_nullable - as TimeOfDay, - end: null == end - ? _value.end - : end // ignore: cast_nullable_to_non_nullable - as TimeOfDay, - startDateTime: null == startDateTime - ? _value.startDateTime - : startDateTime // ignore: cast_nullable_to_non_nullable - as DateTime, - endDateTime: null == endDateTime - ? _value.endDateTime - : endDateTime // ignore: cast_nullable_to_non_nullable - as DateTime, - )); - } -} - -/// @nodoc - -@HiveType(typeId: 1) -class _$_LessonFullTimings implements _LessonFullTimings { - _$_LessonFullTimings( - {@HiveField(0) required this.start, - @HiveField(2) required this.end, - @HiveField(3) required this.startDateTime, - @HiveField(4) required this.endDateTime}); - - @override - @HiveField(0) - final TimeOfDay start; - @override - @HiveField(2) - final TimeOfDay end; - @override - @HiveField(3) - final DateTime startDateTime; - @override - @HiveField(4) - final DateTime endDateTime; - - @override - String toString() { - return 'LessonFullTimings(start: $start, end: $end, startDateTime: $startDateTime, endDateTime: $endDateTime)'; - } - - @override - bool operator ==(dynamic other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$_LessonFullTimings && - (identical(other.start, start) || other.start == start) && - (identical(other.end, end) || other.end == end) && - (identical(other.startDateTime, startDateTime) || - other.startDateTime == startDateTime) && - (identical(other.endDateTime, endDateTime) || - other.endDateTime == endDateTime)); - } - - @override - int get hashCode => - Object.hash(runtimeType, start, end, startDateTime, endDateTime); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$_LessonFullTimingsCopyWith<_$_LessonFullTimings> get copyWith => - __$$_LessonFullTimingsCopyWithImpl<_$_LessonFullTimings>( - this, _$identity); -} - -abstract class _LessonFullTimings implements LessonFullTimings { - factory _LessonFullTimings( - {@HiveField(0) required final TimeOfDay start, - @HiveField(2) required final TimeOfDay end, - @HiveField(3) required final DateTime startDateTime, - @HiveField(4) required final DateTime endDateTime}) = - _$_LessonFullTimings; - - @override - @HiveField(0) - TimeOfDay get start; - @override - @HiveField(2) - TimeOfDay get end; - @override - @HiveField(3) - DateTime get startDateTime; - @override - @HiveField(4) - DateTime get endDateTime; - @override - @JsonKey(ignore: true) - _$$_LessonFullTimingsCopyWith<_$_LessonFullTimings> get copyWith => - throw _privateConstructorUsedError; -} From bee190308d436baffc846568ec2cfea0d6eb4cdd Mon Sep 17 00:00:00 2001 From: StarProxima Date: Tue, 25 Apr 2023 21:14:16 +0300 Subject: [PATCH 3/6] Faded indicator in RecessCard when it ended --- .../features/lesson_card/ui/lesson_card.dart | 2 +- .../ui/widgets/lesson_card_indicator.dart | 4 +- .../ui/widgets/lesson_card_recess.dart | 15 ++++-- .../lesson_card/ui/widgets/recess_card.dart | 51 ++++++++++++++----- 4 files changed, 52 insertions(+), 20 deletions(-) diff --git a/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart b/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart index 5d3c0b0..bfaf4d9 100644 --- a/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart +++ b/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart @@ -54,7 +54,7 @@ class LessonCard extends ConsumerWidget { child: Column( children: [ const LessonCardRecess( - margin: EdgeInsets.only(bottom: 8), + margin: EdgeInsets.only(bottom: 16), ), const LessonCardTimeToStart( margin: EdgeInsets.only(bottom: 8), diff --git a/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_indicator.dart b/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_indicator.dart index df4cdfa..93ceb5d 100644 --- a/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_indicator.dart +++ b/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_indicator.dart @@ -7,7 +7,7 @@ class LessonCardIndicator extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final lesson = ref.watch(_lessonInLessonCard); - double value = + final value = ref.watch(lessonTimeToEndProgressValueProvider(lesson.dateTimings)); final color = ref.watch(appLessonColorByLesson(lesson)); @@ -17,7 +17,7 @@ class LessonCardIndicator extends ConsumerWidget { .select((value) => value.lessonCardLessonTypePosition.isOnIndicator), ); - double width = isOnIndicator ? 20 : 6; + final width = isOnIndicator ? 20.0 : 6.0; return Stack( children: [ diff --git a/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_recess.dart b/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_recess.dart index 9e988d4..bbcdc98 100644 --- a/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_recess.dart +++ b/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_recess.dart @@ -12,21 +12,26 @@ class LessonCardRecess extends ConsumerWidget { final emptyLessonsBefore = ref .watch(_lessonInLessonCard.select((value) => value.emptyLessonsBefore)); + if (emptyLessonsBefore == 0) { + return const SizedBox(); + } + final number = ref.watch(_lessonInLessonCard.select((value) => value.number)); final numberStart = number - emptyLessonsBefore; final numberEnd = number - 1; - if (emptyLessonsBefore == 0) { - return const SizedBox(); - } + final date = ref.watch( + _lessonInLessonCard.select((value) => value.dateTimings.startDateTime), + ); return Padding( padding: margin ?? EdgeInsets.zero, child: RecessCard( - numberStart: numberStart, - numberEnd: numberEnd, + startLessonNumber: numberStart, + endLessonNumber: numberEnd, + dateTime: DateUtils.dateOnly(date), ), ); } diff --git a/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart b/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart index 603d1d4..b05f621 100644 --- a/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart +++ b/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart @@ -1,4 +1,5 @@ import 'package:cube_system/features/settings/state_holders/app_settings_state_holder.dart'; +import 'package:cube_system/models/lesson_timings/lesson_date_timings.dart'; import 'package:cube_system/styles/app_theme_context_extension.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -7,14 +8,18 @@ import 'package:cube_system/features/settings/state_holders/app_lesson_colors.da import 'package:cube_system/features/timetable_page/state_holders/lesson_timings.dart'; import 'package:cube_system/core/extensions.dart'; +import 'package:cube_system/features/timetable_page/features/lesson_card/providers/lesson_time_to_start_progress_value_provider.dart'; + class RecessCard extends ConsumerWidget { - final int numberStart; - final int numberEnd; + final int startLessonNumber; + final int endLessonNumber; + final DateTime dateTime; const RecessCard({ super.key, - required this.numberStart, - required this.numberEnd, + required this.startLessonNumber, + required this.endLessonNumber, + required this.dateTime, }); @override @@ -23,15 +28,31 @@ class RecessCard extends ConsumerWidget { builder: (context, ref, _) { final color = ref.watch(appLessonColors).recess; - final timingsStart = ref.watch(lessonTimings)[numberStart]!; - final timingsEnd = ref.watch(lessonTimings)[numberEnd]!; + final startLessonTimings = + ref.watch(lessonTimings)[startLessonNumber - 1]!; + final endLessonTimings = ref.watch(lessonTimings)[endLessonNumber + 1]!; final timingsStr = - '${timingsStart.start.format(context)} - ${timingsEnd.end.format(context)}'; + '${startLessonTimings.end.format(context)} - ${endLessonTimings.start.format(context)}'; - final numberStr = numberStart != numberEnd - ? '$numberStart - $numberEnd' - : '$numberStart'; + final numberStr = startLessonNumber != endLessonNumber + ? '$startLessonNumber - $endLessonNumber' + : '$startLessonNumber'; + + final dateTimings = LessonDateTimings( + startDateTime: dateTime.add( + Duration( + hours: startLessonTimings.end.hour, + minutes: startLessonTimings.end.minute, + ), + ), + endDateTime: dateTime.add( + Duration( + hours: endLessonTimings.start.hour, + minutes: endLessonTimings.start.minute, + ), + ), + ); return Container( height: 40, @@ -57,7 +78,7 @@ class RecessCard extends ConsumerWidget { value.lessonCardLessonTypePosition.isOnIndicator, ), ); - double width = isOnIndicator ? 20 : 6; + final width = isOnIndicator ? 20.0 : 6.0; return Container( width: width, @@ -74,8 +95,14 @@ class RecessCard extends ConsumerWidget { ), ), builder: (context, ref, child) { + final is0 = ref.watch( + lessonTimeToEndProgressValueProvider(dateTimings) + .select((value) => value == 0), + ); + + final value = is0 ? 0 : 1; return FractionallySizedBox( - heightFactor: 1.cutNumberEdgesZeroToOne(), + heightFactor: value.cutNumberEdgesZeroToOne(), child: child, ); }, From 47e5e6e72c89282a2489d57b0842d41d74bcae99 Mon Sep 17 00:00:00 2001 From: StarProxima Date: Tue, 25 Apr 2023 21:43:24 +0300 Subject: [PATCH 4/6] Fix number layout in RecessCard --- .../features/lesson_card/ui/lesson_card.dart | 4 +- .../lesson_card/ui/widgets/recess_card.dart | 58 +++++++++++++------ 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart b/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart index bfaf4d9..3b7108b 100644 --- a/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart +++ b/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart @@ -54,10 +54,10 @@ class LessonCard extends ConsumerWidget { child: Column( children: [ const LessonCardRecess( - margin: EdgeInsets.only(bottom: 16), + margin: EdgeInsets.only(bottom: 12, top: 8), ), const LessonCardTimeToStart( - margin: EdgeInsets.only(bottom: 8), + margin: EdgeInsets.only(bottom: 8, top: 4), ), Stack( children: [ diff --git a/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart b/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart index b05f621..d9abdff 100644 --- a/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart +++ b/lib/features/timetable_page/features/lesson_card/ui/widgets/recess_card.dart @@ -35,9 +35,11 @@ class RecessCard extends ConsumerWidget { final timingsStr = '${startLessonTimings.end.format(context)} - ${endLessonTimings.start.format(context)}'; - final numberStr = startLessonNumber != endLessonNumber - ? '$startLessonNumber - $endLessonNumber' - : '$startLessonNumber'; + final isOneLengthRecess = startLessonNumber == endLessonNumber; + + final numberStr = isOneLengthRecess + ? '$startLessonNumber' + : '$startLessonNumber - $endLessonNumber'; final dateTimings = LessonDateTimings( startDateTime: dateTime.add( @@ -112,23 +114,43 @@ class RecessCard extends ConsumerWidget { }, ), const SizedBox(width: 12), - Container( - height: 22, - padding: const EdgeInsets.only( - left: 0.75, - top: 0.75, - ).add(const EdgeInsets.symmetric(horizontal: 8, vertical: 1)), - decoration: BoxDecoration( - color: color, - borderRadius: BorderRadius.circular(99), - ), - child: Text( - numberStr, - style: context.textStyles.label.copyWith( - color: Colors.white, + if (isOneLengthRecess) + Container( + height: 22, + width: 22, + padding: const EdgeInsets.only(left: 0.75, bottom: 0.75), + decoration: BoxDecoration( + color: color, + shape: BoxShape.circle, + ), + child: Center( + child: Text( + numberStr, + style: context.textStyles.label.copyWith( + color: Colors.white, + ), + ), + ), + ) + else + Container( + height: 22, + padding: const EdgeInsets.only(bottom: 1).add( + const EdgeInsets.symmetric(horizontal: 8, vertical: 1), + ), + decoration: BoxDecoration( + color: color, + borderRadius: BorderRadius.circular(99), + ), + child: Center( + child: Text( + numberStr, + style: context.textStyles.label.copyWith( + color: Colors.white, + ), + ), ), ), - ), const SizedBox(width: 8), Text( timingsStr, From b22cba3ac4ebd951eb5514a3d3385d5f1f213d0c Mon Sep 17 00:00:00 2001 From: StarProxima Date: Tue, 25 Apr 2023 22:09:43 +0300 Subject: [PATCH 5/6] Fix layout in LessonCardFooter --- .../features/lesson_card/ui/lesson_card.dart | 1 + .../lesson_card/ui/widgets/lesson_card_footer.dart | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart b/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart index 3b7108b..58a4ae2 100644 --- a/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart +++ b/lib/features/timetable_page/features/lesson_card/ui/lesson_card.dart @@ -112,6 +112,7 @@ class LessonCard extends ConsumerWidget { ), child: LessonCardFooter(), ), + const SizedBox(height: 4), ], ), ), diff --git a/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_footer.dart b/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_footer.dart index cc1c1f8..ffe2c49 100644 --- a/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_footer.dart +++ b/lib/features/timetable_page/features/lesson_card/ui/widgets/lesson_card_footer.dart @@ -67,7 +67,6 @@ class LessonCardFooter extends ConsumerWidget { child: Padding( padding: const EdgeInsets.only( top: 4, - bottom: 4, left: 8, ), child: Text( @@ -75,6 +74,8 @@ class LessonCardFooter extends ConsumerWidget { style: context.textStyles.smallLabel.copyWith( color: context.colors.subduedText, ), + maxLines: 1, + overflow: TextOverflow.ellipsis, ), ), ), @@ -87,6 +88,7 @@ class LessonCardFooter extends ConsumerWidget { ), ), Row( + crossAxisAlignment: CrossAxisAlignment.end, children: [ if (lessonTypePosition.isBeforeBottomRightBlock) const Padding( @@ -97,18 +99,20 @@ class LessonCardFooter extends ConsumerWidget { constraints: const BoxConstraints( maxWidth: 160, ), - padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8), + padding: const EdgeInsets.only(top: 4, left: 8), child: Text( rigthText, style: context.textStyles.smallLabel.copyWith( color: context.colors.subduedText, ), textAlign: TextAlign.right, + maxLines: 1, + overflow: TextOverflow.ellipsis, ), ), if (lessonTypePosition.isBottomRight) const Padding( - padding: EdgeInsets.only(right: 4), + padding: EdgeInsets.only(right: 4, left: 8), child: LessonCardLessonTypeChip(), ), ], From d159cd008638502986037eb0ed0644089cbf3a18 Mon Sep 17 00:00:00 2001 From: StarProxima Date: Tue, 25 Apr 2023 22:13:50 +0300 Subject: [PATCH 6/6] Edit text in _SettingsPageAppInfo --- lib/features/settings/ui/widgets/settings_page_app_info.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/features/settings/ui/widgets/settings_page_app_info.dart b/lib/features/settings/ui/widgets/settings_page_app_info.dart index e0e43a0..4a5341c 100644 --- a/lib/features/settings/ui/widgets/settings_page_app_info.dart +++ b/lib/features/settings/ui/widgets/settings_page_app_info.dart @@ -27,7 +27,7 @@ class _SettingsPageAppInfo extends ConsumerWidget { TextSpan( children: [ TextSpan( - text: 'Built using ', + text: 'Developed using ', style: context.textStyles.smallSubTitle.copyWith( color: context.colors.subduedText, ),