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

View File

@@ -27,7 +27,7 @@ class AstromicButtonBase extends StatefulWidget {
final bool isEnabled; final bool isEnabled;
final bool withFeedback; final bool withFeedback;
final bool withHighlightChange; final bool withHighlightChange;
final bool isFullWidth; final TextDirection textDirection;
//s1 -- Style //s1 -- Style
final InteractiveInkFeatureFactory? splashFactory; final InteractiveInkFeatureFactory? splashFactory;
final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted) style; final AstromicButtonStyle Function(bool isEnabled, bool isHighlighted) style;
@@ -44,7 +44,7 @@ class AstromicButtonBase extends StatefulWidget {
this.isEnabled = true, this.isEnabled = true,
this.withFeedback = true, this.withFeedback = true,
this.withHighlightChange = true, this.withHighlightChange = true,
this.isFullWidth = false, required this.textDirection,
//s1 -- Style //s1 -- Style
this.splashFactory, this.splashFactory,
required this.style, required this.style,
@@ -107,11 +107,11 @@ class _AstromicButtonBaseState extends State<AstromicButtonBase> {
width: widget.style(widget.isEnabled, _isHighlighted).borderWidth ?? 1, width: widget.style(widget.isEnabled, _isHighlighted).borderWidth ?? 1,
color: widget.style(widget.isEnabled, _isHighlighted).borderColor ?? Colors.black, 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( child: Ink(
decoration: BoxDecoration( 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, gradient: widget.style(widget.isEnabled, _isHighlighted).backgroundGradient,
), ),
child: InkWell( child: InkWell(
@@ -120,7 +120,7 @@ class _AstromicButtonBaseState extends State<AstromicButtonBase> {
hoverColor: widget.withFeedback ? widget.style(widget.isEnabled, _isHighlighted).hoverColor : Colors.transparent, hoverColor: widget.withFeedback ? widget.style(widget.isEnabled, _isHighlighted).hoverColor : Colors.transparent,
highlightColor: widget.withFeedback ? widget.style(widget.isEnabled, _isHighlighted).highlightColor : 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, onTap: widget.isEnabled && widget.onTap != null ? widget.onTap : null,
onLongPress: widget.isEnabled && widget.onHold != null ? widget.onHold : 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 isEnabled;
final bool withFeedback; final bool withFeedback;
final bool withHighlightChange; final bool withHighlightChange;
final TextDirection textDirection;
//s1 -- Style //s1 -- Style
final InteractiveInkFeatureFactory? splashFactory; final InteractiveInkFeatureFactory? splashFactory;
final bool isCircular; final bool isCircular;
@@ -46,6 +47,7 @@ class AstromicIconButton extends StatefulWidget {
required this.isEnabled, required this.isEnabled,
required this.withFeedback, required this.withFeedback,
required this.withHighlightChange, required this.withHighlightChange,
required this.textDirection,
//s1 -- Style //s1 -- Style
this.splashFactory, this.splashFactory,
required this.isCircular, required this.isCircular,
@@ -102,9 +104,9 @@ class _AstromicIconButtonState extends State<AstromicIconButton> {
//----- //-----
Widget baseChild = AstromicButtonBase( Widget baseChild = AstromicButtonBase(
isEnabled: widget.isEnabled, isEnabled: widget.isEnabled,
withFeedback: widget.withFeedback!, withFeedback: widget.withFeedback,
withHighlightChange: widget.withHighlightChange!, withHighlightChange: widget.withHighlightChange,
isFullWidth: false, textDirection: widget.textDirection,
// //
onTap: !isLoading && context.mounted && widget.onTap != null onTap: !isLoading && context.mounted && widget.onTap != null
? () { ? () {

View File

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

View File

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