import 'package:diplomaticquarterapp/core/service/insurance_service.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_details.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import '../base/base_view.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/core/viewModels/insurance_card_View_model.dart'; class InsuranceUpdate extends StatefulWidget { @override _InsuranceUpdateState createState() => _InsuranceUpdateState(); } class _InsuranceUpdateState extends State with SingleTickerProviderStateMixin { TabController _tabController; InsuranceCardService _insuranceCardService = locator(); @override void initState() { super.initState(); _tabController = TabController(length: 2, vsync: this); } void dispose() { super.dispose(); _tabController.dispose(); } //TODO implement update card Widget build(BuildContext context) { return BaseView( onModelReady: (model) => model.getInsuranceUpdated(), builder: (BuildContext context, InsuranceViewModel model, Widget child) => AppScaffold( appBarTitle: TranslationBase.of(context).insurCards, isShowAppBar: true, baseViewModel: model, body: Scaffold( extendBodyBehindAppBar: true, appBar: PreferredSize( preferredSize: Size.fromHeight(70.0), child: Stack( children: [ Center( child: Container( height: 60.0, margin: EdgeInsets.only(top: 10.0), width: MediaQuery.of(context).size.width * 1.9, decoration: BoxDecoration( border: Border( bottom: BorderSide( color: Theme.of(context).dividerColor, width: 5.7, ), ), color: Colors.white, ), child: Center( child: TabBar( controller: _tabController, isScrollable: true, indicatorWeight: 4.0, indicatorColor: Theme.of(context).primaryColor, labelColor: Theme.of(context).primaryColor, labelPadding: EdgeInsets.symmetric( horizontal: 13.0, vertical: 2.0), unselectedLabelColor: Colors.grey, tabs: [ Container( width: MediaQuery.of(context).size.width * 0.35, child: Center( child: Texts(TranslationBase.of(context) .updateInsuranceSubtitle), ), ), Container( width: MediaQuery.of(context).size.width * 0.35, child: Center( child: Texts(TranslationBase.of(context).history), ), ), ], ), ), ), ) ], ), ), body: Column( children: [ Expanded( child: TabBarView( physics: BouncingScrollPhysics(), controller: _tabController, children: [ Container( child: model.getAllSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList.isNotEmpty?? false ? ListView.builder( itemCount: model.getAllSharedRecordsByStatusResponse .getAllSharedRecordsByStatusList.length, itemBuilder: (BuildContext context, int index) { return model.getAllSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList[index].status == 3 ? Container( margin: EdgeInsets.all(10.0), child: Card( margin: EdgeInsets.fromLTRB( 8.0, 16.0, 8.0, 8.0), color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), child: Container( width: MediaQuery.of(context).size.width, padding: EdgeInsets.all(10.0), child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ Expanded( flex: 3, child: Container( margin: EdgeInsets.only( top: 2.0, left: 10.0, right: 20.0), child: Column( crossAxisAlignment: CrossAxisAlignment .start, children: [ Texts( model .getAllSharedRecordsByStatusResponse .getAllSharedRecordsByStatusList[ index] .patientName, fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), SizedBox( height: 8, ), Texts( TranslationBase.of( context) .fileno + ": " + model .getAllSharedRecordsByStatusResponse .getAllSharedRecordsByStatusList[ index] .patientID .toString(), fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ) ], ), ), ), if (false) Expanded( flex: 2, child: Container( margin: EdgeInsets.only(top: 2.0), child: Column( children: [ Container( child: SecondaryButton( label: TranslationBase .of(context) .fetchData, small: true, textColor: Colors.white, onTap: () { getDetails( model); }, ), ), ], ), ), ) ], ), ), ), ) : Container(); }) : Container( height: 80, margin: EdgeInsets.all(10.0), child: Column( children: [ SizedBox(height: 65,), Container( color: Colors.white, width: MediaQuery.of(context).size.width, padding: EdgeInsets.all(10.0), child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ Expanded( flex: 3, child: Container( margin: EdgeInsets.only( top: 2.0, left: 10.0, right: 20.0), child: Column( crossAxisAlignment: CrossAxisAlignment .start, children: [ Texts( model.user.firstName+" "+model.user.lastName, fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), SizedBox( height: 8, ), Texts( TranslationBase.of( context) .fileno + ": " + model.user.patientID.toString(), fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ) ], ), ), ), if (false) Expanded( flex: 2, child: Container( margin: EdgeInsets.only(top: 2.0), child: Column( children: [ Container( child: SecondaryButton( label: TranslationBase .of(context) .fetchData, small: true, textColor: Colors.white, onTap: () { getDetails( model); }, ), ), ], ), ), ) ], ), ), ], ), ), ), Container( child: ListView.builder( itemCount: model.insuranceUpdate == null ? 0 : model.insuranceUpdate.length, itemBuilder: (BuildContext context, int index) { return Container( margin: EdgeInsets.all(10.0), child: Card( margin: EdgeInsets.fromLTRB(8.0, 16.0, 8.0, 8.0), color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), child: Container( width: MediaQuery.of(context).size.width, padding: EdgeInsets.all(10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ Flex( direction: Axis.horizontal, children: [ Expanded( flex: 3, child: Container( margin: EdgeInsets.only( top: 2.0, left: 10.0, right: 20.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( model.user.firstName + " " + model.user.lastName, fontSize: 14, fontWeight: FontWeight.w500, color: Colors.black, ), SizedBox( height: 8, ), Texts( TranslationBase.of(context) .fileno + ": " + model .insuranceUpdate[ index] .patientID .toString(), fontSize: 14, fontWeight: FontWeight.w500, color: Colors.black, ), SizedBox( height: 8, ), Texts( model.insuranceUpdate[index] .createdOn, fontSize: 14, fontWeight: FontWeight.w500, color: Colors.black, ), ], ), ), ), Expanded( flex: 1, child: Container( margin: EdgeInsets.only(top: 20.0), child: Column( children: [ Image.asset( "assets/images/new-design/confirm_button.png", width: 30.0, height: 30.0), Container( margin: EdgeInsets.only( top: 13.5, left: 2.0), child: Texts( model.insuranceUpdate[index] .statusDescription, textAlign: TextAlign.center, fontSize: 12, color: Colors.black, ), ), ], ), ), ) ], ), ], ), ), ), ); }), ), ], )) ], ), ), ), ); } getDetails(data) { GifLoaderDialogUtils.showMyDialog(context); _insuranceCardService.getInsuranceDetails(data).then((value) => { GifLoaderDialogUtils.hideDialog(context), Navigator.push(context, FadePage(page: InsuranceCardDetails(data: value[0]['CheckList']))) }); } }