Get Ticket Accural Balance Changes
							parent
							
								
									cca95cee6a
								
							
						
					
					
						commit
						c7e44965d6
					
				| @ -0,0 +1,25 @@ | |||||||
|  | import 'dart:convert'; | ||||||
|  | 
 | ||||||
|  | class GetTicketAccuralBalanceModel { | ||||||
|  |   int? accrualNetEntitlement; | ||||||
|  |   String? accuralPlanCode; | ||||||
|  | 
 | ||||||
|  |   GetTicketAccuralBalanceModel({ | ||||||
|  |     this.accrualNetEntitlement, | ||||||
|  |     this.accuralPlanCode, | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   factory GetTicketAccuralBalanceModel.fromRawJson(String str) => GetTicketAccuralBalanceModel.fromJson(json.decode(str)); | ||||||
|  | 
 | ||||||
|  |   String toRawJson() => json.encode(toJson()); | ||||||
|  | 
 | ||||||
|  |   factory GetTicketAccuralBalanceModel.fromJson(Map<String, dynamic> json) => GetTicketAccuralBalanceModel( | ||||||
|  |     accrualNetEntitlement: json["ACCRUAL_NET_ENTITLEMENT"], | ||||||
|  |     accuralPlanCode: json["ACCURAL_PLAN_CODE"], | ||||||
|  |   ); | ||||||
|  | 
 | ||||||
|  |   Map<String, dynamic> toJson() => { | ||||||
|  |     "ACCRUAL_NET_ENTITLEMENT": accrualNetEntitlement, | ||||||
|  |     "ACCURAL_PLAN_CODE": accuralPlanCode, | ||||||
|  |   }; | ||||||
|  | } | ||||||
| @ -0,0 +1,124 @@ | |||||||
|  | import 'package:easy_localization/easy_localization.dart'; | ||||||
|  | import 'package:flutter/material.dart'; | ||||||
|  | import 'package:mohem_flutter_app/app_state/app_state.dart'; | ||||||
|  | import 'package:mohem_flutter_app/classes/colors.dart'; | ||||||
|  | import 'package:mohem_flutter_app/classes/date_uitl.dart'; | ||||||
|  | import 'package:mohem_flutter_app/classes/utils.dart'; | ||||||
|  | import 'package:mohem_flutter_app/extensions/int_extensions.dart'; | ||||||
|  | import 'package:mohem_flutter_app/extensions/string_extensions.dart'; | ||||||
|  | import 'package:mohem_flutter_app/extensions/widget_extensions.dart'; | ||||||
|  | import 'package:mohem_flutter_app/models/dashboard/get_accural_ticket_balance_model.dart'; | ||||||
|  | import 'package:mohem_flutter_app/provider/dashboard_provider_model.dart'; | ||||||
|  | import 'package:mohem_flutter_app/widgets/app_bar_widget.dart'; | ||||||
|  | import 'package:mohem_flutter_app/widgets/balances_dashboard_widget.dart'; | ||||||
|  | import 'package:mohem_flutter_app/widgets/button/default_button.dart'; | ||||||
|  | import 'package:mohem_flutter_app/widgets/sso_webview_widget.dart'; | ||||||
|  | import 'package:provider/provider.dart'; | ||||||
|  | 
 | ||||||
|  | class TicketDetailedScreen extends StatefulWidget { | ||||||
|  |   final String? url; | ||||||
|  |   final String? jwtToken; | ||||||
|  | 
 | ||||||
|  |   const TicketDetailedScreen({super.key, this.url, this.jwtToken}); | ||||||
|  | 
 | ||||||
|  |   @override | ||||||
|  |   State<TicketDetailedScreen> createState() => _TicketDetailedScreenState(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | class _TicketDetailedScreenState extends State<TicketDetailedScreen> { | ||||||
|  |   DashboardProviderModel? dashboardProviderModel; | ||||||
|  |   late DateTime accrualDateTime; | ||||||
|  | 
 | ||||||
|  |   @override | ||||||
|  |   void initState() { | ||||||
|  |     dashboardProviderModel = Provider.of<DashboardProviderModel>(context, listen: false); | ||||||
|  |     accrualDateTime = DateTime.now(); | ||||||
|  |     super.initState(); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   void changeAccrualDate(bool showLoading) async { | ||||||
|  |     try { | ||||||
|  |       if (showLoading) Utils.showLoading(context); | ||||||
|  |       await dashboardProviderModel?.fetchTicketAccuralBalance(context, accrualDateTime); | ||||||
|  |       if (showLoading) Utils.hideLoading(context); | ||||||
|  |       setState(() {}); | ||||||
|  |     } catch (ex) { | ||||||
|  |       if (showLoading) Utils.hideLoading(context); | ||||||
|  |       Utils.handleException(ex, context, null); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   @override | ||||||
|  |   Widget build(BuildContext context) { | ||||||
|  |     return Scaffold( | ||||||
|  |       backgroundColor: Colors.white, | ||||||
|  |       appBar: AppBarWidget(context, title: "Ticket Details"), | ||||||
|  |       body: Column( | ||||||
|  |         children: [ | ||||||
|  |           ListView( | ||||||
|  |             padding: const EdgeInsets.all(21), | ||||||
|  |             physics: const BouncingScrollPhysics(), | ||||||
|  |             children: <Widget>[ | ||||||
|  |               if (dashboardProviderModel == null && dashboardProviderModel?.accrualTicketBalanceList == null) ...<Widget>[Utils.getNoDataWidget(context).paddingOnly(top: 50)] else ...<Widget>[ | ||||||
|  |                 // const BalancesDashboardWidget("Current Ticket Balance", false, showLoading: false), 12.height, | ||||||
|  |                 Container( | ||||||
|  |                   padding: const EdgeInsets.all(16.0), | ||||||
|  |                   decoration: BoxDecoration( | ||||||
|  |                     color: Colors.white, | ||||||
|  |                     borderRadius: BorderRadius.circular(12.0), | ||||||
|  |                     boxShadow: [BoxShadow(color: Colors.grey.withOpacity(0.2), spreadRadius: 2, blurRadius: 5, offset: const Offset(0, 3))], | ||||||
|  |                   ), | ||||||
|  |                   child: Column( | ||||||
|  |                     children: [ | ||||||
|  |                       Row( | ||||||
|  |                         children: [ | ||||||
|  |                           "Current Ticket Balance".toText20().expanded, | ||||||
|  |                           Row( | ||||||
|  |                             children: [ | ||||||
|  |                               const Icon(Icons.calendar_month_rounded, color: MyColors.darkIconColor, size: 16), | ||||||
|  |                               5.width, | ||||||
|  |                               DateUtil.formatDateToDate(accrualDateTime, AppState().isArabic(context)).toText13(isUnderLine: true), | ||||||
|  |                               8.width, | ||||||
|  |                             ], | ||||||
|  |                           ).onPress(() async { | ||||||
|  |                             DateTime selectedDate = await Utils.selectDate(context, accrualDateTime); | ||||||
|  |                             if (selectedDate != accrualDateTime) { | ||||||
|  |                               accrualDateTime = selectedDate; | ||||||
|  |                               changeAccrualDate(true); | ||||||
|  |                             } | ||||||
|  |                           }), | ||||||
|  |                         ], | ||||||
|  |                       ), | ||||||
|  |                       8.height, | ||||||
|  |                       Column( | ||||||
|  |                         crossAxisAlignment: CrossAxisAlignment.start, | ||||||
|  |                         children: | ||||||
|  |                             dashboardProviderModel!.accrualTicketBalanceList!.map<Widget>((GetTicketAccuralBalanceModel item) { | ||||||
|  |                               return Padding( | ||||||
|  |                                 padding: const EdgeInsets.symmetric(vertical: 6.0), | ||||||
|  |                                 child: Row( | ||||||
|  |                                   mainAxisAlignment: MainAxisAlignment.spaceBetween, | ||||||
|  |                                   children: <Widget>[ | ||||||
|  |                                     item.accuralPlanCode.toString().replaceAll('_', ' ').toCamelCase.toText14(), | ||||||
|  |                                     item.accrualNetEntitlement.toString().toText16(color: MyColors.textMixColor, isBold: true), | ||||||
|  |                                   ], | ||||||
|  |                                 ), | ||||||
|  |                               ); | ||||||
|  |                             }).toList(), | ||||||
|  |                       ), | ||||||
|  |                     ], | ||||||
|  |                   ), | ||||||
|  |                 ), | ||||||
|  |               ], | ||||||
|  |             ], | ||||||
|  |           ).expanded, | ||||||
|  |           DefaultButton("Proceed For Booking", () { | ||||||
|  |             if (widget.url != null && widget.jwtToken != null) { | ||||||
|  |               Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) => SsoLoginWebView(url: widget.url, jwtToken: widget.jwtToken))); | ||||||
|  |             } | ||||||
|  |           }).insideContainer, | ||||||
|  |         ], | ||||||
|  |       ), | ||||||
|  |     ); | ||||||
|  |   } | ||||||
|  | } | ||||||
					Loading…
					
					
				
		Reference in New Issue