import 'package:ambito/src/packages/ambito_formbuilder/ambito_formbuilder.dart';
import 'package:flutter/material.dart';
import 'package:screen_breakpoints/screen_breakpoints.dart';

import '../../../packages/ambito_theme/ambito_theme.dart';
import '../../../widgets/appbar/ambito_appbar.dart';
import '../../ambito_page.dart';

class MeasureCreatePage extends AmbitoPage {
  const MeasureCreatePage({super.key});

  @override
  final String path = 'massnahmen';
  @override
  final String title = 'Maßnamen';

  @override
  State<StatefulWidget> createState() => MeasureCreatePageState();
}

class MeasureCreatePageState extends State<MeasureCreatePage> {
  Widget form = const Center(
    child: CircularProgressIndicator(),
  );

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    final AmbitoTheme theme = getTheme(context);
    form = AmbitoFormBuilder().init(context, 'Measure');

    return Scaffold(
      appBar: AmbitoAppbar(
          links: const ['dashboard', 'massnahmen'],
          breakpoint: Breakpoint.fromContext(context),
          theme: theme),
      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()),
                  Text(theme.toString()),
                  theme.verticalSpacerMax,
                  Text(
                    'Neue Maßnahme anlegen',
                    textAlign: TextAlign.start,
                    style: theme.currentThemeData.textTheme.headlineLarge
                        ?.copyWith(
                      color: theme.currentColorScheme.onSurface,
                    ),
                  ),
                  theme.verticalSpacerMax,
                  form,
                ],
              ),
            ),
          ),
        );
      }),
    );
  }
}
