From 0489e9584f6b345f0d6bb7b80ac5f1eac9d96d7f Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Mon, 23 Aug 2021 12:49:00 +0300 Subject: [PATCH 1/3] fix login issue --- lib/config/config.dart | 4 +-- lib/config/shared_pref_kay.dart | 31 ++++++++++--------- .../model/auth/activation_Code_req_model.dart | 5 ++- ...on_code_for_verification_screen_model.dart | 5 ++- .../check_activation_code_request_model.dart | 5 ++- .../viewModel/authentication_view_model.dart | 3 ++ 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index d5086b5b..d0ff0df9 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -const BASE_URL = 'https://hmgwebservices.com/'; -// const BASE_URL = 'https://uat.hmgwebservices.com/'; +// const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index 784c8fff..628f5a0e 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -1,15 +1,16 @@ -final TOKEN = 'token'; -final PROJECT_ID = 'projectID'; -final VIDA_AUTH_TOKEN_ID = 'VidaAuthTokenID'; -final VIDA_REFRESH_TOKEN_ID = 'VidaRefreshTokenID'; -final LOGIN_TOKEN_ID = 'LogInToken'; -final DOCTOR_ID = 'doctorID'; -final SLECTED_PATIENT_TYPE = 'slectedPatientType'; -final APP_Language = 'language'; -final DOCTOR_PROFILE = 'doctorProfile'; -final LIVE_CARE_PATIENT = 'livecare-patient-profile'; -final LOGGED_IN_USER = 'loggedUser'; -final DASHBOARD_DATA = 'dashboard-data'; -final OTP_TYPE = 'otp-type'; -final LAST_LOGIN_USER = 'last-login-user'; -final CLINIC_NAME = 'clinic-name'; +const TOKEN = 'token'; +const PROJECT_ID = 'projectID'; +const VIDA_AUTH_TOKEN_ID = 'VidaAuthTokenID'; +const VIDA_REFRESH_TOKEN_ID = 'VidaRefreshTokenID'; +const LOGIN_TOKEN_ID = 'LogInToken'; +const DOCTOR_ID = 'doctorID'; +const SLECTED_PATIENT_TYPE = 'slectedPatientType'; +const APP_Language = 'language'; +const DOCTOR_PROFILE = 'doctorProfile'; +const LIVE_CARE_PATIENT = 'livecare-patient-profile'; +const LOGGED_IN_USER = 'loggedUser'; +const EMPLOYEE_ID = 'EmployeeID'; +const DASHBOARD_DATA = 'dashboard-data'; +const OTP_TYPE = 'otp-type'; +const LAST_LOGIN_USER = 'last-login-user'; +const CLINIC_NAME = 'clinic-name'; diff --git a/lib/core/model/auth/activation_Code_req_model.dart b/lib/core/model/auth/activation_Code_req_model.dart index 73c97242..85d7f1d3 100644 --- a/lib/core/model/auth/activation_Code_req_model.dart +++ b/lib/core/model/auth/activation_Code_req_model.dart @@ -1,6 +1,7 @@ class ActivationCodeModel { int channel; int languageID; + int loginDoctorID; double versionID; int memberID; int facilityId; @@ -14,7 +15,7 @@ class ActivationCodeModel { this.memberID, this.facilityId, this.otpSendType, - this.generalid}); + this.generalid,this.loginDoctorID}); ActivationCodeModel.fromJson(Map json) { channel = json['Channel']; @@ -24,6 +25,7 @@ class ActivationCodeModel { facilityId = json['facilityId']; otpSendType = json['OTP_SendType']; generalid = json['generalid']; + loginDoctorID = json['LoginDoctorID']; } Map toJson() { @@ -35,6 +37,7 @@ class ActivationCodeModel { data['facilityId'] = this.facilityId; data['OTP_SendType'] = otpSendType; data['generalid'] = this.generalid; + data['LoginDoctorID'] = this.loginDoctorID; return data; } } diff --git a/lib/core/model/auth/activation_code_for_verification_screen_model.dart b/lib/core/model/auth/activation_code_for_verification_screen_model.dart index a261ce46..dae31f8c 100644 --- a/lib/core/model/auth/activation_code_for_verification_screen_model.dart +++ b/lib/core/model/auth/activation_code_for_verification_screen_model.dart @@ -3,6 +3,7 @@ class ActivationCodeForVerificationScreenModel { String mobileNumber; String zipCode; int channel; + int loginDoctorID; int languageID; double versionID; int memberID; @@ -25,7 +26,7 @@ class ActivationCodeForVerificationScreenModel { this.isMobileFingerPrint, this.vidaAuthTokenID, this.vidaRefreshTokenID, - this.iMEI}); + this.iMEI,this.loginDoctorID}); ActivationCodeForVerificationScreenModel.fromJson(Map json) { oTPSendType = json['OTP_SendType']; @@ -41,6 +42,7 @@ class ActivationCodeForVerificationScreenModel { vidaAuthTokenID = json['VidaAuthTokenID']; vidaRefreshTokenID = json['VidaRefreshTokenID']; iMEI = json['IMEI']; + loginDoctorID = json['LoginDoctorID']; } Map toJson() { @@ -56,6 +58,7 @@ class ActivationCodeForVerificationScreenModel { data['generalid'] = this.generalid; data['IsMobileFingerPrint'] = this.isMobileFingerPrint; data['IMEI'] = this.iMEI; + data['LoginDoctorID'] = this.loginDoctorID; return data; } } diff --git a/lib/core/model/auth/check_activation_code_request_model.dart b/lib/core/model/auth/check_activation_code_request_model.dart index c247a4fc..94502a71 100644 --- a/lib/core/model/auth/check_activation_code_request_model.dart +++ b/lib/core/model/auth/check_activation_code_request_model.dart @@ -3,6 +3,7 @@ class CheckActivationCodeRequestModel { String zipCode; int doctorID; int memberID; + int loginDoctorID; String password; String facilityId; String iPAdress; @@ -32,7 +33,7 @@ class CheckActivationCodeRequestModel { this.activationCode, this.vidaAuthTokenID, this.vidaRefreshTokenID, - this.oTPSendType,this.password,this.facilityId,this.memberID,this.isForSilentLogin=false,this.iMEI}); + this.oTPSendType,this.password,this.facilityId,this.memberID,this.isForSilentLogin=false,this.iMEI,this.loginDoctorID}); CheckActivationCodeRequestModel.fromJson(Map json) { mobileNumber = json['MobileNumber']; @@ -49,6 +50,7 @@ class CheckActivationCodeRequestModel { vidaAuthTokenID = json['VidaAuthTokenID']; vidaRefreshTokenID = json['VidaRefreshTokenID']; oTPSendType = json['OTP_SendType']; + loginDoctorID = json['LoginDoctorID']; } Map toJson() { @@ -72,6 +74,7 @@ class CheckActivationCodeRequestModel { data['Password'] = this.password; data['IMEI'] = this.iMEI; data['IsForSilentLogin'] = this.isForSilentLogin; + data['LoginDoctorID'] = this.loginDoctorID; return data; } } diff --git a/lib/core/viewModel/authentication_view_model.dart b/lib/core/viewModel/authentication_view_model.dart index 217b7b58..3641ba6d 100644 --- a/lib/core/viewModel/authentication_view_model.dart +++ b/lib/core/viewModel/authentication_view_model.dart @@ -142,6 +142,7 @@ class AuthenticationViewModel extends BaseViewModel { iMEI: user.iMEI, facilityId: user.projectID, memberID: user.doctorID, + loginDoctorID: user.doctorID, zipCode: user.outSA == true ? '971' : '966', mobileNumber: user.mobile, oTPSendType: authMethodType.getTypeIdService(), @@ -163,6 +164,7 @@ class AuthenticationViewModel extends BaseViewModel { ActivationCodeModel activationCodeModel = ActivationCodeModel( facilityId: projectID, memberID: loggedUser.listMemberInformation[0].memberID, + loginDoctorID: loggedUser.listMemberInformation[0].employeeID, otpSendType: authMethodType.getTypeIdService().toString(), ); await _authService.sendActivationCodeForDoctorApp(activationCodeModel); @@ -196,6 +198,7 @@ class AuthenticationViewModel extends BaseViewModel { facilityId:userInfo.projectID!=null? userInfo.projectID.toString():user.projectID.toString(), oTPSendType: await sharedPref.getInt(OTP_TYPE), iMEI: localToken, + loginDoctorID:userInfo.userID!=null? int.parse(userInfo.userID):user.doctorID,// loggedUser.listMemberInformation[0].employeeID, isForSilentLogin:isSilentLogin, generalid: "Cs2020@2016\$2958"); await _authService.checkActivationCodeForDoctorApp(checkActivationCodeForDoctorApp); From 1712874c87943bfaa8ce88a702b4459dea93ea3b Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Mon, 23 Aug 2021 14:12:50 +0300 Subject: [PATCH 2/3] fix show count in home page --- lib/config/localized_values.dart | 2 +- lib/screens/doctor/doctor_repaly_chat.dart | 40 +++++++++++-------- lib/screens/patients/InPatientPage.dart | 3 ++ .../patient_profile_screen.dart | 14 +++++-- 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 6500c10e..665563db 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -665,7 +665,7 @@ const Map> localizedValues = { 'noteVerify': {'en': 'Verify', 'ar': 'تحقق'}, 'noteConfirm': {'en': 'Confirm', 'ar': 'تاكيد'}, 'noteAdd': {'en': 'Add ', 'ar': 'اضف '}, - 'noteUpdateْْ': {'en': 'Update ', 'ar': 'تحديت'}, + 'noteUpdate': {'en': 'Update ', 'ar': 'تحديت'}, 'orderSheet': {'en': 'Order Sheet', 'ar': 'ورقة الطلب'}, 'order': {'en': 'Order', 'ar': 'الطلب'}, 'sheet': {'en': 'Sheet', 'ar': 'ورقة'}, diff --git a/lib/screens/doctor/doctor_repaly_chat.dart b/lib/screens/doctor/doctor_repaly_chat.dart index afe8e750..c3b58806 100644 --- a/lib/screens/doctor/doctor_repaly_chat.dart +++ b/lib/screens/doctor/doctor_repaly_chat.dart @@ -148,7 +148,7 @@ class DoctorReplayChat extends StatelessWidget { child: AppText( reply.patientName .toString(), - fontSize: 14, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontFamily: 'Poppins', color: Colors.white, fontWeight: FontWeight.bold, @@ -170,7 +170,7 @@ class DoctorReplayChat extends StatelessWidget { ], ), Column( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.end, children: [ AppText( @@ -178,11 +178,11 @@ class DoctorReplayChat extends StatelessWidget { fontWeight: FontWeight .w500, color: Colors.white, - fontSize: 14, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *2.8, ), AppText( reply.createdOn !=null?AppDateUtils.getHour(AppDateUtils.getDateTimeFromServerFormat(reply.createdOn)):AppDateUtils.getHour(DateTime.now()), - fontSize: 14, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *2.8, fontFamily: 'Poppins', color: Colors.white, // fontSize: 18 @@ -223,6 +223,7 @@ class DoctorReplayChat extends StatelessWidget { SizedBox(height: 30,), SizedBox(height: 30,), + if(reply.doctorResponse != null && reply.doctorResponse.isNotEmpty) Align( alignment: Alignment.centerRight, child: Container( @@ -267,7 +268,7 @@ class DoctorReplayChat extends StatelessWidget { width: MediaQuery.of(context).size.width * 0.35, child: AppText( previousModel.doctorProfile.doctorName, - fontSize: 14, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, fontFamily: 'Poppins', color: Color(0xFF2B353E), fontWeight: FontWeight.bold, @@ -278,18 +279,18 @@ class DoctorReplayChat extends StatelessWidget { ], ), Column( - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.end, children: [ AppText( reply.createdOn !=null?AppDateUtils.getDayMonthYearDateFormatted(AppDateUtils.getDateTimeFromServerFormat(reply.createdOn)):AppDateUtils.getDayMonthYearDateFormatted(DateTime.now()), fontWeight: FontWeight .w500, color: Color(0xFF2B353E), - fontSize: 14, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *2.8, ), AppText( reply.createdOn !=null?AppDateUtils.getHour(AppDateUtils.getDateTimeFromServerFormat(reply.createdOn)):AppDateUtils.getHour(DateTime.now()), - fontSize: 14, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *2.8, fontFamily: 'Poppins', color: Color(0xFF2B353E), // fontSize: 18 @@ -358,16 +359,23 @@ class DoctorReplayChat extends StatelessWidget { suffixIcon: FontAwesomeIcons.arrowRight, suffixIconColor: Colors.green, onSuffixTap: ()async { - GifLoaderDialogUtils.showMyDialog(context); - await previousModel.createDoctorResponse(msgController.text, reply); - if(previousModel.state == ViewState.ErrorLocal) { - Helpers.showErrorToast(previousModel.error); + + if(msgController.text.isEmpty){ + Helpers.showErrorToast("Please Add Doctor Reply"); + return; } else { - DrAppToastMsg.showSuccesToast("Thank you for your replay "); - await previousModel.getDoctorReply(); - Navigator.pop(context); + GifLoaderDialogUtils.showMyDialog(context); + await previousModel.createDoctorResponse(msgController.text, reply); + if(previousModel.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(previousModel.error); + } else { + DrAppToastMsg.showSuccesToast("Thank you for your replay "); + await previousModel.getDoctorReply(); + Navigator.pop(context); + } + GifLoaderDialogUtils.hideDialog(context); } - GifLoaderDialogUtils.hideDialog(context); + diff --git a/lib/screens/patients/InPatientPage.dart b/lib/screens/patients/InPatientPage.dart index ffc3d03f..0c0d548d 100644 --- a/lib/screens/patients/InPatientPage.dart +++ b/lib/screens/patients/InPatientPage.dart @@ -161,6 +161,9 @@ class _InPatientPageState extends State { "isSearch": false, "isInpatient": true, "arrivalType": "1", + "isMyPatient":widget.patientSearchViewModel.filteredInPatientItems[index] + .doctorId == + widget.patientSearchViewModel.doctorProfile.doctorID, }); }, ); 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 56dc848f..eec42b86 100644 --- a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart +++ b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart @@ -39,6 +39,7 @@ class _PatientProfileScreenState extends State with Single bool isFromLiveCare = false; bool isInpatient = false; + bool isMyPatient = false; bool isCallFinished = false; bool isDischargedPatient = false; bool isSearchAndOut = false; @@ -97,6 +98,9 @@ class _PatientProfileScreenState extends State with Single if (routeArgs.containsKey("isCallFinished")) { isCallFinished = routeArgs['isCallFinished']; } + if (routeArgs.containsKey("isMyPatient")) { + isMyPatient = routeArgs['isMyPatient']; + } if (isInpatient) _activeTab = 0; else @@ -132,7 +136,9 @@ class _PatientProfileScreenState extends State with Single if (isFromLiveCare && patient.patientStatus == 1) await model.addPatientToDoctorList(patient.vcId); }, builder: (_, model, w) => AppScaffold( + baseViewModel: model, + appBarTitle: TranslationBase.of(context).patientProfile, isShowAppBar: false, body: Column( @@ -198,11 +204,13 @@ class _PatientProfileScreenState extends State with Single ), ], ), - if ( isInpatient? true:isFromLiveCare + if ( (isInpatient && isMyPatient )? true:isFromLiveCare ? patient.episodeNo != null : patient.patientStatusType != null && patient.patientStatusType == 43) BaseView( - onModelReady: (model) async {}, + onModelReady: (model) async { + model.getDoctorProfile(); + }, builder: (_, model, w) => Positioned( top: 180, left: 20, @@ -253,7 +261,7 @@ class _PatientProfileScreenState extends State with Single AppButton( title: "${TranslationBase.of(context).update}\n${TranslationBase.of(context).episode}", - color: isInpatient || isFromLiveCare + color: (isInpatient &&isMyPatient ) || isFromLiveCare ? Colors.red.shade700 : patient.patientStatusType == 43 ? Colors.red.shade700 From 0fb4b4a8902b5e331d2444e6bfd9688c2ce4cbeb Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 23 Aug 2021 14:52:47 +0300 Subject: [PATCH 3/3] add copy to selected texts --- lib/config/localized_values.dart | 1 + lib/util/translations_delegate_base.dart | 1 + .../profile/patient-profile-app-bar.dart | 45 ++-- lib/widgets/shared/app_texts_widget.dart | 231 +++++++++++------- 4 files changed, 166 insertions(+), 112 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 6500c10e..236fb6d4 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -708,5 +708,6 @@ const Map> localizedValues = { "inProgress": {"en": "inProgress", "ar": "تحت المعالجه"}, "Completed": {"en": "Completed", "ar": "مكتمل"}, "Locked": {"en": "Locked", "ar": "مقفل"}, + "textCopiedSuccessfully": {"en": "Text copied successfully", "ar": "تم نسخ النص بنجاح"}, }; diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 2e8d10c9..e104a01e 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -1370,6 +1370,7 @@ class TranslationBase { String get edit => localizedValues['edit'][locale.languageCode]; String get summeryReply => localizedValues['summeryReply'][locale.languageCode]; String get severityValidationError => localizedValues['severityValidationError'][locale.languageCode]; + String get textCopiedSuccessfully => localizedValues['textCopiedSuccessfully'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/patients/profile/patient-profile-app-bar.dart b/lib/widgets/patients/profile/patient-profile-app-bar.dart index 9916ae3e..5901f9b8 100644 --- a/lib/widgets/patients/profile/patient-profile-app-bar.dart +++ b/lib/widgets/patients/profile/patient-profile-app-bar.dart @@ -191,32 +191,25 @@ class PatientProfileAppBar extends StatelessWidget Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - RichText( - text: TextSpan( - style: TextStyle( - fontSize: 1.6 * SizeConfig.textMultiplier, - color: Colors.black), - children: [ - new TextSpan( - text: TranslationBase - .of(context) - .fileNumber, - - style: TextStyle( - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, - fontFamily: 'Poppins', - color: Color(0xFF575757), - fontWeight: FontWeight.w600, - - ),), - new TextSpan( - text: patient.patientId.toString(), - style: TextStyle( - fontWeight: FontWeight.w700, - fontFamily: 'Poppins', - fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, color: Color(0xFF2E303A),)), - ], - ), + Row( + children: [ + AppText( + TranslationBase + .of(context) + .fileNumber, + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3, + color: Color(0xFF575757), + fontWeight: FontWeight.w600, + ), + SizedBox(width: 1,), + AppText( + patient.patientId.toString(), + fontSize: SizeConfig.getTextMultiplierBasedOnWidth() *3.5, + color: Color(0xFF2E303A), + fontWeight: FontWeight.w700, + isCopyable: true, + ), + ], ), Row( children: [ diff --git a/lib/widgets/shared/app_texts_widget.dart b/lib/widgets/shared/app_texts_widget.dart index 4bf89d4e..89c69736 100644 --- a/lib/widgets/shared/app_texts_widget.dart +++ b/lib/widgets/shared/app_texts_widget.dart @@ -1,6 +1,9 @@ import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:hexcolor/hexcolor.dart'; class AppText extends StatefulWidget { @@ -30,6 +33,7 @@ class AppText extends StatefulWidget { final bool visibility; final TextOverflow textOverflow; final TextDecoration textDecoration; + final bool isCopyable; AppText( this.text, { @@ -56,7 +60,9 @@ class AppText extends StatefulWidget { this.allowExpand = true, this.visibility = true, this.textOverflow, - this.textDecoration, this.letterSpacing, + this.textDecoration, + this.letterSpacing, + this.isCopyable = true, }); @override @@ -92,96 +98,149 @@ class _AppTextState extends State { @override Widget build(BuildContext context) { - return Container( - margin: widget.margin != null - ? EdgeInsets.all(widget.margin) - : EdgeInsets.only( - top: widget.marginTop, - right: widget.marginRight, - bottom: widget.marginBottom, - left: widget.marginLeft), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Stack( - children: [ - Text( - !hidden - ? text - : (text.substring( - 0, - text.length > widget.maxLength - ? widget.maxLength - : text.length)), - textAlign: widget.textAlign, - overflow: widget.maxLines != null - ? ((widget.maxLines > 1) - ? TextOverflow.fade - : TextOverflow.ellipsis) - : null, - maxLines: widget.maxLines ?? null, - style: widget.style != null - ? _getFontStyle().copyWith( - fontStyle: widget.italic ? FontStyle.italic : null, - color: widget.color, - fontWeight: widget.fontWeight ?? _getFontWeight(), - height: widget.fontHeight) - : TextStyle( - fontStyle: widget.italic ? FontStyle.italic : null, - color: - widget.color != null ? widget.color : Colors.black, - fontSize: widget.fontSize ?? _getFontSize(), - letterSpacing: - widget.letterSpacing??(widget.variant == "overline" ? 1.5 : null), - fontWeight: widget.fontWeight ?? _getFontWeight(), - fontFamily: widget.fontFamily ?? 'Poppins', - decoration: widget.textDecoration, - height: widget.fontHeight), - ), - if (widget.readMore && text.length > widget.maxLength && hidden) - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Container( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - Theme.of(context).backgroundColor, - Theme.of(context).backgroundColor.withOpacity(0), - ], - begin: Alignment.bottomCenter, - end: Alignment.topCenter)), - height: 30, - ), - ) - ], - ), - if (widget.allowExpand && - widget.readMore && - text.length > widget.maxLength) - Padding( - padding: EdgeInsets.only(top: 8.0, right: 8.0, bottom: 8.0), - child: InkWell( - onTap: () { - setState(() { - hidden = !hidden; - }); - }, - child: Text(hidden ? "Read More" : "Read less", - style: _getFontStyle().copyWith( - color: HexColor('#FF0000'), - fontWeight: FontWeight.w800, - fontFamily: "Poppins", - )), - ), + return GestureDetector( + child: Container( + margin: widget.margin != null + ? EdgeInsets.all(widget.margin) + : EdgeInsets.only( + top: widget.marginTop, + right: widget.marginRight, + bottom: widget.marginBottom, + left: widget.marginLeft), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + _textWidget(), + if (widget.readMore && text.length > widget.maxLength && hidden) + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context).backgroundColor, + Theme.of(context).backgroundColor.withOpacity(0), + ], + begin: Alignment.bottomCenter, + end: Alignment.topCenter)), + height: 30, + ), + ) + ], ), - ], + if (widget.allowExpand && + widget.readMore && + text.length > widget.maxLength) + Padding( + padding: EdgeInsets.only(top: 8.0, right: 8.0, bottom: 8.0), + child: InkWell( + onTap: () { + setState(() { + hidden = !hidden; + }); + }, + child: Text(hidden ? "Read More" : "Read less", + style: _getFontStyle().copyWith( + color: HexColor('#FF0000'), + fontWeight: FontWeight.w800, + fontFamily: "Poppins", + )), + ), + ), + ], + ), ), + // onLongPress: (){ + // if(widget.isCopyable){ + // DrAppToastMsg.showShortToast(TranslationBase.of(context).textCopiedSuccessfully); + // Clipboard.setData(new ClipboardData(text: widget.text)); + // } + // }, ); } + Widget _textWidget() { + if (widget.isCopyable) { + return Theme( + data: ThemeData( + textSelectionColor: Colors.lightBlueAccent, + ), + child: Container( + child: SelectableText( + !hidden + ? text + : (text.substring( + 0, + text.length > widget.maxLength + ? widget.maxLength + : text.length)), + textAlign: widget.textAlign, + // overflow: widget.maxLines != null + // ? ((widget.maxLines > 1) + // ? TextOverflow.fade + // : TextOverflow.ellipsis) + // : null, + maxLines: widget.maxLines ?? null, + style: widget.style != null + ? _getFontStyle().copyWith( + fontStyle: widget.italic ? FontStyle.italic : null, + color: widget.color, + fontWeight: widget.fontWeight ?? _getFontWeight(), + height: widget.fontHeight) + : TextStyle( + fontStyle: widget.italic ? FontStyle.italic : null, + color: widget.color != null ? widget.color : Colors.black, + fontSize: widget.fontSize ?? _getFontSize(), + letterSpacing: widget.letterSpacing ?? + (widget.variant == "overline" ? 1.5 : null), + fontWeight: widget.fontWeight ?? _getFontWeight(), + fontFamily: widget.fontFamily ?? 'Poppins', + decoration: widget.textDecoration, + height: widget.fontHeight), + ), + ), + ); + } else { + return Text( + !hidden + ? text + : (text.substring( + 0, + text.length > widget.maxLength + ? widget.maxLength + : text.length)), + textAlign: widget.textAlign, + overflow: widget.maxLines != null + ? ((widget.maxLines > 1) + ? TextOverflow.fade + : TextOverflow.ellipsis) + : null, + maxLines: widget.maxLines ?? null, + style: widget.style != null + ? _getFontStyle().copyWith( + fontStyle: widget.italic ? FontStyle.italic : null, + color: widget.color, + fontWeight: widget.fontWeight ?? _getFontWeight(), + height: widget.fontHeight) + : TextStyle( + fontStyle: widget.italic ? FontStyle.italic : null, + color: widget.color != null ? widget.color : Colors.black, + fontSize: widget.fontSize ?? _getFontSize(), + letterSpacing: widget.letterSpacing ?? + (widget.variant == "overline" ? 1.5 : null), + fontWeight: widget.fontWeight ?? _getFontWeight(), + fontFamily: widget.fontFamily ?? 'Poppins', + decoration: widget.textDecoration, + height: widget.fontHeight), + ); + } + } + TextStyle _getFontStyle() { switch (widget.style) { case "headline2":