[SYNC]
This commit is contained in:
@@ -1,30 +1,34 @@
|
||||
//s2 Core Packages Imports
|
||||
//s1 Imports
|
||||
//s2 Core Package Imports
|
||||
import 'package:flutter/material.dart';
|
||||
//
|
||||
//s2 1st-party Package Imports
|
||||
//s2 3rd-party Package Imports
|
||||
//s2 Dependancies Imports
|
||||
//s3 Routes
|
||||
//s3 Services
|
||||
//s3 Models
|
||||
import 'src/icon_button.dart';
|
||||
import 'src/link_button.dart';
|
||||
import 'src/state_button.dart';
|
||||
//
|
||||
import 'src/sizing_strategy.enum.dart';
|
||||
import 'src/style.dart';
|
||||
//
|
||||
export 'src/sizing_strategy.enum.dart';
|
||||
export 'src/style.dart';
|
||||
import 'src/enums/enums.exports.dart';
|
||||
import 'src/models/models.exports.dart';
|
||||
//s1 Exports
|
||||
export 'src/enums/enums.exports.dart';
|
||||
export 'src/models/models.exports.dart';
|
||||
|
||||
/// A collection of the available Astromic buttons.
|
||||
class AstromicButtons {
|
||||
//S1 -- State
|
||||
/// an `AstromicStateButton` is a button whoose style is affected by it's state.
|
||||
static Widget state({
|
||||
//
|
||||
void Function(VoidCallback start, VoidCallback stop)? onTap,
|
||||
Function(VoidCallback start, VoidCallback stop)? onHold,
|
||||
//
|
||||
bool? isEnabled,
|
||||
bool? withFeedback,
|
||||
bool? withHighlightChange,
|
||||
TextDirection? textDirection,
|
||||
AstromicButtonConfiguration? configuration,
|
||||
//
|
||||
SizingStrategy? widthSizingStrategy,
|
||||
SizingStrategy? heightSizingStrategy,
|
||||
AstromicSizingStrategy? widthSizingStrategy,
|
||||
AstromicSizingStrategy? heightSizingStrategy,
|
||||
InteractiveInkFeatureFactory? splashFactory,
|
||||
required AstromicButtonStyle Function(bool isEnabled, bool isHighlighted, bool isLoading) style,
|
||||
//
|
||||
@@ -35,30 +39,23 @@ class AstromicButtons {
|
||||
onTap: onTap,
|
||||
onHold: onHold,
|
||||
//
|
||||
isEnabled: isEnabled ?? true,
|
||||
withFeedback: withFeedback ?? true,
|
||||
withHighlightChange: withHighlightChange ?? true,
|
||||
textDirection: textDirection ?? TextDirection.ltr,
|
||||
configuration: configuration,
|
||||
//
|
||||
widthSizingStrategy: widthSizingStrategy,
|
||||
heightSizingStrategy: heightSizingStrategy,
|
||||
splashFactory: splashFactory,
|
||||
style: style,
|
||||
//
|
||||
loadingContent: loadingContent,
|
||||
content: content,
|
||||
);
|
||||
|
||||
//S1 -- Icon
|
||||
/// an `AstromicIconButton` is a button specifically for mapping to an IconButton.
|
||||
static Widget icon({
|
||||
//
|
||||
void Function(VoidCallback start, VoidCallback stop)? onTap,
|
||||
Function(VoidCallback start, VoidCallback stop)? onHold,
|
||||
//
|
||||
bool? isEnabled,
|
||||
bool? withFeedback,
|
||||
bool? withHighlightChange,
|
||||
TextDirection? textDirection,
|
||||
AstromicButtonConfiguration? configuration,
|
||||
//
|
||||
bool? isCircular,
|
||||
InteractiveInkFeatureFactory? splashFactory,
|
||||
@@ -71,27 +68,22 @@ class AstromicButtons {
|
||||
onTap: onTap,
|
||||
onHold: onHold,
|
||||
//
|
||||
isEnabled: isEnabled ?? true,
|
||||
withFeedback: withFeedback ?? true,
|
||||
withHighlightChange: withHighlightChange ?? true,
|
||||
textDirection: textDirection ?? TextDirection.ltr,
|
||||
configuration: configuration,
|
||||
//
|
||||
isCircular: isCircular ?? true,
|
||||
splashFactory: splashFactory,
|
||||
style: style,
|
||||
//
|
||||
loadingContent: loadingContent,
|
||||
icon: icon,
|
||||
);
|
||||
|
||||
//S1 -- Link
|
||||
/// an `AstromicLinkButton` is a button specifically for mapping to LinkButton.
|
||||
static Widget link({
|
||||
//
|
||||
VoidCallback? onTap,
|
||||
VoidCallback? onHold,
|
||||
//
|
||||
bool? isEnabled,
|
||||
TextDirection? textDirection,
|
||||
AstromicButtonConfiguration? configuration,
|
||||
//
|
||||
bool Function(bool isEnabled)? isUnderlined,
|
||||
EdgeInsetsGeometry? contentPadding,
|
||||
@@ -106,8 +98,7 @@ class AstromicButtons {
|
||||
onTap: onTap,
|
||||
onHold: onHold,
|
||||
//
|
||||
isEnabled: isEnabled ?? true,
|
||||
textDirection: textDirection ?? TextDirection.ltr,
|
||||
configuration: configuration,
|
||||
//
|
||||
isUnderlined: isUnderlined ?? (e) => e,
|
||||
contentPadding: contentPadding,
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
//SECTION - Imports
|
||||
//
|
||||
//s1 PACKAGES
|
||||
//---------------
|
||||
//s2 CORE
|
||||
//s1 Imports
|
||||
//s2 Core Package Imports
|
||||
import 'package:flutter/material.dart';
|
||||
//s2 3RD-PARTY
|
||||
//
|
||||
//s1 DEPENDENCIES
|
||||
//----------------
|
||||
//s2 SERVICES
|
||||
//s2 MODELS
|
||||
import 'style.dart';
|
||||
//s2 MISC
|
||||
//!SECTION - Imports
|
||||
//
|
||||
//SECTION - Exports
|
||||
//!SECTION - Exports
|
||||
//
|
||||
//s2 1st-party Package Imports
|
||||
import '../../../Dependencies/gradient_border/gradient_borders.dart';
|
||||
//s2 3rd-party Package Imports
|
||||
//s2 Dependancies Imports
|
||||
//s3 Routes
|
||||
//s3 Services
|
||||
//s3 Models
|
||||
import 'models/models.exports.dart';
|
||||
//s1 Exports
|
||||
|
||||
class AstromicButtonBase extends StatefulWidget {
|
||||
//SECTION - Widget Arguments
|
||||
@@ -24,13 +17,9 @@ class AstromicButtonBase extends StatefulWidget {
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onHold;
|
||||
//s1 -- Configurations
|
||||
final bool isEnabled;
|
||||
final bool withFeedback;
|
||||
final bool withHighlightChange;
|
||||
final TextDirection textDirection;
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
//s1 -- Style
|
||||
final InteractiveInkFeatureFactory? splashFactory;
|
||||
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted) style;
|
||||
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted)? style;
|
||||
//s1 -- Content
|
||||
final Widget Function(bool isEnabled, bool isHighlighted) child;
|
||||
//!SECTION
|
||||
@@ -41,13 +30,9 @@ class AstromicButtonBase extends StatefulWidget {
|
||||
this.onTap,
|
||||
this.onHold,
|
||||
//
|
||||
this.isEnabled = true,
|
||||
this.withFeedback = true,
|
||||
this.withHighlightChange = true,
|
||||
required this.textDirection,
|
||||
this.configuration,
|
||||
//s1 -- Style
|
||||
this.splashFactory,
|
||||
required this.style,
|
||||
this.style,
|
||||
//s1 -- Content
|
||||
required this.child,
|
||||
}) : super(
|
||||
@@ -66,6 +51,8 @@ class _AstromicButtonBaseState extends State<AstromicButtonBase> {
|
||||
//
|
||||
//s1 --State
|
||||
late bool _isHighlighted;
|
||||
late AstromicButtonConfiguration _config;
|
||||
late AstromicButtonStyle _style;
|
||||
//s1 --State
|
||||
//
|
||||
//s1 --Constants
|
||||
@@ -93,6 +80,8 @@ class _AstromicButtonBaseState extends State<AstromicButtonBase> {
|
||||
Widget build(BuildContext context) {
|
||||
//SECTION - Build Setup
|
||||
//s1 -Values
|
||||
_config = widget.configuration ?? AstromicButtonConfiguration(isEnabled: true, withFeedback: true, withHighlightChange: true, textDirection: TextDirection.ltr);
|
||||
_style = widget.style?.call(_config.isEnabled, _isHighlighted) ?? const AstromicButtonStyle();
|
||||
//s1 -Values
|
||||
//
|
||||
//s1 -Widgets
|
||||
@@ -101,30 +90,37 @@ class _AstromicButtonBaseState extends State<AstromicButtonBase> {
|
||||
|
||||
//SECTION - Build Return
|
||||
return Material(
|
||||
color: widget.style(widget.isEnabled, _isHighlighted).backgroundGradient != null ? Colors.transparent : widget.style(widget.isEnabled, _isHighlighted).backgroundColor,
|
||||
shape: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
width: widget.style(widget.isEnabled, _isHighlighted).borderWidth ?? 1,
|
||||
color: widget.style(widget.isEnabled, _isHighlighted).borderColor ?? Colors.black,
|
||||
),
|
||||
borderRadius: widget.style(widget.isEnabled, _isHighlighted).borderRadius?.resolve(widget.textDirection) ?? BorderRadius.circular(0),
|
||||
),
|
||||
color: _style.backgroundGradient != null ? Colors.transparent : _style.backgroundColor,
|
||||
shape: _style.borderGradient != null
|
||||
? GradientOutlineInputBorder(
|
||||
gapPadding: 0,
|
||||
gradient: _style.borderGradient!,
|
||||
borderRadius: _style.borderRadius?.resolve(_config.textDirection) ?? BorderRadius.circular(0),
|
||||
width: _style.borderWidth ?? 1,
|
||||
)
|
||||
: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
width: _style.borderWidth ?? 1,
|
||||
color: _style.borderColor ?? Colors.black,
|
||||
),
|
||||
borderRadius: _style.borderRadius?.resolve(_config.textDirection) ?? BorderRadius.circular(0),
|
||||
),
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: widget.style(widget.isEnabled, _isHighlighted).borderRadius?.resolve(widget.textDirection) ?? BorderRadius.circular(0),
|
||||
gradient: widget.style(widget.isEnabled, _isHighlighted).backgroundGradient,
|
||||
borderRadius: _style.borderRadius?.resolve(_config.textDirection) ?? BorderRadius.circular(0),
|
||||
gradient: _style.backgroundGradient,
|
||||
),
|
||||
child: InkWell(
|
||||
splashFactory: widget.splashFactory,
|
||||
splashColor: widget.withFeedback ? widget.style(widget.isEnabled, _isHighlighted).splashColor : Colors.transparent,
|
||||
hoverColor: widget.withFeedback ? widget.style(widget.isEnabled, _isHighlighted).hoverColor : Colors.transparent,
|
||||
highlightColor: widget.withFeedback ? widget.style(widget.isEnabled, _isHighlighted).highlightColor : Colors.transparent,
|
||||
splashFactory: _style.splashFactory,
|
||||
splashColor: _config.withFeedback ? _style.splashColor : Colors.transparent,
|
||||
hoverColor: _config.withFeedback ? _style.hoverColor : Colors.transparent,
|
||||
highlightColor: _config.withFeedback ? _style.highlightColor : Colors.transparent,
|
||||
//
|
||||
borderRadius: widget.style(widget.isEnabled, _isHighlighted).borderRadius?.resolve(widget.textDirection) ?? BorderRadius.circular(0),
|
||||
borderRadius: _style.borderRadius?.resolve(_config.textDirection) ?? BorderRadius.circular(0),
|
||||
//
|
||||
onTap: widget.isEnabled && widget.onTap != null ? widget.onTap : null,
|
||||
onLongPress: widget.isEnabled && widget.onHold != null ? widget.onHold : null,
|
||||
onHighlightChanged: widget.withHighlightChange
|
||||
onTap: _config.isEnabled && widget.onTap != null ? widget.onTap : null,
|
||||
onLongPress: _config.isEnabled && widget.onHold != null ? widget.onHold : null,
|
||||
onHighlightChanged: _config.withHighlightChange
|
||||
? (v) {
|
||||
setState(() {
|
||||
_isHighlighted = v;
|
||||
@@ -133,9 +129,9 @@ class _AstromicButtonBaseState extends State<AstromicButtonBase> {
|
||||
: null,
|
||||
//
|
||||
child: Padding(
|
||||
padding: widget.style(widget.isEnabled, _isHighlighted).contentPadding ?? EdgeInsets.zero,
|
||||
padding: _style.contentPadding ?? EdgeInsets.zero,
|
||||
child: widget.child(
|
||||
widget.isEnabled,
|
||||
_config.isEnabled,
|
||||
_isHighlighted,
|
||||
),
|
||||
),
|
||||
|
||||
1
lib/src/Buttons/src/enums/enums.exports.dart
Normal file
1
lib/src/Buttons/src/enums/enums.exports.dart
Normal file
@@ -0,0 +1 @@
|
||||
export './sizing_strategy.enum.dart';
|
||||
6
lib/src/Buttons/src/enums/sizing_strategy.enum.dart
Normal file
6
lib/src/Buttons/src/enums/sizing_strategy.enum.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
/// Sizing strategy for how the element is sized in it's bounds; Fill it, Hug it's content, or Fixed.
|
||||
enum AstromicSizingStrategy {
|
||||
hug,
|
||||
fill,
|
||||
fixed,
|
||||
}
|
||||
@@ -1,23 +1,15 @@
|
||||
//SECTION - Imports
|
||||
//
|
||||
//s1 PACKAGES
|
||||
//---------------
|
||||
//s2 CORE
|
||||
//s1 Imports
|
||||
//s2 Core Package Imports
|
||||
import 'package:flutter/material.dart';
|
||||
//s2 1st-party Package Imports
|
||||
//s2 3rd-party Package Imports
|
||||
//s2 Dependancies Imports
|
||||
//s3 Routes
|
||||
//s3 Services
|
||||
//s3 Models
|
||||
import 'base.dart';
|
||||
import 'style.dart';
|
||||
//s2 3RD-PARTY
|
||||
//
|
||||
//s1 DEPENDENCIES
|
||||
//---------------
|
||||
//s2 SERVICES
|
||||
//s2 MODELS
|
||||
//s2 MISC
|
||||
//!SECTION - Imports
|
||||
//
|
||||
//SECTION - Exports
|
||||
//!SECTION - Exports
|
||||
//
|
||||
import 'models/models.exports.dart';
|
||||
//s1 Exports
|
||||
|
||||
class AstromicIconButton extends StatefulWidget {
|
||||
//SECTION - Widget Arguments
|
||||
@@ -25,12 +17,8 @@ class AstromicIconButton extends StatefulWidget {
|
||||
final void Function(VoidCallback start, VoidCallback stop)? onTap;
|
||||
final Function(VoidCallback start, VoidCallback stop)? onHold;
|
||||
//s1 -- Configurations
|
||||
final bool isEnabled;
|
||||
final bool withFeedback;
|
||||
final bool withHighlightChange;
|
||||
final TextDirection textDirection;
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
//s1 -- Style
|
||||
final InteractiveInkFeatureFactory? splashFactory;
|
||||
final bool isCircular;
|
||||
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted, bool isLoading)? style;
|
||||
//s1 -- Content
|
||||
@@ -44,13 +32,9 @@ class AstromicIconButton extends StatefulWidget {
|
||||
this.onTap,
|
||||
this.onHold,
|
||||
//
|
||||
required this.isEnabled,
|
||||
required this.withFeedback,
|
||||
required this.withHighlightChange,
|
||||
required this.textDirection,
|
||||
this.configuration,
|
||||
//s1 -- Style
|
||||
this.splashFactory,
|
||||
required this.isCircular,
|
||||
this.isCircular = true,
|
||||
this.style,
|
||||
//s1 -- Content
|
||||
this.loadingContent,
|
||||
@@ -103,10 +87,7 @@ class _AstromicIconButtonState extends State<AstromicIconButton> {
|
||||
//s1 -Widgets
|
||||
//-----
|
||||
Widget baseChild = AstromicButtonBase(
|
||||
isEnabled: widget.isEnabled,
|
||||
withFeedback: widget.withFeedback,
|
||||
withHighlightChange: widget.withHighlightChange,
|
||||
textDirection: widget.textDirection,
|
||||
configuration: widget.configuration,
|
||||
//
|
||||
onTap: !isLoading && context.mounted && widget.onTap != null
|
||||
? () {
|
||||
@@ -134,10 +115,11 @@ class _AstromicIconButtonState extends State<AstromicIconButton> {
|
||||
});
|
||||
}
|
||||
: null,
|
||||
splashFactory: widget.splashFactory,
|
||||
style: (enabled, highlighted) => widget.style!(enabled, highlighted, isLoading).copyWith(
|
||||
borderRadius: widget.isCircular ? BorderRadiusDirectional.circular(100000000000) : null,
|
||||
),
|
||||
style: widget.style == null
|
||||
? null
|
||||
: (enabled, highlighted) => widget.style!.call(enabled, highlighted, isLoading).copyWith(
|
||||
borderRadius: widget.isCircular ? BorderRadiusDirectional.circular(100000000000) : null,
|
||||
),
|
||||
child: (enabled, highlighted) => isLoading && widget.loadingContent != null ? widget.loadingContent! : widget.icon(enabled, highlighted),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,32 +1,23 @@
|
||||
//SECTION - Imports
|
||||
//
|
||||
//s1 PACKAGES
|
||||
//---------------
|
||||
//s2 CORE
|
||||
//s1 Imports
|
||||
//s2 Core Package Imports
|
||||
import 'package:flutter/material.dart';
|
||||
//s2 3RD-PARTY
|
||||
//
|
||||
//s1 DEPENDENCIES
|
||||
//---------------
|
||||
//s2 SERVICES
|
||||
//s2 MODELS
|
||||
//s2 MISC
|
||||
//s2 1st-party Package Imports
|
||||
//s2 3rd-party Package Imports
|
||||
//s2 Dependancies Imports
|
||||
//s3 Routes
|
||||
//s3 Services
|
||||
//s3 Models
|
||||
import 'base.dart';
|
||||
import 'style.dart';
|
||||
import 'models/models.exports.dart';
|
||||
//s1 Exports
|
||||
|
||||
//!SECTION - Imports
|
||||
//
|
||||
//SECTION - Exports
|
||||
//!SECTION - Exports
|
||||
//
|
||||
class AstromicLinkButton extends StatelessWidget {
|
||||
//SECTION - Widget Arguments
|
||||
//s1 -- Functionality
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onHold;
|
||||
//s1 -- Configurations
|
||||
final bool isEnabled;
|
||||
final TextDirection textDirection;
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
//s1 -- Style
|
||||
final bool Function(bool isEnabled) isUnderlined;
|
||||
final EdgeInsetsGeometry? contentPadding;
|
||||
@@ -45,8 +36,7 @@ class AstromicLinkButton extends StatelessWidget {
|
||||
this.onTap,
|
||||
this.onHold,
|
||||
//s1 -- Configurations
|
||||
required this.isEnabled,
|
||||
required this.textDirection,
|
||||
this.configuration,
|
||||
//s1 -- Style
|
||||
required this.isUnderlined,
|
||||
this.contentPadding,
|
||||
@@ -76,16 +66,13 @@ class AstromicLinkButton extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
textDirection: textDirection,
|
||||
textDirection: configuration?.textDirection,
|
||||
children: [
|
||||
AstromicButtonBase(
|
||||
onTap: onTap,
|
||||
onHold: onHold,
|
||||
//
|
||||
isEnabled: isEnabled,
|
||||
withFeedback: false,
|
||||
withHighlightChange: false,
|
||||
textDirection: textDirection,
|
||||
configuration: configuration,
|
||||
//
|
||||
style: (isEnabled, isHighlighted) => AstromicButtonStyle(
|
||||
contentPadding: contentPadding,
|
||||
|
||||
30
lib/src/Buttons/src/models/configuration.model.dart
Normal file
30
lib/src/Buttons/src/models/configuration.model.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
/// Configuration model for the button element.
|
||||
class AstromicButtonConfiguration {
|
||||
final bool isEnabled;
|
||||
final bool withFeedback;
|
||||
final bool withHighlightChange;
|
||||
final TextDirection textDirection;
|
||||
AstromicButtonConfiguration({
|
||||
required this.isEnabled,
|
||||
required this.withFeedback,
|
||||
required this.withHighlightChange,
|
||||
required this.textDirection,
|
||||
});
|
||||
|
||||
AstromicButtonConfiguration copyWith({
|
||||
bool? isEnabled,
|
||||
bool? withFeedback,
|
||||
bool? withHighlightChange,
|
||||
TextDirection? textDirection,
|
||||
}) {
|
||||
return AstromicButtonConfiguration(
|
||||
isEnabled: isEnabled ?? this.isEnabled,
|
||||
withFeedback: withFeedback ?? this.withFeedback,
|
||||
withHighlightChange: withHighlightChange ?? this.withHighlightChange,
|
||||
textDirection: textDirection ?? this.textDirection,
|
||||
);
|
||||
}
|
||||
}
|
||||
2
lib/src/Buttons/src/models/models.exports.dart
Normal file
2
lib/src/Buttons/src/models/models.exports.dart
Normal file
@@ -0,0 +1,2 @@
|
||||
export 'style.model.dart';
|
||||
export 'configuration.model.dart';
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Styling model for the button element.
|
||||
class AstromicButtonStyle {
|
||||
//s1 -- Colors
|
||||
final Color? backgroundColor;
|
||||
@@ -8,6 +9,7 @@ class AstromicButtonStyle {
|
||||
final Color? splashColor;
|
||||
final Color? highlightColor;
|
||||
final Color? borderColor;
|
||||
final Gradient? borderGradient;
|
||||
//
|
||||
//s1 -- Spacing & Insets
|
||||
final double? fixedHeight;
|
||||
@@ -15,6 +17,8 @@ class AstromicButtonStyle {
|
||||
final EdgeInsetsGeometry? contentPadding;
|
||||
final BorderRadiusGeometry? borderRadius;
|
||||
final double? borderWidth;
|
||||
//s1 -- Interactions
|
||||
final InteractiveInkFeatureFactory? splashFactory;
|
||||
const AstromicButtonStyle({
|
||||
this.backgroundColor = Colors.transparent,
|
||||
this.backgroundGradient,
|
||||
@@ -22,6 +26,7 @@ class AstromicButtonStyle {
|
||||
this.splashColor,
|
||||
this.highlightColor,
|
||||
this.borderColor,
|
||||
this.borderGradient,
|
||||
//
|
||||
this.fixedHeight,
|
||||
this.fixedWidth,
|
||||
@@ -29,6 +34,8 @@ class AstromicButtonStyle {
|
||||
this.borderRadius,
|
||||
this.borderWidth,
|
||||
//
|
||||
this.splashFactory,
|
||||
//
|
||||
});
|
||||
|
||||
AstromicButtonStyle copyWith({
|
||||
@@ -38,11 +45,13 @@ class AstromicButtonStyle {
|
||||
Color? splashColor,
|
||||
Color? highlightColor,
|
||||
Color? borderColor,
|
||||
Gradient? borderGradient,
|
||||
double? fixedHeight,
|
||||
double? fixedWidth,
|
||||
EdgeInsetsGeometry? contentPadding,
|
||||
BorderRadiusGeometry? borderRadius,
|
||||
double? borderWidth,
|
||||
InteractiveInkFeatureFactory? splashFactory,
|
||||
}) {
|
||||
return AstromicButtonStyle(
|
||||
backgroundGradient: backgroundGradient ?? this.backgroundGradient,
|
||||
@@ -51,11 +60,13 @@ class AstromicButtonStyle {
|
||||
splashColor: splashColor ?? this.splashColor,
|
||||
highlightColor: highlightColor ?? this.highlightColor,
|
||||
borderColor: borderColor ?? this.borderColor,
|
||||
borderGradient: borderGradient ?? this.borderGradient,
|
||||
fixedHeight: fixedHeight == -1 ? null : fixedHeight ?? this.fixedHeight,
|
||||
fixedWidth: fixedWidth == -1 ? null : fixedWidth ?? this.fixedWidth,
|
||||
contentPadding: contentPadding ?? this.contentPadding,
|
||||
borderRadius: borderRadius ?? this.borderRadius,
|
||||
borderWidth: borderWidth ?? this.borderWidth,
|
||||
splashFactory: splashFactory ?? this.splashFactory,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
enum SizingStrategy {
|
||||
hug,
|
||||
fill,
|
||||
fixed,
|
||||
}
|
||||
@@ -1,24 +1,16 @@
|
||||
//SECTION - Imports
|
||||
//
|
||||
//s1 PACKAGES
|
||||
//---------------
|
||||
//s2 CORE
|
||||
//s1 Imports
|
||||
//s2 Core Package Imports
|
||||
import 'package:flutter/material.dart';
|
||||
//s2 1st-party Package Imports
|
||||
//s2 3rd-party Package Imports
|
||||
//s2 Dependancies Imports
|
||||
//s3 Routes
|
||||
//s3 Services
|
||||
//s3 Models
|
||||
import 'base.dart';
|
||||
//s2 3RD-PARTY
|
||||
//
|
||||
//s1 DEPENDENCIES
|
||||
//---------------
|
||||
//s2 SERVICES
|
||||
//s2 MODELS
|
||||
import 'sizing_strategy.enum.dart';
|
||||
import 'style.dart';
|
||||
//s2 MISC
|
||||
//!SECTION - Imports
|
||||
//
|
||||
//SECTION - Exports
|
||||
//!SECTION - Exports
|
||||
//
|
||||
import 'enums/enums.exports.dart';
|
||||
import 'models/models.exports.dart';
|
||||
//s1 Exports
|
||||
|
||||
class AstromicStateButton extends StatefulWidget {
|
||||
//SECTION - Widget Arguments
|
||||
@@ -26,14 +18,11 @@ class AstromicStateButton extends StatefulWidget {
|
||||
final void Function(VoidCallback start, VoidCallback stop)? onTap;
|
||||
final Function(VoidCallback start, VoidCallback stop)? onHold;
|
||||
//s1 -- Configurations
|
||||
final bool isEnabled;
|
||||
final bool withFeedback;
|
||||
final bool withHighlightChange;
|
||||
final TextDirection textDirection;
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
|
||||
//s1 -- Style
|
||||
final SizingStrategy? widthSizingStrategy;
|
||||
final SizingStrategy? heightSizingStrategy;
|
||||
final InteractiveInkFeatureFactory? splashFactory;
|
||||
final AstromicSizingStrategy? widthSizingStrategy;
|
||||
final AstromicSizingStrategy? heightSizingStrategy;
|
||||
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted, bool isLoading)? style;
|
||||
//s1 -- Content
|
||||
final Widget? loadingContent;
|
||||
@@ -46,19 +35,15 @@ class AstromicStateButton extends StatefulWidget {
|
||||
this.onTap,
|
||||
this.onHold,
|
||||
//
|
||||
required this.isEnabled,
|
||||
required this.withFeedback,
|
||||
required this.withHighlightChange,
|
||||
required this.textDirection,
|
||||
this.configuration,
|
||||
//s1 -- Style
|
||||
this.widthSizingStrategy = SizingStrategy.hug,
|
||||
this.heightSizingStrategy = SizingStrategy.hug,
|
||||
this.splashFactory,
|
||||
this.widthSizingStrategy = AstromicSizingStrategy.hug,
|
||||
this.heightSizingStrategy = AstromicSizingStrategy.hug,
|
||||
this.style,
|
||||
//s1 -- Content
|
||||
this.loadingContent,
|
||||
required this.content,
|
||||
}) : assert(heightSizingStrategy != SizingStrategy.fill, 'Height strategy cannot be fill');
|
||||
}) : assert(heightSizingStrategy != AstromicSizingStrategy.fill, 'Height strategy cannot be fill');
|
||||
|
||||
@override
|
||||
State<AstromicStateButton> createState() => _AstromicStateButtonState();
|
||||
@@ -106,10 +91,7 @@ class _AstromicStateButtonState extends State<AstromicStateButton> {
|
||||
//s1 -Widgets
|
||||
//-----
|
||||
Widget baseChild = AstromicButtonBase(
|
||||
isEnabled: widget.isEnabled,
|
||||
withFeedback: widget.withFeedback,
|
||||
withHighlightChange: widget.withHighlightChange,
|
||||
textDirection: widget.textDirection,
|
||||
configuration: widget.configuration,
|
||||
//
|
||||
onTap: !isLoading && context.mounted && widget.onTap != null
|
||||
? () {
|
||||
@@ -137,16 +119,15 @@ class _AstromicStateButtonState extends State<AstromicStateButton> {
|
||||
});
|
||||
}
|
||||
: null,
|
||||
splashFactory: widget.splashFactory,
|
||||
style: (enabled, highlighted) => widget.style!(enabled, highlighted, isLoading).copyWith(
|
||||
contentPadding: widget.heightSizingStrategy == SizingStrategy.fixed && widget.widthSizingStrategy == SizingStrategy.fixed
|
||||
contentPadding: widget.heightSizingStrategy == AstromicSizingStrategy.fixed && widget.widthSizingStrategy == AstromicSizingStrategy.fixed
|
||||
? EdgeInsets.zero
|
||||
: widget.heightSizingStrategy == SizingStrategy.fixed && widget.widthSizingStrategy != SizingStrategy.fixed
|
||||
: widget.heightSizingStrategy == AstromicSizingStrategy.fixed && widget.widthSizingStrategy != AstromicSizingStrategy.fixed
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: widget.style!(enabled, highlighted, isLoading).contentPadding?.horizontal ?? 0,
|
||||
vertical: 0,
|
||||
)
|
||||
: widget.widthSizingStrategy == SizingStrategy.fixed && widget.heightSizingStrategy != SizingStrategy.fixed
|
||||
: widget.widthSizingStrategy == AstromicSizingStrategy.fixed && widget.heightSizingStrategy != AstromicSizingStrategy.fixed
|
||||
? EdgeInsets.symmetric(
|
||||
vertical: widget.style!(enabled, highlighted, isLoading).contentPadding?.vertical ?? 0,
|
||||
horizontal: 0,
|
||||
@@ -161,18 +142,24 @@ class _AstromicStateButtonState extends State<AstromicStateButton> {
|
||||
|
||||
//SECTION - Build Return
|
||||
return Row(
|
||||
mainAxisSize: widget.widthSizingStrategy == SizingStrategy.hug ? MainAxisSize.min : MainAxisSize.max,
|
||||
mainAxisSize: widget.widthSizingStrategy == AstromicSizingStrategy.hug ? MainAxisSize.min : MainAxisSize.max,
|
||||
children: [
|
||||
widget.widthSizingStrategy == SizingStrategy.fill
|
||||
widget.widthSizingStrategy == AstromicSizingStrategy.fill
|
||||
? Expanded(
|
||||
child: SizedBox(
|
||||
height: widget.heightSizingStrategy == SizingStrategy.fixed && widget.style != null ? widget.style!(widget.isEnabled, isHighlighted, isLoading).fixedHeight : null,
|
||||
height: widget.heightSizingStrategy == AstromicSizingStrategy.fixed && widget.style != null
|
||||
? widget.style!(widget.configuration?.isEnabled ?? true, isHighlighted, isLoading).fixedHeight
|
||||
: null,
|
||||
child: baseChild,
|
||||
),
|
||||
)
|
||||
: SizedBox(
|
||||
width: widget.widthSizingStrategy == SizingStrategy.fixed && widget.style != null ? widget.style!(widget.isEnabled, isHighlighted, isLoading).fixedWidth : null,
|
||||
height: widget.heightSizingStrategy == SizingStrategy.fixed && widget.style != null ? widget.style!(widget.isEnabled, isHighlighted, isLoading).fixedHeight : null,
|
||||
width: widget.widthSizingStrategy == AstromicSizingStrategy.fixed && widget.style != null
|
||||
? widget.style!(widget.configuration?.isEnabled ?? true, isHighlighted, isLoading).fixedWidth
|
||||
: null,
|
||||
height: widget.heightSizingStrategy == AstromicSizingStrategy.fixed && widget.style != null
|
||||
? widget.style!(widget.configuration?.isEnabled ?? true, isHighlighted, isLoading).fixedHeight
|
||||
: null,
|
||||
child: baseChild,
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user