Add icon, color, widget_builder, responsive for core module
This commit is contained in:
@@ -18,6 +18,7 @@ export 'presentation/views/text/input_decoration_builder.dart';
|
||||
export 'presentation/views/text/text_builder.dart';
|
||||
export 'presentation/views/responsive/responsive_widget.dart';
|
||||
export 'presentation/views/list/tree_view.dart';
|
||||
export 'presentation/views/button/button_builder.dart';
|
||||
|
||||
// Resources
|
||||
export 'presentation/resources/assets_paths.dart';
|
||||
|
||||
@@ -33,4 +33,10 @@ extension AppColor on Color {
|
||||
static const storageMaxSizeColor = Color(0xFF101D43);
|
||||
static const storageUseSizeColor = Color(0xFF2D0CFF);
|
||||
static const myFolderTitleColor = Color(0xFF7E869B);
|
||||
static const titleAppBarMailboxListMail = Color(0xFF182952);
|
||||
static const notifyCountAppBarMailboxListMail = Color(0xFF3840F7);
|
||||
static const bgNotifyCountAppBarMailboxListMail = Color(0xFFE6E5FF);
|
||||
static const bgMailboxListMail = Color(0xFFFBFBFF);
|
||||
static const bgMessenger = Color(0xFFF2F2F5);
|
||||
static const textButtonColor = Color(0xFF182952);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,16 @@ class ImagePaths {
|
||||
String get icMailboxNewFolder => _getImagePath('ic_mailbox_new_folder.svg');
|
||||
String get icFolderArrow => _getImagePath('ic_folder_arrow.svg');
|
||||
String get icExpandFolder => _getImagePath('ic_expand_folder.svg');
|
||||
String get icBack => _getImagePath('ic_back.svg');
|
||||
String get icEyeDisable => _getImagePath('ic_eye_disable.svg');
|
||||
String get icFolder => _getImagePath('ic_folder.svg');
|
||||
String get icForward => _getImagePath('ic_forward.svg');
|
||||
String get icReply => _getImagePath('ic_reply.svg');
|
||||
String get icReplyAll => _getImagePath('ic_reply_all.svg');
|
||||
String get icStar => _getImagePath('ic_star.svg');
|
||||
String get icTrash => _getImagePath('ic_trash.svg');
|
||||
String get icCalendar => _getImagePath('ic_calendar.svg');
|
||||
String get icShare => _getImagePath('ic_share.svg');
|
||||
|
||||
String _getImagePath(String imageName) {
|
||||
return AssetsPaths.images + imageName;
|
||||
|
||||
@@ -2,36 +2,24 @@ import 'package:flutter/widgets.dart';
|
||||
|
||||
class ResponsiveUtils {
|
||||
|
||||
static const int _minLargeWidth = 950;
|
||||
static const int _minMediumWidth = 600;
|
||||
static const int minDesktopWidth = 1200;
|
||||
static const int minTabletWidth = 600;
|
||||
|
||||
static const double _loginTextFieldWidthSmallScreen = 280.0;
|
||||
static const double _loginTextFieldWidthLargeScreen = 320.0;
|
||||
static const double _loginButtonWidth = 240.0;
|
||||
|
||||
double getSizeWidthScreen(BuildContext context) {
|
||||
return MediaQuery.of(context).size.width;
|
||||
}
|
||||
double getSizeWidthScreen(BuildContext context) => MediaQuery.of(context).size.width;
|
||||
|
||||
double getSizeHeightScreen(BuildContext context) {
|
||||
return MediaQuery.of(context).size.height;
|
||||
}
|
||||
double getSizeHeightScreen(BuildContext context) => MediaQuery.of(context).size.height;
|
||||
|
||||
bool isLargeScreen(BuildContext context) {
|
||||
return getSizeWidthScreen(context) >= _minLargeWidth;
|
||||
}
|
||||
bool isMobile(BuildContext context) => getSizeWidthScreen(context) < minTabletWidth;
|
||||
|
||||
bool isSmallScreen(BuildContext context) {
|
||||
return getSizeWidthScreen(context) < _minMediumWidth;
|
||||
}
|
||||
bool isTablet(BuildContext context) => getSizeWidthScreen(context) >= minTabletWidth && getSizeWidthScreen(context) < minDesktopWidth;
|
||||
|
||||
bool isMediumScreen(BuildContext context) {
|
||||
return getSizeWidthScreen(context) >= _minMediumWidth && getSizeWidthScreen(context) < _minLargeWidth;
|
||||
}
|
||||
bool isDesktop(BuildContext context) => getSizeWidthScreen(context) >= minDesktopWidth;
|
||||
|
||||
double getWidthLoginTextField(BuildContext context) => isSmallScreen(context)
|
||||
? _loginTextFieldWidthSmallScreen
|
||||
: _loginTextFieldWidthLargeScreen;
|
||||
double getWidthLoginTextField(BuildContext context) => isMobile(context) ? _loginTextFieldWidthSmallScreen : _loginTextFieldWidthLargeScreen;
|
||||
|
||||
double getWidthLoginButton() => _loginButtonWidth;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:core/core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
typedef OnPressActionClick = void Function();
|
||||
|
||||
class ButtonBuilder {
|
||||
OnPressActionClick? _onPressActionClick;
|
||||
|
||||
String? _icon;
|
||||
String? _text;
|
||||
double? _size;
|
||||
bool? _isVertical;
|
||||
Key? _key;
|
||||
|
||||
ButtonBuilder key(Key key) {
|
||||
_key = key;
|
||||
return this;
|
||||
}
|
||||
|
||||
ButtonBuilder size(double size) {
|
||||
_size = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
ButtonBuilder text(String text, {required bool isVertical}) {
|
||||
_text = text;
|
||||
_isVertical = isVertical;
|
||||
return this;
|
||||
}
|
||||
|
||||
ButtonBuilder(this._icon);
|
||||
|
||||
ButtonBuilder onBackActionClick(OnPressActionClick onPressActionClick) {
|
||||
_onPressActionClick = onPressActionClick;
|
||||
return this;
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
color: Colors.transparent,
|
||||
child: MediaQuery(
|
||||
data: MediaQueryData(padding: EdgeInsets.zero),
|
||||
child: GestureDetector(
|
||||
child: _buildBody(),
|
||||
onTap: () {
|
||||
if (_onPressActionClick != null) {
|
||||
_onPressActionClick!();
|
||||
}
|
||||
},
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
if (_text != null) {
|
||||
return _isVertical!
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildIcon(),
|
||||
SizedBox(height: 8),
|
||||
_buildText(),
|
||||
])
|
||||
: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildIcon(),
|
||||
SizedBox(width: 8),
|
||||
_buildText(),
|
||||
]);
|
||||
} else {
|
||||
return _buildIcon();
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildIcon() => SvgPicture.asset(_icon ?? '', width: _size ?? 24, height: _size ?? 24, fit: BoxFit.fill);
|
||||
|
||||
Widget _buildText() {
|
||||
return Text(
|
||||
'${_text ?? ''}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 12, color: AppColor.textButtonColor, fontWeight: FontWeight.w500),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,29 +2,29 @@ import 'package:core/presentation/utils/responsive_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ResponsiveWidget extends StatelessWidget {
|
||||
final Widget? largeScreen;
|
||||
final Widget mediumScreen;
|
||||
final Widget? smallScreen;
|
||||
final Widget mobile;
|
||||
final Widget tablet;
|
||||
final Widget? desktop;
|
||||
|
||||
final ResponsiveUtils responsiveUtils;
|
||||
|
||||
const ResponsiveWidget({
|
||||
Key? key,
|
||||
this.largeScreen,
|
||||
required this.mediumScreen,
|
||||
this.smallScreen,
|
||||
required this.mobile,
|
||||
required this.tablet,
|
||||
this.desktop,
|
||||
required this.responsiveUtils,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
if (responsiveUtils.isLargeScreen(context)) {
|
||||
return largeScreen ?? mediumScreen;
|
||||
} else if (responsiveUtils.isMediumScreen(context)) {
|
||||
return mediumScreen;
|
||||
if (responsiveUtils.isDesktop(context)) {
|
||||
return desktop ?? tablet;
|
||||
} else if (responsiveUtils.isTablet(context)) {
|
||||
return tablet;
|
||||
} else {
|
||||
return smallScreen ?? mediumScreen;
|
||||
return mobile;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user