TF-78 Create action bar and context menu when multiple selected email

This commit is contained in:
dab246
2021-09-15 10:05:27 +07:00
committed by Dat H. Pham
parent 59ab5265fd
commit 161eed5d72
21 changed files with 980 additions and 66 deletions
@@ -2,12 +2,15 @@ import 'package:core/presentation/extensions/color_extension.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
typedef OnTapAvatarActionClick = void Function();
class AvatarBuilder {
Key? _key;
String? _text;
double? _size;
String? _iconStatus;
Color? _bgColor;
OnTapAvatarActionClick? _onTapAvatarActionClick;
AvatarBuilder key(Key key) {
_key = key;
@@ -34,31 +37,41 @@ class AvatarBuilder {
return this;
}
AvatarBuilder addOnTapActionClick(OnTapAvatarActionClick onTapAvatarActionClick) {
_onTapAvatarActionClick = onTapAvatarActionClick;
return this;
}
Widget build() {
return Container(
key: _key,
width: _size ?? 40,
height: _size ?? 40,
alignment: Alignment.center,
child: Stack(
children: [
Container(
width: _size ?? 40,
height: _size ?? 40,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular((_size ?? 40) / 2),
border: Border.all(color: Colors.white),
color: _bgColor ?? AppColor.avatarColor),
child: Text(
'${_text ?? ''}',
style: TextStyle(fontSize: 20, color: AppColor.avatarTextColor, fontWeight: FontWeight.w500))),
if (_iconStatus != null && _iconStatus!.isNotEmpty)
Align(
child: SvgPicture.asset(_iconStatus!, width: 12, height: 12, fit: BoxFit.fill),
alignment: Alignment.bottomRight)
],
)
return GestureDetector(
onTap: () {
if (_onTapAvatarActionClick != null) {
_onTapAvatarActionClick!();
}},
child: Container(
key: _key,
width: _size ?? 40,
height: _size ?? 40,
alignment: Alignment.center,
child: Stack(
children: [
Container(
width: _size ?? 40,
height: _size ?? 40,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular((_size ?? 40) / 2),
border: Border.all(color: Colors.white),
color: _bgColor ?? AppColor.avatarColor),
child: Text(
'${_text ?? ''}',
style: TextStyle(fontSize: 20, color: AppColor.avatarTextColor, fontWeight: FontWeight.w500))),
if (_iconStatus != null && _iconStatus!.isNotEmpty)
Align(
child: SvgPicture.asset(_iconStatus!, width: 12, height: 12, fit: BoxFit.fill),
alignment: Alignment.bottomRight)
],
)),
);
}
}
@@ -0,0 +1,44 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
typedef OnPressIconActionClick = void Function();
class IconBuilder {
Key? _key;
double? _size;
String? _icon;
OnPressIconActionClick? _onPressIconActionClick;
IconBuilder(this._icon);
void key(Key key) {
_key = key;
}
void size(double size) {
_size = size;
}
void addOnTapActionClick(OnPressIconActionClick onPressIconActionClick) {
_onPressIconActionClick = onPressIconActionClick;
}
Widget build() {
return Container(
key: _key,
width: _size ?? 40,
height: _size ?? 40,
alignment: Alignment.center,
padding: EdgeInsets.all(3),
child: IconButton(
padding: EdgeInsets.zero,
iconSize: _size ?? 40,
icon: SvgPicture.asset(_icon!, width: _size ?? 40, height: _size ?? 40, fit: BoxFit.fill),
onPressed: () => {
if (_onPressIconActionClick != null) {
_onPressIconActionClick!()
}
})
);
}
}