From 2cf19e40b8ae94a3be3299da8301390a0d27727d Mon Sep 17 00:00:00 2001 From: "Michael W. Aziz" Date: Sat, 18 May 2024 15:52:42 +0300 Subject: [PATCH] [FIX] Text Direction resolving in the buttons --- lib/src/Buttons/buttons.astromic.dart | 5 ++++- lib/src/Buttons/src/base.dart | 10 +++++----- lib/src/Buttons/src/icon_button.dart | 8 +++++--- lib/src/Buttons/src/link_button.dart | 3 +-- lib/src/Buttons/src/state_button.dart | 4 +++- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/src/Buttons/buttons.astromic.dart b/lib/src/Buttons/buttons.astromic.dart index 42bf3cc..571dd97 100644 --- a/lib/src/Buttons/buttons.astromic.dart +++ b/lib/src/Buttons/buttons.astromic.dart @@ -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, diff --git a/lib/src/Buttons/src/base.dart b/lib/src/Buttons/src/base.dart index 5b99677..2ede509 100644 --- a/lib/src/Buttons/src/base.dart +++ b/lib/src/Buttons/src/base.dart @@ -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 { 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 { 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, diff --git a/lib/src/Buttons/src/icon_button.dart b/lib/src/Buttons/src/icon_button.dart index 5f55dc5..c7ebe0c 100644 --- a/lib/src/Buttons/src/icon_button.dart +++ b/lib/src/Buttons/src/icon_button.dart @@ -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 { //----- 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 ? () { diff --git a/lib/src/Buttons/src/link_button.dart b/lib/src/Buttons/src/link_button.dart index b931b3d..114d939 100644 --- a/lib/src/Buttons/src/link_button.dart +++ b/lib/src/Buttons/src/link_button.dart @@ -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, diff --git a/lib/src/Buttons/src/state_button.dart b/lib/src/Buttons/src/state_button.dart index b08e591..8aecdd6 100644 --- a/lib/src/Buttons/src/state_button.dart +++ b/lib/src/Buttons/src/state_button.dart @@ -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 { isEnabled: widget.isEnabled, withFeedback: widget.withFeedback, withHighlightChange: widget.withHighlightChange, - isFullWidth: false, + textDirection: widget.textDirection, // onTap: !isLoading && context.mounted && widget.onTap != null ? () {