Skip to content

Commit 194acf0

Browse files
committed
feat: add nextScheduleName to schedule form state and events
- Introduced nextScheduleName to ScheduleFormEvent, ScheduleFormState, and related components to enhance schedule overlap handling. - Updated localization messages in SchedulePlaceMovingTimeState and ScheduleFormSpareTimeState to include the next schedule name for better user feedback during scheduling conflicts.
1 parent 1b3bf53 commit 194acf0

File tree

6 files changed

+18
-4
lines changed

6 files changed

+18
-4
lines changed

lib/presentation/schedule_create/bloc/schedule_form_bloc.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class ScheduleFormBloc extends Bloc<ScheduleFormEvent, ScheduleFormState> {
129129
),
130130
timeLeftUntilNextSchedulePreparation:
131131
event.timeLeftUntilNextSchedulePreparation,
132+
nextScheduleName: event.nextScheduleName,
132133
));
133134
}
134135

lib/presentation/schedule_create/bloc/schedule_form_event.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,21 @@ final class ScheduleFormScheduleDateTimeChanged extends ScheduleFormEvent {
3333
final DateTime scheduleDate;
3434
final DateTime scheduleTime;
3535
final Duration? timeLeftUntilNextSchedulePreparation;
36+
final String? nextScheduleName;
3637

3738
const ScheduleFormScheduleDateTimeChanged({
3839
required this.scheduleDate,
3940
required this.scheduleTime,
4041
this.timeLeftUntilNextSchedulePreparation,
42+
this.nextScheduleName,
4143
});
4244

4345
@override
4446
List<Object> get props => [
4547
scheduleDate,
4648
scheduleTime,
4749
timeLeftUntilNextSchedulePreparation ?? const Duration(days: -999999),
50+
nextScheduleName ?? '',
4851
];
4952
}
5053

lib/presentation/schedule_create/bloc/schedule_form_state.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ final class ScheduleFormState extends Equatable {
1717
final PreparationEntity? preparation;
1818
final bool isValid;
1919
final Duration? timeLeftUntilNextSchedulePreparation;
20+
final String? nextScheduleName;
2021

2122
ScheduleFormState({
2223
this.status = ScheduleFormStatus.initial,
@@ -31,6 +32,7 @@ final class ScheduleFormState extends Equatable {
3132
this.preparation,
3233
this.isValid = false,
3334
this.timeLeftUntilNextSchedulePreparation,
35+
this.nextScheduleName,
3436
}) : id = id ?? Uuid().v7();
3537

3638
ScheduleFormState copyWith({
@@ -46,6 +48,7 @@ final class ScheduleFormState extends Equatable {
4648
PreparationEntity? preparation,
4749
bool? isValid,
4850
Duration? timeLeftUntilNextSchedulePreparation,
51+
String? nextScheduleName,
4952
}) {
5053
return ScheduleFormState(
5154
status: status ?? this.status,
@@ -62,6 +65,7 @@ final class ScheduleFormState extends Equatable {
6265
timeLeftUntilNextSchedulePreparation:
6366
timeLeftUntilNextSchedulePreparation ??
6467
this.timeLeftUntilNextSchedulePreparation,
68+
nextScheduleName: nextScheduleName ?? this.nextScheduleName,
6569
);
6670
}
6771

@@ -99,5 +103,6 @@ final class ScheduleFormState extends Equatable {
99103
preparation,
100104
isValid,
101105
timeLeftUntilNextSchedulePreparation,
106+
nextScheduleName,
102107
];
103108
}

lib/presentation/schedule_create/schedule_date_time/cubit/schedule_date_time_cubit.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class ScheduleDateTimeCubit extends Cubit<ScheduleDateTimeState> {
189189
scheduleDate: state.scheduleDate.value!,
190190
scheduleTime: state.scheduleTime.value!,
191191
timeLeftUntilNextSchedulePreparation: state.overlapDuration,
192+
nextScheduleName: state.nextScheduleName,
192193
));
193194
}
194195
}

lib/presentation/schedule_create/schedule_place_moving_time.dart/cubit/schedule_place_moving_time_state.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ class SchedulePlaceMovingTimeState extends Equatable {
2828

2929
final localizations = AppLocalizations.of(context)!;
3030
final minutes = overlapDuration!.inMinutes.abs();
31+
final scheduleName =
32+
context.read<ScheduleFormBloc>().state.nextScheduleName ?? '';
3133

3234
if (isOverlapping) {
33-
return localizations.scheduleOverlapError(minutes, '');
35+
return localizations.scheduleOverlapError(minutes, scheduleName);
3436
} else {
35-
return localizations.scheduleOverlapWarning(minutes, '');
37+
return localizations.scheduleOverlapWarning(minutes, scheduleName);
3638
}
3739
}
3840

lib/presentation/schedule_create/schedule_spare_and_preparing_time/cubit/schedule_form_spare_time_state.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ class ScheduleFormSpareTimeState extends Equatable {
3030

3131
final localizations = AppLocalizations.of(context)!;
3232
final minutes = overlapDuration!.inMinutes.abs();
33+
final scheduleName =
34+
context.read<ScheduleFormBloc>().state.nextScheduleName ?? '';
3335

3436
if (isOverlapping) {
35-
return localizations.scheduleOverlapError(minutes, '');
37+
return localizations.scheduleOverlapError(minutes, scheduleName);
3638
} else {
37-
return localizations.scheduleOverlapWarning(minutes, '');
39+
return localizations.scheduleOverlapWarning(minutes, scheduleName);
3840
}
3941
}
4042

0 commit comments

Comments
 (0)