feat: Refactor code structure and optimize performance across multiple modules

This commit is contained in:
Achintha Isuru
2025-11-17 23:29:28 -05:00
parent 831570f2e0
commit a64cbd9edf
1508 changed files with 105319 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import 'package:krow/features/profile/schedule/data/models/schedule_slot_model.dart';
class DayScheduleModel {
DayScheduleModel({
required this.date,
required this.slots,
this.isWeekly = false,
});
final DateTime date;
final bool isWeekly;
List<ScheduleSlotModel> slots;
}

View File

@@ -0,0 +1,38 @@
import 'package:krow/core/application/common/date_time_extension.dart';
class ScheduleSlotModel {
ScheduleSlotModel({
required this.isWeekly,
required this.startAt,
required this.endAt,
this.id,
});
factory ScheduleSlotModel.fromJson(Map<String, dynamic> data) {
return ScheduleSlotModel(
id: data['id'] as String?,
isWeekly: data['type'] == 'weekly',
startAt: DateTime.parse(data['start_at'] as String),
endAt: DateTime.parse(data['end_at'] as String),
);
}
final String? id;
final bool isWeekly;
final DateTime startAt;
final DateTime endAt;
// TODO(Sleep): For now has to use .replaceAll('.000', '') for trim DateTime otherwise will result in error from backend.
Map<String, dynamic> toJson() {
return {
// if (id != null) 'id': id,
'type': isWeekly ? 'weekly' : 'range',
'start_at': startAt.toString().replaceAll('.000', ''),
'end_at': endAt.toString().replaceAll('.000', ''),
'day_of_week': startAt.getWeekdayId(),
};
}
String getIdKey() =>
isWeekly ? startAt.getWeekdayId() : startAt.getDayDateId();
}