Add object for model and core module
This commit is contained in:
@@ -13,6 +13,7 @@ class ButtonBuilder {
|
||||
String? _icon;
|
||||
String? _text;
|
||||
double? _size;
|
||||
double? _padding;
|
||||
bool? _isVertical;
|
||||
Key? _key;
|
||||
|
||||
@@ -26,6 +27,11 @@ class ButtonBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
ButtonBuilder padding(double padding) {
|
||||
_padding = padding;
|
||||
return this;
|
||||
}
|
||||
|
||||
ButtonBuilder text(String text, {required bool isVertical}) {
|
||||
_text = text;
|
||||
_isVertical = isVertical;
|
||||
@@ -66,7 +72,6 @@ class ButtonBuilder {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildIcon(),
|
||||
SizedBox(height: 8),
|
||||
_buildText(),
|
||||
])
|
||||
: Row(
|
||||
@@ -74,7 +79,6 @@ class ButtonBuilder {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
_buildIcon(),
|
||||
SizedBox(width: 8),
|
||||
_buildText(),
|
||||
]);
|
||||
} else {
|
||||
@@ -82,7 +86,9 @@ class ButtonBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildIcon() => SvgPicture.asset(_icon ?? '', width: _size ?? 24, height: _size ?? 24, fit: BoxFit.fill);
|
||||
Widget _buildIcon() => Padding(
|
||||
padding: EdgeInsets.all(_padding ?? 10),
|
||||
child: SvgPicture.asset(_icon ?? '', width: _size ?? 24, height: _size ?? 24, fit: BoxFit.fill));
|
||||
|
||||
Widget _buildText() {
|
||||
return Text(
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
class AvatarBuilder {
|
||||
Key? _key;
|
||||
String? _text;
|
||||
double? _size;
|
||||
String? _iconStatus;
|
||||
Color? _bgColor;
|
||||
|
||||
AvatarBuilder key(Key key) {
|
||||
_key = key;
|
||||
return this;
|
||||
}
|
||||
|
||||
AvatarBuilder size(double size) {
|
||||
_size = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
AvatarBuilder text(String text) {
|
||||
_text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
AvatarBuilder iconStatus(String iconStatus) {
|
||||
_iconStatus = iconStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
AvatarBuilder backgroundColor(Color bgColor) {
|
||||
_bgColor = bgColor;
|
||||
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)
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
class SliverGridDelegateFixedHeight
|
||||
extends SliverGridDelegate {
|
||||
/// Creates a delegate that makes grid layouts with a fixed number of tiles in
|
||||
/// the cross axis.
|
||||
///
|
||||
/// All of the arguments must not be null. The `mainAxisSpacing` and
|
||||
/// `crossAxisSpacing` arguments must not be negative. The `crossAxisCount`
|
||||
/// and `childAspectRatio` arguments must be greater than zero.
|
||||
const SliverGridDelegateFixedHeight({
|
||||
required this.crossAxisCount,
|
||||
this.mainAxisSpacing = 0.0,
|
||||
this.crossAxisSpacing = 0.0,
|
||||
this.height = 56.0,
|
||||
}) : assert(crossAxisCount > 0),
|
||||
assert(mainAxisSpacing >= 0),
|
||||
assert(crossAxisSpacing >= 0),
|
||||
assert(height > 0);
|
||||
|
||||
/// The number of children in the cross axis.
|
||||
final int crossAxisCount;
|
||||
|
||||
/// The number of logical pixels between each child along the main axis.
|
||||
final double mainAxisSpacing;
|
||||
|
||||
/// The number of logical pixels between each child along the cross axis.
|
||||
final double crossAxisSpacing;
|
||||
|
||||
/// The height of the crossAxis.
|
||||
final double height;
|
||||
|
||||
bool _debugAssertIsValid() {
|
||||
assert(crossAxisCount > 0);
|
||||
assert(mainAxisSpacing >= 0.0);
|
||||
assert(crossAxisSpacing >= 0.0);
|
||||
assert(height > 0.0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
SliverGridLayout getLayout(SliverConstraints constraints) {
|
||||
assert(_debugAssertIsValid());
|
||||
final double usableCrossAxisExtent = constraints.crossAxisExtent - crossAxisSpacing * (crossAxisCount - 1);
|
||||
final double childCrossAxisExtent = usableCrossAxisExtent / crossAxisCount;
|
||||
final double childMainAxisExtent = height;
|
||||
return SliverGridRegularTileLayout(
|
||||
crossAxisCount: crossAxisCount,
|
||||
mainAxisStride: childMainAxisExtent + mainAxisSpacing,
|
||||
crossAxisStride: childCrossAxisExtent + crossAxisSpacing,
|
||||
childMainAxisExtent: childMainAxisExtent,
|
||||
childCrossAxisExtent: childCrossAxisExtent,
|
||||
reverseCrossAxis: axisDirectionIsReversed(constraints.crossAxisDirection),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRelayout(SliverGridDelegateFixedHeight oldDelegate) {
|
||||
return oldDelegate.crossAxisCount != crossAxisCount ||
|
||||
oldDelegate.mainAxisSpacing != mainAxisSpacing ||
|
||||
oldDelegate.crossAxisSpacing != crossAxisSpacing ||
|
||||
oldDelegate.height != height;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user