ambito/lib/src/pages/actions/actions_pre_page.dart

193 lines
6.7 KiB
Dart
Raw Normal View History

2024-11-07 05:52:03 +01:00
import 'package:ambito/src/entity/_general/filter/item_filter_repository.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/entity/measure/measure_repository.dart';
import 'package:ambito/src/pages/ambito_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
2024-11-18 09:15:00 +01:00
import 'package:screen_breakpoints/screen_breakpoints.dart';
2024-11-07 05:52:03 +01:00
import '../../../main.dart';
import '../../packages/ambito_theme/ambito_theme.dart';
import '../../widgets/appbar/ambito_appbar.dart';
class ActionsPrePage extends AmbitoPage {
const ActionsPrePage({super.key});
@override
final String path = 'massnahmen';
@override
final String title = 'Maßnamen';
@override
State<StatefulWidget> createState() => ActionsPrePageState();
}
class ActionsPrePageState extends State<ActionsPrePage> {
List<Widget> cards = [];
Map<String, int> counter = {};
Map<String, int> ids = {};
int counterComplete = 0;
@override
void initState() {
List<ItemFilter>? filters = ItemFilterRepository().getByType('areaType');
counterComplete = MeasureRepository().getMeasureCount();
for (ItemFilter filter in filters!) {
setState(() {
cards.add(
InkWell(
onTap: () {
prefs.setString('selected_areaType', filter.name!).then((value) {
Get.toNamed('/massnahmendatenbank');
setState(() {});
});
},
2024-11-18 15:19:07 +01:00
onHover: (hovered) {},
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
focusColor: Colors.transparent,
hoverColor: Colors.transparent,
2024-11-07 05:52:03 +01:00
child: SizedBox(
2024-11-09 22:03:03 +01:00
width: 262,
2024-11-18 09:15:00 +01:00
height: 380,
2024-11-07 05:52:03 +01:00
child: Card(
2024-11-18 09:15:00 +01:00
elevation: 0,
color: actionAreaColors[filter.name!],
2024-11-07 05:52:03 +01:00
child: Column(
children: [
ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.asset(
filter.image!,
),
),
2024-11-18 09:15:00 +01:00
largeTheme.verticalSpacer,
2024-11-07 05:52:03 +01:00
Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: Text(
filter.name!,
2024-11-18 15:19:07 +01:00
style: largeTheme.currentThemeData.textTheme.labelMedium
2024-11-07 05:52:03 +01:00
?.copyWith(
color: actionAreaFGColors[filter.name!],
fontWeight: FontWeight.bold,
),
),
),
2024-11-18 09:15:00 +01:00
largeTheme.verticalSpacer,
2024-11-07 05:52:03 +01:00
Padding(
padding: const EdgeInsets.only(left: 16, right: 16),
child: Text(
filter.description!,
2024-11-18 09:15:00 +01:00
style: largeTheme.currentThemeData.textTheme.bodyMedium
2024-11-07 05:52:03 +01:00
?.copyWith(
2024-11-18 09:15:00 +01:00
color: largeTheme.currentColorScheme.onSurface,
2024-11-07 05:52:03 +01:00
),
),
),
const Spacer(),
Padding(
padding: const EdgeInsets.only(
left: 16, right: 16, bottom: 16),
child: Text(
'Anzahl: ${filter.ids!.length}',
2024-11-18 09:15:00 +01:00
style: largeTheme.currentThemeData.textTheme.titleMedium
2024-11-07 05:52:03 +01:00
?.copyWith(
color: actionAreaFGColors[filter.name!],
fontWeight: FontWeight.bold,
),
),
),
],
),
),
),
),
);
});
}
super.initState();
}
@override
Widget build(BuildContext context) {
2024-11-18 09:15:00 +01:00
final AmbitoTheme theme = getTheme(context);
2024-11-07 05:52:03 +01:00
return Scaffold(
appBar: AmbitoAppbar(
links: const ['dashboard', 'massnahmen'],
2024-11-18 09:15:00 +01:00
breakpoint: Breakpoint.fromContext(context),
2024-11-07 05:52:03 +01:00
),
2024-11-18 09:15:00 +01:00
body: BreakpointBuilder(builder: (
context,
breakpoint,
configuration,
) {
return SingleChildScrollView(
child: Center(
child: SizedBox(
width: Breakpoint.fromContext(context).width,
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(breakpoint.toString()),
theme.verticalSpacerMax,
Text(
'Maßnahmenkategorien',
textAlign: TextAlign.start,
style: theme.currentThemeData.textTheme.headlineLarge
?.copyWith(
color: theme.currentColorScheme.onSurface,
),
2024-11-09 22:03:33 +01:00
),
2024-11-18 09:15:00 +01:00
theme.verticalSpacerMax,
Wrap(
alignment: WrapAlignment.center,
spacing: 32,
children: cards,
),
theme.verticalSpacerMax,
2024-11-18 15:19:07 +01:00
InkWell(
onHover: (hovered) {},
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
focusColor: Colors.transparent,
hoverColor: Colors.transparent,
onTap: () async {
2024-11-09 22:03:33 +01:00
await prefs.setString('selected_areaType', '');
await Get.toNamed('/massnahmendatenbank');
},
2024-11-18 09:15:00 +01:00
child: Container(
decoration: BoxDecoration(
2024-11-18 15:19:07 +01:00
borderRadius:
const BorderRadius.all(Radius.circular(8)),
2024-11-18 09:15:00 +01:00
color:
theme.currentColorScheme.onSurface.withOpacity(.1),
2024-11-09 22:03:33 +01:00
),
2024-11-18 09:15:00 +01:00
width: Breakpoint.fromContext(context).width,
child: Padding(
2024-11-18 15:19:07 +01:00
padding: const EdgeInsets.all(20),
2024-11-18 09:15:00 +01:00
child: Text(
'Alle Maßnahmen anzeigen',
style: theme.headlineMedium.copyWith(
color: theme.currentColorScheme.outline,
),
textAlign: TextAlign.center,
),
),
),
),
],
),
2024-11-09 22:03:33 +01:00
),
2024-11-09 22:03:03 +01:00
),
2024-11-18 09:15:00 +01:00
);
}),
2024-11-07 05:52:03 +01:00
);
}
}