TF-46 Create object, builder for model and core module
This commit is contained in:
@@ -25,6 +25,7 @@ export 'presentation/views/list/tree_view.dart';
|
||||
export 'presentation/views/button/button_builder.dart';
|
||||
export 'presentation/views/image/avatar_builder.dart';
|
||||
export 'presentation/views/list/sliver_grid_delegate_fixed_height.dart';
|
||||
export 'presentation/views/text/text_form_field_builder.dart';
|
||||
|
||||
// Resources
|
||||
export 'presentation/resources/assets_paths.dart';
|
||||
|
||||
@@ -16,3 +16,21 @@ extension DateTimeExtension on DateTime {
|
||||
return now.year == this.year;
|
||||
}
|
||||
}
|
||||
|
||||
extension DateTimeNullableExtension on DateTime? {
|
||||
|
||||
String toPattern() {
|
||||
if (this != null) {
|
||||
if (this!.isToday()) {
|
||||
return 'h:mm a';
|
||||
} else if (this!.isYesterday()) {
|
||||
return 'EEE';
|
||||
} else if (this!.isThisYear()) {
|
||||
return 'MMMd';
|
||||
} else {
|
||||
return 'yMMMd';
|
||||
}
|
||||
}
|
||||
return 'yMMMd';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,4 +46,10 @@ extension AppColor on Color {
|
||||
static const avatarTextColor = Color(0xFF3840F7);
|
||||
static const sentTimeTextColorUnRead = Color(0xFF182952);
|
||||
static const subjectEmailTextColorUnRead = Color(0xFF3840F7);
|
||||
static const dividerColor = Color(0xFFEAEAEA);
|
||||
static const bgComposer = Color(0xFFFBFBFF);
|
||||
static const emailAddressChipColor = Color(0xFFF5F5F7);
|
||||
static const enableSendEmailButtonColor = Color(0xFF3840F7);
|
||||
static const disableSendEmailButtonColor = Color(0xFFACAFFF);
|
||||
static const borderLeftEmailContentColor = Color(0xFFEFEFEF);
|
||||
}
|
||||
|
||||
@@ -12,4 +12,18 @@ extension HtmlExtension on String {
|
||||
String removeMaxHeightZeroPixel() => replaceAll(RegExp('max-height:0px;'), '');
|
||||
|
||||
String changeStyleBackground() => replaceAll(RegExp('background:'), 'background-color:');
|
||||
|
||||
String addBorderLefForBlockQuote() => replaceAll(RegExp('<blockquote'), '<blockquote style=\"margin-left:8px;margin-right:8px;padding-left:12px;padding-right:12px;border-left:6px solid #EFEFEF;\"');
|
||||
|
||||
String addBlockTag(String tag, {String? attribute}) => attribute != null ? '<$tag $attribute>$this</$tag>' : '<$tag>$this</$tag>';
|
||||
|
||||
String addNewLineTag({int count = 1}) {
|
||||
if (count == 1) return '$this<br>';
|
||||
|
||||
var htmlString = this;
|
||||
for (var i = 0; i < count; i++) {
|
||||
htmlString = '$htmlString<br>';
|
||||
}
|
||||
return htmlString;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,11 @@ class ImagePaths {
|
||||
String get icOffline => _getImagePath('ic_offline.svg');
|
||||
String get icFlagged => _getImagePath('ic_flagged.svg');
|
||||
String get icMoreReceiver => _getImagePath('ic_more_receiver.svg');
|
||||
String get icComposerClose => _getImagePath('ic_composer_close.svg');
|
||||
String get icComposerSend => _getImagePath('ic_composer_send.svg');
|
||||
String get icComposerMenu => _getImagePath('ic_composer_menu.svg');
|
||||
String get icComposerFileShare => _getImagePath('ic_composer_file_share.svg');
|
||||
String get icExpandAddress => _getImagePath('ic_expand_address.svg');
|
||||
|
||||
String _getImagePath(String imageName) {
|
||||
return AssetsPaths.images + imageName;
|
||||
|
||||
@@ -20,7 +20,8 @@ class HtmlMessagePurifier {
|
||||
.removeMaxHeightZeroPixel()
|
||||
.removeMaxWidthZeroPixel()
|
||||
.removeHeightZeroPixel()
|
||||
.removeWidthZeroPixel();
|
||||
.removeWidthZeroPixel()
|
||||
.addBorderLefForBlockQuote();
|
||||
}
|
||||
|
||||
String sanitizeHtml(
|
||||
|
||||
@@ -16,6 +16,7 @@ class ButtonBuilder {
|
||||
double? _padding;
|
||||
bool? _isVertical;
|
||||
Key? _key;
|
||||
Color? _color;
|
||||
|
||||
ButtonBuilder key(Key key) {
|
||||
_key = key;
|
||||
@@ -27,6 +28,11 @@ class ButtonBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
ButtonBuilder color(Color color) {
|
||||
_color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
ButtonBuilder padding(double padding) {
|
||||
_padding = padding;
|
||||
return this;
|
||||
@@ -40,7 +46,7 @@ class ButtonBuilder {
|
||||
|
||||
ButtonBuilder(this._icon);
|
||||
|
||||
ButtonBuilder onBackActionClick(OnPressActionClick onPressActionClick) {
|
||||
ButtonBuilder onPressActionClick(OnPressActionClick onPressActionClick) {
|
||||
_onPressActionClick = onPressActionClick;
|
||||
return this;
|
||||
}
|
||||
@@ -88,7 +94,7 @@ class ButtonBuilder {
|
||||
|
||||
Widget _buildIcon() => Padding(
|
||||
padding: EdgeInsets.all(_padding ?? 10),
|
||||
child: SvgPicture.asset(_icon ?? '', width: _size ?? 24, height: _size ?? 24, fit: BoxFit.fill));
|
||||
child: SvgPicture.asset(_icon ?? '', width: _size ?? 24, height: _size ?? 24, fit: BoxFit.fill, color: _color));
|
||||
|
||||
Widget _buildText() {
|
||||
return Text(
|
||||
|
||||
@@ -8,6 +8,8 @@ class TextFieldBuilder {
|
||||
TextInputAction? _textInputAction;
|
||||
InputDecoration? _inputDecoration;
|
||||
bool? _obscureText;
|
||||
int? _maxLines = 1;
|
||||
TextEditingController? _textController;
|
||||
|
||||
TextFieldBuilder key(Key key) {
|
||||
_key = key;
|
||||
@@ -39,13 +41,25 @@ class TextFieldBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
TextFieldBuilder setText(String value) {
|
||||
_textController = TextEditingController.fromValue(TextEditingValue(text: value));
|
||||
return this;
|
||||
}
|
||||
|
||||
TextFieldBuilder maxLines(int? value) {
|
||||
_maxLines = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
TextField build() {
|
||||
return TextField(
|
||||
key: _key ?? Key('TextFieldBuilder'),
|
||||
onChanged: _onTextChange,
|
||||
cursorColor: AppColor.primaryColor,
|
||||
controller: _textController,
|
||||
textInputAction: _textInputAction,
|
||||
decoration: _inputDecoration,
|
||||
maxLines: _maxLines,
|
||||
style: _textStyle ?? TextStyle(color: AppColor.textFieldTextColor),
|
||||
obscureText: _obscureText ?? false,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef OnTapActionClick = void Function();
|
||||
|
||||
class TextFormFieldBuilder {
|
||||
Key? _key;
|
||||
ValueChanged<String>? _onTextChange;
|
||||
InputDecoration? _inputDecoration;
|
||||
TextInputAction? _textInputAction;
|
||||
TextStyle? _textStyle;
|
||||
OnTapActionClick? _onTapActionClick;
|
||||
|
||||
void key(Key key) {
|
||||
_key = key;
|
||||
}
|
||||
|
||||
void onChange(ValueChanged<String> onChange) {
|
||||
_onTextChange = onChange;
|
||||
}
|
||||
|
||||
void textStyle(TextStyle style) {
|
||||
_textStyle = style;
|
||||
}
|
||||
|
||||
void textDecoration(InputDecoration inputDecoration) {
|
||||
_inputDecoration = inputDecoration;
|
||||
}
|
||||
|
||||
void textInputAction(TextInputAction inputAction) {
|
||||
_textInputAction = inputAction;
|
||||
}
|
||||
|
||||
void addOnTapActionClick(OnTapActionClick onTapActionClick) {
|
||||
_onTapActionClick = onTapActionClick;
|
||||
}
|
||||
|
||||
TextFormField build() {
|
||||
return TextFormField(
|
||||
key: _key ?? Key('text_form_field_builder'),
|
||||
keyboardType: TextInputType.multiline,
|
||||
maxLines: null,
|
||||
onChanged: _onTextChange,
|
||||
style: _textStyle,
|
||||
decoration: _inputDecoration,
|
||||
textInputAction: _textInputAction,
|
||||
onTap: () {
|
||||
if (_onTapActionClick != null) {
|
||||
_onTapActionClick!();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user