[0.1.0]
This commit is contained in:
@@ -79,7 +79,7 @@ class AstromicButtons {
|
||||
onTap: onTap,
|
||||
onHold: onHold,
|
||||
configuration: configuration,
|
||||
isUnderlined: isUnderlined ?? (e) => e,
|
||||
isUnderlined: isUnderlined ?? (bool e) => e,
|
||||
contentPadding: contentPadding,
|
||||
style: style,
|
||||
text: text,
|
||||
|
||||
@@ -12,16 +12,6 @@ import 'models/models.exports.dart';
|
||||
//s1 Exports
|
||||
|
||||
class AstromicButtonBase extends StatefulWidget {
|
||||
//SECTION - Widget Arguments
|
||||
//s1 -- Functionality
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onHold;
|
||||
//s1 -- Configurations
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
//s1 -- Style
|
||||
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted)? style;
|
||||
//s1 -- Content
|
||||
final Widget Function(bool isEnabled, bool isHighlighted) child;
|
||||
//!SECTION
|
||||
//
|
||||
const AstromicButtonBase({
|
||||
@@ -38,6 +28,16 @@ class AstromicButtonBase extends StatefulWidget {
|
||||
}) : super(
|
||||
key: key,
|
||||
);
|
||||
//SECTION - Widget Arguments
|
||||
//s1 -- Functionality
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onHold;
|
||||
//s1 -- Configurations
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
//s1 -- Style
|
||||
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted)? style;
|
||||
//s1 -- Content
|
||||
final Widget Function(bool isEnabled, bool isHighlighted) child;
|
||||
|
||||
@override
|
||||
State<AstromicButtonBase> createState() => _AstromicButtonBaseState();
|
||||
@@ -121,7 +121,7 @@ class _AstromicButtonBaseState extends State<AstromicButtonBase> {
|
||||
onTap: _config.isEnabled && widget.onTap != null ? widget.onTap : null,
|
||||
onLongPress: _config.isEnabled && widget.onHold != null ? widget.onHold : null,
|
||||
onHighlightChanged: _config.withHighlightChange
|
||||
? (v) {
|
||||
? (bool v) {
|
||||
setState(() {
|
||||
_isHighlighted = v;
|
||||
});
|
||||
|
||||
@@ -12,18 +12,6 @@ import 'models/models.exports.dart';
|
||||
//s1 Exports
|
||||
|
||||
class AstromicIconButton extends StatefulWidget {
|
||||
//SECTION - Widget Arguments
|
||||
//s1 -- Functionality
|
||||
final void Function(VoidCallback start, VoidCallback stop)? onTap;
|
||||
final Function(VoidCallback start, VoidCallback stop)? onHold;
|
||||
//s1 -- Configurations
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
//s1 -- Style
|
||||
final bool isCircular;
|
||||
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted, bool isLoading)? style;
|
||||
//s1 -- Content
|
||||
final Widget? loadingContent;
|
||||
final Widget Function(bool isEnabled, bool isHighlighted) icon;
|
||||
//!SECTION
|
||||
//
|
||||
const AstromicIconButton({
|
||||
@@ -40,6 +28,18 @@ class AstromicIconButton extends StatefulWidget {
|
||||
this.loadingContent,
|
||||
required this.icon,
|
||||
});
|
||||
//SECTION - Widget Arguments
|
||||
//s1 -- Functionality
|
||||
final void Function(VoidCallback start, VoidCallback stop)? onTap;
|
||||
final Function(VoidCallback start, VoidCallback stop)? onHold;
|
||||
//s1 -- Configurations
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
//s1 -- Style
|
||||
final bool isCircular;
|
||||
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted, bool isLoading)? style;
|
||||
//s1 -- Content
|
||||
final Widget? loadingContent;
|
||||
final Widget Function(bool isEnabled, bool isHighlighted) icon;
|
||||
|
||||
@override
|
||||
State<AstromicIconButton> createState() => _AstromicIconButtonState();
|
||||
@@ -117,10 +117,10 @@ class _AstromicIconButtonState extends State<AstromicIconButton> {
|
||||
: null,
|
||||
style: widget.style == null
|
||||
? null
|
||||
: (enabled, highlighted) => widget.style!.call(enabled, highlighted, isLoading).copyWith(
|
||||
: (bool enabled, bool 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),
|
||||
child: (bool enabled, bool highlighted) => isLoading && widget.loadingContent != null ? widget.loadingContent! : widget.icon(enabled, highlighted),
|
||||
);
|
||||
|
||||
//s1 -Widgets
|
||||
|
||||
@@ -12,22 +12,6 @@ import 'models/models.exports.dart';
|
||||
//s1 Exports
|
||||
|
||||
class AstromicLinkButton extends StatelessWidget {
|
||||
//SECTION - Widget Arguments
|
||||
//s1 -- Functionality
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onHold;
|
||||
//s1 -- Configurations
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
//s1 -- Style
|
||||
final bool Function(bool isEnabled) isUnderlined;
|
||||
final EdgeInsetsGeometry? contentPadding;
|
||||
final TextStyle Function(bool isEnabled)? style;
|
||||
//
|
||||
//s1 -- Content
|
||||
final String? text;
|
||||
final Widget? textWidget;
|
||||
final Widget? prefix;
|
||||
final Widget? suffix;
|
||||
//!SECTION
|
||||
//
|
||||
const AstromicLinkButton({
|
||||
@@ -50,6 +34,22 @@ class AstromicLinkButton extends StatelessWidget {
|
||||
super(
|
||||
key: key,
|
||||
);
|
||||
//SECTION - Widget Arguments
|
||||
//s1 -- Functionality
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onHold;
|
||||
//s1 -- Configurations
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
//s1 -- Style
|
||||
final bool Function(bool isEnabled) isUnderlined;
|
||||
final EdgeInsetsGeometry? contentPadding;
|
||||
final TextStyle Function(bool isEnabled)? style;
|
||||
//
|
||||
//s1 -- Content
|
||||
final String? text;
|
||||
final Widget? textWidget;
|
||||
final Widget? prefix;
|
||||
final Widget? suffix;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -64,27 +64,24 @@ class AstromicLinkButton extends StatelessWidget {
|
||||
//SECTION - Build Return
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
textDirection: configuration?.textDirection,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
AstromicButtonBase(
|
||||
onTap: onTap,
|
||||
onHold: onHold,
|
||||
//
|
||||
configuration: configuration,
|
||||
//
|
||||
style: (isEnabled, isHighlighted) => AstromicButtonStyle(
|
||||
style: (bool isEnabled, bool isHighlighted) => AstromicButtonStyle(
|
||||
contentPadding: contentPadding,
|
||||
borderWidth: 0,
|
||||
borderRadius: BorderRadius.zero,
|
||||
borderColor: Colors.transparent,
|
||||
),
|
||||
//
|
||||
child: (isEnabled, isHighlighted) => Row(
|
||||
child: (bool isEnabled, bool isHighlighted) => Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
if (prefix != null) prefix!,
|
||||
textWidget != null
|
||||
? textWidget!
|
||||
|
||||
@@ -2,23 +2,6 @@ import 'package:flutter/material.dart';
|
||||
|
||||
/// Styling model for the button element.
|
||||
class AstromicButtonStyle {
|
||||
//s1 -- Colors
|
||||
final Color? backgroundColor;
|
||||
final Gradient? backgroundGradient;
|
||||
final Color? hoverColor;
|
||||
final Color? splashColor;
|
||||
final Color? highlightColor;
|
||||
final Color? borderColor;
|
||||
final Gradient? borderGradient;
|
||||
//
|
||||
//s1 -- Spacing & Insets
|
||||
final double? fixedHeight;
|
||||
final double? fixedWidth;
|
||||
final EdgeInsetsGeometry? contentPadding;
|
||||
final BorderRadiusGeometry? borderRadius;
|
||||
final double? borderWidth;
|
||||
//s1 -- Interactions
|
||||
final InteractiveInkFeatureFactory? splashFactory;
|
||||
const AstromicButtonStyle({
|
||||
this.backgroundColor = Colors.transparent,
|
||||
this.backgroundGradient,
|
||||
@@ -37,6 +20,23 @@ class AstromicButtonStyle {
|
||||
this.splashFactory,
|
||||
//
|
||||
});
|
||||
//s1 -- Colors
|
||||
final Color? backgroundColor;
|
||||
final Gradient? backgroundGradient;
|
||||
final Color? hoverColor;
|
||||
final Color? splashColor;
|
||||
final Color? highlightColor;
|
||||
final Color? borderColor;
|
||||
final Gradient? borderGradient;
|
||||
//
|
||||
//s1 -- Spacing & Insets
|
||||
final double? fixedHeight;
|
||||
final double? fixedWidth;
|
||||
final EdgeInsetsGeometry? contentPadding;
|
||||
final BorderRadiusGeometry? borderRadius;
|
||||
final double? borderWidth;
|
||||
//s1 -- Interactions
|
||||
final InteractiveInkFeatureFactory? splashFactory;
|
||||
|
||||
AstromicButtonStyle copyWith({
|
||||
Color? backgroundColor,
|
||||
|
||||
@@ -13,20 +13,6 @@ import 'models/models.exports.dart';
|
||||
//s1 Exports
|
||||
|
||||
class AstromicStateButton extends StatefulWidget {
|
||||
//SECTION - Widget Arguments
|
||||
//s1 -- Functionality
|
||||
final void Function(VoidCallback start, VoidCallback stop)? onTap;
|
||||
final Function(VoidCallback start, VoidCallback stop)? onHold;
|
||||
//s1 -- Configurations
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
|
||||
//s1 -- Style
|
||||
final AstromicSizingStrategy? widthSizingStrategy;
|
||||
final AstromicSizingStrategy? heightSizingStrategy;
|
||||
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted, bool isLoading)? style;
|
||||
//s1 -- Content
|
||||
final Widget? loadingContent;
|
||||
final Widget Function(bool isEnabled, bool isHighlighted) content;
|
||||
//!SECTION
|
||||
//
|
||||
const AstromicStateButton({
|
||||
@@ -44,6 +30,20 @@ class AstromicStateButton extends StatefulWidget {
|
||||
this.loadingContent,
|
||||
required this.content,
|
||||
}) : assert(heightSizingStrategy != AstromicSizingStrategy.fill, 'Height strategy cannot be fill');
|
||||
//SECTION - Widget Arguments
|
||||
//s1 -- Functionality
|
||||
final void Function(VoidCallback start, VoidCallback stop)? onTap;
|
||||
final Function(VoidCallback start, VoidCallback stop)? onHold;
|
||||
//s1 -- Configurations
|
||||
final AstromicButtonConfiguration? configuration;
|
||||
|
||||
//s1 -- Style
|
||||
final AstromicSizingStrategy? widthSizingStrategy;
|
||||
final AstromicSizingStrategy? heightSizingStrategy;
|
||||
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted, bool isLoading)? style;
|
||||
//s1 -- Content
|
||||
final Widget? loadingContent;
|
||||
final Widget Function(bool isEnabled, bool isHighlighted) content;
|
||||
|
||||
@override
|
||||
State<AstromicStateButton> createState() => _AstromicStateButtonState();
|
||||
@@ -119,22 +119,20 @@ class _AstromicStateButtonState extends State<AstromicStateButton> {
|
||||
});
|
||||
}
|
||||
: null,
|
||||
style: (enabled, highlighted) => widget.style!(enabled, highlighted, isLoading).copyWith(
|
||||
style: (bool enabled, bool highlighted) => widget.style!(enabled, highlighted, isLoading).copyWith(
|
||||
contentPadding: widget.heightSizingStrategy == AstromicSizingStrategy.fixed && widget.widthSizingStrategy == AstromicSizingStrategy.fixed
|
||||
? EdgeInsets.zero
|
||||
: widget.heightSizingStrategy == AstromicSizingStrategy.fixed && widget.widthSizingStrategy != AstromicSizingStrategy.fixed
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: widget.style!(enabled, highlighted, isLoading).contentPadding?.horizontal ?? 0,
|
||||
vertical: 0,
|
||||
)
|
||||
: widget.widthSizingStrategy == AstromicSizingStrategy.fixed && widget.heightSizingStrategy != AstromicSizingStrategy.fixed
|
||||
? EdgeInsets.symmetric(
|
||||
vertical: widget.style!(enabled, highlighted, isLoading).contentPadding?.vertical ?? 0,
|
||||
horizontal: 0,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: (enabled, highlighted) => isLoading && widget.loadingContent != null ? widget.loadingContent! : widget.content(enabled, highlighted),
|
||||
child: (bool enabled, bool highlighted) => isLoading && widget.loadingContent != null ? widget.loadingContent! : widget.content(enabled, highlighted),
|
||||
);
|
||||
|
||||
//s1 -Widgets
|
||||
@@ -143,7 +141,7 @@ class _AstromicStateButtonState extends State<AstromicStateButton> {
|
||||
//SECTION - Build Return
|
||||
return Row(
|
||||
mainAxisSize: widget.widthSizingStrategy == AstromicSizingStrategy.hug ? MainAxisSize.min : MainAxisSize.max,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
widget.widthSizingStrategy == AstromicSizingStrategy.fill
|
||||
? Expanded(
|
||||
child: SizedBox(
|
||||
|
||||
Reference in New Issue
Block a user