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 createState() => DashboardPageState(); } class DashboardPageState extends State { List cards = []; @override void initState() { cards.add( _buildCard( Colors.green, 'images/actions/nist_brut_unterschlupforte.jpg', 'Meine\nMaß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( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( title, textAlign: TextAlign.center, style: baseTheme.currentThemeData.textTheme.headlineSmall ?.copyWith( color: greenColors['primary'], fontWeight: FontWeight.bold, ), ), baseTheme.verticalSpacerSmall, 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), ), ), ), ], ), ], ), ), ), ); } }