2024-11-09 22:03:03 +01:00
import ' package:ambito/src/packages/ambito_theme/ambito_theme.dart ' ;
import ' package:flutter/material.dart ' ;
import ' package:get/get.dart ' ;
import ' package:percent_indicator/linear_percent_indicator.dart ' ;
import ' ../../../main.dart ' ;
import ' ../../widgets/appbar/ambito_appbar.dart ' ;
class DashboardPage extends StatefulWidget {
const DashboardPage (
{ super . key , required this . businessId , required this . userId } ) ;
final int businessId ;
final int userId ;
@ override
State < StatefulWidget > createState ( ) = > DashboardPageState ( ) ;
}
class DashboardPageState extends State < DashboardPage > {
List < Widget > cards = [ ] ;
@ override
void initState ( ) {
cards . add (
_buildCard (
Colors . green ,
' images/actions/nist_brut_unterschlupforte.jpg ' ,
' Meine \n Maßnahmen ' ,
' /dashboard/meine-massnahmen ' ,
) ,
) ;
cards . add (
_buildCard (
Colors . green ,
' images/actions/steinhaufen.jpg ' ,
' Urkunde ' ,
' /dashboard/urkunde ' ,
) ,
) ;
cards . add (
_buildCard (
Colors . green ,
' images/actions/staudenbeete.jpg ' ,
' Flächen ' ,
' /dashboard/flaechen ' ,
) ,
) ;
cards . add (
_buildCard (
Colors . green ,
' images/actions/pflanzgefaesse.jpg ' ,
' Stammdaten ' ,
' /dashboard/stammdaten ' ,
) ,
) ;
super . initState ( ) ;
}
@ override
Widget build ( BuildContext context ) {
return Scaffold (
appBar: AmbitoAppbar (
links: const [ ' dashboard ' , ' massnahmen ' ] ,
) ,
body: SingleChildScrollView (
child: Align (
alignment: Alignment . topCenter ,
child: SizedBox (
width: 1152 ,
child: Column (
mainAxisSize: MainAxisSize . min ,
mainAxisAlignment: MainAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
baseTheme . verticalSpacerMax ,
Text (
' Willkommen, Max Mustermann! ' ,
textAlign: TextAlign . start ,
style: baseTheme . currentThemeData . textTheme . headlineLarge
? . copyWith (
color: baseTheme . currentColorScheme . onSurface ,
) ,
) ,
baseTheme . verticalSpacerMax ,
Wrap (
alignment: WrapAlignment . center ,
spacing: 32 ,
children: cards ,
) ,
baseTheme . verticalSpacerMax ,
Row (
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
SizedBox (
width: 532 ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Text (
' Biodiversitätsbewertung ' ,
textAlign: TextAlign . start ,
style: baseTheme
. currentThemeData . textTheme . headlineMedium
? . copyWith (
color: baseTheme . currentColorScheme . onSurface ,
) ,
) ,
baseTheme . verticalSpacer ,
SizedBox (
width: 532 ,
child: Card (
elevation: 4 ,
surfaceTintColor:
orangeColors [ ' primary ' ] ? . withOpacity ( 0.3 ) ,
child: Padding (
padding: const EdgeInsets . all ( 16 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Text (
' Fragebögen ' ,
textAlign: TextAlign . left ,
style: baseTheme . currentThemeData
. textTheme . headlineSmall
? . copyWith (
color: orangeColors [ ' primary ' ] ,
fontWeight: FontWeight . bold ,
) ,
) ,
baseTheme . verticalSpacerSmall ,
Row (
children: [
LinearPercentIndicator (
width: 440 ,
lineHeight: 20.0 ,
animation: true ,
percent: 0.8 ,
padding: EdgeInsets . zero ,
backgroundColor: baseTheme
. currentColorScheme . surface ,
progressColor:
orangeColors [ ' primary ' ] ,
barRadius: const Radius . circular ( 8 ) ,
) ,
const Spacer ( ) ,
IconButton (
iconSize: 24 ,
onPressed: ( ) { } ,
icon: const Icon (
Icons . arrow_forward_ios ,
) ,
color: Colors . white ,
style: IconButton . styleFrom (
fixedSize: const Size ( 20 , 20 ) ,
padding: const EdgeInsets . all ( 2 ) ,
backgroundColor:
orangeColors [ ' primary ' ] ,
shape: RoundedRectangleBorder (
borderRadius:
BorderRadius . circular ( 8 ) ,
) ,
) ,
) ,
] ,
) ,
baseTheme . verticalSpacerSmall ,
Text (
' 4 / 5 abgeschlossen ' ,
textAlign: TextAlign . start ,
style: baseTheme
. currentThemeData . textTheme . bodyLarge
? . copyWith (
color: baseTheme
. currentColorScheme . onSurface ,
) ,
) ,
] ,
) ,
) ,
) ,
) ,
baseTheme . verticalSpacer ,
SizedBox (
width: 532 ,
child: Card (
elevation: 4 ,
surfaceTintColor:
greenColors [ ' primary ' ] ? . withOpacity ( 0.3 ) ,
child: Padding (
padding: const EdgeInsets . all ( 16 ) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Text (
' Ergebnisse ' ,
textAlign: TextAlign . left ,
style: baseTheme . currentThemeData
. textTheme . headlineSmall
? . copyWith (
color: greenColors [ ' primary ' ] ,
fontWeight: FontWeight . bold ,
) ,
) ,
baseTheme . verticalSpacerSmall ,
Row (
children: [
LinearPercentIndicator (
width: 480 ,
lineHeight: 20.0 ,
animation: true ,
percent: 0.8 ,
padding: EdgeInsets . zero ,
backgroundColor: baseTheme
. currentColorScheme . surface ,
progressColor: greenColors [ ' primary ' ] ,
barRadius: const Radius . circular ( 8 ) ,
) ,
] ,
) ,
baseTheme . verticalSpacerSmall ,
Text (
' Weinberg: 80% ' ,
textAlign: TextAlign . start ,
style: baseTheme
. currentThemeData . textTheme . bodyLarge
? . copyWith (
color: baseTheme
. currentColorScheme . onSurface ,
) ,
) ,
baseTheme . verticalSpacerSmall ,
Row (
children: [
LinearPercentIndicator (
width: 480 ,
lineHeight: 20.0 ,
animation: true ,
percent: 0.52 ,
padding: EdgeInsets . zero ,
backgroundColor: baseTheme
. currentColorScheme . surface ,
progressColor: greenColors [ ' primary ' ] ,
barRadius: const Radius . circular ( 8 ) ,
) ,
] ,
) ,
baseTheme . verticalSpacerSmall ,
Text (
' Landschaft: 52% ' ,
textAlign: TextAlign . start ,
style: baseTheme
. currentThemeData . textTheme . bodyLarge
? . copyWith (
color: baseTheme
. currentColorScheme . onSurface ,
) ,
) ,
baseTheme . verticalSpacerSmall ,
Row (
children: [
LinearPercentIndicator (
width: 480 ,
lineHeight: 20.0 ,
animation: true ,
percent: 0.27 ,
padding: EdgeInsets . zero ,
backgroundColor: baseTheme
. currentColorScheme . surface ,
progressColor: greenColors [ ' primary ' ] ,
barRadius: const Radius . circular ( 8 ) ,
) ,
] ,
) ,
baseTheme . verticalSpacerSmall ,
Text (
' Betriebsstätte: 27% ' ,
textAlign: TextAlign . start ,
style: baseTheme
. currentThemeData . textTheme . bodyLarge
? . copyWith (
color: baseTheme
. currentColorScheme . onSurface ,
) ,
) ,
] ,
) ,
) ,
) ,
) ,
] ,
) ,
) ,
const Spacer ( ) ,
SizedBox (
width: 532 ,
child: Column (
mainAxisAlignment: MainAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Text (
' Förderungen ' ,
textAlign: TextAlign . start ,
style: baseTheme
. currentThemeData . textTheme . headlineMedium
? . copyWith (
color: baseTheme . currentColorScheme . onSurface ,
) ,
) ,
baseTheme . verticalSpacer ,
Text (
' Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. ' ,
textAlign: TextAlign . start ,
style: baseTheme
. currentThemeData . textTheme . bodyLarge
? . copyWith (
color: baseTheme . currentColorScheme . onSurface ,
) ,
) ,
baseTheme . verticalSpacer ,
_buildProjectCard (
' Projekt A ' ,
' Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. ' ,
) ,
baseTheme . verticalSpacer ,
_buildProjectCard (
' Projekt B ' ,
' Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. ' ,
) ,
] ,
) ,
) ,
] ,
) ,
] ,
) ,
) ,
) ,
) ,
) ;
}
Widget _buildCard ( Color background , String image , String title , String link ) {
return GestureDetector (
onTap: ( ) {
Get . toNamed ( link ) ;
} ,
child: SizedBox (
width: 262 ,
height: 250 ,
child: Card (
elevation: 4 ,
surfaceTintColor: Colors . white ,
child: Column (
children: [
ClipRRect (
borderRadius: BorderRadius . circular ( 8.0 ) ,
child: Image . asset (
image ,
) ,
) ,
Expanded (
child: Center (
child: Text (
title ,
textAlign: TextAlign . center ,
style: baseTheme . currentThemeData . textTheme . headlineSmall
? . copyWith (
color: const Color ( 0xFF666666 ) ,
fontWeight: FontWeight . bold ,
) ,
) ,
) ,
) ,
] ,
) ,
) ,
) ,
) ;
}
Widget _buildProjectCard ( String title , String text ) {
return SizedBox (
width: 532 ,
child: Card (
elevation: 4 ,
surfaceTintColor: Colors . white ,
child: Padding (
2024-11-09 22:03:33 +01:00
padding: const EdgeInsets . all ( 16 ) ,
2024-11-09 22:03:03 +01:00
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Text (
title ,
textAlign: TextAlign . center ,
style: baseTheme . currentThemeData . textTheme . headlineSmall
? . copyWith (
color: greenColors [ ' primary ' ] ,
fontWeight: FontWeight . bold ,
) ,
) ,
2024-11-09 22:03:33 +01:00
baseTheme . verticalSpacerSmall ,
2024-11-09 22:03:03 +01:00
Row (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Expanded (
child: Text (
text ,
softWrap: true ,
overflow: TextOverflow . ellipsis ,
maxLines: 3 ,
textAlign: TextAlign . start ,
style: baseTheme . currentThemeData . textTheme . bodyLarge
? . copyWith (
color: baseTheme . currentColorScheme . onSurface ,
) ,
) ,
) ,
IconButton (
iconSize: 24 ,
onPressed: ( ) { } ,
icon: const Icon (
Icons . arrow_forward_ios ,
) ,
color: Colors . white ,
style: IconButton . styleFrom (
fixedSize: const Size ( 20 , 20 ) ,
padding: const EdgeInsets . all ( 2 ) ,
backgroundColor: greenColors [ ' primary ' ] ,
shape: RoundedRectangleBorder (
borderRadius: BorderRadius . circular ( 8 ) ,
) ,
) ,
) ,
] ,
) ,
] ,
) ,
) ,
) ,
) ;
}
}