106 lines
3.2 KiB
Dart
106 lines
3.2 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
|
import 'package:marianum_mobile/data/timetable/timetableProps.dart';
|
|
import 'package:marianum_mobile/screen/pages/timetable/weekView.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
class Timetable extends StatefulWidget {
|
|
const Timetable({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<Timetable> createState() => _TimetableState();
|
|
}
|
|
|
|
class _TimetableState extends State<Timetable> {
|
|
bool draggable = true;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
Provider.of<TimetableProps>(context, listen: false).run();
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Consumer<TimetableProps>(
|
|
builder: (context, value, child) {
|
|
if(value.primaryLoading()) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
|
|
TimetableProps timetable = Provider.of<TimetableProps>(context, listen: false);
|
|
return Column(
|
|
children: [
|
|
Expanded(
|
|
child: GestureDetector(
|
|
child: WeekView(value),
|
|
onHorizontalDragUpdate: (details) {
|
|
if(!draggable) return;
|
|
if(details.delta.dx > 5) {
|
|
draggable = false;
|
|
timetable.switchWeek(previous: true);
|
|
} else if(details.delta.dx < 5) {
|
|
draggable = false;
|
|
timetable.switchWeek();
|
|
}
|
|
},
|
|
onHorizontalDragEnd: (details) {
|
|
draggable = true;
|
|
},
|
|
),
|
|
),
|
|
|
|
// Flexible(
|
|
// child:
|
|
// ),
|
|
|
|
Visibility(
|
|
visible: false,
|
|
child: Container(
|
|
padding: const EdgeInsets.only(top: 5, bottom: 5),
|
|
decoration: BoxDecoration(
|
|
border: Border(
|
|
top: BorderSide(width: 2, color: Theme.of(context).disabledColor)
|
|
)
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
IconButton(
|
|
onPressed: () => timetable.switchWeek(previous: true),
|
|
icon: const Icon(Icons.navigate_before_sharp),
|
|
color: Theme.of(context).primaryColor,
|
|
iconSize: 30,
|
|
),
|
|
Row(
|
|
children: [
|
|
IconButton(
|
|
onPressed: () => timetable.nearest(),
|
|
icon: const Icon(Icons.home),
|
|
color: Theme.of(context).primaryColor,
|
|
iconSize: 30,
|
|
),
|
|
],
|
|
),
|
|
IconButton(
|
|
onPressed: () => timetable.switchWeek(),
|
|
icon: const Icon(Icons.navigate_next_sharp),
|
|
color: Theme.of(context).primaryColor,
|
|
iconSize: 30,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
)
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|