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/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; 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, ), PageStepperWidget( stepsCount: 3, currentStepIndex: _currentIndex + 1, screenSize: screenSize, stepsTitles: [ "Search", "Activation", "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(), RegisterConfirmationPatientPage(), ]), ), ), ], ), )), 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, fontSize: 2.2, 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: Color(0xFF359846), color: Color(0xFF359846), fontColor: Colors.white, fontSize: 2.0, onPressed: () {}, ), ), ), ], ), ); default: return Container( // height: 100, color: Colors.red, 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, fontSize: 2.2, 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: Color(0xFFB8382B), fontColor: Colors.white, fontSize: 2.0, onPressed: () { changePageViewIndex(_currentIndex + 1); }, ), ), ), ], ), ); } } }