Init core module
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
abstract class InputDecorationBuilder {
|
||||
String? prefixText;
|
||||
String? labelText;
|
||||
TextStyle? labelStyle;
|
||||
String? hintText;
|
||||
TextStyle? hintStyle;
|
||||
EdgeInsets? contentPadding;
|
||||
OutlineInputBorder? enabledBorder;
|
||||
|
||||
InputDecorationBuilder setPrefixText(String newPrefixText) {
|
||||
prefixText = newPrefixText;
|
||||
return this;
|
||||
}
|
||||
|
||||
InputDecorationBuilder setLabelText(String newLabelText) {
|
||||
labelText = newLabelText;
|
||||
return this;
|
||||
}
|
||||
|
||||
InputDecorationBuilder setLabelStyle(TextStyle newLabelStyle) {
|
||||
labelStyle = newLabelStyle;
|
||||
return this;
|
||||
}
|
||||
|
||||
InputDecorationBuilder setHintText(String newHintText) {
|
||||
hintText = newHintText;
|
||||
return this;
|
||||
}
|
||||
|
||||
InputDecorationBuilder setHintStyle(TextStyle newHintStyle) {
|
||||
hintStyle = newHintStyle;
|
||||
return this;
|
||||
}
|
||||
|
||||
InputDecorationBuilder setContentPadding(EdgeInsets newContentPadding) {
|
||||
contentPadding = newContentPadding;
|
||||
return this;
|
||||
}
|
||||
|
||||
InputDecorationBuilder setEnabledBorder(OutlineInputBorder newEnabledBorder) {
|
||||
enabledBorder = newEnabledBorder;
|
||||
return this;
|
||||
}
|
||||
|
||||
InputDecoration build() {
|
||||
return InputDecoration(
|
||||
prefixText: prefixText,
|
||||
labelText: labelText,
|
||||
labelStyle: labelStyle,
|
||||
hintText: hintText,
|
||||
hintStyle: hintStyle,
|
||||
contentPadding: contentPadding,
|
||||
enabledBorder: enabledBorder);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
/// A builder which builds a reusable slogan widget.
|
||||
/// This contains the logo and the slogan text.
|
||||
/// The elements are arranged in a column.
|
||||
class SloganBuilder {
|
||||
Key? _key;
|
||||
String? _text;
|
||||
TextStyle? _textStyle;
|
||||
TextAlign? _textAlign;
|
||||
String? _logo;
|
||||
|
||||
SloganBuilder key(Key key) {
|
||||
_key = key;
|
||||
return this;
|
||||
}
|
||||
|
||||
SloganBuilder setSloganText(String text) {
|
||||
_text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
SloganBuilder setSloganTextStyle(TextStyle textStyle) {
|
||||
_textStyle = textStyle;
|
||||
return this;
|
||||
}
|
||||
|
||||
SloganBuilder setSloganTextAlign(TextAlign textAlign) {
|
||||
_textAlign = textAlign;
|
||||
return this;
|
||||
}
|
||||
|
||||
SloganBuilder setLogo(String logo) {
|
||||
_logo = logo;
|
||||
return this;
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
_logo != null ? SvgPicture.asset(_logo!, width: 150, height: 150) : SizedBox.shrink(),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 16, left: 16, right: 16),
|
||||
child: Text(_text ?? '', key: _key, style: _textStyle, textAlign: _textAlign),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:core/presentation/utils/style_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TextBuilder {
|
||||
String? _text;
|
||||
TextStyle? _textStyle;
|
||||
TextAlign? _textAlign;
|
||||
Key? _key;
|
||||
|
||||
TextBuilder key(Key key) {
|
||||
_key = key;
|
||||
return this;
|
||||
}
|
||||
|
||||
TextBuilder text(String text) {
|
||||
_text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
TextBuilder textStyle(TextStyle textStyle) {
|
||||
_textStyle = textStyle;
|
||||
return this;
|
||||
}
|
||||
|
||||
TextBuilder textAlign(TextAlign textAlign) {
|
||||
_textAlign = textAlign;
|
||||
return this;
|
||||
}
|
||||
|
||||
Text build() {
|
||||
return Text(_text ?? '', key: _key ?? Key('TextBuilder'), style: _textStyle ?? CommonTextStyle.textStyleNormal, textAlign: _textAlign ?? TextAlign.center);
|
||||
}
|
||||
}
|
||||
|
||||
class CenterTextBuilder extends TextBuilder {
|
||||
@override
|
||||
Text build() {
|
||||
return Text(_text ?? '', key: _key ?? Key('TextBuilder'), style: _textStyle, textAlign: TextAlign.center);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TextFieldBuilder {
|
||||
Key? _key;
|
||||
ValueChanged<String>? _onTextChange;
|
||||
TextStyle? _textStyle;
|
||||
TextInputAction? _textInputAction;
|
||||
InputDecoration? _inputDecoration;
|
||||
bool? _obscureText;
|
||||
|
||||
TextFieldBuilder key(Key key) {
|
||||
_key = key;
|
||||
return this;
|
||||
}
|
||||
|
||||
TextFieldBuilder onChange(ValueChanged<String> onChange) {
|
||||
_onTextChange = onChange;
|
||||
return this;
|
||||
}
|
||||
|
||||
TextFieldBuilder textStyle(TextStyle style) {
|
||||
_textStyle = style;
|
||||
return this;
|
||||
}
|
||||
|
||||
TextFieldBuilder textInputAction(TextInputAction inputAction) {
|
||||
_textInputAction = inputAction;
|
||||
return this;
|
||||
}
|
||||
|
||||
TextFieldBuilder textDecoration(InputDecoration inputDecoration) {
|
||||
_inputDecoration = inputDecoration;
|
||||
return this;
|
||||
}
|
||||
|
||||
TextFieldBuilder obscureText(bool obscureText) {
|
||||
_obscureText = obscureText;
|
||||
return this;
|
||||
}
|
||||
|
||||
TextField build() {
|
||||
return TextField(
|
||||
key: _key ?? Key('TextFieldBuilder'),
|
||||
onChanged: _onTextChange,
|
||||
cursorColor: AppColor.primaryColor,
|
||||
textInputAction: _textInputAction,
|
||||
decoration: _inputDecoration,
|
||||
style: _textStyle ?? TextStyle(color: AppColor.textFieldTextColor),
|
||||
obscureText: _obscureText ?? false,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user