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":