Removed zooming from timetable
This commit is contained in:
parent
7e8e49c2dd
commit
0b7908ec28
@ -4,9 +4,7 @@ part 'timetableSettings.g.dart';
|
|||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable()
|
||||||
class TimetableSettings {
|
class TimetableSettings {
|
||||||
double zoom;
|
TimetableSettings();
|
||||||
|
|
||||||
TimetableSettings({required this.zoom});
|
|
||||||
|
|
||||||
factory TimetableSettings.fromJson(Map<String, dynamic> json) => _$TimetableSettingsFromJson(json);
|
factory TimetableSettings.fromJson(Map<String, dynamic> json) => _$TimetableSettingsFromJson(json);
|
||||||
Map<String, dynamic> toJson() => _$TimetableSettingsToJson(this);
|
Map<String, dynamic> toJson() => _$TimetableSettingsToJson(this);
|
||||||
|
@ -7,11 +7,7 @@ part of 'timetableSettings.dart';
|
|||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
TimetableSettings _$TimetableSettingsFromJson(Map<String, dynamic> json) =>
|
TimetableSettings _$TimetableSettingsFromJson(Map<String, dynamic> json) =>
|
||||||
TimetableSettings(
|
TimetableSettings();
|
||||||
zoom: (json['zoom'] as num).toDouble(),
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$TimetableSettingsToJson(TimetableSettings instance) =>
|
Map<String, dynamic> _$TimetableSettingsToJson(TimetableSettings instance) =>
|
||||||
<String, dynamic>{
|
<String, dynamic>{};
|
||||||
'zoom': instance.zoom,
|
|
||||||
};
|
|
||||||
|
@ -34,16 +34,11 @@ enum CalendarActions { addEvent, viewEvents }
|
|||||||
class _TimetableState extends State<Timetable> {
|
class _TimetableState extends State<Timetable> {
|
||||||
CalendarController controller = CalendarController();
|
CalendarController controller = CalendarController();
|
||||||
late Timer updateTimings;
|
late Timer updateTimings;
|
||||||
|
|
||||||
double elementScale = 40;
|
|
||||||
double baseElementScale = 40;
|
|
||||||
|
|
||||||
late final SettingsProvider settings;
|
late final SettingsProvider settings;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
settings = Provider.of<SettingsProvider>(context, listen: false);
|
settings = Provider.of<SettingsProvider>(context, listen: false);
|
||||||
elementScale = baseElementScale = settings.val().timetableSettings.zoom;
|
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
Provider.of<TimetableProps>(context, listen: false).run();
|
Provider.of<TimetableProps>(context, listen: false).run();
|
||||||
@ -132,62 +127,50 @@ class _TimetableState extends State<Timetable> {
|
|||||||
GetHolidaysResponse holidays = value.getHolidaysResponse;
|
GetHolidaysResponse holidays = value.getHolidaysResponse;
|
||||||
|
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
child: GestureDetector(
|
child: SfCalendar(
|
||||||
onScaleStart: (details) => baseElementScale = elementScale,
|
view: CalendarView.workWeek,
|
||||||
onScaleUpdate: (details) {
|
dataSource: _buildTableEvents(value),
|
||||||
setState(() {
|
|
||||||
elementScale = (baseElementScale * details.scale).clamp(40, 80);
|
maxDate: DateTime.now().add(const Duration(days: 7)).nextWeekday(DateTime.saturday),
|
||||||
|
minDate: DateTime.now().subtract(const Duration (days: 14)).nextWeekday(DateTime.sunday),
|
||||||
|
|
||||||
|
controller: controller,
|
||||||
|
|
||||||
|
onViewChanged: (ViewChangedDetails details) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
||||||
|
Provider.of<TimetableProps>(context, listen: false).updateWeek(details.visibleDates.first, details.visibleDates.last);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onScaleEnd: (details) {
|
|
||||||
settings.val(write: true).timetableSettings.zoom = elementScale;
|
onTap: (calendarTapDetails) {
|
||||||
|
if(calendarTapDetails.appointments == null) return;
|
||||||
|
Appointment tapped = calendarTapDetails.appointments!.first;
|
||||||
|
AppointmentDetails.show(context, value, tapped);
|
||||||
},
|
},
|
||||||
|
|
||||||
child: SfCalendar(
|
firstDayOfWeek: DateTime.monday,
|
||||||
view: CalendarView.workWeek,
|
specialRegions: _buildSpecialTimeRegions(holidays),
|
||||||
dataSource: _buildTableEvents(value),
|
timeSlotViewSettings: const TimeSlotViewSettings(
|
||||||
|
startHour: 07.5,
|
||||||
maxDate: DateTime.now().add(const Duration(days: 7)).nextWeekday(DateTime.saturday),
|
endHour: 16.5,
|
||||||
minDate: DateTime.now().subtract(const Duration (days: 14)).nextWeekday(DateTime.sunday),
|
timeInterval: Duration(minutes: 30),
|
||||||
|
timeFormat: "HH:mm",
|
||||||
controller: controller,
|
dayFormat: "EE",
|
||||||
|
timeIntervalHeight: 40,
|
||||||
onViewChanged: (ViewChangedDetails details) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
||||||
Provider.of<TimetableProps>(context, listen: false).updateWeek(details.visibleDates.first, details.visibleDates.last);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onTap: (calendarTapDetails) {
|
|
||||||
if(calendarTapDetails.appointments == null) return;
|
|
||||||
Appointment tapped = calendarTapDetails.appointments!.first;
|
|
||||||
AppointmentDetails.show(context, value, tapped);
|
|
||||||
},
|
|
||||||
|
|
||||||
firstDayOfWeek: DateTime.monday,
|
|
||||||
specialRegions: _buildSpecialTimeRegions(holidays),
|
|
||||||
timeSlotViewSettings: TimeSlotViewSettings(
|
|
||||||
startHour: 07.5,
|
|
||||||
endHour: 16.5,
|
|
||||||
timeInterval: const Duration(minutes: 30),
|
|
||||||
timeFormat: "HH:mm",
|
|
||||||
dayFormat: "EE",
|
|
||||||
timeIntervalHeight: elementScale,
|
|
||||||
),
|
|
||||||
|
|
||||||
timeRegionBuilder: (BuildContext context, TimeRegionDetails timeRegionDetails) => TimeRegionComponent(details: timeRegionDetails),
|
|
||||||
appointmentBuilder: (BuildContext context, CalendarAppointmentDetails details) => AppointmentComponent(
|
|
||||||
details: details,
|
|
||||||
crossedOut: _isCrossedOut(details)
|
|
||||||
),
|
|
||||||
|
|
||||||
headerHeight: 0,
|
|
||||||
selectionDecoration: const BoxDecoration(),
|
|
||||||
|
|
||||||
allowAppointmentResize: false,
|
|
||||||
allowDragAndDrop: false,
|
|
||||||
allowViewNavigation: false,
|
|
||||||
),
|
),
|
||||||
|
|
||||||
|
timeRegionBuilder: (BuildContext context, TimeRegionDetails timeRegionDetails) => TimeRegionComponent(details: timeRegionDetails),
|
||||||
|
appointmentBuilder: (BuildContext context, CalendarAppointmentDetails details) => AppointmentComponent(
|
||||||
|
details: details,
|
||||||
|
crossedOut: _isCrossedOut(details)
|
||||||
|
),
|
||||||
|
|
||||||
|
headerHeight: 0,
|
||||||
|
selectionDecoration: const BoxDecoration(),
|
||||||
|
|
||||||
|
allowAppointmentResize: false,
|
||||||
|
allowDragAndDrop: false,
|
||||||
|
allowViewNavigation: false,
|
||||||
),
|
),
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
Provider.of<TimetableProps>(context, listen: false).run(renew: true);
|
Provider.of<TimetableProps>(context, listen: false).run(renew: true);
|
||||||
|
@ -22,9 +22,7 @@ class DefaultSettings {
|
|||||||
askedForPreferredGradeSystem: false,
|
askedForPreferredGradeSystem: false,
|
||||||
inputs: []
|
inputs: []
|
||||||
),
|
),
|
||||||
timetableSettings: TimetableSettings(
|
timetableSettings: TimetableSettings(),
|
||||||
zoom: 40,
|
|
||||||
),
|
|
||||||
talkSettings: TalkSettings(
|
talkSettings: TalkSettings(
|
||||||
sortFavoritesToTop: true,
|
sortFavoritesToTop: true,
|
||||||
sortUnreadToTop: false,
|
sortUnreadToTop: false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user