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

Added FButton.icon for a single icon button #138

Merged
merged 40 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
af29913
Added FButton.icon for a single icon button
Aug 3, 2024
3487e11
Added sample and docs for FButton.icon
Aug 3, 2024
30d6b16
Added FButton.icon for a single icon button
Aug 3, 2024
f78b1b8
Added sample and docs for FButton.icon
Aug 3, 2024
8bd0fd2
Commit from GitHub Actions (Forui Samples Presubmit)
Pante Aug 4, 2024
7edd519
Commit from GitHub Actions (Forui Presubmit)
Pante Aug 4, 2024
16fc755
Merge remote-tracking branch 'origin/icon-button' into icon-button
sommye-ctr Aug 4, 2024
9ab4805
Added golden images
sommye-ctr Aug 10, 2024
e484a3d
Commit from GitHub Actions (Forui Presubmit)
sommye-ctr Aug 10, 2024
c51dfb6
Commit from GitHub Actions (Forui Samples Presubmit)
sommye-ctr Aug 10, 2024
d59b46c
Update docs/pages/docs/button.mdx
sommye-ctr Aug 11, 2024
c825216
Update forui/lib/src/widgets/button/button.dart
sommye-ctr Aug 11, 2024
4b505e5
Update forui/lib/src/widgets/divider.dart
sommye-ctr Aug 11, 2024
1b4cbb6
Renamed icon to child in FButton.icon(...)
sommye-ctr Aug 11, 2024
d40dff4
Merge remote-tracking branch 'origin/icon-button' into icon-button
sommye-ctr Aug 11, 2024
88ce938
Renamed icon to child in FButton.icon(...)
sommye-ctr Aug 11, 2024
a0c46d9
Commit from GitHub Actions (Forui Presubmit)
sommye-ctr Aug 11, 2024
8e3294d
Updated forui/lib/src/widgets/button/button.dart
sommye-ctr Aug 11, 2024
fbd8bb4
Merge remote-tracking branch 'origin/icon-button' into icon-button
sommye-ctr Aug 11, 2024
0b66c57
Added FButtonIconContentStyle
sommye-ctr Aug 13, 2024
52182c6
Commit from GitHub Actions (Forui Presubmit)
sommye-ctr Aug 13, 2024
537f33c
Commit from GitHub Actions (Forui Samples Presubmit)
sommye-ctr Aug 13, 2024
c25995a
Added FButtonIconContentStyle to FButtonCustomStyle
sommye-ctr Aug 14, 2024
17f1374
Merge remote-tracking branch 'origin/icon-button' into icon-button
sommye-ctr Aug 14, 2024
be7ac55
Added FButtonIconContentStyle to FButtonCustomStyle
sommye-ctr Aug 15, 2024
399ba33
Commit from GitHub Actions (Forui Presubmit)
sommye-ctr Aug 15, 2024
57ae4bb
Merge branch 'main' into icon-button
Pante Aug 15, 2024
094a11b
Commit from GitHub Actions (Forui Samples Presubmit)
Pante Aug 15, 2024
c9cac75
Merge branch 'main' into icon-button
Pante Aug 15, 2024
70b886a
Minor Changes
sommye-ctr Aug 15, 2024
4045bdb
Removed FButtonIconStyle from FButton
sommye-ctr Aug 15, 2024
a5e783e
Merge remote-tracking branch 'origin/icon-button' into icon-button
sommye-ctr Aug 15, 2024
2462171
Resolved changes
sommye-ctr Aug 15, 2024
1b8736d
Commit from GitHub Actions (Forui Presubmit)
sommye-ctr Aug 15, 2024
dd55aed
Resolved errors
sommye-ctr Aug 15, 2024
c784e14
Merge remote-tracking branch 'origin/icon-button' into icon-button
sommye-ctr Aug 15, 2024
3e449db
Commit from GitHub Actions (Forui Presubmit)
sommye-ctr Aug 15, 2024
5f0da01
Added default value to FCustomButtonStyle.iconContent
sommye-ctr Aug 16, 2024
38d117f
Merge remote-tracking branch 'origin/icon-button' into icon-button
sommye-ctr Aug 16, 2024
fe6d682
Commit from GitHub Actions (Forui Presubmit)
sommye-ctr Aug 16, 2024
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
20 changes: 18 additions & 2 deletions docs/pages/docs/button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ FButton.raw(
</Tabs.Tab>
</Tabs>

### With Icon
### With Text+Icon
sommye-ctr marked this conversation as resolved.
Show resolved Hide resolved
<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='button' variant='icon' query={{}}/>
Expand All @@ -117,4 +117,20 @@ FButton.raw(
),
```
</Tabs.Tab>
</Tabs>
</Tabs>

### With Only Icon
<Tabs items={['Preview', 'Code']}>
<Tabs.Tab>
<Widget name='button' variant='only-icon' query={{}}/>
</Tabs.Tab>
<Tabs.Tab>
```dart {2}
FButton.icon(
icon: FButtonIcon(icon: FAssets.icons.chevronRight),
onPress: () {},
),
```
</Tabs.Tab>
</Tabs>

24 changes: 12 additions & 12 deletions forui/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.4"
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -378,18 +378,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.15.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -631,10 +631,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
version: "0.7.2"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -687,10 +687,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
url: "https://pub.dev"
source: hosted
version: "14.2.1"
version: "14.2.4"
watcher:
dependency: transitive
description:
Expand Down
12 changes: 12 additions & 0 deletions forui/lib/src/widgets/button/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ class FButton extends StatelessWidget {
label: label,
);

/// Creates a [FButton] that contains only an [icon]
sommye-ctr marked this conversation as resolved.
Show resolved Hide resolved
FButton.icon({
required this.onPress,
required Widget icon,
sommye-ctr marked this conversation as resolved.
Show resolved Hide resolved
this.style = Variant.outline,
this.onLongPress,
this.autofocus = false,
this.focusNode,
this.onFocusChange,
super.key,
}) : child = _FButtonIconContent(icon: icon);

/// Creates a [FButton] with custom content.
const FButton.raw({
required this.onPress,
Expand Down
16 changes: 16 additions & 0 deletions forui/lib/src/widgets/button/button_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ final class _FButtonContent extends StatelessWidget {
}
}

final class _FButtonIconContent extends StatelessWidget {
final Widget icon;

const _FButtonIconContent({required this.icon});

@override
Widget build(BuildContext context) {
final (:style, enabled: _) = FButton._of(context);
sommye-ctr marked this conversation as resolved.
Show resolved Hide resolved

return Padding(
padding: style.content.padding,
child: icon,
);
}
}

/// [FButton] content's style.
class FButtonContentStyle with Diagnosticable {
/// The [TextStyle] when this button is enabled.
Expand Down
5 changes: 5 additions & 0 deletions forui/lib/src/widgets/divider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ final class FDividerStyle with Diagnosticable {
..add(DiagnosticsProperty('padding', padding))
..add(ColorProperty('color', color))
..add(DoubleProperty('width', width));

FButton.icon(
onPress: () {},
icon: FButtonIcon(icon: FAssets.icons.arrowRight),
);
sommye-ctr marked this conversation as resolved.
Show resolved Hide resolved
}

@override
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions forui/test/src/widgets/button/button_golden_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,59 @@ void main() {
matchesGoldenFile('button/$name-$variant-disabled-raw-button.png'),
);
});

testWidgets('$name with enabled icon', (tester) async {
await tester.pumpWidget(
TestScaffold(
data: theme,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: FButton.icon(
onPress: () {},
style: variant,
icon: FButtonIcon(
icon: FAssets.icons.chevronRight,
),
),
),
),
);

await expectLater(
find.byType(TestScaffold),
matchesGoldenFile(
'button/$name-$variant-icon-enabled-button.png',
),
);
});

testWidgets('$name with disabled icon', (tester) async {
await tester.pumpWidget(
TestScaffold(
data: theme,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: FButton.icon(
onPress: null,
style: variant,
icon: FButtonIcon(
icon: FAssets.icons.chevronRight,
),
),
),
),
);

await expectLater(
find.byType(TestScaffold),
matchesGoldenFile(
'button/$name-$variant-icon-disabled-button.png',
),
);
});
}
}
});
}

//flutter test --update-goldens /Users/somyemahajan/Projects/forui/forui/test/src/widgets/button/button_golden_test.dart
sommye-ctr marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions samples/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class _AppRouter extends RootStackRouter {
path: '/button/icon',
page: ButtonIconRoute.page,
),
AutoRoute(
path: '/button/only-icon',
page: ButtonOnlyIconRoute.page,
),
AutoRoute(
path: '/calendar/default',
page: CalendarRoute.page,
Expand Down
15 changes: 15 additions & 0 deletions samples/lib/widgets/button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,18 @@ class ButtonIconPage extends SampleScaffold {
),
);
}

@RoutePage()
class ButtonOnlyIconPage extends SampleScaffold {
ButtonOnlyIconPage({
@queryParam super.theme,
});

@override
Widget child(BuildContext context) => IntrinsicWidth(
child: FButton.icon(
icon: FButtonIcon(icon: FAssets.icons.chevronRight),
onPress: () {},
),
);
}
24 changes: 12 additions & 12 deletions samples/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.4"
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -407,18 +407,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.15.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -652,10 +652,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
version: "0.7.2"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -708,10 +708,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
url: "https://pub.dev"
source: hosted
version: "14.2.1"
version: "14.2.4"
watcher:
dependency: transitive
description:
Expand Down