Fix size Discard Changes button in dialog composer
This commit is contained in:
@@ -34,6 +34,8 @@ class ConfirmDialogBuilder {
|
|||||||
Color? _backgroundColor;
|
Color? _backgroundColor;
|
||||||
bool showAsBottomSheet;
|
bool showAsBottomSheet;
|
||||||
List<TextSpan>? listTextSpan;
|
List<TextSpan>? listTextSpan;
|
||||||
|
int? titleActionButtonMaxLines;
|
||||||
|
bool isArrangeActionButtonsVertical;
|
||||||
|
|
||||||
OnConfirmButtonAction? _onConfirmButtonAction;
|
OnConfirmButtonAction? _onConfirmButtonAction;
|
||||||
OnCancelButtonAction? _onCancelButtonAction;
|
OnCancelButtonAction? _onCancelButtonAction;
|
||||||
@@ -45,6 +47,8 @@ class ConfirmDialogBuilder {
|
|||||||
this.showAsBottomSheet = false,
|
this.showAsBottomSheet = false,
|
||||||
this.listTextSpan,
|
this.listTextSpan,
|
||||||
this.maxWith = double.infinity,
|
this.maxWith = double.infinity,
|
||||||
|
this.titleActionButtonMaxLines,
|
||||||
|
this.isArrangeActionButtonsVertical = false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -223,7 +227,32 @@ class ConfirmDialogBuilder {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
if (isArrangeActionButtonsVertical)
|
||||||
|
...[
|
||||||
|
if (_cancelText.isNotEmpty)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(top: 8, start: 16, end: 16),
|
||||||
|
child: _buildButton(
|
||||||
|
name: _cancelText,
|
||||||
|
bgColor: _colorCancelButton,
|
||||||
|
radius: _radiusButton,
|
||||||
|
textStyle: _styleTextCancelButton,
|
||||||
|
action: _onCancelButtonAction),
|
||||||
|
),
|
||||||
|
if (_confirmText.isNotEmpty)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.only(top: 8, start: 16, end: 16),
|
||||||
|
child: _buildButton(
|
||||||
|
name: _confirmText,
|
||||||
|
bgColor: _colorConfirmButton,
|
||||||
|
radius: _radiusButton,
|
||||||
|
textStyle: _styleTextConfirmButton,
|
||||||
|
action: _onConfirmButtonAction),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
]
|
||||||
|
else
|
||||||
|
Padding(
|
||||||
padding: _paddingButton ?? const EdgeInsetsDirectional.only(bottom: 16, start: 16, end: 16),
|
padding: _paddingButton ?? const EdgeInsetsDirectional.only(bottom: 16, start: 16, end: 16),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -254,27 +283,33 @@ class ConfirmDialogBuilder {
|
|||||||
TextStyle? textStyle,
|
TextStyle? textStyle,
|
||||||
Color? bgColor,
|
Color? bgColor,
|
||||||
double? radius,
|
double? radius,
|
||||||
Function? action
|
Function()? action
|
||||||
}) {
|
}) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
|
height: titleActionButtonMaxLines == 1 ? 45 : null,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () => action?.call(),
|
onPressed: action,
|
||||||
style: ButtonStyle(
|
style: ElevatedButton.styleFrom(
|
||||||
foregroundColor: MaterialStateProperty.resolveWith<Color>(
|
foregroundColor: bgColor ?? AppColor.colorTextButton,
|
||||||
(Set<MaterialState> states) => bgColor ?? AppColor.colorTextButton),
|
backgroundColor: bgColor ?? AppColor.colorTextButton,
|
||||||
backgroundColor: MaterialStateProperty.resolveWith<Color>(
|
shape: RoundedRectangleBorder(
|
||||||
(Set<MaterialState> states) => bgColor ?? AppColor.colorTextButton),
|
borderRadius: BorderRadius.circular(radius ?? 8),
|
||||||
shape: MaterialStateProperty.all(RoundedRectangleBorder(
|
side: BorderSide(width: 0, color: bgColor ?? AppColor.colorTextButton),
|
||||||
borderRadius: BorderRadius.circular(radius ?? 8),
|
),
|
||||||
side: BorderSide(width: 0, color: bgColor ?? AppColor.colorTextButton),
|
padding: const EdgeInsets.all(8),
|
||||||
)),
|
elevation: 0
|
||||||
padding: MaterialStateProperty.resolveWith<EdgeInsets>((Set<MaterialState> states) => const EdgeInsets.all(8)),
|
),
|
||||||
elevation: MaterialStateProperty.resolveWith<double>((Set<MaterialState> states) => 0)),
|
child: Text(
|
||||||
child: Text(name ?? '',
|
name ?? '',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: textStyle ?? const TextStyle(fontSize: 17, fontWeight: FontWeight.w500, color: Colors.white)),
|
maxLines: titleActionButtonMaxLines,
|
||||||
)
|
style: textStyle ?? const TextStyle(
|
||||||
|
fontSize: 17,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Colors.white
|
||||||
|
)),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ mixin MessageDialogActionMixin {
|
|||||||
Color? cancelButtonColor,
|
Color? cancelButtonColor,
|
||||||
EdgeInsetsGeometry? marginIcon,
|
EdgeInsetsGeometry? marginIcon,
|
||||||
PopInvokedCallback? onPopInvoked,
|
PopInvokedCallback? onPopInvoked,
|
||||||
|
bool isArrangeActionButtonsVertical = false,
|
||||||
|
int? titleActionButtonMaxLines,
|
||||||
}
|
}
|
||||||
) async {
|
) async {
|
||||||
final responsiveUtils = Get.find<ResponsiveUtils>();
|
final responsiveUtils = Get.find<ResponsiveUtils>();
|
||||||
@@ -41,7 +43,12 @@ mixin MessageDialogActionMixin {
|
|||||||
|
|
||||||
if (alignCenter) {
|
if (alignCenter) {
|
||||||
final childWidget = PointerInterceptor(
|
final childWidget = PointerInterceptor(
|
||||||
child: (ConfirmDialogBuilder(imagePaths, listTextSpan: listTextSpan)
|
child: (ConfirmDialogBuilder(
|
||||||
|
imagePaths,
|
||||||
|
listTextSpan: listTextSpan,
|
||||||
|
titleActionButtonMaxLines: titleActionButtonMaxLines,
|
||||||
|
isArrangeActionButtonsVertical: isArrangeActionButtonsVertical
|
||||||
|
)
|
||||||
..key(const Key('confirm_dialog_action'))
|
..key(const Key('confirm_dialog_action'))
|
||||||
..title(title ?? '')
|
..title(title ?? '')
|
||||||
..content(message)
|
..content(message)
|
||||||
@@ -92,7 +99,9 @@ mixin MessageDialogActionMixin {
|
|||||||
imagePaths,
|
imagePaths,
|
||||||
showAsBottomSheet: true,
|
showAsBottomSheet: true,
|
||||||
listTextSpan: listTextSpan,
|
listTextSpan: listTextSpan,
|
||||||
maxWith: responsiveUtils.getSizeScreenShortestSide(context) - 16
|
maxWith: responsiveUtils.getSizeScreenShortestSide(context) - 16,
|
||||||
|
titleActionButtonMaxLines: titleActionButtonMaxLines,
|
||||||
|
isArrangeActionButtonsVertical: isArrangeActionButtonsVertical
|
||||||
)
|
)
|
||||||
..key(const Key('confirm_dialog_action'))
|
..key(const Key('confirm_dialog_action'))
|
||||||
..title(title ?? '')
|
..title(title ?? '')
|
||||||
@@ -168,7 +177,12 @@ mixin MessageDialogActionMixin {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final childWidget = PointerInterceptor(
|
final childWidget = PointerInterceptor(
|
||||||
child: (ConfirmDialogBuilder(imagePaths, listTextSpan: listTextSpan)
|
child: (ConfirmDialogBuilder(
|
||||||
|
imagePaths,
|
||||||
|
listTextSpan: listTextSpan,
|
||||||
|
titleActionButtonMaxLines: titleActionButtonMaxLines,
|
||||||
|
isArrangeActionButtonsVertical: isArrangeActionButtonsVertical
|
||||||
|
)
|
||||||
..key(const Key('confirm_dialog_action'))
|
..key(const Key('confirm_dialog_action'))
|
||||||
..title(title ?? '')
|
..title(title ?? '')
|
||||||
..content(message)
|
..content(message)
|
||||||
|
|||||||
@@ -1923,6 +1923,8 @@ class ComposerController extends BaseController with DragDropFileMixin {
|
|||||||
alignCenter: true,
|
alignCenter: true,
|
||||||
outsideDismissible: false,
|
outsideDismissible: false,
|
||||||
autoPerformPopBack: false,
|
autoPerformPopBack: false,
|
||||||
|
titleActionButtonMaxLines: 1,
|
||||||
|
isArrangeActionButtonsVertical: true,
|
||||||
usePopScope: true,
|
usePopScope: true,
|
||||||
onConfirmAction: () => _handleSaveMessageToDraft(context),
|
onConfirmAction: () => _handleSaveMessageToDraft(context),
|
||||||
onCancelAction: () {
|
onCancelAction: () {
|
||||||
|
|||||||
Reference in New Issue
Block a user