Skip to content

Commit

Permalink
fix: [MDS-410] Button fullWidth property bugs out in some conditions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Kypsis authored Mar 2, 2023
1 parent 956e0db commit 52ed9b7
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 48 deletions.
4 changes: 2 additions & 2 deletions lib/moon_design.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export 'package:moon_design/src/widgets/common/progress_indicators/circular_prog
export 'package:moon_design/src/widgets/common/progress_indicators/linear_progress_indicator.dart';
export 'package:moon_design/src/widgets/effects/focus_effect.dart';
export 'package:moon_design/src/widgets/effects/pulse_effect.dart';
export 'package:moon_design/src/widgets/loader/circular_loader.dart';
export 'package:moon_design/src/widgets/loader/linear_loader.dart';
export 'package:moon_design/src/widgets/loaders/circular_loader.dart';
export 'package:moon_design/src/widgets/loaders/linear_loader.dart';
export 'package:moon_design/src/widgets/progress/circular_progress.dart';
export 'package:moon_design/src/widgets/progress/linear_progress.dart';
export 'package:moon_design/src/widgets/tag/tag.dart';
Expand Down
93 changes: 47 additions & 46 deletions lib/src/widgets/buttons/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ class MoonButton extends StatelessWidget {
curve: effectiveHoverEffectCurve,
width: width,
height: effectiveHeight,
padding: correctedPadding,
constraints: BoxConstraints(minWidth: effectiveHeight),
decoration: ShapeDecoration(
color: canAnimateHover ? hoverColor : backgroundColor,
Expand Down Expand Up @@ -434,59 +433,61 @@ class MoonButton extends StatelessWidget {
),
),
),
child: AnimatedIconTheme(
duration: effectiveHoverEffectDuration,
curve: effectiveHoverEffectCurve,
color: effectiveTextColor,
size: effectiveMoonButtonSize.iconSizeValue,
child: AnimatedDefaultTextStyle(
style: TextStyle(color: effectiveTextColor, fontSize: effectiveMoonButtonSize.textStyle.fontSize),
child: Padding(
padding: isFullWidth ? EdgeInsets.zero : correctedPadding,
child: AnimatedIconTheme(
duration: effectiveHoverEffectDuration,
curve: effectiveHoverEffectCurve,
child: isFullWidth
? Stack(
fit: StackFit.expand,
alignment: Alignment.center,
children: [
if (leftIcon != null)
Align(
alignment: Alignment.centerLeft,
child: Padding(
color: effectiveTextColor,
size: effectiveMoonButtonSize.iconSizeValue,
child: AnimatedDefaultTextStyle(
style: TextStyle(color: effectiveTextColor, fontSize: effectiveMoonButtonSize.textStyle.fontSize),
duration: effectiveHoverEffectDuration,
curve: effectiveHoverEffectCurve,
child: isFullWidth
? Stack(
fit: StackFit.expand,
children: [
if (leftIcon != null)
Container(
margin: EdgeInsets.symmetric(horizontal: effectiveGap),
alignment: Directionality.of(context) == TextDirection.ltr
? Alignment.centerLeft
: Alignment.centerRight,
child: leftIcon,
),
if (label != null)
Align(
child: label,
),
if (rightIcon != null)
Container(
margin: EdgeInsets.symmetric(horizontal: effectiveGap),
alignment: Directionality.of(context) == TextDirection.ltr
? Alignment.centerRight
: Alignment.centerLeft,
child: rightIcon,
),
],
)
: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (leftIcon != null)
Padding(
padding: EdgeInsets.symmetric(horizontal: effectiveGap),
child: leftIcon,
),
),
if (label != null)
Align(
child: label,
),
if (rightIcon != null)
Align(
alignment: Alignment.centerRight,
child: Padding(
if (label != null) label!,
if (rightIcon != null)
Padding(
padding: EdgeInsets.symmetric(horizontal: effectiveGap),
child: rightIcon,
),
),
],
)
: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (leftIcon != null)
Padding(
padding: EdgeInsets.symmetric(horizontal: effectiveGap),
child: leftIcon,
),
if (label != null) label!,
if (rightIcon != null)
Padding(
padding: EdgeInsets.symmetric(horizontal: effectiveGap),
child: rightIcon,
),
],
),
],
),
),
),
),
);
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 52ed9b7

Please sign in to comment.