diff --git a/lib/client/app_client.dart b/lib/client/app_client.dart index 6018b041..68c4fb8b 100644 --- a/lib/client/app_client.dart +++ b/lib/client/app_client.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/interceptor/http_interceptor.dart'; import 'package:http/http.dart'; @@ -6,7 +7,6 @@ import 'package:http/http.dart'; // DESCRIPTION : Custom App client to pin base url for all srvices class AppClient { - static const String BASE_URL = "https://hmgwebservices.com/"; static Client client = HttpInterceptor().getClient(); diff --git a/lib/config/config.dart b/lib/config/config.dart index e17c98cf..2db3184a 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -1,2 +1,5 @@ const MAX_SMALL_SCREEN = 660; -const BASE_URL = 'https://hmgwebservices.com/Services/'; \ No newline at end of file +const BASE_URL = 'https://hmgwebservices.com/Services/'; +const ONLY_NUMBERS = "[0-9]"; +const ONLY_LETTERS = "[a-zA-Z]"; +const ONLY_DATE = "[0-9/]"; diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart index 314dfeb0..5e4877b4 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/providers/auth_provider.dart @@ -1,22 +1,19 @@ import 'dart:convert'; import 'package:doctor_app_flutter/client/app_client.dart'; import 'package:flutter/cupertino.dart'; - -import '../config/config.dart'; -import '../interceptor/http_interceptor.dart'; import '../models/user_model.dart'; const LOGIN_URL = - 'Services/Sentry.svc/REST/MemberLogIN_New'; + 'Sentry.svc/REST/MemberLogIN_New'; const INSERT_DEVICE_IMEI = - 'Services/Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; + 'Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; const SELECT_DEVICE_IMEI = - 'Services/Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; + 'Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = - 'Services/Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; + 'Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; -const MEMBER_CHECK_ACTIVATION_CODE_NEW ='Services/Sentry.svc/REST/MemberCheckActivationCode_New'; +const MEMBER_CHECK_ACTIVATION_CODE_NEW ='Sentry.svc/REST/MemberCheckActivationCode_New'; class AuthProvider with ChangeNotifier { Future login(UserModel userInfo) async { const url = LOGIN_URL; diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index 6051c85e..6cd681c7 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -1,9 +1,9 @@ import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/routes.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:flutter/services.dart'; import '../../config/size_config.dart'; -import '../../util/text_validator.dart'; import '../../widgets/shared/app_buttons_widget.dart'; import '../../widgets/shared/app_scaffold_widget.dart'; import '../../widgets/shared/app_text_form_field.dart'; @@ -15,6 +15,7 @@ import 'package:flutter/rendering.dart'; import '../../lookups/patient_lookup.dart'; import '../../models/patient_model.dart'; import '../../widgets/patients/dynamic_elements.dart'; +import '../../config/config.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); @@ -57,12 +58,12 @@ class _PatientSearchScreenState extends State { PatientOutSA: false); void _validateInputs() { - print({_patientSearchFormValues.ProjectID}); + print("####IBRAHIM TEST#####"+_patientSearchFormValues.From); // _patientSearchFormValues.TokenID = if (_formKey.currentState.validate()) { // If all data are correct then save data to out variables - // _formKey.currentState.save(); + _formKey.currentState.save(); sharedPref.getString(TOKEN).then((token) { print(token+"EEEEEE"); @@ -173,9 +174,10 @@ class _PatientSearchScreenState extends State { onSaved: (value) { _patientSearchFormValues.FirstName = value; }, - validator: (value) { - return TextValidator().validateName(value); - }, + // validator: (value) { + // return TextValidator().validateName(value); + // }, + inputFormatter: ONLY_LETTERS ), SizedBox( height: 10, @@ -185,9 +187,10 @@ class _PatientSearchScreenState extends State { onSaved: (value) { _patientSearchFormValues.MiddleName = value; }, - validator: (value) { - return TextValidator().validateName(value); - }, + // validator: (value) { + // return TextValidator().validateName(value); + // }, + inputFormatter: ONLY_LETTERS ), SizedBox( height: 10, @@ -197,9 +200,10 @@ class _PatientSearchScreenState extends State { onSaved: (value) { _patientSearchFormValues.LastName = value; }, - validator: (value) { - return TextValidator().validateName(value); - }, + // validator: (value) { + // return TextValidator().validateName(value); + // }, + inputFormatter: ONLY_LETTERS ), SizedBox( height: 10, @@ -207,9 +211,10 @@ class _PatientSearchScreenState extends State { AppTextFormField( textInputType: TextInputType.number, hintText: 'Phone Number', - validator: (value) { - return TextValidator().validateMobile(value); - }, + // validator: (value) { + // return TextValidator().validateMobile(value); + // }, + inputFormatter: ONLY_NUMBERS, onSaved: (value) { _patientSearchFormValues.PatientMobileNumber = value; @@ -221,9 +226,8 @@ class _PatientSearchScreenState extends State { AppTextFormField( textInputType: TextInputType.number, hintText: 'Patiant ID', - validator: (value) { - return TextValidator().validateIdNumber(value); - }, + // + inputFormatter: ONLY_NUMBERS, onSaved: (value) { _patientSearchFormValues.PatientID = 89000; }), @@ -233,9 +237,10 @@ class _PatientSearchScreenState extends State { AppTextFormField( textInputType: TextInputType.number, hintText: 'Patiant File', - validator: (value) { - return TextValidator().validateIdNumber(value); - }, + // validator: (value) { + // return TextValidator().validateIdNumber(value); + // }, + inputFormatter: ONLY_NUMBERS, onSaved: (value) { //_patientSearchFormValues. = value; }, diff --git a/lib/widgets/patients/dynamic_elements.dart b/lib/widgets/patients/dynamic_elements.dart index e446b9d0..443c7385 100644 --- a/lib/widgets/patients/dynamic_elements.dart +++ b/lib/widgets/patients/dynamic_elements.dart @@ -1,7 +1,7 @@ +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/models/patient_model.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; import 'package:flutter/material.dart'; -import '../../util/text_validator.dart'; import 'package:intl/intl.dart'; class DynamicElements extends StatefulWidget { @@ -51,14 +51,15 @@ class _DynamicElementsState extends State { textInputType: TextInputType.number, hintText: 'From', controller: _fromDateController, - validator: (value) { - return TextValidator().validateDate(_fromDateController.text); - }, + // validator: (value) { + // return TextValidator().validateDate(_fromDateController.text); + // }, + inputFormatter: ONLY_DATE, onTap: () { _presentDatePicker('_selectedFromDate'); }, onSaved: (value) { - widget._patientSearchFormValues.From = value; + widget._patientSearchFormValues.From = _fromDateController.text; }, ), @@ -72,11 +73,12 @@ class _DynamicElementsState extends State { onTap: () { _presentDatePicker('_selectedToDate'); }, - validator: (value) { - return TextValidator().validateDate(_toDateController.text); - }, + // validator: (value) { + // return TextValidator().validateDate(_toDateController.text); + // }, + inputFormatter: ONLY_DATE, onSaved: (value) { - widget._patientSearchFormValues.To = value; + widget._patientSearchFormValues.To = _toDateController.text; }, ), ], diff --git a/lib/widgets/shared/app_text_form_field.dart b/lib/widgets/shared/app_text_form_field.dart index 97a23098..54b0f9a3 100644 --- a/lib/widgets/shared/app_text_form_field.dart +++ b/lib/widgets/shared/app_text_form_field.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; // OWNER : Ibrahim albitar // DATE : 19-04-2020 @@ -10,6 +11,7 @@ class AppTextFormField extends FormField { AppTextFormField({ FormFieldSetter onSaved, + String inputFormatter, FormFieldValidator validator, ValueChanged onChanged, GestureTapCallback onTap, @@ -26,6 +28,7 @@ class AppTextFormField extends FormField { children: [ TextFormField( keyboardType: textInputType, + inputFormatters: [WhitelistingTextInputFormatter(RegExp(inputFormatter)),], onChanged: onChanged?? (value){ state.didChange(value); },