TF-1813 Support RichText in confirm dialog
(cherry picked from commit cabaf34f1a7c7281b933a157f2edb91dba9faefa)
This commit is contained in:
+24
-7
@@ -19,8 +19,9 @@ class ConfirmationDialogActionSheetBuilder {
|
||||
TextStyle? _styleConfirmButton;
|
||||
TextStyle? _styleCancelButton;
|
||||
TextStyle? _styleMessage;
|
||||
List<TextSpan>? listTextSpan;
|
||||
|
||||
ConfirmationDialogActionSheetBuilder(this._context);
|
||||
ConfirmationDialogActionSheetBuilder(this._context, {this.listTextSpan});
|
||||
|
||||
void onConfirmAction(String confirmText, OnConfirmActionClick onConfirmActionClick) {
|
||||
_onConfirmActionClick = onConfirmActionClick;
|
||||
@@ -54,20 +55,36 @@ class ConfirmationDialogActionSheetBuilder {
|
||||
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
|
||||
builder: (context) => PointerInterceptor(child: CupertinoActionSheet(
|
||||
actions: [
|
||||
Container(
|
||||
if (_messageText != null && _messageText!.isNotEmpty)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
|
||||
color: Colors.white,
|
||||
child: MouseRegion(
|
||||
cursor: BuildUtils.isWeb ? MaterialStateMouseCursor.clickable : MouseCursor.defer,
|
||||
child: CupertinoActionSheetAction(
|
||||
child: Text(
|
||||
_messageText ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
style: _styleMessage ?? const TextStyle(fontSize: 14, color: AppColor.colorMessageConfirmDialog)),
|
||||
onPressed: () => {},
|
||||
),
|
||||
)
|
||||
)
|
||||
else if (listTextSpan != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 10),
|
||||
color: Colors.white,
|
||||
child: MouseRegion(
|
||||
cursor: BuildUtils.isWeb ? MaterialStateMouseCursor.clickable : MouseCursor.defer,
|
||||
child: CupertinoActionSheetAction(
|
||||
child: Text(
|
||||
_messageText ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
style: _styleMessage ?? const TextStyle(fontSize: 14, color: AppColor.colorMessageConfirmDialog)),
|
||||
child: RichText(text: TextSpan(
|
||||
style: _styleMessage ?? const TextStyle(fontSize: 14, color: AppColor.colorMessageConfirmDialog),
|
||||
children: listTextSpan
|
||||
)),
|
||||
onPressed: () => {},
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Colors.white,
|
||||
child: MouseRegion(
|
||||
|
||||
@@ -23,6 +23,7 @@ class ConfirmDialogBuilder {
|
||||
TextStyle? _styleTitle;
|
||||
TextStyle? _styleContent;
|
||||
double? _radiusButton;
|
||||
double? heightButton;
|
||||
EdgeInsets? _paddingTitle;
|
||||
EdgeInsets? _paddingContent;
|
||||
EdgeInsets? _paddingButton;
|
||||
@@ -34,6 +35,7 @@ class ConfirmDialogBuilder {
|
||||
Alignment? _alignment;
|
||||
Color? _backgroundColor;
|
||||
bool showAsBottomSheet;
|
||||
List<TextSpan>? listTextSpan;
|
||||
|
||||
OnConfirmButtonAction? _onConfirmButtonAction;
|
||||
OnCancelButtonAction? _onCancelButtonAction;
|
||||
@@ -41,7 +43,11 @@ class ConfirmDialogBuilder {
|
||||
|
||||
ConfirmDialogBuilder(
|
||||
this._imagePath,
|
||||
{this.showAsBottomSheet = false}
|
||||
{
|
||||
this.showAsBottomSheet = false,
|
||||
this.listTextSpan,
|
||||
this.heightButton,
|
||||
}
|
||||
);
|
||||
|
||||
void key(Key key) {
|
||||
@@ -116,7 +122,7 @@ class ConfirmDialogBuilder {
|
||||
_heightDialog = value;
|
||||
}
|
||||
|
||||
void aligment(Alignment? alignment) {
|
||||
void alignment(Alignment? alignment) {
|
||||
_alignment = alignment;
|
||||
}
|
||||
|
||||
@@ -204,6 +210,19 @@ class ConfirmDialogBuilder {
|
||||
style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog)
|
||||
),
|
||||
),
|
||||
)
|
||||
else if (listTextSpan != null)
|
||||
Padding(
|
||||
padding: _paddingContent ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
||||
child: Center(
|
||||
child: RichText(
|
||||
textAlign: TextAlign.center,
|
||||
text: TextSpan(
|
||||
style: _styleContent ?? const TextStyle(fontSize: 17.0, color: AppColor.colorMessageDialog),
|
||||
children: listTextSpan
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: _paddingButton ?? const EdgeInsets.only(bottom: 16, left: 16, right: 16),
|
||||
@@ -214,6 +233,7 @@ class ConfirmDialogBuilder {
|
||||
name: _cancelText,
|
||||
bgColor: _colorCancelButton,
|
||||
radius: _radiusButton,
|
||||
height: heightButton,
|
||||
textStyle: _styleTextCancelButton,
|
||||
action: _onCancelButtonAction)),
|
||||
if (_confirmText.isNotEmpty && _cancelText.isNotEmpty) const SizedBox(width: 16),
|
||||
@@ -222,6 +242,7 @@ class ConfirmDialogBuilder {
|
||||
name: _confirmText,
|
||||
bgColor: _colorConfirmButton,
|
||||
radius: _radiusButton,
|
||||
height: heightButton,
|
||||
textStyle: _styleTextConfirmButton,
|
||||
action: _onConfirmButtonAction))
|
||||
]
|
||||
@@ -231,11 +252,16 @@ class ConfirmDialogBuilder {
|
||||
}
|
||||
|
||||
Widget _buildButton({
|
||||
String? name, TextStyle? textStyle, Color? bgColor, double? radius, Function? action
|
||||
String? name,
|
||||
TextStyle? textStyle,
|
||||
Color? bgColor,
|
||||
double? radius,
|
||||
double? height,
|
||||
Function? action
|
||||
}) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
height: height ?? 48,
|
||||
child: ElevatedButton(
|
||||
onPressed: () => action?.call(),
|
||||
style: ButtonStyle(
|
||||
|
||||
Reference in New Issue
Block a user