import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientRegistrationViewModel.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; import 'package:doctor_app_flutter/screens/patients/profile/UCAF/page-stepper-widget.dart'; import 'package:doctor_app_flutter/screens/patients/register_patient/RegisterConfirmationPatientPage.dart'; import 'package:doctor_app_flutter/screens/patients/register_patient/VerifyMethodPage.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; import 'package:flutter/material.dart'; import 'RegisterSearchPatientPage.dart'; class RegisterPatientPage extends StatefulWidget { const RegisterPatientPage({Key key}) : super(key: key); @override _RegisterPatientPageState createState() => _RegisterPatientPageState(); } class _RegisterPatientPageState extends State with TickerProviderStateMixin { PageController _controller; int _currentIndex = 0; bool _isLoading = false; 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 void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; ///TODO Elham* Add Translation return BaseView( builder: (_, model, w) => AppScaffold( baseViewModel: model, isShowAppBar: true, isLoading: _isLoading, appBar: PatientSearchHeader( title: TranslationBase.of(context).registeraPatient, ), body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Container( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 10, ), //TODO Elham* Fix overflow PageStepperWidget( stepsCount: 3, currentStepIndex: _currentIndex + 1, screenSize: screenSize, stepsTitles: [ TranslationBase.of(context).search, TranslationBase.of(context).activation, TranslationBase.of(context).confirmation, ], ), 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: [ RegisterSearchPatientPage( changePageViewIndex: changePageViewIndex, model: model), ActivationPage( model: model, changePageViewIndex: changePageViewIndex, ), RegisterConfirmationPatientPage( model: model, ), ]), ), ), ], ), )), // pagerButtons(model), ], ), ), ); } Widget pagerButtons(PatientRegistrationViewModel model) { switch (_currentIndex) { case 2: return Container( margin: EdgeInsets.symmetric(vertical: 16, horizontal: 16), child: Row( children: [ Expanded( child: Container( child: AppButton( title: TranslationBase.of(context).cancel, hasBorder: true, vPadding: 12, hPadding: 8, borderColor: Color(0xFFeaeaea), color: Color(0xFFeaeaea), fontColor: Colors.black, onPressed: () { Navigator.of(context).pop(); }, ), ), ), SizedBox( width: 8, ), Expanded( child: Container( child: AppButton( title: TranslationBase.of(context).noteConfirm, hasBorder: true, vPadding: 12, hPadding: 8, borderColor: AppGlobal.appGreenColor, color: AppGlobal.appGreenColor, fontColor: Colors.white, onPressed: () {}, ), ), ), ], ), ); default: return Container( padding: EdgeInsets.symmetric(vertical: 16, horizontal: 16), child: Row( children: [ Expanded( child: Container( child: AppButton( title: TranslationBase.of(context).cancel, hasBorder: true, vPadding: 12, hPadding: 8, borderColor: Color(0xFFeaeaea), color: Color(0xFFeaeaea), fontColor: Colors.black, onPressed: () { Navigator.of(context).pop(); }, ), ), ), SizedBox( width: 8, ), Expanded( child: Container( child: AppButton( title: TranslationBase.of(context).next, hasBorder: true, vPadding: 12, hPadding: 8, borderColor: Color(0xFFB8382B), color: AppGlobal.appRedColor, fontColor: Colors.white, onPressed: () { changePageViewIndex(_currentIndex + 1); }, ), ), ), ], ), ); } } }