import 'package:cims_apps/application/assets/path_assets.dart';
import 'package:cims_apps/application/component/button/button_view.dart';
import 'package:cims_apps/application/component/image/image_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/application/component/text_form/text_form_view.dart';
import 'package:cims_apps/application/theme/color_palette.dart';
import 'package:cims_apps/core/route/route.dart';
import 'package:cims_apps/core/utils/size_config.dart';
import 'package:cims_apps/features/auth/registration/view/submission_data/data_bank/guide_screen.dart';
import 'package:cims_apps/features/auth/registration/viewmodel/submission_data_viewmodel.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import 'confirm_bank_account.dart';

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

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
        providers: [
          ChangeNotifierProvider(
            create: (context) => SubmissionDataViewModel(),
          )
        ],
        builder: (context, child) {
          return SizedBox(
            child: Consumer<SubmissionDataViewModel>(
                builder: (context, provider, child) {
              return SingleChildScrollView(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    const TextCaption(title: 'Input your bank account data'),
                    SelectFormView(
                      name: 'Bank Name',
                      hintText: 'Select Bank',
                      listItem: provider.listBank,
                      ctrl: provider.ctrlBankName,
                      onSelect: (value) {},
                    ),
                    TextFormView(
                      name: 'Account Number',
                      hintText: 'Input Account Number',
                      keyboardType: TextInputType.number,
                      trailingTitleWidget: SizedBox(
                        width: 24,
                        child: GestureDetector(
                          onTap: () {
                            routePush(context, page: const GuideScreen());
                          },
                          child:
                              const ImageView(image: PathAssets.iconQuestion),
                        ),
                      ),
                    ),
                    TextFormView(
                      name: 'Account Owner Name',
                      hintText: 'Input Account Name',
                    ),
                    const Text(
                      "Make sure the account you use is in your name, not someone else's",
                      style: TextStyle(
                        color: ColorPalette.slate400,
                      ),
                    ),
                    SizedBox(height: SizeConfig.height * .08),
                    ButtonView(
                      name: 'Next',
                      onPressed: () {
                        provider.next(context).then((value) {
                          if (value) {
                            routePush(context,
                                page: const ConfirmBankAccount());
                          }
                        });
                      },
                    )
                  ],
                ),
              );
            }),
          );
        });
  }
}
