Advertisement
mactech24

Cable tv with bloc

May 18th, 2024
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 41.48 KB | None | 0 0
  1. //Vtu State
  2. // ignore_for_file: public_member_api_docs, sort_constructors_first
  3. part of 'vtu_bloc.dart';
  4.  
  5. class VtuState extends Equatable {
  6.   final FormSubmissionStatus formStatus;
  7.   final List<DataModel> dataService;
  8.   final List<AirtimeModel> airtimeService;
  9.   final List<BillPaymentModel> billPaymentService;
  10.   final List<CableModel> cableService;
  11.   final int selectedCableService;
  12.   final List<CableIdModel> cableProductId;
  13.   final int selectedCablePlan;
  14.   const VtuState({
  15.     this.formStatus = const InitialFormStatus(),
  16.     this.dataService = const [],
  17.     this.airtimeService = const [],
  18.     this.billPaymentService = const [],
  19.     this.cableService = const [],
  20.     this.selectedCableService = 0,
  21.     this.cableProductId = const [],
  22.     this.selectedCablePlan = 0,
  23.   });
  24.  
  25.   VtuState copyWith({
  26.     FormSubmissionStatus? formStatus,
  27.     List<DataModel>? dataService,
  28.     List<AirtimeModel>? airtimeService,
  29.     List<BillPaymentModel>? billPaymentService,
  30.     List<CableModel>? cableService,
  31.     int? selectedCableService,
  32.     List<CableIdModel>? cableProductId,
  33.     int? selectedCablePlan,
  34.   }) {
  35.     return VtuState(
  36.         formStatus: formStatus ?? this.formStatus,
  37.         dataService: dataService ?? this.dataService,
  38.         airtimeService: airtimeService ?? this.airtimeService,
  39.         billPaymentService: billPaymentService ?? this.billPaymentService,
  40.         cableService: cableService ?? this.cableService,
  41.         selectedCableService: selectedCableService ?? this.selectedCableService,
  42.         cableProductId: cableProductId ?? this.cableProductId,
  43.         selectedCablePlan: selectedCablePlan ?? this.selectedCablePlan);
  44.   }
  45.  
  46.   @override
  47.   List<Object?> get props => [
  48.         formStatus,
  49.         billPaymentService,
  50.         dataService,
  51.         cableService,
  52.         airtimeService,
  53.         selectedCableService,
  54.         cableProductId,
  55.         selectedCablePlan,
  56.       ];
  57. }
  58.  
  59.  
  60.  
  61. //Vtu Event
  62.  
  63. // ignore_for_file: prefer_const_constructors_in_immutables
  64.  
  65. part of 'vtu_bloc.dart';
  66.  
  67. abstract class VtuEvent extends Equatable {
  68.   const VtuEvent();
  69.   @override
  70.   List<Object?> get props => [];
  71. }
  72.  
  73. class VtuInitial extends VtuEvent {
  74.   const VtuInitial();
  75. }
  76.  
  77. class GetDataService extends VtuEvent {
  78.   const GetDataService();
  79. }
  80.  
  81. class GetAirtimeService extends VtuEvent {
  82.   const GetAirtimeService();
  83. }
  84.  
  85. class GetCableService extends VtuEvent {
  86.   const GetCableService();
  87. }
  88.  
  89. class GetCableProductId extends VtuEvent {
  90.   final String cableId;
  91.   const GetCableProductId({required this.cableId});
  92.   @override
  93.   List<Object?> get props => [cableId];
  94. }
  95.  
  96. class SelectCableService extends VtuEvent {
  97.   final int selectedIndex;
  98.   const SelectCableService({required this.selectedIndex});
  99.   @override
  100.   List<Object?> get props => [selectedIndex];
  101. }
  102.  
  103. class SelectCablePlan extends VtuEvent {
  104.   final int selectedIndex;
  105.   const SelectCablePlan({required this.selectedIndex});
  106.   @override
  107.   List<Object?> get props => [selectedIndex];
  108. }
  109.  
  110. class GetBillPaymentService extends VtuEvent {
  111.   const GetBillPaymentService();
  112. }
  113.  
  114.  
  115. //Vtu bloc
  116. import 'dart:async';
  117. import 'package:bitfornaira/blocs/form_submission_status.dart';
  118. import 'package:bitfornaira/models/airtime_model.dart';
  119. import 'package:bitfornaira/models/bill_model.dart';
  120. import 'package:bitfornaira/models/cable_id_model.dart';
  121. import 'package:bitfornaira/models/cable_model.dart';
  122. import 'package:bitfornaira/models/data_model.dart';
  123. import 'package:bitfornaira/repository/vtu_repository.dart';
  124. import 'package:bloc/bloc.dart';
  125. import 'package:equatable/equatable.dart';
  126.  
  127. part 'vtu_event.dart';
  128. part 'vtu_state.dart';
  129.  
  130. class VtuBloc extends Bloc<VtuEvent, VtuState> {
  131.   final VtuRepository vtuRepo;
  132.  
  133.   VtuBloc({required this.vtuRepo}) : super(const VtuState()) {
  134.     on<VtuInitial>((event, emit) =>
  135.         emit(state.copyWith(formStatus: const InitialFormStatus())));
  136.     on<GetDataService>(_getDataService);
  137.     on<GetAirtimeService>(_getAirtimeService);
  138.     on<GetCableService>(_getCableService);
  139.     on<GetBillPaymentService>(_getBillPaymentService);
  140.     on<SelectCableService>(_selectCableService);
  141.     on<GetCableProductId>(_getCableProductId);
  142.     on<SelectCablePlan>(_selectCablePlan);
  143.   }
  144.   FutureOr<void> _getDataService(
  145.       GetDataService event, Emitter<VtuState> emit) async {
  146.     emit(state.copyWith(formStatus: FormSubmitting()));
  147.     try {
  148.       List data = await vtuRepo.getVtuServices("DATA");
  149.       List<DataModel> dataList =
  150.           data.map((e) => DataModel.fromJson(e)).toList();
  151.       emit(state.copyWith(
  152.           dataService: dataList, formStatus: SubmissionSuccess()));
  153.     } catch (e) {
  154.       emit(state.copyWith(formStatus: SubmissionFailed(msg: e.toString())));
  155.     }
  156.   }
  157.  
  158.   FutureOr<void> _getAirtimeService(
  159.       GetAirtimeService event, Emitter<VtuState> emit) async {
  160.     emit(state.copyWith(formStatus: FormSubmitting()));
  161.  
  162.     try {
  163.       List data = await vtuRepo.getVtuServices("AIRTIME");
  164.       List<AirtimeModel> dataList =
  165.           data.map((e) => AirtimeModel.fromJson(e)).toList();
  166.       emit(state.copyWith(
  167.           airtimeService: dataList, formStatus: SubmissionSuccess()));
  168.     } catch (e) {
  169.       emit(state.copyWith(formStatus: SubmissionFailed(msg: e.toString())));
  170.     }
  171.   }
  172.  
  173.   FutureOr<void> _getCableService(
  174.       GetCableService event, Emitter<VtuState> emit) async {
  175.     emit(state.copyWith(formStatus: FormSubmitting()));
  176.     try {
  177.       List data = await vtuRepo.getVtuServices("CABLE");
  178.       List<CableModel> dataList =
  179.           data.map((e) => CableModel.fromJson(e)).toList();
  180.       emit(state.copyWith(
  181.           cableService: dataList, formStatus: SubmissionSuccess()));
  182.     } catch (e) {
  183.       emit(state.copyWith(formStatus: SubmissionFailed(msg: e.toString())));
  184.     }
  185.   }
  186.  
  187.   FutureOr<void> _getBillPaymentService(
  188.       GetBillPaymentService event, Emitter<VtuState> emit) async {
  189.     try {
  190.       emit(state.copyWith(formStatus: FormSubmitting()));
  191.       List data = await vtuRepo.getVtuServices("BILLPAYMENT");
  192.       List<BillPaymentModel> dataList =
  193.           data.map((e) => BillPaymentModel.fromJson(e)).toList();
  194.       emit(state.copyWith(
  195.           billPaymentService: dataList, formStatus: SubmissionSuccess()));
  196.     } catch (e) {
  197.       emit(state.copyWith(formStatus: SubmissionFailed(msg: e.toString())));
  198.     }
  199.   }
  200.  
  201.   FutureOr<void> _selectCableService(
  202.       SelectCableService event, Emitter<VtuState> emit) {
  203.     emit(state.copyWith(selectedCableService: event.selectedIndex));
  204.   }
  205.  
  206.   FutureOr<void> _getCableProductId(
  207.       GetCableProductId event, Emitter<VtuState> emit) async {
  208.     emit(state.copyWith(formStatus: FormSubmitting()));
  209.     try {
  210.       List data = await vtuRepo.getCableTvId(event.cableId);
  211.       List<CableIdModel> dataList =
  212.           data.map((e) => CableIdModel.fromJson(e)).toList();
  213.       emit(state.copyWith(
  214.           formStatus: SubmissionSuccess(), cableProductId: dataList));
  215.     } catch (e) {
  216.       emit(state.copyWith(
  217.         formStatus: SubmissionFailed(msg: e.toString()),
  218.       ));
  219.     }
  220.   }
  221.  
  222.   FutureOr<void> _selectCablePlan(
  223.       SelectCablePlan event, Emitter<VtuState> emit) {
  224.     emit(state.copyWith(selectedCablePlan: event.selectedIndex));
  225.   }
  226. }
  227.  
  228. //Cable Tv Screen
  229. import 'package:bitfornaira/blocs/form_submission_status.dart';
  230. import 'package:bitfornaira/blocs/vtu/vtu_bloc.dart';
  231. import 'package:bitfornaira/constants/colors.dart';
  232. import 'package:bitfornaira/constants/icons_url.dart';
  233. import 'package:bitfornaira/constants/image_url.dart';
  234. import 'package:bitfornaira/constants/strings.dart';
  235. import 'package:bitfornaira/repository/vtu_repository.dart';
  236. import 'package:bitfornaira/screens/CableTv/widgets/cable_tv_widget.dart';
  237. import 'package:bitfornaira/utils/utils_size.dart';
  238. import 'package:flutter/material.dart';
  239. import 'package:flutter_bloc/flutter_bloc.dart';
  240. import 'package:shimmer/shimmer.dart';
  241. import '../../global_widgets/global_widget.dart';
  242.  
  243. class CableTv extends StatefulWidget {
  244.   const CableTv({Key? key}) : super(key: key);
  245.   static String routeName = "/cableTv";
  246.   @override
  247.   _CableTvState createState() => _CableTvState();
  248. }
  249.  
  250. class _CableTvState extends State<CableTv> {
  251.   @override
  252.   void initState() {
  253.     super.initState();
  254.     if (context.read<VtuBloc>().state.cableService.isEmpty == true) {
  255.       context.read<VtuBloc>().add(const GetCableService());
  256.     }
  257.     VtuRepository vtuRepo = VtuRepository();
  258.     vtuRepo.getCableTvId("cableId");
  259.   }
  260.  
  261.   @override
  262.   Widget build(BuildContext context) {
  263.     Size size = MediaQuery.of(context).size;
  264.  
  265.     return Scaffold(
  266.       body: SingleChildScrollView(
  267.         child: BlocConsumer<VtuBloc, VtuState>(
  268.           listener: (context, state) {},
  269.           builder: (context, state) {
  270.             return Container(
  271.               height: size.height,
  272.               width: size.width,
  273.               color: federalBlue,
  274.               child: Stack(
  275.                 alignment: Alignment.center,
  276.                 children: [
  277.                   Container(),
  278.                   Positioned(
  279.                     top: getProportionateScreenHeight(35),
  280.                     right: getProportionateScreenWidth(20),
  281.                     left: getProportionateScreenWidth(20),
  282.                     child: Container(
  283.                       height: size.height * 0.2,
  284.                       decoration: BoxDecoration(
  285.                         color: cartonColor,
  286.                         borderRadius: BorderRadius.only(
  287.                           topLeft: Radius.circular(
  288.                             getProportionateScreenWidth(30),
  289.                           ),
  290.                           topRight: Radius.circular(
  291.                             getProportionateScreenWidth(30),
  292.                           ),
  293.                         ),
  294.                       ),
  295.                     ),
  296.                   ),
  297.                   Positioned(
  298.                     top: getProportionateScreenHeight(45),
  299.                     right: getProportionateScreenWidth(0),
  300.                     left: getProportionateScreenWidth(0),
  301.                     child: Container(
  302.                       height: size.height,
  303.                       padding: EdgeInsets.symmetric(
  304.                         horizontal: getProportionateScreenWidth(5),
  305.                         vertical: getProportionateScreenWidth(20),
  306.                       ),
  307.                       decoration: BoxDecoration(
  308.                         color: bgColor,
  309.                         borderRadius: BorderRadius.only(
  310.                           topLeft: Radius.circular(
  311.                             getProportionateScreenWidth(30),
  312.                           ),
  313.                           topRight: Radius.circular(
  314.                             getProportionateScreenWidth(30),
  315.                           ),
  316.                         ),
  317.                       ),
  318.                       child: SingleChildScrollView(
  319.                         child: Column(
  320.                           children: [
  321.                             customAppBar(
  322.                               context: context,
  323.                               title: cableTv,
  324.                             ),
  325.                             verticalSpace(
  326.                               getProportionateScreenHeight(10),
  327.                             ),
  328.                             Padding(
  329.                               padding: EdgeInsets.symmetric(
  330.                                 horizontal: getProportionateScreenWidth(10),
  331.                               ),
  332.                               child: Column(
  333.                                 children: [
  334.                                   Row(
  335.                                     children: [
  336.                                       Text(
  337.                                         serviceProviderText,
  338.                                         style: TextStyle(
  339.                                           fontFamily: appFontFamily1,
  340.                                           color: black,
  341.                                           fontWeight: FontWeight.w400,
  342.                                           fontSize:
  343.                                               getProportionateScreenWidth(16),
  344.                                         ),
  345.                                       )
  346.                                     ],
  347.                                   ),
  348.                                   verticalSpace(
  349.                                       getProportionateScreenHeight(10)),
  350.                                   state.formStatus is FormSubmitting
  351.                                       ? Row(
  352.                                           mainAxisAlignment:
  353.                                               MainAxisAlignment.spaceBetween,
  354.                                           children: [1, 2, 3, 4]
  355.                                               .map((e) => Shimmer.fromColors(
  356.                                                   baseColor:
  357.                                                       Colors.grey.shade300,
  358.                                                   highlightColor:
  359.                                                       Colors.grey.shade100,
  360.                                                   child: Column(
  361.                                                     children: [
  362.                                                       Container(
  363.                                                         decoration: BoxDecoration(
  364.                                                             color: Theme.of(
  365.                                                                     context)
  366.                                                                 .cardColor,
  367.                                                             borderRadius:
  368.                                                                 BorderRadius
  369.                                                                     .circular(
  370.                                                                         50)),
  371.                                                         height:
  372.                                                             getProportionateScreenHeight(
  373.                                                                 67),
  374.                                                         width:
  375.                                                             getProportionateScreenHeight(
  376.                                                                 67),
  377.                                                       ),
  378.                                                       verticalSpace(
  379.                                                           getProportionateScreenHeight(
  380.                                                               15)),
  381.                                                       Container(
  382.                                                         decoration:
  383.                                                             BoxDecoration(
  384.                                                           color:
  385.                                                               Theme.of(context)
  386.                                                                   .cardColor,
  387.                                                         ),
  388.                                                         height:
  389.                                                             getProportionateScreenHeight(
  390.                                                                 10),
  391.                                                         width:
  392.                                                             getProportionateScreenHeight(
  393.                                                                 50),
  394.                                                       ),
  395.                                                     ],
  396.                                                   )))
  397.                                               .toList(),
  398.                                         )
  399.                                       : Row(
  400.                                           // mainAxisAlignment: MainAxisAlignment.start,
  401.                                           children: List.generate(
  402.                                               state.cableService.length,
  403.                                               (index) {
  404.                                           final myCableService =
  405.                                               state.cableService[index];
  406.                                           return cableTvServiceProviderCards(
  407.                                             selected:
  408.                                                 state.selectedCableService ==
  409.                                                         index
  410.                                                     ? true
  411.                                                     : false,
  412.                                             borderColor:
  413.                                                 state.selectedCableService ==
  414.                                                         index
  415.                                                     ? black
  416.                                                     : transparent,
  417.                                             context: context,
  418.                                             icon: gotvUrl,
  419.                                             text: myCableService.name,
  420.                                             onTap: () {
  421.                                               print("pressed");
  422.                                               context.read<VtuBloc>().add(
  423.                                                     SelectCableService(
  424.                                                         selectedIndex: index),
  425.                                                   );
  426.                                               context.read<VtuBloc>().add(
  427.                                                   GetCableProductId(
  428.                                                       cableId:
  429.                                                           myCableService.id));
  430.                                               print(myCableService.id);
  431.                                             },
  432.                                           );
  433.                                         })),
  434.                                   verticalSpace(
  435.                                       getProportionateScreenHeight(15)),
  436.                                   fieldTitle(text: subscriptionPlanText),
  437.                                   cableTvDropDownContainer(
  438.                                     context: context,
  439.                                     containerColor: white,
  440.                                     text: selectSubscriptionPlan,
  441.                                     icon: arrowDownUrl,
  442.                                     onTap: () {
  443.                                       showModalBottomSheet(
  444.                                         context: context,
  445.                                         builder: (BuildContext context) {
  446.                                           return const SelectCableTvPlanBottomSheet();
  447.                                         },
  448.                                       );
  449.                                     },
  450.                                   ),
  451.                                   verticalSpace(
  452.                                       getProportionateScreenHeight(10)),
  453.                                   fieldTitle(text: smartCardNumber),
  454.                                   const buildTextField(
  455.                                     hintText: enterIUCNumber,
  456.                                     fillColor: white,
  457.                                     filled: true,
  458.                                   ),
  459.                                   verticalSpace(
  460.                                       getProportionateScreenHeight(50)),
  461.                                   customButton(
  462.                                       context: context,
  463.                                       buttonColor: orange.withOpacity(0.3),
  464.                                       buttonTextColor: white,
  465.                                       buttonText: proceedText,
  466.                                       onPressed: () {
  467.                                         showModalBottomSheet(
  468.                                           context: context,
  469.                                           builder: (BuildContext context) {
  470.                                             return const CableTvTransactionConfirmationBottomSheet();
  471.                                           },
  472.                                         );
  473.                                       }),
  474.                                 ],
  475.                               ),
  476.                             )
  477.                           ],
  478.                         ),
  479.                       ),
  480.                     ),
  481.                   ),
  482.                 ],
  483.               ),
  484.             );
  485.           },
  486.         ),
  487.       ),
  488.     );
  489.   }
  490. }
  491.  
  492. //Cable Tv Widgets
  493.  
  494. import 'dart:async';
  495.  
  496. import 'package:bitfornaira/blocs/vtu/vtu_bloc.dart';
  497. import 'package:bitfornaira/constants/colors.dart';
  498. import 'package:bitfornaira/constants/icons_url.dart';
  499. import 'package:bitfornaira/constants/image_url.dart';
  500. import 'package:bitfornaira/constants/strings.dart';
  501. import 'package:bitfornaira/global_widgets/global_widget.dart';
  502. import 'package:bitfornaira/screens/BuyData/transaction_successful.dart';
  503. import 'package:bitfornaira/utils/utils_size.dart';
  504. import 'package:flutter/material.dart';
  505. import 'package:flutter_bloc/flutter_bloc.dart';
  506.  
  507. Widget cableTvServiceProviderCards({
  508.   required BuildContext context,
  509.   required String icon,
  510.   required String text,
  511.   required Color borderColor,
  512.   bool? selected,
  513.   void Function()? onTap,
  514. }) {
  515.   return Stack(
  516.     alignment: Alignment.center,
  517.     children: [
  518.       Container(
  519.         height: getProportionateScreenHeight(100),
  520.         width: getProportionateScreenHeight(90),
  521.         child: Column(
  522.           children: [
  523.             InkWell(
  524.               onTap: onTap,
  525.               child: Container(
  526.                 height: getProportionateScreenHeight(67),
  527.                 width: getProportionateScreenHeight(67),
  528.                 decoration: BoxDecoration(
  529.                   borderRadius: BorderRadius.circular(50),
  530.                   border: Border.all(color: borderColor),
  531.                 ),
  532.                 child: Image.asset(
  533.                   icon,
  534.                   fit: BoxFit.cover,
  535.                 ),
  536.               ),
  537.             ),
  538.             verticalSpace(getProportionateScreenHeight(5)),
  539.             Text(
  540.               text,
  541.               style: TextStyle(
  542.                 fontFamily: appFontFamily1,
  543.                 fontSize: getProportionateScreenWidth(14),
  544.                 color: black,
  545.                 fontWeight: FontWeight.w400,
  546.               ),
  547.             )
  548.           ],
  549.         ),
  550.       ),
  551.       Positioned(
  552.         top: 0,
  553.         right: getProportionateScreenWidth(10),
  554.         child: selected == true
  555.             ? Container(
  556.                 height: getProportionateScreenHeight(20),
  557.                 width: getProportionateScreenHeight(20),
  558.                 decoration: const BoxDecoration(
  559.                   color: black,
  560.                   shape: BoxShape.circle,
  561.                 ),
  562.                 child: Icon(
  563.                   Icons.check,
  564.                   color: white,
  565.                   size: getProportionateScreenHeight(14),
  566.                 ),
  567.               )
  568.             : const SizedBox(),
  569.       )
  570.     ],
  571.   );
  572. }
  573.  
  574. Widget cableTvDropDownContainer({
  575.   required BuildContext context,
  576.   required String text,
  577.   required String icon,
  578.   required Color containerColor,
  579.   void Function()? onTap,
  580. }) {
  581.   return InkWell(
  582.     onTap: onTap,
  583.     child: Container(
  584.       height: getProportionateScreenHeight(55),
  585.       width: double.infinity,
  586.       padding: EdgeInsets.symmetric(
  587.         horizontal: getProportionateScreenWidth(15),
  588.       ),
  589.       decoration: BoxDecoration(
  590.         color: containerColor,
  591.         border: Border.all(color: lightGrey),
  592.         borderRadius: BorderRadius.all(
  593.           Radius.circular(
  594.             getProportionateScreenHeight(10),
  595.           ),
  596.         ),
  597.       ),
  598.       child: Row(
  599.         mainAxisAlignment: MainAxisAlignment.spaceBetween,
  600.         children: [
  601.           Text(
  602.             text,
  603.             style: TextStyle(
  604.               fontFamily: appFontFamily1,
  605.               fontSize: getProportionateScreenWidth(14),
  606.               fontWeight: FontWeight.w400,
  607.               color: lightGrey,
  608.             ),
  609.           ),
  610.           Image.asset(
  611.             icon,
  612.             width: getProportionateScreenWidth(12),
  613.           )
  614.         ],
  615.       ),
  616.     ),
  617.   );
  618. }
  619.  
  620. Widget cableTvValueContainer({
  621.   required BuildContext context,
  622.   required String text,
  623.   required Color buttonColor,
  624.   required Color textColor,
  625.   void Function()? onTap,
  626. }) {
  627.   return InkWell(
  628.     onTap: onTap,
  629.     child: Container(
  630.       alignment: Alignment.centerLeft,
  631.       height: getProportionateScreenHeight(55),
  632.       margin: EdgeInsets.only(bottom: getProportionateScreenHeight(8)),
  633.       width: double.infinity,
  634.       padding: EdgeInsets.only(left: getProportionateScreenWidth(8)),
  635.       decoration: BoxDecoration(
  636.         color: buttonColor,
  637.         borderRadius: BorderRadius.all(
  638.           Radius.circular(getProportionateScreenHeight(10)),
  639.         ),
  640.       ),
  641.       child: Text(
  642.         text,
  643.         style: TextStyle(
  644.           fontFamily: monseratFont,
  645.           color: textColor,
  646.           fontSize: getProportionateScreenWidth(14),
  647.           fontWeight: FontWeight.w400,
  648.         ),
  649.       ),
  650.     ),
  651.   );
  652. }
  653.  
  654. class SelectCableTvPlanBottomSheet extends StatelessWidget {
  655.   const SelectCableTvPlanBottomSheet({super.key});
  656.   @override
  657.   Widget build(BuildContext context) {
  658.     return BlocBuilder<VtuBloc, VtuState>(
  659.       builder: (context, state) {
  660.         return ClipRRect(
  661.           borderRadius: BorderRadius.only(
  662.             topLeft: Radius.circular(getProportionateScreenWidth(20)),
  663.             topRight: Radius.circular(getProportionateScreenWidth(20)),
  664.           ),
  665.           child: Container(
  666.             color: white,
  667.             width: double.infinity,
  668.             padding: EdgeInsets.all(getProportionateScreenWidth(16)),
  669.             // ignore: sort_child_properties_last
  670.             child: SingleChildScrollView(
  671.               child: Column(
  672.                 mainAxisSize: MainAxisSize.min,
  673.                 children: <Widget>[
  674.                   Row(
  675.                     mainAxisAlignment: MainAxisAlignment.center,
  676.                     children: [
  677.                       Text(
  678.                         selectdataText,
  679.                         style: TextStyle(
  680.                           fontSize: getProportionateScreenWidth(17),
  681.                           fontWeight: FontWeight.w400,
  682.                         ),
  683.                       ),
  684.                     ],
  685.                   ),
  686.                   verticalSpace(getProportionateScreenHeight(10)),
  687.                   Column(
  688.                     children: List.generate(state.cableService.length, (index) {
  689.                       final productPlanList = state.cableService[index];
  690.                       return cableTvValueContainer(
  691.                         context: context,
  692.                         text:
  693.                             "Basic  Bouquet - Monthly - ₦${productPlanList.sellingPrice.toString()}",
  694.                         textColor: state.selectedCablePlan == index
  695.                             ? lightWhite
  696.                             : black,
  697.                         buttonColor: state.selectedCablePlan == index
  698.                             ? federalBlue
  699.                             : lighthash,
  700.                         onTap: () {
  701.                           context
  702.                               .read<VtuBloc>()
  703.                               .add(SelectCablePlan(selectedIndex: index));
  704.                           // print(productPlanList.sellingPrice.toString());
  705.                         },
  706.                       );
  707.                     }),
  708.                   )
  709.                 ],
  710.               ),
  711.             ),
  712.           ),
  713.         );
  714.       },
  715.     );
  716.   }
  717. }
  718.  
  719. Widget cableTvransConfirmationWidget({
  720.   required String transConfirm,
  721.   required String transConfirmValue,
  722. }) {
  723.   return Padding(
  724.     padding: EdgeInsets.only(bottom: getProportionateScreenHeight(18)),
  725.     child: Row(
  726.       mainAxisAlignment: MainAxisAlignment.spaceBetween,
  727.       children: [
  728.         Text(
  729.           transConfirm,
  730.           style: TextStyle(
  731.             fontSize: getProportionateScreenWidth(14),
  732.             fontWeight: FontWeight.w400,
  733.             color: lightBlack,
  734.           ),
  735.         ),
  736.         Text(
  737.           transConfirmValue,
  738.           style: TextStyle(
  739.             fontFamily: monseratFont,
  740.             fontSize: getProportionateScreenWidth(14),
  741.             fontWeight: FontWeight.w400,
  742.             color: lightBlack,
  743.           ),
  744.         ),
  745.       ],
  746.     ),
  747.   );
  748. }
  749.  
  750. class CableTvTransactionConfirmationBottomSheet extends StatelessWidget {
  751.   const CableTvTransactionConfirmationBottomSheet({super.key});
  752.   @override
  753.   Widget build(BuildContext context) {
  754.     return BlocBuilder<VtuBloc, VtuState>(
  755.       builder: (context, state) {
  756.         return ClipRRect(
  757.           borderRadius: BorderRadius.only(
  758.             topLeft: Radius.circular(getProportionateScreenWidth(20)),
  759.             topRight: Radius.circular(getProportionateScreenWidth(20)),
  760.           ),
  761.           child: Container(
  762.             color: white,
  763.             width: double.infinity,
  764.             padding: EdgeInsets.all(getProportionateScreenWidth(16)),
  765.             // ignore: sort_child_properties_last
  766.             child: SingleChildScrollView(
  767.               child: Column(
  768.                 mainAxisSize: MainAxisSize.min,
  769.                 children: <Widget>[
  770.                   Row(
  771.                     mainAxisAlignment: MainAxisAlignment.center,
  772.                     children: [
  773.                       Text(
  774.                         transactionConfirmationText,
  775.                         style: TextStyle(
  776.                           fontSize: getProportionateScreenWidth(16),
  777.                           fontWeight: FontWeight.w400,
  778.                           color: black,
  779.                         ),
  780.                       ),
  781.                     ],
  782.                   ),
  783.                   verticalSpace(getProportionateScreenHeight(25)),
  784.                   Container(
  785.                     padding: EdgeInsets.all(getProportionateScreenWidth(20)),
  786.                     decoration: BoxDecoration(
  787.                       color: bgColor,
  788.                       borderRadius: BorderRadius.all(
  789.                         Radius.circular(getProportionateScreenWidth(8)),
  790.                       ),
  791.                     ),
  792.                     child: Column(
  793.                       children: [
  794.                         cableTvransConfirmationWidget(
  795.                           transConfirm: subscriptionPlanText,
  796.                           transConfirmValue: basicBouquet,
  797.                         ),
  798.                         cableTvransConfirmationWidget(
  799.                           transConfirm: cableTvAmount,
  800.                           transConfirmValue: cableTvAmountValue,
  801.                         ),
  802.                         cableTvransConfirmationWidget(
  803.                           transConfirm: smartCardNum,
  804.                           transConfirmValue: smartCardNumberValue,
  805.                         ),
  806.                       ],
  807.                     ),
  808.                   ),
  809.                   verticalSpace(getProportionateScreenHeight(50)),
  810.                   customButton(
  811.                     context: context,
  812.                     buttonColor: orange,
  813.                     buttonTextColor: white,
  814.                     buttonText: proceedText,
  815.                     onPressed: () {
  816.                       Navigator.pop(context);
  817.                       showModalBottomSheet(
  818.                         context: context,
  819.                         builder: (BuildContext context) {
  820.                           return const VerifyFingerprintBottomSheet();
  821.                         },
  822.                       );
  823.                     },
  824.                   ),
  825.                   verticalSpace(getProportionateScreenHeight(20)),
  826.                 ],
  827.               ),
  828.             ),
  829.           ),
  830.         );
  831.       },
  832.     );
  833.   }
  834. }
  835.  
  836. class VerifyFingerprintBottomSheet extends StatelessWidget {
  837.   const VerifyFingerprintBottomSheet({super.key});
  838.   @override
  839.   Widget build(BuildContext context) {
  840.     return ClipRRect(
  841.       borderRadius: BorderRadius.only(
  842.         topLeft: Radius.circular(getProportionateScreenWidth(20)),
  843.         topRight: Radius.circular(getProportionateScreenWidth(20)),
  844.       ),
  845.       child: Container(
  846.         color: white,
  847.         width: double.infinity,
  848.         padding: EdgeInsets.all(getProportionateScreenWidth(16)),
  849.         // ignore: sort_child_properties_last
  850.         child: SingleChildScrollView(
  851.           child: Column(
  852.             mainAxisSize: MainAxisSize.min,
  853.             children: <Widget>[
  854.               Row(
  855.                 mainAxisAlignment: MainAxisAlignment.center,
  856.                 children: [
  857.                   Text(
  858.                     verifyFingerprintText,
  859.                     style: TextStyle(
  860.                       fontSize: getProportionateScreenWidth(16),
  861.                       fontWeight: FontWeight.w400,
  862.                       color: black,
  863.                     ),
  864.                   ),
  865.                 ],
  866.               ),
  867.               Text(
  868.                 touchFingerprintText,
  869.                 style: TextStyle(
  870.                   fontFamily: appFontFamily1,
  871.                   fontSize: getProportionateScreenWidth(12),
  872.                   fontWeight: FontWeight.w300,
  873.                   color: lightBlack,
  874.                 ),
  875.               ),
  876.               verticalSpace(getProportionateScreenHeight(20)),
  877.               Container(
  878.                 height: getProportionateScreenHeight(90),
  879.                 width: getProportionateScreenHeight(90),
  880.                 padding: EdgeInsets.all(getProportionateScreenWidth(8)),
  881.                 decoration: BoxDecoration(
  882.                   borderRadius: BorderRadius.circular(50),
  883.                   color: bgColor,
  884.                 ),
  885.                 child: InkWell(
  886.                   onTap: () {},
  887.                   child: Container(
  888.                       height: getProportionateScreenHeight(90),
  889.                       width: getProportionateScreenHeight(90),
  890.                       padding: EdgeInsets.all(getProportionateScreenWidth(18)),
  891.                       decoration: BoxDecoration(
  892.                         borderRadius: BorderRadius.circular(50),
  893.                         color: orange,
  894.                       ),
  895.                       child: Image.asset(whiteFingerprint)),
  896.                 ),
  897.               ),
  898.               verticalSpace(getProportionateScreenHeight(50)),
  899.               InkWell(
  900.                 onTap: () {
  901.                   Navigate.pop(context);
  902.                   showModalBottomSheet(
  903.                     context: context,
  904.                     builder: (BuildContext context) {
  905.                       return const TransactionPinBottomSheet();
  906.                     },
  907.                   );
  908.                 },
  909.                 child: Text(
  910.                   switchToTransactionPinText,
  911.                   style: TextStyle(
  912.                     fontFamily: appFontFamily1,
  913.                     fontSize: getProportionateScreenWidth(18),
  914.                     fontWeight: FontWeight.w400,
  915.                     color: orange,
  916.                   ),
  917.                 ),
  918.               )
  919.             ],
  920.           ),
  921.         ),
  922.       ),
  923.     );
  924.   }
  925. }
  926.  
  927. class TransactionPinBottomSheet extends StatefulWidget {
  928.   const TransactionPinBottomSheet({super.key});
  929.  
  930.   @override
  931.   State<TransactionPinBottomSheet> createState() =>
  932.       _TransactionPinBottomSheetState();
  933. }
  934.  
  935. class _TransactionPinBottomSheetState extends State<TransactionPinBottomSheet> {
  936.   String enteredPin = '';
  937.  
  938.   Widget numButton(int number) {
  939.     return Padding(
  940.       padding: const EdgeInsets.only(top: 16),
  941.       child: TextButton(
  942.         onPressed: () {
  943.           setState(() {
  944.             if (enteredPin.length < 4) {
  945.               enteredPin += number.toString();
  946.             } else {
  947.               Timer(const Duration(seconds: 2), () {
  948.                 Navigate.navigateToNamed(
  949.                     context, TransactionSuccessful.routeName);
  950.               });
  951.             }
  952.           });
  953.         },
  954.         child: Text(
  955.           number.toString(),
  956.           style: const TextStyle(
  957.             fontSize: 24,
  958.             fontWeight: FontWeight.w600,
  959.             color: Colors.black,
  960.           ),
  961.         ),
  962.       ),
  963.     );
  964.   }
  965.  
  966.   @override
  967.   Widget build(BuildContext context) {
  968.     print(enteredPin);
  969.     return ClipRRect(
  970.       borderRadius: BorderRadius.only(
  971.         topLeft: Radius.circular(getProportionateScreenWidth(20)),
  972.         topRight: Radius.circular(getProportionateScreenWidth(20)),
  973.       ),
  974.       child: Container(
  975.         color: white,
  976.         width: double.infinity,
  977.         padding: EdgeInsets.all(getProportionateScreenWidth(16)),
  978.         // ignore: sort_child_properties_last
  979.         child: SingleChildScrollView(
  980.           child: Column(
  981.             mainAxisSize: MainAxisSize.min,
  982.             children: <Widget>[
  983.               Row(
  984.                 mainAxisAlignment: MainAxisAlignment.center,
  985.                 children: [
  986.                   Text(
  987.                     verifyFingerprintText,
  988.                     style: TextStyle(
  989.                       fontSize: getProportionateScreenWidth(16),
  990.                       fontWeight: FontWeight.w400,
  991.                       color: black,
  992.                     ),
  993.                   ),
  994.                 ],
  995.               ),
  996.               verticalSpace(getProportionateScreenHeight(8)),
  997.               Text(
  998.                 touchFingerprintText,
  999.                 style: TextStyle(
  1000.                   fontFamily: appFontFamily1,
  1001.                   fontSize: getProportionateScreenWidth(12),
  1002.                   fontWeight: FontWeight.w300,
  1003.                   color: lightBlack,
  1004.                 ),
  1005.               ),
  1006.               verticalSpace(getProportionateScreenHeight(20)),
  1007.               Row(
  1008.                 mainAxisAlignment: MainAxisAlignment.center,
  1009.                 children: List.generate(
  1010.                   4,
  1011.                   (index) {
  1012.                     return Container(
  1013.                       margin: EdgeInsets.all(getProportionateScreenWidth(8)),
  1014.                       width: getProportionateScreenHeight(50),
  1015.                       height: getProportionateScreenHeight(50),
  1016.                       decoration: BoxDecoration(
  1017.                         borderRadius: BorderRadius.circular(6.0),
  1018.                         color: bgColor,
  1019.                         border: Border.all(
  1020.                           color: orange,
  1021.                         ),
  1022.                       ),
  1023.                       child: index < enteredPin.length
  1024.                           ? Center(
  1025.                               child: Text(
  1026.                                 enteredPin[index],
  1027.                                 style: TextStyle(
  1028.                                   fontFamily: appFontFamily1,
  1029.                                   fontSize: getProportionateScreenHeight(22),
  1030.                                   color: lightBlack,
  1031.                                   fontWeight: FontWeight.w500,
  1032.                                 ),
  1033.                               ),
  1034.                             )
  1035.                           : null,
  1036.                     );
  1037.                   },
  1038.                 ),
  1039.               ),
  1040.               for (var i = 0; i < 3; i++)
  1041.                 Padding(
  1042.                   padding: EdgeInsets.only(
  1043.                     left: getProportionateScreenWidth(30),
  1044.                     right: getProportionateScreenWidth(30),
  1045.                     bottom: getProportionateScreenWidth(10),
  1046.                   ),
  1047.                   child: Row(
  1048.                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
  1049.                     children: List.generate(
  1050.                       3,
  1051.                       (index) => numButton(1 + 3 * i + index),
  1052.                     ).toList(),
  1053.                   ),
  1054.                 ),
  1055.               Padding(
  1056.                 padding: EdgeInsets.only(
  1057.                   left: getProportionateScreenWidth(30),
  1058.                   right: getProportionateScreenWidth(30),
  1059.                   bottom: getProportionateScreenWidth(10),
  1060.                 ),
  1061.                 child: Row(
  1062.                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
  1063.                   children: [
  1064.                     TextButton(
  1065.                       onPressed: () {
  1066.                         //Fingerprint activation goes here
  1067.                       },
  1068.                       child: Image.asset(
  1069.                         orangeFingerprint,
  1070.                         width: getProportionateScreenWidth(40),
  1071.                       ),
  1072.                     ),
  1073.                     numButton(0),
  1074.                     TextButton(
  1075.                       onPressed: () {
  1076.                         setState(
  1077.                           () {
  1078.                             if (enteredPin.isNotEmpty) {
  1079.                               enteredPin = enteredPin.substring(
  1080.                                   0, enteredPin.length - 1);
  1081.                             }
  1082.                           },
  1083.                         );
  1084.                       },
  1085.                       child: Image.asset(
  1086.                         backSpace,
  1087.                         width: getProportionateScreenWidth(25),
  1088.                       ),
  1089.                     ),
  1090.                   ],
  1091.                 ),
  1092.               ),
  1093.             ],
  1094.           ),
  1095.         ),
  1096.       ),
  1097.     );
  1098.   }
  1099. }
  1100.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement