2024-12-16 11:15:11 +01:00
|
|
|
import 'package:ambito/src/entity/measure/months/measure_months.dart';
|
|
|
|
import 'package:ambito/src/entity/measure/months/measure_months_datasource.dart';
|
2024-11-07 05:52:03 +01:00
|
|
|
import 'package:ambito/src/packages/ambito_theme/ambito_theme.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2024-12-16 11:15:11 +01:00
|
|
|
import 'package:isar/isar.dart';
|
2024-11-18 09:15:00 +01:00
|
|
|
import 'package:screen_breakpoints/screen_breakpoints.dart';
|
2024-12-16 11:15:11 +01:00
|
|
|
import 'package:syncfusion_flutter_core/theme.dart';
|
|
|
|
import 'package:syncfusion_flutter_datagrid/datagrid.dart';
|
|
|
|
import 'package:toggle_switch/toggle_switch.dart';
|
2024-11-07 05:52:03 +01:00
|
|
|
|
2024-11-09 22:03:03 +01:00
|
|
|
import '../../consts/consts.dart';
|
2024-12-16 11:15:11 +01:00
|
|
|
import '../../widgets/page/base_page.dart';
|
2024-11-07 05:52:03 +01:00
|
|
|
|
|
|
|
class CalendarPage extends StatefulWidget {
|
|
|
|
const CalendarPage({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() => CalendarPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class CalendarPageState extends State<CalendarPage> {
|
2024-12-16 11:15:11 +01:00
|
|
|
int display = 0;
|
2024-11-07 05:52:03 +01:00
|
|
|
|
2024-12-16 11:15:11 +01:00
|
|
|
String type = 'maintenance';
|
2024-11-07 05:52:03 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
2024-12-16 11:15:11 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
List<MeasureMonths> mm = isar.measureMonths.where().sortByName().findAll();
|
2024-11-07 05:52:03 +01:00
|
|
|
|
2024-12-16 11:15:11 +01:00
|
|
|
final AmbitoTheme theme = getTheme(context);
|
2024-11-07 05:52:03 +01:00
|
|
|
|
2024-12-16 11:15:11 +01:00
|
|
|
return BasePage().getPage(
|
|
|
|
context,
|
|
|
|
SingleChildScrollView(
|
|
|
|
child: Expanded(
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.topCenter,
|
|
|
|
child: Padding(
|
|
|
|
padding: context.breakpoint.padding,
|
|
|
|
child: SizedBox(
|
|
|
|
width: 1152,
|
|
|
|
height: MediaQuery.of(context).size.height - 80,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(bottom: 40),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
theme.verticalSpacerMax,
|
|
|
|
Text(
|
|
|
|
'Kalender',
|
|
|
|
textAlign: TextAlign.start,
|
|
|
|
style: theme.headlineLarge.copyWith(
|
|
|
|
color: theme.currentColorScheme.onSurface,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
theme.verticalSpacer,
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
ToggleSwitch(
|
|
|
|
initialLabelIndex: display,
|
|
|
|
totalSwitches: 2,
|
|
|
|
minWidth: 200,
|
|
|
|
borderWidth: 1,
|
|
|
|
labels: const ['Pflege', 'Maßnahme'],
|
|
|
|
activeBgColor: [
|
|
|
|
theme.currentColorScheme.secondary
|
|
|
|
],
|
|
|
|
borderColor: [theme.currentColorScheme.secondary],
|
|
|
|
inactiveBgColor: Colors.white,
|
|
|
|
activeFgColor:
|
|
|
|
theme.currentColorScheme.onSecondary,
|
|
|
|
customTextStyles: [theme.bodyMedium],
|
|
|
|
onToggle: (index) {
|
|
|
|
setState(() {
|
|
|
|
display = index ?? 0;
|
|
|
|
if (display == 0) {
|
|
|
|
type = 'maintenance';
|
|
|
|
} else {
|
|
|
|
type = 'apply';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
theme.verticalSpacer,
|
|
|
|
Expanded(
|
|
|
|
child: gridWidget(
|
|
|
|
mm,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
theme.verticalSpacerMax,
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2024-11-07 05:52:03 +01:00
|
|
|
),
|
2024-12-16 11:15:11 +01:00
|
|
|
),
|
|
|
|
));
|
2024-11-07 05:52:03 +01:00
|
|
|
}
|
|
|
|
|
2024-12-16 11:15:11 +01:00
|
|
|
Widget gridWidget(List<MeasureMonths> mm) {
|
2024-11-20 17:09:53 +01:00
|
|
|
final AmbitoTheme theme = getTheme(context);
|
|
|
|
|
2024-12-16 11:15:11 +01:00
|
|
|
return SizedBox(
|
|
|
|
width: 1152,
|
|
|
|
child: SfDataGridTheme(
|
|
|
|
data: SfDataGridThemeData(
|
|
|
|
headerColor: theme.currentColorScheme.primaryContainer,
|
|
|
|
sortIcon: Icon(
|
|
|
|
Icons.keyboard_arrow_down,
|
|
|
|
color: theme.currentColorScheme.primary,
|
2024-11-07 05:52:03 +01:00
|
|
|
),
|
|
|
|
),
|
2024-12-16 11:15:11 +01:00
|
|
|
child: SfDataGrid(
|
|
|
|
allowSorting: true,
|
|
|
|
source:
|
|
|
|
MeasureMonthsDatasource(areas: mm, context: context, type: type),
|
|
|
|
columnWidthMode: ColumnWidthMode.fill,
|
|
|
|
columns: [
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'name',
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Bezeichnung',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'jan',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Jan',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'feb',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Feb',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'mar',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Mär',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'apr',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Apr',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'may',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Mai',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'jun',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Jun',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'jul',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Jul',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'aug',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Aug',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'sep',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Sep',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'oct',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Okt',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'nov',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Nov',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
GridColumn(
|
|
|
|
columnName: 'dec',
|
|
|
|
maximumWidth: 70,
|
|
|
|
label: Container(
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: Text(
|
|
|
|
'Dez',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: theme.bodyMedium.copyWith(
|
|
|
|
color: theme.currentColorScheme.primary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2024-11-07 05:52:03 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|