TF-381 Apply new UI for list emails
This commit is contained in:
@@ -4,10 +4,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
typedef OnPressActionClick = void Function();
|
||||
typedef OnPressActionWithPositionClick = void Function(RelativeRect? position);
|
||||
|
||||
class ButtonBuilder {
|
||||
OnPressActionClick? _onPressActionClick;
|
||||
OnPressActionWithPositionClick? _onPressActionWithPositionClick;
|
||||
|
||||
BuildContext? _context;
|
||||
String? _icon;
|
||||
String? _text;
|
||||
double? _size;
|
||||
@@ -15,12 +18,21 @@ class ButtonBuilder {
|
||||
bool? _isVertical;
|
||||
Key? _key;
|
||||
Color? _iconColor;
|
||||
Color? _colorButton;
|
||||
TextStyle? _textStyle;
|
||||
BoxDecoration? _decoration;
|
||||
Widget? _iconAction;
|
||||
double? _radiusSplash;
|
||||
EdgeInsets? _padding;
|
||||
|
||||
void key(Key key) {
|
||||
_key = key;
|
||||
}
|
||||
|
||||
void context(BuildContext context) {
|
||||
_context = context;
|
||||
}
|
||||
|
||||
void size(double size) {
|
||||
_size = size;
|
||||
}
|
||||
@@ -29,6 +41,26 @@ class ButtonBuilder {
|
||||
_iconColor = color;
|
||||
}
|
||||
|
||||
void colorButton(Color color) {
|
||||
_colorButton = color;
|
||||
}
|
||||
|
||||
void decoration(BoxDecoration decoration) {
|
||||
_decoration = decoration;
|
||||
}
|
||||
|
||||
void addIconAction(Widget icon) {
|
||||
_iconAction = icon;
|
||||
}
|
||||
|
||||
void radiusSplash(double? radius) {
|
||||
_radiusSplash = radius;
|
||||
}
|
||||
|
||||
void padding(EdgeInsets? padding) {
|
||||
_padding = padding;
|
||||
}
|
||||
|
||||
void textStyle(TextStyle style) {
|
||||
_textStyle = style;
|
||||
}
|
||||
@@ -48,13 +80,33 @@ class ButtonBuilder {
|
||||
_onPressActionClick = onPressActionClick;
|
||||
}
|
||||
|
||||
void addOnPressActionWithPositionClick(OnPressActionWithPositionClick onPressActionClick) {
|
||||
_onPressActionWithPositionClick = onPressActionClick;
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
return InkWell(
|
||||
onTap: () => _onPressActionClick?.call(),
|
||||
onTap: () => _onPressActionClick != null ? _onPressActionClick?.call() : null,
|
||||
onTapDown: (detail) {
|
||||
if (_onPressActionWithPositionClick != null && _context != null) {
|
||||
final screenSize = MediaQuery.of(_context!).size;
|
||||
final offset = detail.globalPosition;
|
||||
final position = RelativeRect.fromLTRB(
|
||||
offset.dx,
|
||||
offset.dy,
|
||||
screenSize.width - offset.dx,
|
||||
screenSize.height - offset.dy,
|
||||
);
|
||||
_onPressActionWithPositionClick?.call(position);
|
||||
}
|
||||
},
|
||||
borderRadius: BorderRadius.all(Radius.circular(_radiusSplash ?? 0)),
|
||||
child: Container(
|
||||
key: _key,
|
||||
alignment: Alignment.center,
|
||||
color: Colors.white,
|
||||
color: _decoration == null ? _colorButton ?? Colors.white : null,
|
||||
decoration: _decoration,
|
||||
padding: _padding ?? EdgeInsets.zero,
|
||||
child: _buildBody()
|
||||
)
|
||||
);
|
||||
@@ -64,18 +116,18 @@ class ButtonBuilder {
|
||||
if (_text != null) {
|
||||
return _isVertical!
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildIcon(),
|
||||
_buildText(),
|
||||
if (_iconAction != null) _iconAction!
|
||||
])
|
||||
: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildIcon(),
|
||||
_buildText(),
|
||||
if (_iconAction != null) _iconAction!
|
||||
]);
|
||||
} else {
|
||||
return _buildIcon();
|
||||
|
||||
@@ -12,9 +12,15 @@ Widget buildIconWeb({
|
||||
double? iconSize,
|
||||
}) {
|
||||
return Material(
|
||||
type: MaterialType.circle,
|
||||
color: Colors.transparent,
|
||||
child: IconButton(icon: icon, iconSize: iconSize, padding: iconPadding ?? EdgeInsets.all(8.0), tooltip: tooltip, onPressed: onTap)
|
||||
shape: CircleBorder(),
|
||||
child: IconButton(
|
||||
icon: icon,
|
||||
iconSize: iconSize,
|
||||
padding: iconPadding ?? EdgeInsets.all(8.0),
|
||||
splashRadius: 20,
|
||||
tooltip: tooltip,
|
||||
onPressed: onTap)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user