import 'package:cims_apps/application/component/button/button_view.dart';
import 'package:cims_apps/application/component/select_form/select_form_view.dart';
import 'package:cims_apps/application/component/text_caption/text_caption.dart';
import 'package:cims_apps/core/route/route.dart';
import 'package:cims_apps/features/auth/registration/view/submission_data/submission_parent.dart';
import 'package:cims_apps/features/auth/registration/viewmodel/submission_data_viewmodel.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class SubmitPersonalData extends StatelessWidget {
  const SubmitPersonalData({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
        create: (context) => SubmissionDataViewModel(),
        builder: (context, child) {
          return Consumer<SubmissionDataViewModel>(
              builder: (context, provider, child) {
            return SingleChildScrollView(
              child: Form(
                key: provider.formKeyPersonalData,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    const TextCaption(title: 'Your personal details'),
                    SelectFormView(
                      name: 'Occupation',
                      hintText: 'Select occupation ',
                      ctrl: provider.ctrlOccupation,
                      listItem: provider.listOccupation,
                      onSelect: (value) {},
                    ),
                    SelectFormView(
                      name: 'Income Level (IDR)',
                      hintText: 'Select Income ',
                      ctrl: provider.ctrlIncome,
                      listItem: provider.listIncome,
                      onSelect: (value) {},
                    ),
                    SelectFormView(
                      name: 'Marital Status',
                      hintText: 'Select Marital Status ',
                      ctrl: provider.ctrlMarital,
                      listItem: provider.listMarital,
                      onSelect: (value) {},
                    ),
                    SelectFormView(
                      name: 'Source of Fund',
                      hintText: 'Select Source of Fund ',
                      ctrl: provider.ctrlSourceFund,
                      listItem: provider.listSourceFund,
                      onSelect: (value) {},
                    ),
                    Align(
                      alignment: Alignment.bottomCenter,
                      child: ButtonView(
                        name: 'Next',
                        onPressed: () async {
                          await provider.next(context).then((value) {
                            if (value) {
                              routePush(context,
                                  page: const SubmissionParent());
                            }
                          });
                        },
                      ),
                    )
                  ],
                ),
              ),
            );
          });
        });
  }
}
