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

feat: implement ControlSize for PushButton #447

Merged
merged 15 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 9 additions & 5 deletions .github/workflows/dart_code_metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ jobs:
- uses: actions/checkout@v3

- name: Run Dart Code Metrics
uses: dart-code-checker/[email protected]
uses: subosito/flutter-action@v2
with:
channel: stable

- name: Install dependencies
run: flutter pub get
- uses: CQLabs/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
pull_request_comment: true
fatal_warnings: true
fatal_performance: true
fatal_style: true

- run: dcm analyze --ci-key="${{ secrets.DCM_CI_KEY }}" --email="${{ secrets.DCM_EMAIL }}" lib
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [2.0.0-beta.5]
🚨 Breaking Changes 🚨
* `PushButton` has been updated to support the `ControlSize` enum.
* The `buttonSize` property has been changed to `controlSize`.
* Buttons can now be any of the following sizes: mini, small, regular, or large.
* `PushButton.isSecondary` is now `PushButton.secondary`.

🔄 Updated 🔄
* `PushButton`'s secondary and disabled colors more closely match their native counterparts.

## [2.0.0-beta.4]
🛠️ Fixed 🛠️
* `ToolBar`s in use where a `SideBar` is not present will now have their title's avoid the traffic lights (native window controls).
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,23 +632,22 @@ MacosPopupButton<String>(

## PushButton

A push button appears within a view and initiates an instantaneous app-specific action, such as printing a document or
deleting a file. Push buttons contain text—not icons—and often open a separate window, dialog, or app so the user can
Push buttons are the standard button type in macOS. Push buttons contain text—not icons—and often open a separate window, dialog, or app so the user can
complete a task. [Learn more](https://developer.apple.com/design/human-interface-guidelines/macos/buttons/push-buttons/)

| Dark Theme | Light Theme |
| ------------------------------------------ | ------------------------------------------ |
| <img src="https://imgur.com/GsShoF6.jpg"/> | <img src="https://imgur.com/klWHTAX.jpg"/> |
| <img src="https://imgur.com/v99ekWA.jpg"/> | <img src="https://imgur.com/hj6uGhI.jpg"/> |
| <img src="https://imgur.com/wt0K6u4.jpg"/> | <img src="https://imgur.com/7khWnwt.jpg"/> |
| <img src="https://imgur.com/TgfjJdQ.jpg"/> | <img src="https://imgur.com/83cEMeP.jpg"/> |
|--------------------------------------------|--------------------------------------------|
| <img src="https://imgur.com/iWNuPqs.png"/> | <img src="https://imgur.com/QPIHrJt.png"/> |

ℹ️ **Note** ℹ️
Native push buttons can be styled as text-only, text with an icon, or icon-only. Currently, text-only push buttons are supported. To create an icon-only button, use the `MacosIconButton` widget.

Here's an example of how to create a basic push button:

```dart
PushButton(
child: Text('button'),
buttonSize: ButtonSize.large,
controlSize: ControlSize.regular,
onPressed: () {
print('button pressed');
},
Expand Down
2 changes: 0 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ linter:
- use_super_parameters

analyzer:
plugins:
- dart_code_metrics
exclude:
- test/mock_canvas.dart
- test/recording_canvas.dart
Expand Down
461 changes: 400 additions & 61 deletions example/lib/pages/buttons_page.dart

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions example/lib/pages/dialogs_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class _DialogsPageState extends State<DialogsPage> {
child: Column(
children: [
PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.regular,
child: const Text('Show Alert Dialog 1'),
onPressed: () => showMacosAlertDialog(
context: context,
Expand All @@ -52,7 +52,7 @@ class _DialogsPageState extends State<DialogsPage> {
),
//horizontalActions: false,
primaryButton: PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.regular,
onPressed: Navigator.of(context).pop,
child: const Text('Primary'),
),
Expand All @@ -61,7 +61,7 @@ class _DialogsPageState extends State<DialogsPage> {
),
const SizedBox(height: 16),
PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.regular,
child: const Text('Show Alert Dialog 2'),
onPressed: () => showMacosAlertDialog(
context: context,
Expand All @@ -78,13 +78,13 @@ class _DialogsPageState extends State<DialogsPage> {
),
//horizontalActions: false,
primaryButton: PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.regular,
onPressed: Navigator.of(context).pop,
child: const Text('Primary'),
),
secondaryButton: PushButton(
buttonSize: ButtonSize.large,
isSecondary: true,
controlSize: ControlSize.regular,
secondary: true,
onPressed: Navigator.of(context).pop,
child: const Text('Secondary'),
),
Expand All @@ -93,7 +93,7 @@ class _DialogsPageState extends State<DialogsPage> {
),
const SizedBox(height: 16),
PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.regular,
child: const Text('Show Alert Dialog 3'),
onPressed: () => showMacosAlertDialog(
context: context,
Expand All @@ -110,13 +110,13 @@ class _DialogsPageState extends State<DialogsPage> {
),
horizontalActions: false,
primaryButton: PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.regular,
onPressed: Navigator.of(context).pop,
child: const Text('Primary'),
),
secondaryButton: PushButton(
buttonSize: ButtonSize.large,
isSecondary: true,
controlSize: ControlSize.regular,
secondary: true,
onPressed: Navigator.of(context).pop,
child: const Text('Secondary'),
),
Expand All @@ -125,7 +125,7 @@ class _DialogsPageState extends State<DialogsPage> {
),
const SizedBox(height: 16),
PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.regular,
child: const Text('Show Alert Dialog 4'),
onPressed: () => showMacosAlertDialog(
context: context,
Expand All @@ -143,13 +143,13 @@ class _DialogsPageState extends State<DialogsPage> {
),
horizontalActions: false,
primaryButton: PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.regular,
onPressed: Navigator.of(context).pop,
child: const Text('Primary'),
),
secondaryButton: PushButton(
buttonSize: ButtonSize.large,
isSecondary: true,
controlSize: ControlSize.regular,
secondary: true,
onPressed: Navigator.of(context).pop,
child: const Text('Secondary'),
),
Expand All @@ -159,7 +159,7 @@ class _DialogsPageState extends State<DialogsPage> {
),
const SizedBox(height: 16),
PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.regular,
child: const Text('Show sheet'),
onPressed: () {
showMacosSheet(
Expand Down Expand Up @@ -249,7 +249,7 @@ class DemoSheet extends StatelessWidget {
),
const Spacer(),
PushButton(
buttonSize: ButtonSize.large,
controlSize: ControlSize.regular,
child: const Text('Get started'),
onPressed: () => Navigator.of(context).pop(),
),
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.0-beta.4"
version: "2.0.0-beta.5"
macos_window_utils:
dependency: transitive
description:
Expand Down
Loading