[FIX] Text Direction resolving in the buttons

This commit is contained in:
2024-05-18 15:52:42 +03:00
parent be1271f2da
commit 2cf19e40b8
5 changed files with 18 additions and 12 deletions

View File

@@ -21,6 +21,7 @@ class AstromicButtons {
bool? isEnabled,
bool? withFeedback,
bool? withHighlightChange,
TextDirection? textDirection,
//
SizingStrategy? widthSizingStrategy,
SizingStrategy? heightSizingStrategy,
@@ -37,6 +38,7 @@ class AstromicButtons {
isEnabled: isEnabled ?? true,
withFeedback: withFeedback ?? true,
withHighlightChange: withHighlightChange ?? true,
textDirection: textDirection ?? TextDirection.ltr,
//
widthSizingStrategy: widthSizingStrategy,
heightSizingStrategy: heightSizingStrategy,
@@ -56,6 +58,7 @@ class AstromicButtons {
bool? isEnabled,
bool? withFeedback,
bool? withHighlightChange,
TextDirection? textDirection,
//
bool? isCircular,
InteractiveInkFeatureFactory? splashFactory,
@@ -71,6 +74,7 @@ class AstromicButtons {
isEnabled: isEnabled ?? true,
withFeedback: withFeedback ?? true,
withHighlightChange: withHighlightChange ?? true,
textDirection: textDirection ?? TextDirection.ltr,
//
isCircular: isCircular ?? true,
splashFactory: splashFactory,
@@ -88,7 +92,6 @@ class AstromicButtons {
//
bool? isEnabled,
TextDirection? textDirection,
//
bool Function(bool isEnabled)? isUnderlined,
EdgeInsetsGeometry? contentPadding,

View File

@@ -27,7 +27,7 @@ class AstromicButtonBase extends StatefulWidget {
final bool isEnabled;
final bool withFeedback;
final bool withHighlightChange;
final bool isFullWidth;
final TextDirection textDirection;
//s1 -- Style
final InteractiveInkFeatureFactory? splashFactory;
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted) style;
@@ -44,7 +44,7 @@ class AstromicButtonBase extends StatefulWidget {
this.isEnabled = true,
this.withFeedback = true,
this.withHighlightChange = true,
this.isFullWidth = false,
required this.textDirection,
//s1 -- Style
this.splashFactory,
required this.style,
@@ -107,11 +107,11 @@ class _AstromicButtonBaseState extends State<AstromicButtonBase> {
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(null) ?? BorderRadius.circular(0),
borderRadius: widget.style(widget.isEnabled, _isHighlighted).borderRadius?.resolve(widget.textDirection) ?? BorderRadius.circular(0),
),
child: Ink(
decoration: BoxDecoration(
borderRadius: widget.style(widget.isEnabled, _isHighlighted).borderRadius?.resolve(null) ?? BorderRadius.circular(0),
borderRadius: widget.style(widget.isEnabled, _isHighlighted).borderRadius?.resolve(widget.textDirection) ?? BorderRadius.circular(0),
gradient: widget.style(widget.isEnabled, _isHighlighted).backgroundGradient,
),
child: InkWell(
@@ -120,7 +120,7 @@ class _AstromicButtonBaseState extends State<AstromicButtonBase> {
hoverColor: widget.withFeedback ? widget.style(widget.isEnabled, _isHighlighted).hoverColor : Colors.transparent,
highlightColor: widget.withFeedback ? widget.style(widget.isEnabled, _isHighlighted).highlightColor : Colors.transparent,
//
borderRadius: widget.style(widget.isEnabled, _isHighlighted).borderRadius?.resolve(null) ?? BorderRadius.circular(0),
borderRadius: widget.style(widget.isEnabled, _isHighlighted).borderRadius?.resolve(widget.textDirection) ?? BorderRadius.circular(0),
//
onTap: widget.isEnabled && widget.onTap != null ? widget.onTap : null,
onLongPress: widget.isEnabled && widget.onHold != null ? widget.onHold : null,

View File

@@ -28,6 +28,7 @@ class AstromicIconButton extends StatefulWidget {
final bool isEnabled;
final bool withFeedback;
final bool withHighlightChange;
final TextDirection textDirection;
//s1 -- Style
final InteractiveInkFeatureFactory? splashFactory;
final bool isCircular;
@@ -46,6 +47,7 @@ class AstromicIconButton extends StatefulWidget {
required this.isEnabled,
required this.withFeedback,
required this.withHighlightChange,
required this.textDirection,
//s1 -- Style
this.splashFactory,
required this.isCircular,
@@ -102,9 +104,9 @@ class _AstromicIconButtonState extends State<AstromicIconButton> {
//-----
Widget baseChild = AstromicButtonBase(
isEnabled: widget.isEnabled,
withFeedback: widget.withFeedback!,
withHighlightChange: widget.withHighlightChange!,
isFullWidth: false,
withFeedback: widget.withFeedback,
withHighlightChange: widget.withHighlightChange,
textDirection: widget.textDirection,
//
onTap: !isLoading && context.mounted && widget.onTap != null
? () {

View File

@@ -4,7 +4,6 @@
//---------------
//s2 CORE
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
//s2 3RD-PARTY
//
//s1 DEPENDENCIES
@@ -86,7 +85,7 @@ class AstromicLinkButton extends StatelessWidget {
isEnabled: isEnabled,
withFeedback: false,
withHighlightChange: false,
isFullWidth: false,
textDirection: textDirection,
//
style: (isEnabled, isHighlighted) => AstromicButtonStyle(
contentPadding: contentPadding,

View File

@@ -29,6 +29,7 @@ class AstromicStateButton extends StatefulWidget {
final bool isEnabled;
final bool withFeedback;
final bool withHighlightChange;
final TextDirection textDirection;
//s1 -- Style
final SizingStrategy? widthSizingStrategy;
final SizingStrategy? heightSizingStrategy;
@@ -48,6 +49,7 @@ class AstromicStateButton extends StatefulWidget {
required this.isEnabled,
required this.withFeedback,
required this.withHighlightChange,
required this.textDirection,
//s1 -- Style
this.widthSizingStrategy = SizingStrategy.hug,
this.heightSizingStrategy = SizingStrategy.hug,
@@ -107,7 +109,7 @@ class _AstromicStateButtonState extends State<AstromicStateButton> {
isEnabled: widget.isEnabled,
withFeedback: widget.withFeedback,
withHighlightChange: widget.withHighlightChange,
isFullWidth: false,
textDirection: widget.textDirection,
//
onTap: !isLoading && context.mounted && widget.onTap != null
? () {