part of '../dashboard_page.dart';

extension PartsDashboardPage on DashboardPageState {
  Widget _bioDiversityPart(AmbitoTheme theme) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          'Biodiversitätsbewertung',
          textAlign: TextAlign.start,
          style: theme.headlineMedium.copyWith(
            color: theme.currentColorScheme.onSurface,
          ),
        ),
        theme.verticalSpacer,
        SizedBox(
          width: double.infinity,
          child: Card(
            elevation: 0,
            color: orangeColors['primary']?..withValues(alpha: 0.1),
            child: Padding(
              padding: const EdgeInsets.all(16),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    'Fragebögen',
                    textAlign: TextAlign.left,
                    style: theme.currentThemeData.textTheme.headlineSmall
                        ?.copyWith(
                      color: orangeColors['primary'],
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  theme.verticalSpacerSmall,
                  Row(
                    children: [
                      Expanded(
                        child: LinearPercentIndicator(
                          lineHeight: 20.0,
                          animation: true,
                          percent: 0.8,
                          padding: EdgeInsets.zero,
                          backgroundColor: theme.currentColorScheme.surface,
                          progressColor: orangeColors['primary'],
                          barRadius: const Radius.circular(8),
                        ),
                      ),
                      const SizedBox(
                        width: 20,
                      ),
                      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),
                          ),
                        ),
                      ),
                    ],
                  ),
                  theme.verticalSpacerSmall,
                  Text(
                    '4 / 5 abgeschlossen',
                    textAlign: TextAlign.start,
                    style: theme.currentThemeData.textTheme.bodyLarge?.copyWith(
                      color: theme.currentColorScheme.onSurface,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
        theme.verticalSpacer,
        SizedBox(
          width: double.infinity,
          child: Card(
            elevation: 0,
            color: greenColors['primary']?..withValues(alpha: 0.3),
            child: Padding(
              padding: const EdgeInsets.all(16),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    'Ergebnisse',
                    textAlign: TextAlign.left,
                    style: theme.currentThemeData.textTheme.headlineSmall
                        ?.copyWith(
                      color: greenColors['primary'],
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                  theme.verticalSpacerSmall,
                  Row(
                    children: [
                      Expanded(
                        child: LinearPercentIndicator(
                          lineHeight: 20.0,
                          animation: true,
                          percent: 0.8,
                          padding: EdgeInsets.zero,
                          backgroundColor: theme.currentColorScheme.surface,
                          progressColor: greenColors['primary'],
                          barRadius: const Radius.circular(8),
                        ),
                      ),
                    ],
                  ),
                  theme.verticalSpacerSmall,
                  Text(
                    'Weinberg: 80%',
                    textAlign: TextAlign.start,
                    style: theme.currentThemeData.textTheme.bodyLarge?.copyWith(
                      color: theme.currentColorScheme.onSurface,
                    ),
                  ),
                  theme.verticalSpacerSmall,
                  Row(
                    children: [
                      Expanded(
                        child: LinearPercentIndicator(
                          lineHeight: 20.0,
                          animation: true,
                          percent: 0.52,
                          padding: EdgeInsets.zero,
                          backgroundColor: theme.currentColorScheme.surface,
                          progressColor: greenColors['primary'],
                          barRadius: const Radius.circular(8),
                        ),
                      ),
                    ],
                  ),
                  theme.verticalSpacerSmall,
                  Text(
                    'Landschaft: 52%',
                    textAlign: TextAlign.start,
                    style: theme.currentThemeData.textTheme.bodyLarge?.copyWith(
                      color: theme.currentColorScheme.onSurface,
                    ),
                  ),
                  theme.verticalSpacerSmall,
                  Row(
                    children: [
                      Expanded(
                        child: LinearPercentIndicator(
                          lineHeight: 20.0,
                          animation: true,
                          percent: 0.27,
                          padding: EdgeInsets.zero,
                          backgroundColor: theme.currentColorScheme.surface,
                          progressColor: greenColors['primary'],
                          barRadius: const Radius.circular(8),
                        ),
                      ),
                    ],
                  ),
                  theme.verticalSpacerSmall,
                  Text(
                    'Betriebsstätte: 27%',
                    textAlign: TextAlign.start,
                    style: theme.currentThemeData.textTheme.bodyLarge?.copyWith(
                      color: theme.currentColorScheme.onSurface,
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ],
    );
  }

  Widget _fundingPart(AmbitoTheme theme) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          'Förderungen',
          textAlign: TextAlign.start,
          style: theme.currentThemeData.textTheme.headlineMedium?.copyWith(
            color: theme.currentColorScheme.onSurface,
          ),
        ),
        theme.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: theme.currentThemeData.textTheme.bodyLarge?.copyWith(
            color: theme.currentColorScheme.onSurface,
          ),
        ),
        theme.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.',
        ),
        theme.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 _buildProjectCard(String title, String text) {
    final AmbitoTheme theme = getTheme(context);

    return SizedBox(
      width: 532,
      child: Card(
        elevation: 0,
        color: Theme.of(context).colorScheme.outline..withValues(alpha: .1),
        child: Padding(
          padding: const EdgeInsets.all(16),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                title,
                textAlign: TextAlign.center,
                style: theme.currentThemeData.textTheme.headlineSmall?.copyWith(
                  color: greenColors['primary'],
                  fontWeight: FontWeight.bold,
                ),
              ),
              theme.verticalSpacerSmall,
              Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Expanded(
                    child: Text(
                      text,
                      softWrap: true,
                      overflow: TextOverflow.ellipsis,
                      maxLines: 3,
                      textAlign: TextAlign.start,
                      style:
                          theme.currentThemeData.textTheme.bodyLarge?.copyWith(
                        color: theme.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),
                      ),
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}
