TF-390 Apply new ui composer for browser
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef IconWebCallback = void Function();
|
||||
@@ -20,7 +21,7 @@ Widget buildIconWeb({
|
||||
iconSize: iconSize,
|
||||
padding: iconPadding ?? EdgeInsets.all(8.0),
|
||||
splashRadius: splashRadius ?? 20,
|
||||
tooltip: tooltip,
|
||||
tooltip: tooltip ?? '',
|
||||
onPressed: onTap)
|
||||
);
|
||||
}
|
||||
@@ -50,4 +51,47 @@ Widget buildIconWebHasPosition(BuildContext context, {
|
||||
child: icon,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget buildTextCircleButton(String text, {
|
||||
TextStyle? textStyle,
|
||||
IconWebCallback? onTap,
|
||||
}) {
|
||||
return Material(
|
||||
shape: CircleBorder(),
|
||||
color: Colors.transparent,
|
||||
child: TextButton(
|
||||
child: Text(
|
||||
text,
|
||||
style: textStyle ?? TextStyle(fontWeight: FontWeight.normal, fontSize: 15, color: AppColor.lineItemListColor)),
|
||||
style: ButtonStyle(
|
||||
overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => AppColor.colorFocusButton),
|
||||
shape: MaterialStateProperty.all(CircleBorder()),
|
||||
padding: MaterialStateProperty.resolveWith<EdgeInsets>((Set<MaterialState> states) => EdgeInsets.all(5)),
|
||||
elevation: MaterialStateProperty.resolveWith<double>((Set<MaterialState> states) => 0)),
|
||||
onPressed: () => onTap?.call()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildTextButton(String text, {
|
||||
TextStyle? textStyle,
|
||||
double? width,
|
||||
double? height,
|
||||
Color? backgroundColor,
|
||||
double? radius,
|
||||
IconWebCallback? onTap,
|
||||
}) {
|
||||
return SizedBox(
|
||||
width: width ?? double.infinity,
|
||||
height: height ?? 40,
|
||||
child: ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.resolveWith((states) => backgroundColor ?? AppColor.colorTextButton),
|
||||
elevation: MaterialStateProperty.resolveWith((states) => 0),
|
||||
shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(radius ?? 0)))),
|
||||
child: Text(text, style: textStyle ?? TextStyle(fontSize: 17, color: Colors.white, fontWeight: FontWeight.w500)),
|
||||
onPressed: () => onTap?.call()
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@ class ConfirmDialogBuilder {
|
||||
TextStyle? _styleTitle;
|
||||
TextStyle? _styleContent;
|
||||
double? _radiusButton;
|
||||
EdgeInsets? _paddingTitle;
|
||||
EdgeInsets? _paddingContent;
|
||||
EdgeInsets? _paddingButton;
|
||||
EdgeInsets? _marginIcon;
|
||||
|
||||
OnConfirmButtonAction? _onConfirmButtonAction;
|
||||
OnCancelButtonAction? _onCancelButtonAction;
|
||||
@@ -74,6 +78,22 @@ class ConfirmDialogBuilder {
|
||||
_radiusButton = radius;
|
||||
}
|
||||
|
||||
void paddingTitle(EdgeInsets? value) {
|
||||
_paddingTitle = value;
|
||||
}
|
||||
|
||||
void paddingContent(EdgeInsets? value) {
|
||||
_paddingContent = value;
|
||||
}
|
||||
|
||||
void paddingButton(EdgeInsets? value) {
|
||||
_paddingButton = value;
|
||||
}
|
||||
|
||||
void marginIcon(EdgeInsets? value) {
|
||||
_marginIcon = value;
|
||||
}
|
||||
|
||||
void onConfirmButtonAction(String confirmText, OnConfirmButtonAction? onConfirmButtonAction) {
|
||||
_confirmText = confirmText;
|
||||
_onConfirmButtonAction = onConfirmButtonAction;
|
||||
@@ -104,19 +124,21 @@ class ConfirmDialogBuilder {
|
||||
if (_onCloseButtonAction != null)
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: IconButton(
|
||||
padding: EdgeInsets.only(top: 16, right: 16),
|
||||
onPressed: () => _onCloseButtonAction?.call(),
|
||||
icon: SvgPicture.asset(_imagePath.icCloseMailbox, width: 30, height: 30, fit: BoxFit.fill))),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 8, right: 8),
|
||||
child: buildIconWeb(
|
||||
icon: SvgPicture.asset(_imagePath.icCloseMailbox, fit: BoxFit.fill),
|
||||
onTap: () => _onCloseButtonAction?.call())
|
||||
)),
|
||||
if (_iconWidget != null)
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 24),
|
||||
margin: _marginIcon ?? EdgeInsets.only(top: 24),
|
||||
alignment: Alignment.center,
|
||||
child: _iconWidget,
|
||||
),
|
||||
if (_title.isNotEmpty)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 12),
|
||||
padding: _paddingTitle ?? EdgeInsets.only(top: 12),
|
||||
child: Center(
|
||||
child: Text(
|
||||
_title,
|
||||
@@ -127,7 +149,7 @@ class ConfirmDialogBuilder {
|
||||
),
|
||||
if (_content.isNotEmpty)
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
||||
padding: _paddingContent ?? EdgeInsets.symmetric(horizontal: 16, vertical: 24),
|
||||
child: Center(
|
||||
child: Text(_content,
|
||||
textAlign: TextAlign.center,
|
||||
@@ -136,22 +158,24 @@ class ConfirmDialogBuilder {
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 16, left: 16, right: 16),
|
||||
padding: _paddingButton ?? EdgeInsets.only(bottom: 16, left: 16, right: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: _buildButton(
|
||||
if (_cancelText.isNotEmpty)
|
||||
Expanded(child: _buildButton(
|
||||
name: _cancelText,
|
||||
bgColor: _colorCancelButton,
|
||||
radius: _radiusButton,
|
||||
textStyle: _styleTextCancelButton,
|
||||
action: _onCancelButtonAction)),
|
||||
SizedBox(width: 16),
|
||||
Expanded(child: _buildButton(
|
||||
name: _confirmText,
|
||||
bgColor: _colorConfirmButton,
|
||||
radius: _radiusButton,
|
||||
textStyle: _styleTextConfirmButton,
|
||||
action: _onConfirmButtonAction))
|
||||
if (_confirmText.isNotEmpty && _cancelText.isNotEmpty) SizedBox(width: 16),
|
||||
if (_confirmText.isNotEmpty)
|
||||
Expanded(child: _buildButton(
|
||||
name: _confirmText,
|
||||
bgColor: _colorConfirmButton,
|
||||
radius: _radiusButton,
|
||||
textStyle: _styleTextConfirmButton,
|
||||
action: _onConfirmButtonAction))
|
||||
]
|
||||
))
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user