Skip to content

Commit

Permalink
Implement new SmallButton type widget
Browse files Browse the repository at this point in the history
  • Loading branch information
JvnSlv committed Aug 6, 2024
1 parent b92fe46 commit 2cbcec6
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 9 deletions.
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]
- Added `SmallButtonType.icon` type to `SmallButton` widget

## [0.1.0]
- Fixed loading state of 'SmallButton' widget
### Breaking changes:
Expand Down
2 changes: 1 addition & 1 deletion packages/widget_toolkit/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
22 changes: 19 additions & 3 deletions packages/widget_toolkit/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,25 @@ class CommonComponentsPage extends StatelessWidget {
Padding(
padding: const EdgeInsets.symmetric(
vertical: 10, horizontal: 15),
child: SmallButton(
onPressed: () {},
icon: Icons.home_work_outlined,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SmallButton(
onPressed: () {},
type: SmallButtonType.icon,
icon: Icons.home_work_outlined,
),
SmallButton(
onPressed: () {},
type: SmallButtonType.outline,
icon: Icons.home_work_outlined,
),
SmallButton(
onPressed: () {},
type: SmallButtonType.filled,
icon: Icons.home_work_outlined,
),
],
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/widget_toolkit/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.1"
version: "0.1.0"
xml:
dependency: transitive
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../sized_loading_indicator.dart';
import 'button_color_style.dart';
import 'button_state.dart';

enum SmallButtonType { filled, outline }
enum SmallButtonType { filled, outline, icon }

class SmallButton extends StatelessWidget {
final String? tooltip;
Expand Down Expand Up @@ -122,6 +122,16 @@ class SmallButton extends StatelessWidget {
onPressed: onPressed,
child: icon,
);
case SmallButtonType.icon:
return IconButton(
style: IconButton.styleFrom(
padding: const EdgeInsets.all(0),
shape: const CircleBorder(),
fixedSize: const Size(48, 48),
),
icon: icon,
onPressed: onPressed,
);
}
}

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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import '../factory/small_button_factory.dart';
void main() {
runGoldenBuilderTests(
'small_button_golden_tests',
surfaceSize: const Size(700, 350),
surfaceSize: const Size(700, 500),
matcherCustomPump: (widget) =>
widget.pump(const Duration(milliseconds: 350)),
builder: GoldenBuilder.grid(
Expand Down Expand Up @@ -46,6 +46,22 @@ void main() {
..addScenario(
'pressed outlined',
smallButtonFactory(
type: SmallButtonType.outline, state: ButtonStateModel.pressed)),
type: SmallButtonType.outline, state: ButtonStateModel.pressed))
..addScenario(
'loading icon',
smallButtonFactory(
type: SmallButtonType.icon, state: ButtonStateModel.loading))
..addScenario(
'enabled icon',
smallButtonFactory(
type: SmallButtonType.icon, state: ButtonStateModel.enabled))
..addScenario(
'disabled icon',
smallButtonFactory(
type: SmallButtonType.icon, state: ButtonStateModel.disabled))
..addScenario(
'pressed icon',
smallButtonFactory(
type: SmallButtonType.icon, state: ButtonStateModel.pressed)),
);
}

0 comments on commit 2cbcec6

Please sign in to comment.