import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-ucaf-viewmodel.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/UCAF/page-stepper-widget.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/app_bar/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; import 'package:flutter/material.dart'; import '../../../../routes.dart'; import 'UCAF-detail-screen.dart'; import 'UCAF-input-screen.dart'; class UCAFPagerScreen extends StatefulWidget { const UCAFPagerScreen({Key key}) : super(key: key); @override _UCAFPagerScreenState createState() => _UCAFPagerScreenState(); } class _UCAFPagerScreenState extends State with TickerProviderStateMixin { PageController _controller; int _currentIndex = 0; bool _isLoading = true; PatiantInformtion patient; String patientType; String arrivalType; changePageViewIndex(pageIndex, {isChangeState = true}) { if (pageIndex != _currentIndex && isChangeState) changeLoadingState(true); _controller.jumpToPage(pageIndex); setState(() { _currentIndex = pageIndex; }); } void changeLoadingState(bool isLoading) { setState(() { _isLoading = isLoading; }); } @override void initState() { _controller = new PageController(); super.initState(); } @override Widget build(BuildContext context) { final routeArgs = ModalRoute.of(context).settings.arguments as Map; patient = routeArgs['patient']; patientType = routeArgs['patientType']; arrivalType = routeArgs['arrivalType']; final screenSize = MediaQuery.of(context).size; return BaseView( builder: (_, model, w) => AppScaffold( isShowAppBar: true, isLoading: _isLoading, appBar: PatientProfileAppBar(patient), appBarTitle: TranslationBase.of(context).ucaf, body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Container( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // PatientHeaderWidgetNoAvatar(patient), Container( margin: EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ AppText( "${TranslationBase.of(context).patient}", fontFamily: 'Poppins', fontSize: SizeConfig.textMultiplier * 1.6, fontWeight: FontWeight.w600, ), AppText( "${TranslationBase.of(context).ucaf}", fontFamily: 'Poppins', fontSize: SizeConfig.textMultiplier * 3, fontWeight: FontWeight.bold, ) ], ), ), PageStepperWidget( stepsCount: 2, currentStepIndex: _currentIndex + 1, screenSize: screenSize, ), SizedBox( height: 10, ), Expanded( child: Container( color: Theme.of(context).scaffoldBackgroundColor, child: PageView( physics: NeverScrollableScrollPhysics(), controller: _controller, onPageChanged: (index) { setState(() { _currentIndex = index; }); }, scrollDirection: Axis.horizontal, children: [ UCAFInputScreen( patient, changeLoadingState: changeLoadingState, ), UcafDetailScreen( patient, model, changeLoadingState: changeLoadingState, ), ]), ), ), ], ), ), ), _isLoading ? Container( height: 0, ) : ucafButtons(model), ], ), )); } Widget ucafButtons(UcafViewModel model) { switch (_currentIndex) { case 0: return Container( margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: AppButton( title: TranslationBase.of(context).next, color: Color(0xFFD02127), onPressed: () { changePageViewIndex(1); // Navigator.of(context).pushNamed(PATIENT_UCAF_DETAIL, arguments: { // 'patient': patient, // 'patientType': patientType, // 'arrivalType': arrivalType // }); }, ), ); case 1: return Container( margin: EdgeInsets.symmetric(vertical: 8, horizontal: 16), child: Row( children: [ Expanded( child: Container( child: AppButton( title: TranslationBase.of(context).cancel, hasBorder: true, vPadding: 8, hPadding: 8, borderColor: Colors.white, color: Colors.white, fontColor: Color(0xFFB8382B), onPressed: () { Navigator.of(context).popUntil((route) { return route.settings.name == PATIENTS_PROFILE; }); }, ), ), ), SizedBox( width: 8, ), Expanded( child: Container( child: AppButton( title: TranslationBase.of(context).save, hasBorder: true, vPadding: 8, hPadding: 8, borderColor: Color(0xFFB8382B), color: AppGlobal.appRedColor, fontColor: Colors.white, onPressed: () { model.saveUCAFOnTap(); }, ), ), ), ], ), ); default: return Container(); } } }