import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/lacum-registration-viewModel.dart'; import 'package:diplomaticquarterapp/models/id-name-pair.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/radio-group-dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'lakum-terms-conditions-page.dart'; class LakumRegistrationPage extends StatefulWidget { final String patientIdentificationNo; LakumRegistrationPage(this.patientIdentificationNo); @override _LakumRegistrationPageState createState() => _LakumRegistrationPageState(); } class _LakumRegistrationPageState extends State { final TextEditingController _firstNameController = TextEditingController(); final TextEditingController _lastNameController = TextEditingController(); final TextEditingController _mobileNumberController = TextEditingController(); List languages = List(); IdNamePair selectedLanguage; @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); languages.clear(); languages.add(IdNamePair(1, TranslationBase.of(context).arabic)); languages.add(IdNamePair(2, TranslationBase.of(context).english)); bool canSubmit = _firstNameController.text != null && _firstNameController.text != "" && _lastNameController.text != null && _lastNameController.text != "" && _mobileNumberController.text != null && _mobileNumberController.text != "" && selectedLanguage != null; return BaseView( builder: (_, model, wi) => AppScaffold( appBarTitle: "${TranslationBase.of(context).register} ${TranslationBase.of(context).lakum}", isShowAppBar: true, isShowDecPage: false, backgroundColor: Colors.white, baseViewModel: model, body: Container( width: double.infinity, child: SingleChildScrollView( child: SizedBox( height: mediaQuery.size.height - 60 - mediaQuery.padding.top, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.max, children: [ Column( children: [ Image.asset( "assets/images/pharmacy_module/lakum/lakum_card_front_bg.png", fit: BoxFit.fill, height: 150, width: mediaQuery.size.width, ), Container( margin: EdgeInsets.symmetric(horizontal: 8), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( height: 10, ), Texts( TranslationBase.of(context).firstName, fontSize: 13, fontWeight: FontWeight.normal, color: Color(0xff8a8a8a), ), TextField( controller: _firstNameController, style: TextStyle( fontSize: 16, color: Colors.black, ), ), SizedBox( height: 10, ), Texts( TranslationBase.of(context).lastName, fontSize: 13, fontWeight: FontWeight.normal, color: Color(0xff8a8a8a), ), TextField( controller: _lastNameController, style: TextStyle( fontSize: 16, color: Colors.black, ), ), SizedBox( height: 10, ), Texts( TranslationBase.of(context).mobileNumber, fontSize: 13, fontWeight: FontWeight.normal, color: Color(0xff8a8a8a), ), TextField( controller: _mobileNumberController, style: TextStyle( fontSize: 16, color: Colors.black, ), ), SizedBox( height: 10, ), Texts( TranslationBase.of(context) .prefferedLanguage, fontSize: 13, fontWeight: FontWeight.normal, color: Color(0xff8a8a8a), ), InkWell( onTap: () { RadioGroupDialog dialog = new RadioGroupDialog( context: context, title: TranslationBase.of(context) .prefferedLanguage, okText: TranslationBase.of(context) .confirm, cancelText: TranslationBase.of(context) .cancel_nocaps, list: languages, okFunction: (selectedValue) { setState(() { selectedLanguage = selectedValue; }); print( "selectedLanguage = ${selectedValue.name}"); }, cancelFunction: () => {}); showDialog( barrierDismissible: false, context: context, builder: (BuildContext context) { return dialog; }, ); }, child: TextField( enabled: false, decoration: InputDecoration( suffixIcon: Icon(Icons.arrow_drop_down), hintText: selectedLanguage == null ? "${TranslationBase.of(context).prefferedLanguage}" : "${selectedLanguage.name}", hintStyle: TextStyle( fontSize: 16, color: Colors.black, )), style: TextStyle( fontSize: 16, color: Colors.grey.shade700, ), ), ), ], ), ), ], ), Container( color: Colors.green, margin: EdgeInsets.all(8), child: BorderedButton( TranslationBase.of(context).register, backgroundColor: canSubmit ? Color(0xff339933) : Color(0xff99cc99), textColor: Colors.white, fontSize: 16, hPadding: 8, vPadding: 12, handler: canSubmit ? () { Navigator.push( context, FadePage( page: LakumTermsConditions( widget .patientIdentificationNo, _firstNameController.text, _lastNameController.text, _mobileNumberController .text, selectedLanguage.id))) .then((status) => { if (status == 200) {Navigator.pop(context, "")} // back to previous page }); } : null, ), ), ], ), ), ), ), )); } }