2024-12-17 13:13:01 +01:00
|
|
|
import 'dart:convert';
|
|
|
|
|
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';
|
2024-12-17 13:13:01 +01:00
|
|
|
import 'package:syncfusion_flutter_datagrid_export/export.dart';
|
|
|
|
import 'package:syncfusion_flutter_pdf/pdf.dart';
|
2024-12-16 11:15:11 +01:00
|
|
|
import 'package:toggle_switch/toggle_switch.dart';
|
2024-12-17 13:13:01 +01:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2024-11-07 05:52:03 +01:00
|
|
|
|
2024-11-09 22:03:03 +01:00
|
|
|
import '../../consts/consts.dart';
|
2024-12-17 13:13:01 +01:00
|
|
|
import '../../widgets/buttons/print_button.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-17 13:13:01 +01:00
|
|
|
final GlobalKey<SfDataGridState> key = GlobalKey<SfDataGridState>();
|
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
2024-12-17 13:13:01 +01:00
|
|
|
Spacer(),
|
|
|
|
PrintButton(
|
|
|
|
onPressed: () async {
|
|
|
|
PdfDocument document =
|
|
|
|
key.currentState!.exportToPdfDocument(
|
|
|
|
headerFooterExport:
|
|
|
|
(DataGridPdfHeaderFooterExportDetails
|
|
|
|
headerFooterExport) {
|
|
|
|
final double width = headerFooterExport
|
|
|
|
.pdfPage
|
|
|
|
.getClientSize()
|
|
|
|
.width;
|
|
|
|
final PdfPageTemplateElement header =
|
|
|
|
PdfPageTemplateElement(
|
|
|
|
Rect.fromLTWH(0, 0, width, 65));
|
|
|
|
header.graphics.drawString(
|
|
|
|
'Dingens"',
|
|
|
|
PdfStandardFont(
|
|
|
|
PdfFontFamily.helvetica, 13,
|
|
|
|
style: PdfFontStyle.bold),
|
|
|
|
bounds:
|
|
|
|
const Rect.fromLTWH(0, 25, 400, 60),
|
|
|
|
);
|
|
|
|
headerFooterExport.pdfDocumentTemplate.top =
|
|
|
|
header;
|
|
|
|
},
|
|
|
|
cellExport: (details) {},
|
|
|
|
fitAllColumnsInOnePage: true,
|
|
|
|
);
|
|
|
|
final List<int> bytes = document.saveSync();
|
|
|
|
launchUrl(Uri.parse(
|
|
|
|
"data:application/octet-stream;base64,${base64Encode(bytes)}"));
|
|
|
|
},
|
|
|
|
),
|
2024-12-16 11:15:11 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
theme.verticalSpacer,
|
|
|
|
Expanded(
|
|
|
|
child: gridWidget(
|
|
|
|
mm,
|
2024-12-17 13:13:01 +01:00
|
|
|
key,
|
2024-12-16 11:15:11 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
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-17 13:13:01 +01:00
|
|
|
Widget gridWidget(List<MeasureMonths> mm, GlobalKey<SfDataGridState> key) {
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
isScrollbarAlwaysShown: true,
|
|
|
|
key: key,
|
|
|
|
allowSorting: false,
|
2024-12-16 11:15:11 +01:00
|
|
|
source:
|
|
|
|
MeasureMonthsDatasource(areas: mm, context: context, type: type),
|
|
|
|
columnWidthMode: ColumnWidthMode.fill,
|
|
|
|
columns: [
|
|
|
|
GridColumn(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Bezeichnung',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Jan',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Feb',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Mär',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Apr',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Mai',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Jun',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Jul',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Aug',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Sep',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Okt',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Nov',
|
2024-12-16 11:15:11 +01:00
|
|
|
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(
|
2024-12-17 13:13:01 +01:00
|
|
|
columnName: 'Dez',
|
2024-12-16 11:15:11 +01:00
|
|
|
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
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|