From edbb99e445449875b777d0db8a64ef6cab11b3ca Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 4 Jan 2022 14:16:31 +0200 Subject: [PATCH 1/2] small fix --- assets/images/HMG_logo.png | Bin 0 -> 5167 bytes lib/config/config.dart | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 assets/images/HMG_logo.png diff --git a/assets/images/HMG_logo.png b/assets/images/HMG_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..480ba15e0dc06bfdb010cf200cbead6b8a2d9f01 GIT binary patch literal 5167 zcmV+~6wvF5P)Px#IAvH#W=%~1DgXcg2mk?xX#fNO00031000^Q000000-yo_1ONa40RR91&7cDS z1ONa40RR91DgXcg03Io4oB#k5rAb6VRCodHT~BWt#}%L1UAk@@z!cn56TtMXjSpsS zMQcNpC7&&QfJ8K6r@2}A1fo8H>6>dOFztK*(`VZe1*bu8mJUgKGX*3-4>3dmHJX~c zJN^A;cc|fVmw#kZQWP$*n%SB6-n@D9-kW)|vy>FmYbt>wCV^M)f3PZ)SQJtgj{s{e zB~-&za&6|v?>5Pga|DiD2?CDmK?+w3b-`ni(hEHz7Xs z(dS9<4h7zV=h+zMM*F*cc-ZYn1MNJ(7+pK_<99_NRV$0mk&9^>jYfxA#u)I3i&Bbp zc<$Oi8jWUFM~+%KcrGa==S+XdJB+`EU7@SswQ|(>9hDzCID-@QZDB=9wQkDBnL099 znfc*gjbUgq<_LwG%7^0z#hHKqt2qpvelP=PntsR!QAfj3N^R#{w|EfkjiZg^QpnJR zAvH1kjJY4GY3LtjYBo_0G8RqiZ^7yp?iQkO!gRLW@@ zn7%1yBN*4&zA&tmB9A|XVd5ksdqY!+P|LGN$uUC$W@Pyp{WuD%0UC(u=Oj`OZ#%0P zpqqc0pMU8%Vbg9T44nc-`WANql_OR!EzBw8wer|-zH%@%a{$FMmLM-NO*ia%<~y{o z=5(ZcAG9iIw32vyMx&=e^X%YVC|L%0F%aQ3;*Im-asn@AD_?8+3Lq#=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atePage.dart | 8 +- lib/config/config.dart | 2 +- .../auth/verification_methods_screen.dart | 7 +- .../patient_profile_screen.dart | 25 +- .../radiology/radiology_details_page.dart | 9 +- .../bottom_sheet_dialog_button.dart | 3 - .../soap_update/update_soap_index.dart | 29 +- .../RegisterSearchPatientPage.dart | 4 +- .../shared/buttons/app_buttons_widget.dart | 8 +- .../shared/buttons/secondary_button.dart | 259 ------------------ 10 files changed, 41 insertions(+), 313 deletions(-) delete mode 100644 lib/widgets/shared/buttons/secondary_button.dart diff --git a/lib/UpdatePage.dart b/lib/UpdatePage.dart index 749b4298..44f96f4a 100644 --- a/lib/UpdatePage.dart +++ b/lib/UpdatePage.dart @@ -5,11 +5,11 @@ import 'dart:io' show Platform; 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/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; -import 'widgets/shared/buttons/secondary_button.dart'; class UpdatePage extends StatelessWidget { final String message; @@ -62,15 +62,15 @@ class UpdatePage extends StatelessWidget { child: Container( // padding: const EdgeInsets.all(8.0), margin: EdgeInsets.all(15), - child: SecondaryButton( + child: AppButton( color: Colors.red[800], - onTap: () { + onPressed: () { if (Platform.isIOS) launch(iosLink); else launch(androidLink); }, - label: TranslationBase.of(context).updateNow.toUpperCase(), + title: TranslationBase.of(context).updateNow.toUpperCase(), ), ), ), diff --git a/lib/config/config.dart b/lib/config/config.dart index e4d46d02..2301eab0 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -436,7 +436,7 @@ const TRANSACTION_NO = 0; const LANGUAGE_ID = 2; const STAMP = '2020-04-27T12:17:17.721Z'; const IP_ADDRESS = '9.9.9.9'; -const VERSION_ID = 6.7; +const VERSION_ID = 6.5; const CHANNEL = 9; const SESSION_ID = 'BlUSkYymTt'; const IS_LOGIN_FOR_DOCTOR_APP = true; diff --git a/lib/screens/auth/verification_methods_screen.dart b/lib/screens/auth/verification_methods_screen.dart index e1f2f49b..c4f9a6ce 100644 --- a/lib/screens/auth/verification_methods_screen.dart +++ b/lib/screens/auth/verification_methods_screen.dart @@ -13,7 +13,6 @@ import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/buttons/secondary_button.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; @@ -468,12 +467,12 @@ class _VerificationMethodsScreenState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ - SecondaryButton( - label: + AppButton( + title: TranslationBase.of(context).useAnotherAccount ?? '', color: Color(0xFFD02127), //fontWeight: FontWeight.w700, - onTap: () { + onPressed: () { authenticationViewModel.deleteUser(); authenticationViewModel .setAppStatus(APP_STATUS.UNAUTHENTICATED); diff --git a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart index 6cf1acb0..0c12b913 100644 --- a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart +++ b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/AnalyticsService.dart'; import 'package:doctor_app_flutter/core/service/VideoCallService.dart'; @@ -242,14 +243,16 @@ class _PatientProfileScreenState extends State title: "${TranslationBase.of(context).createNew}\n${TranslationBase.of(context).episode}", color: isFromLiveCare || isInpatient - ? Colors.red.shade700 + ? AppGlobal.appRedColor : patient.patientStatusType == 43 - ? Colors.red.shade700 - : Colors.grey.shade700, + ? AppGlobal.appRedColor + : AppGlobal.appRedColor, fontColor: Colors.white, - vPadding: 8, + // vPadding: 8, + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort ? 9 : 6), radius: 30, - hPadding: 20, + hPadding: 25, fontWeight: FontWeight.normal, fontSize: 12, icon: SvgPicture.asset( @@ -278,14 +281,16 @@ class _PatientProfileScreenState extends State color: ((isInpatient) || isFromLiveCare) && model.state != ViewState.BusyLocal - ? Colors.red.shade700 + ? AppGlobal.appRedColor : patient.patientStatusType == 43 - ? Colors.red.shade700 - : Colors.grey.shade700, + ?AppGlobal.appRedColor + : AppGlobal.appRedColor, fontColor: Colors.white, - vPadding: 8, + // vPadding: 8, + height: SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort ? 9 : 6), radius: 30, - hPadding: 20, + hPadding: 25, fontWeight: FontWeight.normal, fontSize: 12, icon: SvgPicture.asset( diff --git a/lib/screens/patients/profile/radiology/radiology_details_page.dart b/lib/screens/patients/profile/radiology/radiology_details_page.dart index 7f1fa507..df3bbb06 100644 --- a/lib/screens/patients/profile/radiology/radiology_details_page.dart +++ b/lib/screens/patients/profile/radiology/radiology_details_page.dart @@ -7,7 +7,7 @@ import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-profile-app-bar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/buttons/secondary_button.dart'; +import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -101,18 +101,17 @@ class RadiologyDetailsPage extends StatelessWidget { child: Container( margin: EdgeInsets.only(left: 35, right: 35, top: 12, bottom: 12), - child: SecondaryButton( + child: AppButton( color: Color(0xffD02127), disabled: finalRadiology.dIAPACSURL == "", - textColor: Color(0xffFFFFFF), - onTap: () async { + onPressed: () async { await locator().logEvent( eventCategory: "RadiologyDetailsPage", eventAction: "Open Radiology Image", ); launch(model.radImageURL); }, - label: TranslationBase.of(context).openRad, + title: TranslationBase.of(context).openRad, ), ), ) diff --git a/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart b/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart index 835dd225..92275fb4 100644 --- a/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart +++ b/lib/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_dialog_button.dart @@ -32,10 +32,7 @@ class BottomSheetDialogButton extends StatelessWidget { widthFactor: .80, child: Center( child: AppButton( - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 8 : 6), title: label, - padding: 10, color: Color(0xFF359846), onPressed: onTap, ), diff --git a/lib/screens/patients/profile/soap_update/update_soap_index.dart b/lib/screens/patients/profile/soap_update/update_soap_index.dart index c2dcf103..fd6a62d8 100644 --- a/lib/screens/patients/profile/soap_update/update_soap_index.dart +++ b/lib/screens/patients/profile/soap_update/update_soap_index.dart @@ -169,9 +169,6 @@ class _UpdateSoapIndexState extends State child: AppButton( title: TranslationBase.of(context).next, fontWeight: FontWeight.w600, - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 8 : 6), - padding: 10, color: Colors.red[700], onPressed: () async { model.nextOnSubjectPage(model); @@ -189,9 +186,9 @@ class _UpdateSoapIndexState extends State child: AppButton( title: TranslationBase.of(context).previous, color: Colors.grey[300], - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 8 : 6), - padding: 10, + // height: SizeConfig.heightMultiplier * + // (SizeConfig.isHeightVeryShort ? 8 : 6), + // padding: 10, fontColor: Colors.black, fontWeight: FontWeight.w600, onPressed: () { @@ -211,9 +208,9 @@ class _UpdateSoapIndexState extends State : TranslationBase.of(context).next, fontWeight: FontWeight.w600, color: Colors.red[700], - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 8 : 6), - padding: 10, + // height: SizeConfig.heightMultiplier * + // (SizeConfig.isHeightVeryShort ? 8 : 6), + // padding: 10, disabled: model.state == ViewState.BusyLocal, onPressed: () async { await model.nextOnObjectivePage(model); @@ -235,9 +232,6 @@ class _UpdateSoapIndexState extends State title: TranslationBase.of(context).previous, color: Colors.grey[300], fontColor: Colors.black, - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 8 : 6), - padding: 10, fontWeight: FontWeight.w600, disabled: model.state == ViewState.BusyLocal, onPressed: () async { @@ -253,9 +247,7 @@ class _UpdateSoapIndexState extends State title: TranslationBase.of(context).next, fontWeight: FontWeight.w600, color: Colors.red[700], - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 8 : 6), - padding: 10, + disabled: model.state == ViewState.BusyLocal, onPressed: () async { model.nextOnAssessmentPage(model); @@ -274,9 +266,6 @@ class _UpdateSoapIndexState extends State children: [ Expanded( child: AppButton( - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 8 : 6), - padding: 10, title: TranslationBase.of(context).previous, color: Colors.grey[300], fontColor: Colors.black, @@ -292,9 +281,7 @@ class _UpdateSoapIndexState extends State ), Expanded( child: AppButton( - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 8 : 6), - padding: 10, + title: model.isAddProgress ? TranslationBase.of(context).next : TranslationBase.of(context).finish, diff --git a/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart b/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart index 7a2866b5..f3ca4ea7 100644 --- a/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart +++ b/lib/screens/patients/register_patient/RegisterSearchPatientPage.dart @@ -316,7 +316,7 @@ class _RegisterSearchPatientPageState extends State { child: AppButton( title: TranslationBase.of(context).cancel, hasBorder: true, - vPadding: 12, + // vPadding: 12, hPadding: 8, borderColor: Color(0xFFeaeaea), color: Color(0xFFeaeaea), @@ -335,8 +335,6 @@ class _RegisterSearchPatientPageState extends State { child: AppButton( title: TranslationBase.of(context).next, hasBorder: true, - vPadding: 12, - hPadding: 8, borderColor: Color(0xFFB8382B), color: AppGlobal.appRedColor, fontColor: Colors.white, diff --git a/lib/widgets/shared/buttons/app_buttons_widget.dart b/lib/widgets/shared/buttons/app_buttons_widget.dart index 46b6fb6d..5f2d3faf 100644 --- a/lib/widgets/shared/buttons/app_buttons_widget.dart +++ b/lib/widgets/shared/buttons/app_buttons_widget.dart @@ -33,7 +33,7 @@ class AppButton extends StatefulWidget { this.icon, this.color, this.fontSize, - this.padding = 13, + this.padding = 8, this.loading = false, this.disabled = false, this.fontColor = Colors.white, @@ -53,11 +53,13 @@ class _AppButtonState extends State { @override Widget build(BuildContext context) { if (widget.fontSize == null) { - widget.fontSize = SizeConfig.getHeightMultiplier() * 1.9; + widget.fontSize = SizeConfig.getHeightMultiplier() * + (SizeConfig.isHeightVeryShort ? 1.3 : 1.7); } return Container( // height: MediaQuery.of(context).size.height * 0.075, - height: widget.height, + height: widget.height?? SizeConfig.heightMultiplier * + (SizeConfig.isHeightVeryShort ? 6 : 5), child: IgnorePointer( ignoring: widget.loading || widget.disabled, child: RawMaterialButton( diff --git a/lib/widgets/shared/buttons/secondary_button.dart b/lib/widgets/shared/buttons/secondary_button.dart deleted file mode 100644 index 2ef22a80..00000000 --- a/lib/widgets/shared/buttons/secondary_button.dart +++ /dev/null @@ -1,259 +0,0 @@ -import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -/// SecondaryButton widget -/// [label] button label -/// [icon] button icon its optional -/// [iconOnly] just show the icon -/// [color] the background color -/// [textColor] the text color -/// [onTap] button function -/// [loading] show the progress indicator -/// [disabled] disabled the button -/// [borderColor] the button border color -/// [noBorderRadius] remove border radius -class SecondaryButton extends StatefulWidget { - SecondaryButton( - {Key key, - this.label = "", - this.icon, - this.iconOnly = false, - this.color, - this.textColor = Colors.white, - this.onTap, - this.loading: false, - this.small = false, - this.disabled = false, - this.borderColor, - this.noBorderRadius = false}) - : super(key: key); - - final String label; - final Widget icon; - final VoidCallback onTap; - final bool loading; - final Color color; - final Color textColor; - final Color borderColor; - final bool small; - final bool iconOnly; - final bool disabled; - final bool noBorderRadius; - - @override - _SecondaryButtonState createState() => _SecondaryButtonState(); -} - -class _SecondaryButtonState extends State - with TickerProviderStateMixin { - double _buttonSize = 1.0; - AnimationController _animationController; - Animation _animation; - - double _rippleSize = 0.0; - AnimationController _rippleController; - Animation _rippleAnimation; - - @override - void initState() { - if (widget.disabled != null && !widget.disabled) { - setState(() { - _rippleSize = 1.0; - }); - } - _animationController = AnimationController( - vsync: this, - lowerBound: 0.7, - upperBound: 1.0, - duration: Duration(milliseconds: 120)); - _animation = CurvedAnimation( - parent: _animationController, - curve: Curves.easeOutQuad, - reverseCurve: Curves.easeOutQuad); - _animation.addListener(() { - setState(() { - _buttonSize = _animation.value; - }); - }); - - _rippleController = AnimationController( - vsync: this, - lowerBound: 0.0, - upperBound: 1.0, - duration: Duration(seconds: 1)); - _rippleAnimation = CurvedAnimation( - parent: _rippleController, curve: Curves.easeInOutQuint); - _rippleAnimation.addListener(() { - setState(() { - _rippleSize = _rippleAnimation.value; - }); - }); - super.initState(); - } - - @override - void dispose() { - _animationController.dispose(); - _rippleController.dispose(); - super.dispose(); - } - - Widget _buildIcon() { - if (widget.icon != null && (widget.label != null && widget.label != "")) { - return Container(height: 25.0, child: widget.icon); - } else if (widget.icon != null && - (widget.label == null || widget.label == "")) { - return Container(height: 25.0, width: 25, child: widget.icon); - } else { - return Container(); - } - } - - @override - void didUpdateWidget(SecondaryButton oldWidget) { - super.didUpdateWidget(oldWidget); - if (oldWidget.disabled != widget.disabled) { - bool d = widget.disabled ?? false; - if (!d) { - _rippleController.forward(); - } else { - if (_rippleSize == 1.0) - _rippleController.reverse(from: 1.0); - else - _rippleController.reverse(); - } - } - } - - @override - Widget build(BuildContext context) { - ProjectViewModel projectViewModel = Provider.of(context); - return IgnorePointer( - ignoring: widget.loading, - child: GestureDetector( - onTapDown: (TapDownDetails tap) { - _animationController.reverse(from: 1.0); - }, - onTapUp: (TapUpDetails tap) { - _animationController.forward(); - }, - onTapCancel: () { - _animationController.forward(); - }, - onTap: () => { - widget.disabled ? null : widget.onTap(), - }, - // onTap: widget.disabled?null:Feedback.wrapForTap(widget.onTap, context), - behavior: HitTestBehavior.opaque, - child: Transform.scale( - scale: _buttonSize, - child: Container( - decoration: BoxDecoration( - border: widget.borderColor != null - ? Border.all( - color: widget.borderColor.withOpacity(0.1), width: 2.0) - : null, - borderRadius: BorderRadius.all(Radius.circular(100.0)), - boxShadow: [ - BoxShadow( - color: Color.fromRGBO(0, 0, 0, 0.04), - spreadRadius: -0.0, - offset: Offset(0, 4.0), - blurRadius: 18.0) - ], - ), - child: ClipRRect( - borderRadius: widget.noBorderRadius - ? BorderRadius.all(Radius.circular(0.0)) - : BorderRadius.all(Radius.circular(10.0)), - child: Stack( - children: [ - Positioned( - left: 0, - bottom: 0, - child: Container( - width: MediaQuery.of(context).size.width, - height: 100, - decoration: BoxDecoration( - color: widget.disabled - ? Colors.grey - : widget.color ?? Theme.of(context).buttonColor), - ), - ), - Positioned( - left: -MediaQuery.of(context).size.width * 2.2 / 1.8, - bottom: -MediaQuery.of(context).size.width * 2.2 / 1.8, - child: Transform.scale( - scale: widget.disabled != null ? _rippleSize : 1.0, - child: Container( - width: MediaQuery.of(context).size.width * 2.2, - height: MediaQuery.of(context).size.width * 2.2, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: widget.disabled - ? Colors.grey - : widget.color ?? Theme.of(context).buttonColor, - ), - ), - ), - ), - Container( - padding: widget.iconOnly - ? EdgeInsets.symmetric(vertical: 4.0, horizontal: 5.0) - : EdgeInsets.only( - top: widget.small ? 8.0 : 14.0, - bottom: widget.small ? 6.0 : 14.0, - left: 18.0, - right: 18.0), - child: Stack( - children: [ - Positioned( - child: _buildIcon(), - ), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.max, - children: [ - widget.loading - ? Padding( - padding: EdgeInsets.all(2.6), - child: SizedBox( - height: 19.0, - width: 19.0, - child: CircularProgressIndicator( - backgroundColor: Colors.white, - valueColor: - AlwaysStoppedAnimation( - Colors.grey[300], - ), - ), - ), - ) - : Padding( - padding: EdgeInsets.only( - bottom: widget.small ? 4.0 : 3.0), - child: Text( - widget.label, - style: TextStyle( - color: widget.textColor, - fontSize: 16, - fontWeight: FontWeight.w700, - fontFamily: 'Poppins'), - ), - ) - ], - ) - ], - ), - ), - ], - ), - ), - ), - ), - ), - ); - } -}