Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loading indicator alignment on SmallButton widget #115

Merged
merged 8 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/widget_toolkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [0.1.1]
- Fixed loading state of 'SmallButton' widget

## [0.1.0]
### Breaking changes:
- Removed static `.withDependencies` constructor from widgets
Expand Down
RomanovaPrime marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class SmallButton extends StatelessWidget {
final SmallButtonType type;

SmallButton({
this.tooltip,
required this.onPressed,
required this.icon,
this.tooltip,
this.type = SmallButtonType.outline,
this.state = ButtonStateModel.enabled,
this.colorStyle,
Expand Down Expand Up @@ -61,6 +61,15 @@ class SmallButton extends StatelessWidget {
colorGradientEnd,
]);

final icon = state == ButtonStateModel.loading
StanevPrime marked this conversation as resolved.
Show resolved Hide resolved
? SizedLoadingIndicator.textButtonValue()
: DynamicIcon(
this.icon,
color: colorStyle?.activeButtonTextColor ??
getColorByType(color, context),
semanticLabel: tooltip,
);

final text = Ink(
padding: context.widgetToolkitTheme.smallButtonPadding,
decoration: BoxDecoration(
Expand All @@ -75,12 +84,7 @@ class SmallButton extends StatelessWidget {
: null,
gradient: type == SmallButtonType.filled ? gradient : null,
),
child: DynamicIcon(
icon,
color:
colorStyle?.activeButtonTextColor ?? getColorByType(color, context),
semanticLabel: tooltip,
),
child: icon,
);

return AnimatedSwitcher(
Expand All @@ -90,10 +94,6 @@ class SmallButton extends StatelessWidget {
}

Widget _buildChild(BuildContext context, Widget icon, Color primaryColor) {
if (state == ButtonStateModel.loading) {
return SizedLoadingIndicator.textButtonValue();
}

switch (type) {
case SmallButtonType.filled:
return ElevatedButton(
Expand Down
2 changes: 1 addition & 1 deletion packages/widget_toolkit/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: widget_toolkit
description: The Widget Toolkit package consists of several lightweight and customisable UI components that boost productivity and reduce the development time.
version: 0.1.0
version: 0.1.1
repository: https://github.com/Prime-Holding/widget_toolkit/tree/master/packages/widget_toolkit
issue_tracker: https://github.com/orgs/Prime-Holding/projects/6
homepage: https://www.primeholding.com
Expand Down
Loading