From 0c534cffaecb2a008bb51323c91c5950c3e151c3 Mon Sep 17 00:00:00 2001 From: Sultan khan <> Date: Sun, 29 Oct 2023 15:27:07 +0300 Subject: [PATCH] code update in progress --- .../medical/vital_sign_view_model.dart | 2 +- .../rrt-pickup-address-page.dart | 11 +- lib/pages/ToDoList/ToDo.dart | 2 +- .../livecare/live_care_payment_page.dart | 8 +- .../medical/medical_profile_page_new.dart | 2 +- .../steps/stepsTracker.dart | 30 +- .../vital_sign/vital_sign_details_screen.dart | 6 +- .../vital_sign_details_wideget.dart | 16 +- .../medical/vital_sign/vital_sign_item.dart | 8 +- .../vital_sign_item_details_screen.dart | 18 +- .../vital_sing_chart_and_detials.dart | 18 +- .../vital_sing_chart_blood_pressure.dart | 24 +- .../PackageOrderCompletedPage.dart | 2 +- lib/widgets/input/text_field.dart | 518 +++++++++--------- lib/widgets/others/app_scaffold_widget.dart | 2 +- 15 files changed, 333 insertions(+), 334 deletions(-) diff --git a/lib/core/viewModels/medical/vital_sign_view_model.dart b/lib/core/viewModels/medical/vital_sign_view_model.dart index b669c693..232246d4 100644 --- a/lib/core/viewModels/medical/vital_sign_view_model.dart +++ b/lib/core/viewModels/medical/vital_sign_view_model.dart @@ -19,7 +19,7 @@ class VitalSignViewModel extends BaseViewModel { String respirationBeatPerMinute = "0"; String bloodPressure = "0 / 0"; - getPatientVitalSign({int? appointmentNo, required int projectID}) async { + getPatientVitalSign({int? appointmentNo, int? projectID}) async { setState(ViewState.Busy); if (appointmentNo != null && projectID != null) { diff --git a/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart b/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart index 3aee659f..f230a1d6 100644 --- a/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart +++ b/lib/pages/ErService/rapid-response-team/rrt-pickup-address-page.dart @@ -74,9 +74,8 @@ class RRTRequestPickupAddressPageState extends State, //Changed by Aamir - onCameraMove: (camera) { - _updatePosition(camera as CameraPosition); - }, + onCameraMove: _updatePosition!, + onMapCreated: () { _getUserLocation(); setState(() {}); @@ -233,9 +232,9 @@ class RRTRequestPickupAddressPageState extends State { showNewAppBarTitle: true, showNewAppBar: true, description: TranslationBase.of(context).erConsultation, - onTap: () { - Navigator.pop(context); - Navigator.pop(context); - }, + // onTap: () { + // Navigator.pop(context); + // Navigator.pop(context); + // }, body: Container( width: double.infinity, height: double.infinity, diff --git a/lib/pages/medical/medical_profile_page_new.dart b/lib/pages/medical/medical_profile_page_new.dart index 086b1b53..e3094877 100644 --- a/lib/pages/medical/medical_profile_page_new.dart +++ b/lib/pages/medical/medical_profile_page_new.dart @@ -13,7 +13,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class MedicalProfilePageNew extends StatefulWidget { - Function? onTap; + VoidCallbackAction? onTap; String? a; MedicalProfilePageNew({this.onTap}); @override diff --git a/lib/pages/medical/smart_watch_health_data/steps/stepsTracker.dart b/lib/pages/medical/smart_watch_health_data/steps/stepsTracker.dart index aea6fe20..a0f33d80 100644 --- a/lib/pages/medical/smart_watch_health_data/steps/stepsTracker.dart +++ b/lib/pages/medical/smart_watch_health_data/steps/stepsTracker.dart @@ -19,9 +19,9 @@ class StepsTracker extends StatefulWidget { } class _StepsTrackerState extends State with SingleTickerProviderStateMixin { - TabController _tabController; + TabController? _tabController; - ProjectViewModel projectViewModel; + ProjectViewModel? projectViewModel; int weeklyStatsAvgValue = 0; int monthlyStatsAvgValue = 0; @@ -76,13 +76,13 @@ class _StepsTrackerState extends State with SingleTickerProviderSt unselectedLabelColor: Color(0xff575757), labelPadding: EdgeInsets.only(top: 0, bottom: 0, left: 20, right: 20), labelStyle: TextStyle( - fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins', + fontFamily: projectViewModel!.isArabic ? 'Cairo' : 'Poppins', fontSize: 16, fontWeight: FontWeight.w600, letterSpacing: -0.48, ), unselectedLabelStyle: TextStyle( - fontFamily: projectViewModel.isArabic ? 'Cairo' : 'Poppins', + fontFamily: projectViewModel!.isArabic ? 'Cairo' : 'Poppins', fontSize: 16, fontWeight: FontWeight.w600, letterSpacing: -0.48, @@ -129,7 +129,7 @@ class _StepsTrackerState extends State with SingleTickerProviderSt res['Med_GetWeekStepsTransactionsStsList'].forEach((element) { weekyStepsList.add(new WeeklyStepsResModel.fromJson(element)); if (element['Value'] != null) { - num value = num.tryParse(element['Value'] ?? "0"); + num value = num.parse(element['Value'] ?? "0"); avgWeeklyStepsValue += value.toInt(); weeklyDataLength++; } @@ -158,7 +158,7 @@ class _StepsTrackerState extends State with SingleTickerProviderSt res['Med_GetMonthStepsTransactionsStsList'].forEach((element) { monthlyStepsList.add(new WeeklyStepsResModel.fromJson(element)); if (element['Value'] != null) { - num value = num.tryParse(element['Value'] ?? "0"); + num value = num.parse(element['Value'] ?? "0"); avgMonthlyStepsValue += value.toInt(); monthlyDataLength++; } @@ -212,8 +212,8 @@ class _StepsTrackerState extends State with SingleTickerProviderSt (element) { weeklyTimeSeriesData.add( TimeSeriesSales2( - DateUtil.convertStringToDate(element.machineDate), - element.value != null ? element.value.toDouble() : 0.0, + DateUtil.convertStringToDate(element.machineDate!), + element.value != null ? element.value!.toDouble() : 0.0, ), ); }, @@ -228,8 +228,8 @@ class _StepsTrackerState extends State with SingleTickerProviderSt (element) { monthlyTimeSeriesData.add( TimeSeriesSales2( - DateUtil.convertStringToDate(element.machineDate), - element.value != null ? element.value.toDouble() : 0.0, + DateUtil.convertStringToDate(element.machineDate!), + element.value != null ? element.value!.toDouble() : 0.0, ), ); }, @@ -244,8 +244,8 @@ class _StepsTrackerState extends State with SingleTickerProviderSt (element) { yearlyTimeSeriesData.add( TimeSeriesSales2( - new DateTime(element.year, element.month, 1), - element.valueSum != null ? double.tryParse(element.valueSum.toString()) : 0.0, + new DateTime(element.year!, element.month!, 1), + element.valueSum! != null ? double.parse(element.valueSum.toString()) : 0.0, ), ); }, @@ -497,7 +497,7 @@ class _StepsTrackerState extends State with SingleTickerProviderSt children: [ Utils.tableColumnValue( '${DateUtil.getDayMonthYearDateFormatted( - new DateTime(step.year, step.month, 1), + new DateTime(step.year!, step.month!, 1), )} ', isCapitable: false, mProjectViewModel: projectViewModel), @@ -527,7 +527,7 @@ class _StepsTrackerState extends State with SingleTickerProviderSt children: [ Utils.tableColumnValue( '${DateUtil.getDayMonthYearDateFormatted( - DateUtil.convertStringToDate(step.machineDate), + DateUtil.convertStringToDate(step.machineDate!), )} ', isCapitable: false, mProjectViewModel: projectViewModel), @@ -557,7 +557,7 @@ class _StepsTrackerState extends State with SingleTickerProviderSt children: [ Utils.tableColumnValue( '${DateUtil.getDayMonthYearDateFormatted( - DateUtil.convertStringToDate(step.machineDate), + DateUtil.convertStringToDate(step.machineDate!), )} ', isCapitable: false, mProjectViewModel: projectViewModel), diff --git a/lib/pages/medical/vital_sign/vital_sign_details_screen.dart b/lib/pages/medical/vital_sign/vital_sign_details_screen.dart index c859c8b3..0a02a33a 100644 --- a/lib/pages/medical/vital_sign/vital_sign_details_screen.dart +++ b/lib/pages/medical/vital_sign/vital_sign_details_screen.dart @@ -17,8 +17,8 @@ import 'package:flutter_svg/svg.dart'; class VitalSignDetailsScreen extends StatelessWidget { static const String url = "assets/images/"; - int appointmentNo; - int projectID; + int? appointmentNo; + int? projectID; bool isNotOneAppointment; VitalSignDetailsScreen({this.appointmentNo, this.projectID, this.isNotOneAppointment = true}); @@ -44,7 +44,7 @@ class VitalSignDetailsScreen extends StatelessWidget { imagesInfo.add(ImagesInfo( imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-vital-signs/en/1.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-vital-signs/ar/1.png')); return BaseView( - onModelReady: appointmentNo != null && projectID != null ? (model) => model.getPatientVitalSign(appointmentNo: appointmentNo, projectID: projectID) : (model) => model.getPatientVitalSign(), + onModelReady: appointmentNo != null && projectID != null ? (model) => model.getPatientVitalSign(appointmentNo: appointmentNo, projectID: projectID!) : (model) => model!.getPatientVitalSign(), builder: (_, mode, widget) { initList(context, mode); return AppScaffold( diff --git a/lib/pages/medical/vital_sign/vital_sign_details_wideget.dart b/lib/pages/medical/vital_sign/vital_sign_details_wideget.dart index 048f30f0..0daaf104 100644 --- a/lib/pages/medical/vital_sign/vital_sign_details_wideget.dart +++ b/lib/pages/medical/vital_sign/vital_sign_details_wideget.dart @@ -8,13 +8,13 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class VitalSignDetailsWidget extends StatefulWidget { - final List vitalList; - final String title1; - final String title2; - final String viewKey; + final List? vitalList; + final String? title1; + final String? title2; + final String? viewKey; VitalSignDetailsWidget( - {Key key, this.vitalList, this.title1, this.title2, this.viewKey}); + {Key? key, this.vitalList, this.title1, this.title2, this.viewKey}); @override _VitalSignDetailsWidgetState createState() => _VitalSignDetailsWidgetState(); @@ -39,7 +39,7 @@ class _VitalSignDetailsWidgetState extends State { children: [ Table( border: TableBorder.symmetric( - inside: BorderSide(width: 2.0, color: Colors.grey[300]), + inside: BorderSide(width: 2.0, color: Colors.grey[300]!), ), children: fullData(projectViewModel), ), @@ -85,7 +85,7 @@ class _VitalSignDetailsWidgetState extends State { height: 60), ) ])); - widget.vitalList.forEach((vital) { + widget.vitalList!.forEach((vital) { var data = vital.toJson()[widget.viewKey]; if (data != 0) tableRow.add(TableRow(children: [ @@ -95,7 +95,7 @@ class _VitalSignDetailsWidgetState extends State { color: Colors.white, child: Center( child: Texts( - '${projectViewModel.isArabic ? DateUtil.getWeekDayArabic(vital.vitalSignDate.weekday) : DateUtil.getWeekDay(vital.vitalSignDate.weekday)}, ${vital.vitalSignDate.day} ${projectViewModel.isArabic ? DateUtil.getMonthArabic(vital.vitalSignDate.month) : DateUtil.getMonth(vital.vitalSignDate.month)}, ${vital.vitalSignDate.year} ', + '${projectViewModel.isArabic ? DateUtil.getWeekDayArabic(vital.vitalSignDate!.weekday) : DateUtil.getWeekDay(vital.vitalSignDate!.weekday)}, ${vital.vitalSignDate!.day} ${projectViewModel.isArabic ? DateUtil.getMonthArabic(vital.vitalSignDate!.month) : DateUtil.getMonth(vital.vitalSignDate!.month)}, ${vital.vitalSignDate!.year} ', textAlign: TextAlign.center, ), ), diff --git a/lib/pages/medical/vital_sign/vital_sign_item.dart b/lib/pages/medical/vital_sign/vital_sign_item.dart index 1549db39..9b89d7f7 100644 --- a/lib/pages/medical/vital_sign/vital_sign_item.dart +++ b/lib/pages/medical/vital_sign/vital_sign_item.dart @@ -8,14 +8,14 @@ import 'package:flutter_svg/flutter_svg.dart'; class VitalSignItem extends StatelessWidget { const VitalSignItem({ - Key key, - @required this.vitalSign, + Key? key, + required this.vitalSign, this.height, this.width, }) : super(key: key); - final double height; - final double width; + final double? height; + final double? width; final VitalSign vitalSign; @override diff --git a/lib/pages/medical/vital_sign/vital_sign_item_details_screen.dart b/lib/pages/medical/vital_sign/vital_sign_item_details_screen.dart index c3c85160..6de6defe 100644 --- a/lib/pages/medical/vital_sign/vital_sign_item_details_screen.dart +++ b/lib/pages/medical/vital_sign/vital_sign_item_details_screen.dart @@ -8,13 +8,13 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class VitalSignItemDetailsScreen extends StatelessWidget { - final VitalSignDetails pageKey; - final String pageTitle; - List VSchart; + final VitalSignDetails? pageKey; + final String? pageTitle; + List? VSchart; VitalSignItemDetailsScreen({this.vitalList, this.pageKey, this.pageTitle}); - final List vitalList; + final List? vitalList; @override Widget build(BuildContext context) { @@ -157,20 +157,20 @@ class VitalSignItemDetailsScreen extends StatelessWidget { default: } return AppScaffold( - appBarTitle: pageTitle, + appBarTitle: pageTitle!, isShowAppBar: true, showNewAppBarTitle: true, showNewAppBar: true, body: ListView( - children: VSchart.map((chartInfo) { - var vitalListTemp = vitalList.where( + children: VSchart!.map((chartInfo) { + var vitalListTemp = vitalList!.where( (element) => element.toJson()[chartInfo['viewKey']] != null, ); if (vitalListTemp.length != 0 && chartInfo['viewKey'] == 'BloodPressure') { return VitalSingChartBloodPressure( - vitalList: vitalList, + vitalList: vitalList!, name: projectViewModel.isArabic ? chartInfo['nameAr'] : chartInfo['name'], title1: chartInfo['title1'], title2: projectViewModel.isArabic ? chartInfo['title2Ar'] : chartInfo['title2'], @@ -182,7 +182,7 @@ class VitalSignItemDetailsScreen extends StatelessWidget { return vitalListTemp.length != 0 ? VitalSingChartAndDetials( - vitalList: vitalList, + vitalList: vitalList!, name: projectViewModel.isArabic ? chartInfo['nameAr'] : chartInfo['name'], title1: chartInfo['title1'], title2: projectViewModel.isArabic ? chartInfo['title2Ar'] : chartInfo['title2'], diff --git a/lib/pages/medical/vital_sign/vital_sing_chart_and_detials.dart b/lib/pages/medical/vital_sign/vital_sing_chart_and_detials.dart index 3211755c..f7d5f362 100644 --- a/lib/pages/medical/vital_sign/vital_sing_chart_and_detials.dart +++ b/lib/pages/medical/vital_sign/vital_sing_chart_and_detials.dart @@ -14,12 +14,12 @@ import 'LineChartCurved.dart'; class VitalSingChartAndDetials extends StatefulWidget { VitalSingChartAndDetials({ - Key key, - @required this.vitalList, - @required this.name, - @required this.viewKey, - @required this.title1, - @required this.title2, + Key? key, + required this.vitalList, + required this.name, + required this.viewKey, + required this.title1, + required this.title2, }) : super(key: key); final List vitalList; @@ -35,7 +35,7 @@ class VitalSingChartAndDetials extends StatefulWidget { class _VitalSingChartAndDetialsState extends State { List timeSeriesData = []; bool isExpended = true; - ProjectViewModel projectViewModel; + ProjectViewModel? projectViewModel; @override void initState() { @@ -116,7 +116,7 @@ class _VitalSingChartAndDetialsState extends State { TableRow( children: [ Utils.tableColumnValue( - "${projectViewModel.isArabic ? DateUtil.getWeekDayArabic(labResultList[i].vitalSignDate.weekday) : DateUtil.getWeekDay(labResultList[i].vitalSignDate.weekday)}, ${labResultList[i].vitalSignDate.day} ${projectViewModel.isArabic ? DateUtil.getMonthArabic(labResultList[i].vitalSignDate.month) : DateUtil.getMonth(labResultList[i].vitalSignDate.month)}, ${labResultList[i].vitalSignDate.year}", + "${projectViewModel!.isArabic ? DateUtil.getWeekDayArabic(labResultList[i].vitalSignDate!.weekday) : DateUtil.getWeekDay(labResultList[i].vitalSignDate!.weekday)}, ${labResultList[i].vitalSignDate!.day} ${projectViewModel!.isArabic ? DateUtil.getMonthArabic(labResultList[i].vitalSignDate!.month) : DateUtil.getMonth(labResultList[i].vitalSignDate!.month)}, ${labResultList[i].vitalSignDate!.year}", isLast: i == (labResultList.length - 1)), Utils.tableColumnValue('${labResultList[i].toJson()[widget.viewKey]}', isLast: i == (labResultList.length - 1)), ], @@ -134,7 +134,7 @@ class _VitalSingChartAndDetialsState extends State { if (element.toJson()[widget.viewKey] != null && element.toJson()[widget.viewKey]?.toInt() != 0) timeSeriesData.add( TimeSeriesSales2( - new DateTime(element.vitalSignDate.year, element.vitalSignDate.month, element.vitalSignDate.day), + new DateTime(element.vitalSignDate!.year, element.vitalSignDate!.month, element.vitalSignDate!.day), element.toJson()[widget.viewKey].toDouble(), ), ); diff --git a/lib/pages/medical/vital_sign/vital_sing_chart_blood_pressure.dart b/lib/pages/medical/vital_sign/vital_sing_chart_blood_pressure.dart index 2d04e91a..a985e461 100644 --- a/lib/pages/medical/vital_sign/vital_sing_chart_blood_pressure.dart +++ b/lib/pages/medical/vital_sign/vital_sing_chart_blood_pressure.dart @@ -12,14 +12,14 @@ import 'LineChartCurvedBloodPressure.dart'; class VitalSingChartBloodPressure extends StatelessWidget { VitalSingChartBloodPressure({ - Key key, - @required this.vitalList, - @required this.name, - @required this.viewKey1, - @required this.viewKey2, - @required this.title1, - @required this.title2, - @required this.title3, + Key? key, + required this.vitalList, + required this.name, + required this.viewKey1, + required this.viewKey2, + required this.title1, + required this.title2, + required this.title3, }) : super(key: key); final List vitalList; @@ -31,7 +31,7 @@ class VitalSingChartBloodPressure extends StatelessWidget { final String title3; List timeSeriesData1 = []; List timeSeriesData2 = []; - ProjectViewModel projectViewModel; + ProjectViewModel? projectViewModel; @override Widget build(BuildContext context) { @@ -112,7 +112,7 @@ class VitalSingChartBloodPressure extends StatelessWidget { TableRow( children: [ Utils.tableColumnValue( - "${projectViewModel.isArabic ? DateUtil.getWeekDayArabic(labResultList[i].vitalSignDate.weekday) : DateUtil.getWeekDay(labResultList[i].vitalSignDate.weekday)}, ${labResultList[i].vitalSignDate.day} ${projectViewModel.isArabic ? DateUtil.getMonthArabic(labResultList[i].vitalSignDate.month) : DateUtil.getMonth(labResultList[i].vitalSignDate.month)}, ${labResultList[i].vitalSignDate.year}", + "${projectViewModel!.isArabic ? DateUtil.getWeekDayArabic(labResultList[i].vitalSignDate!.weekday) : DateUtil.getWeekDay(labResultList[i].vitalSignDate!.weekday)}, ${labResultList[i].vitalSignDate!.day} ${projectViewModel!.isArabic ? DateUtil.getMonthArabic(labResultList[i].vitalSignDate!.month) : DateUtil.getMonth(labResultList[i].vitalSignDate!.month)}, ${labResultList[i].vitalSignDate!.year}", isLast: i == (labResultList.length - 1)), Utils.tableColumnValue('${labResultList[i].toJson()[viewKey1]}', isLast: i == (labResultList.length - 1)), Utils.tableColumnValue('${labResultList[i].toJson()[viewKey2]}', isLast: i == (labResultList.length - 1)), @@ -131,14 +131,14 @@ class VitalSingChartBloodPressure extends StatelessWidget { if (element.toJson()[viewKey1]?.toInt() != 0) timeSeriesData1.add( TimeSeriesSales2( - new DateTime(element.vitalSignDate.year, element.vitalSignDate.month, element.vitalSignDate.day), + new DateTime(element.vitalSignDate!.year, element.vitalSignDate!.month, element.vitalSignDate!.day), element.toJson()[viewKey1].toDouble(), ), ); if (element.toJson()[viewKey2]?.toInt() != 0) timeSeriesData2.add( TimeSeriesSales2( - new DateTime(element.vitalSignDate.year, element.vitalSignDate.month, element.vitalSignDate.day), + new DateTime(element.vitalSignDate!.year, element.vitalSignDate!.month, element.vitalSignDate!.day), element.toJson()[viewKey2].toDouble(), ), ); diff --git a/lib/pages/packages_offers/PackageOrderCompletedPage.dart b/lib/pages/packages_offers/PackageOrderCompletedPage.dart index ee56d325..453de1fc 100644 --- a/lib/pages/packages_offers/PackageOrderCompletedPage.dart +++ b/lib/pages/packages_offers/PackageOrderCompletedPage.dart @@ -19,7 +19,7 @@ class PackageOrderCompletedPage extends StatelessWidget { String? subTitle; String? actionTitle; - PackageOrderCompletedPage({this.buttonWidth, this.buttonHeight, required this.heading, required this.title, required this.subTitle, this.actionTitle}); + PackageOrderCompletedPage({this.buttonWidth, this.buttonHeight, this.heading, this.title, this.subTitle, this.actionTitle}); @override Widget build(BuildContext context) { diff --git a/lib/widgets/input/text_field.dart b/lib/widgets/input/text_field.dart index f4637a28..be6c9989 100644 --- a/lib/widgets/input/text_field.dart +++ b/lib/widgets/input/text_field.dart @@ -37,262 +37,262 @@ class NumberTextInputFormatter extends TextInputFormatter { final _mobileFormatter = NumberTextInputFormatter(); -// class TextFields extends StatefulWidget { -// TextFields( -// {Key? key, -// this.type, -// this.hintText, -// this.suffixIcon, -// this.autoFocus, -// this.onChanged, -// this.initialValue, -// this.minLines, -// this.maxLines, -// this.inputFormatters, -// this.padding, -// this.focus = false, -// this.maxLengthEnforced = true, -// this.suffixIconColor, -// this.inputAction, -// this.onSubmit, -// this.keepPadding = true, -// this.textCapitalization = TextCapitalization.none, -// this.controller, -// this.keyboardType, -// this.validator, -// this.borderOnlyError = false, -// this.onSaved, -// this.onSuffixTap, -// this.readOnly= false, -// this.maxLength, -// this.prefixIcon, -// this.bare = false, -// this.onTap, -// this.fontSize = 16.0, -// this.fontWeight = FontWeight.w700, -// this.fillColor, -// this.hintColor}) -// : super(key: key); -// -// final String? hintText; -// final String? initialValue; -// final String? type; -// final bool? autoFocus; -// final IconData? suffixIcon; -// final Color? suffixIconColor; -// final Icon? prefixIcon; -// final VoidCallback? onTap; -// final TextEditingController? controller; -// final TextInputType? keyboardType; -// final FormFieldValidator? validator; -// final Function? onSaved; -// final Function? onSuffixTap; -// final Function? onChanged; -// final Function? onSubmit; -// final bool? readOnly; -// final int? maxLength; -// final int? minLines; -// final int? maxLines; -// final bool? maxLengthEnforced; -// final bool? bare; -// final TextInputAction? inputAction; -// final double? fontSize; -// final FontWeight? fontWeight; -// final bool? keepPadding; -// final TextCapitalization? textCapitalization; -// final List? inputFormatters; -// final EdgeInsets? padding; -// final bool? focus; -// final bool? borderOnlyError; -// final Color? hintColor; -// final Color? fillColor; -// -// @override -// _TextFieldsState createState() => _TextFieldsState(); -// } -// -// class _TextFieldsState extends State { -// final FocusNode _focusNode = FocusNode(); -// bool? focus = false; -// bool? view = false; -// -// @override -// void initState() { -// super.initState(); -// _focusNode.addListener(() { -// setState(() { -// focus = _focusNode.hasFocus; -// }); -// }); -// } -// -// @override -// void didUpdateWidget(TextFields oldWidget) { -// if (widget.focus != null) _focusNode.requestFocus(); -// super.didUpdateWidget(oldWidget); -// } -// -// @override -// void dispose() { -// _focusNode.dispose(); -// super.dispose(); -// } -// -// Widget _buildSuffixIcon() { -// switch (widget.type) { -// case "password": -// return Padding( -// padding: const EdgeInsets.only(right: 8.0), -// child: view! -// ? InkWell( -// onTap: () { -// this.setState( -// () { -// view = false; -// }, -// ); -// }, -// child: Icon( -// Icons.remove_red_eye_sharp, -// size: 24.0, -// color: Color.fromRGBO(78, 62, 253, 1.0), -// ), -// ) -// : InkWell( -// onTap: () { -// this.setState(() { -// view = true; -// }); -// }, -// child: Icon(Icons.remove_red_eye_sharp, -// size: 24.0, color: Colors.grey[500]), -// ), -// ); -// default: -// if (widget.suffixIcon != null) -// return InkWell( -// onTap: widget.onSuffixTap, -// child: Icon(widget.suffixIcon, -// size: 22.0, -// color: widget.suffixIconColor != null -// ? widget.suffixIconColor -// : Colors.grey[500]), -// ); -// else -// return null; -// } -// } -// -// bool _determineReadOnly() { -// if (widget.readOnly != null && widget.readOnly!) { -// _focusNode.unfocus(); -// return true; -// } else { -// return false; -// } -// } -// -// @override -// Widget build(BuildContext context) { -// return (AnimatedContainer( -// duration: Duration(milliseconds: 300), -// decoration: widget.bare! -// ? null -// : BoxDecoration(boxShadow: [ -// // BoxShadow( -// // color: Color.fromRGBO(70, 68, 167, focus ? 0.20 : 0), -// // offset: Offset(0.0, 13.0), -// // blurRadius: focus ? 34.0 : 12.0) -// BoxShadow( -// color: Color.fromRGBO(110, 68, 80, focus ? 0.20 : 0), -// offset: Offset(0.0, 13.0), -// blurRadius: focus ? 34.0 : 12.0) -// ]), -// child: TextFormField( -// keyboardAppearance: Theme.of(context).brightness, -// scrollPhysics: BouncingScrollPhysics(), -// textCapitalization: widget.textCapitalization, -// onFieldSubmitted: widget.inputAction == TextInputAction.next -// ? (widget.onSubmit != null -// ? widget.onSubmit -// : (val) { -// _focusNode.nextFocus(); -// }) -// : widget.onSubmit, -// textInputAction: widget.inputAction, -// minLines: widget.minLines ?? 1, -// maxLines: widget.maxLines ?? 1, -// // maxLengthEnforcement: widget.maxLengthEnforced, -// initialValue: widget.initialValue, -// onChanged: widget.onChanged, -// focusNode: _focusNode, -// maxLength: widget.maxLength ?? null, -// controller: widget.controller, -// keyboardType: widget.keyboardType, -// readOnly: _determineReadOnly(), -// obscureText: widget.type == "password" && !view ? true : false, -// autofocus: widget.autoFocus ?? false, -// validator: widget.validator, -// onSaved: widget.onSaved, -// style: Theme.of(context) -// .textTheme -// .bodyText1 -// .copyWith(fontSize: widget.fontSize, fontWeight: widget.fontWeight), -// inputFormatters: widget.keyboardType == TextInputType.phone -// ? [ -// FilteringTextInputFormatter.digitsOnly, -// _mobileFormatter, -// ] -// : widget.inputFormatters, -// decoration: InputDecoration( -// counterText: "", -// hintText: widget.hintText, -// hintStyle: TextStyle( -// fontSize: widget.fontSize, -// fontWeight: widget.fontWeight, -// color: widget.hintColor ?? Theme.of(context).hintColor, -// ), -// contentPadding: widget.padding != null -// ? widget.padding -// : EdgeInsets.symmetric( -// vertical: (widget.bare && !widget.keepPadding) ? 0.0 : 10.0, -// horizontal: 16.0), -// filled: true, -// fillColor: widget.bare -// ? Colors.transparent -// : Theme.of(context).backgroundColor, -// suffixIcon: _buildSuffixIcon(), -// prefixIcon: widget.prefixIcon, -// errorStyle: TextStyle( -// fontSize: 14.0, -// fontWeight: widget.fontWeight, -// height: widget.borderOnlyError ? 0.0 : null), -// errorBorder: OutlineInputBorder( -// borderSide: BorderSide( -// color: Theme.of(context) -// .errorColor -// .withOpacity(widget.bare ? 0.0 : 0.5), -// width: 1.0), -// borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), -// focusedErrorBorder: OutlineInputBorder( -// borderSide: BorderSide( -// color: Theme.of(context) -// .errorColor -// .withOpacity(widget.bare ? 0.0 : 0.5), -// width: 1.0), -// borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), -// focusedBorder: OutlineInputBorder( -// borderSide: BorderSide(color: Colors.grey, width: 1.0), -// borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), -// disabledBorder: OutlineInputBorder( -// borderSide: BorderSide(color: Colors.grey, width: 1.0), -// borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0)), -// enabledBorder: OutlineInputBorder( -// borderSide: BorderSide(color: Colors.grey, width: 1.0), -// borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0), -// ), -// ), -// ), -// )); -// } -// } +class TextFields extends StatefulWidget { + TextFields( + {Key? key, + this.type, + this.hintText, + this.suffixIcon, + this.autoFocus, + this.onChanged, + this.initialValue, + this.minLines, + this.maxLines, + this.inputFormatters, + this.padding, + this.focus = false, + this.maxLengthEnforced = true, + this.suffixIconColor, + this.inputAction, + this.onSubmit, + this.keepPadding = true, + this.textCapitalization = TextCapitalization.none, + this.controller, + this.keyboardType, + this.validator, + this.borderOnlyError = false, + this.onSaved, + this.onSuffixTap, + this.readOnly= false, + this.maxLength, + this.prefixIcon, + this.bare = false, + this.onTap, + this.fontSize = 16.0, + this.fontWeight = FontWeight.w700, + this.fillColor, + this.hintColor}) + : super(key: key); + + final String? hintText; + final String? initialValue; + final String? type; + final bool? autoFocus; + final IconData? suffixIcon; + final Color? suffixIconColor; + final Icon? prefixIcon; + final VoidCallback? onTap; + final TextEditingController? controller; + final TextInputType? keyboardType; + final FormFieldValidator? validator; + final Function(String?)? onSaved; + final VoidCallback? onSuffixTap; + final Function(String?)? onChanged; + final Function(String?)? onSubmit; + final bool? readOnly; + final int? maxLength; + final int? minLines; + final int? maxLines; + final bool? maxLengthEnforced; + final bool? bare; + final TextInputAction? inputAction; + final double? fontSize; + final FontWeight? fontWeight; + final bool? keepPadding; + final TextCapitalization? textCapitalization; + final List? inputFormatters; + final EdgeInsets? padding; + final bool? focus; + final bool? borderOnlyError; + final Color? hintColor; + final Color? fillColor; + + @override + _TextFieldsState createState() => _TextFieldsState(); +} + +class _TextFieldsState extends State { + final FocusNode _focusNode = FocusNode(); + bool? focus = false; + bool? view = false; + + @override + void initState() { + super.initState(); + _focusNode.addListener(() { + setState(() { + focus = _focusNode.hasFocus; + }); + }); + } + + @override + void didUpdateWidget(TextFields oldWidget) { + if (widget.focus != null) _focusNode.requestFocus(); + super.didUpdateWidget(oldWidget); + } + + @override + void dispose() { + _focusNode.dispose(); + super.dispose(); + } + + Widget _buildSuffixIcon() { + switch (widget.type) { + case "password": + return Padding( + padding: const EdgeInsets.only(right: 8.0), + child: view! + ? InkWell( + onTap: () { + this.setState( + () { + view = false; + }, + ); + }, + child: Icon( + Icons.remove_red_eye_sharp, + size: 24.0, + color: Color.fromRGBO(78, 62, 253, 1.0), + ), + ) + : InkWell( + onTap: () { + this.setState(() { + view = true; + }); + }, + child: Icon(Icons.remove_red_eye_sharp, + size: 24.0, color: Colors.grey[500]), + ), + ); + default: + if (widget.suffixIcon != null) + return InkWell( + onTap: widget.onSuffixTap, + child: Icon(widget.suffixIcon, + size: 22.0, + color: widget.suffixIconColor != null + ? widget.suffixIconColor + : Colors.grey[500]), + ); + else + return SizedBox(); + } + } + + bool _determineReadOnly() { + if (widget.readOnly != null && widget.readOnly!) { + _focusNode.unfocus(); + return true; + } else { + return false; + } + } + + @override + Widget build(BuildContext context) { + return (AnimatedContainer( + duration: Duration(milliseconds: 300), + decoration: widget.bare! + ? null + : BoxDecoration(boxShadow: [ + // BoxShadow( + // color: Color.fromRGBO(70, 68, 167, focus ? 0.20 : 0), + // offset: Offset(0.0, 13.0), + // blurRadius: focus ? 34.0 : 12.0) + BoxShadow( + color: Color.fromRGBO(110, 68, 80, focus! ? 0.20 : 0), + offset: Offset(0.0, 13.0), + blurRadius: focus! ? 34.0 : 12.0) + ]), + child: TextFormField( + keyboardAppearance: Theme.of(context).brightness, + scrollPhysics: BouncingScrollPhysics(), + textCapitalization: widget.textCapitalization!, + onFieldSubmitted: widget.inputAction! == TextInputAction.next! + ? (widget.onSubmit! != null + ? widget.onSubmit! + : (val) { + _focusNode.nextFocus!(); + }) + : widget.onSubmit!, + textInputAction: widget.inputAction, + minLines: widget.minLines ?? 1, + maxLines: widget.maxLines ?? 1, + // maxLengthEnforcement: widget.maxLengthEnforced, + initialValue: widget.initialValue, + onChanged: widget.onChanged!, + focusNode: _focusNode, + maxLength: widget.maxLength ?? null, + controller: widget.controller, + keyboardType: widget.keyboardType, + readOnly: _determineReadOnly(), + obscureText: widget.type == "password" && !view! ? true : false, + autofocus: widget.autoFocus ?? false, + validator: widget.validator, + onSaved: widget.onSaved, + style: Theme.of(context) + .textTheme + .bodyText1! + .copyWith(fontSize: widget.fontSize, fontWeight: widget.fontWeight), + inputFormatters: widget.keyboardType == TextInputType.phone + ? [ + FilteringTextInputFormatter.digitsOnly, + _mobileFormatter, + ] + : widget.inputFormatters, + decoration: InputDecoration( + counterText: "", + hintText: widget.hintText, + hintStyle: TextStyle( + fontSize: widget.fontSize, + fontWeight: widget.fontWeight, + color: widget.hintColor ?? Theme.of(context).hintColor, + ), + contentPadding: widget.padding != null + ? widget.padding + : EdgeInsets.symmetric( + vertical: (widget.bare! && !widget.keepPadding!) ? 0.0 : 10.0, + horizontal: 16.0), + filled: true, + fillColor: widget.bare! + ? Colors.transparent + : Theme.of(context).backgroundColor, + suffixIcon: _buildSuffixIcon(), + prefixIcon: widget.prefixIcon, + errorStyle: TextStyle( + fontSize: 14.0, + fontWeight: widget.fontWeight, + height: widget.borderOnlyError! ? 0.0 : null), + errorBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Theme.of(context) + .errorColor + .withOpacity(widget.bare! ? 0.0 : 0.5), + width: 1.0), + borderRadius: BorderRadius.circular(widget.bare! ? 0.0 : 8.0)), + focusedErrorBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Theme.of(context) + .errorColor + .withOpacity(widget.bare! ? 0.0 : 0.5), + width: 1.0), + borderRadius: BorderRadius.circular(widget.bare! ? 0.0 : 8.0)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 1.0), + borderRadius: BorderRadius.circular(widget.bare! ? 0.0 : 8.0)), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 1.0), + borderRadius: BorderRadius.circular(widget.bare! ? 0.0 : 8.0)), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Colors.grey, width: 1.0), + borderRadius: BorderRadius.circular(widget.bare! ? 0.0 : 8.0), + ), + ), + ), + )); + } +} diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 89e80792..c0d1918c 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -76,7 +76,7 @@ class AppScaffold extends StatefulWidget { final int? dropdownIndexValue; List? dropDownList; final void Function(int?)? dropDownIndexChange; - final Function? onTap; + final VoidCallbackAction? onTap; final bool isMainPharmacyPages; final bool extendBody; final ValueChanged? changeCurrentTab;