192 lines
6.7 KiB
Dart
192 lines
6.7 KiB
Dart
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';
|
|
import 'package:screen_breakpoints/screen_breakpoints.dart';
|
|
|
|
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(() {});
|
|
});
|
|
},
|
|
onHover: (hovered) {},
|
|
highlightColor: Colors.transparent,
|
|
splashColor: Colors.transparent,
|
|
focusColor: Colors.transparent,
|
|
hoverColor: Colors.transparent,
|
|
child: SizedBox(
|
|
width: 262,
|
|
height: 380,
|
|
child: Card(
|
|
elevation: 0,
|
|
color: actionAreaColors[filter.name!],
|
|
child: Column(
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(8.0),
|
|
child: Image.asset(
|
|
filter.image!,
|
|
),
|
|
),
|
|
largeTheme.verticalSpacer,
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 16, right: 16),
|
|
child: Text(
|
|
filter.name!,
|
|
style: largeTheme.currentThemeData.textTheme.labelMedium
|
|
?.copyWith(
|
|
color: actionAreaFGColors[filter.name!],
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
largeTheme.verticalSpacer,
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 16, right: 16),
|
|
child: Text(
|
|
filter.description!,
|
|
style: largeTheme.currentThemeData.textTheme.bodyMedium
|
|
?.copyWith(
|
|
color: largeTheme.currentColorScheme.onSurface,
|
|
),
|
|
),
|
|
),
|
|
const Spacer(),
|
|
Padding(
|
|
padding: const EdgeInsets.only(
|
|
left: 16, right: 16, bottom: 16),
|
|
child: Text(
|
|
'Anzahl: ${filter.ids!.length}',
|
|
style: largeTheme.currentThemeData.textTheme.titleMedium
|
|
?.copyWith(
|
|
color: actionAreaFGColors[filter.name!],
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final AmbitoTheme theme = getTheme(context);
|
|
|
|
return Scaffold(
|
|
appBar: AmbitoAppbar(
|
|
links: const ['dashboard', 'massnahmen'],
|
|
breakpoint: Breakpoint.fromContext(context),
|
|
),
|
|
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,
|
|
),
|
|
),
|
|
theme.verticalSpacerMax,
|
|
Wrap(
|
|
alignment: WrapAlignment.center,
|
|
spacing: 32,
|
|
children: cards,
|
|
),
|
|
theme.verticalSpacerMax,
|
|
InkWell(
|
|
onHover: (hovered) {},
|
|
highlightColor: Colors.transparent,
|
|
splashColor: Colors.transparent,
|
|
focusColor: Colors.transparent,
|
|
hoverColor: Colors.transparent,
|
|
onTap: () async {
|
|
await prefs.setString('selected_areaType', '');
|
|
await Get.toNamed('/massnahmendatenbank');
|
|
},
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius:
|
|
const BorderRadius.all(Radius.circular(8)),
|
|
color:
|
|
theme.currentColorScheme.onSurface.withOpacity(.1),
|
|
),
|
|
width: Breakpoint.fromContext(context).width,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: Text(
|
|
'Alle Maßnahmen anzeigen',
|
|
style: theme.headlineMedium.copyWith(
|
|
color: theme.currentColorScheme.outline,
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
}
|