Skip to content

Commit 2b9c084

Browse files
authored
feat: implement ControlSize for PushButton (#447)
* feat: support `ControlSize` enum in `PushButton` * chore: clean up code * chore: update version & changelog * chore: adjust border radius for regular control size * fix: border radius no longer looks choppy * improve: disabled background color * refactor: `isSecondary` -> `secondary` * chore: update changelog * docs: update top-level `PushButton` dartdoc * docs: update readme * chore: migrate to DCM Teams * fix: dcm action * fix: push button tests * docs: update readme
1 parent 057b1b8 commit 2b9c084

File tree

13 files changed

+578
-282
lines changed

13 files changed

+578
-282
lines changed

.github/workflows/dart_code_metrics.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ jobs:
99
- uses: actions/checkout@v3
1010

1111
- name: Run Dart Code Metrics
12-
uses: dart-code-checker/dart-code-metrics-action@v4.0.0
12+
uses: subosito/flutter-action@v2
13+
with:
14+
channel: stable
15+
16+
- name: Install dependencies
17+
run: flutter pub get
18+
- uses: CQLabs/setup-dcm@v1.0.0
1319
with:
1420
github_token: ${{ secrets.GITHUB_TOKEN }}
15-
pull_request_comment: true
16-
fatal_warnings: true
17-
fatal_performance: true
18-
fatal_style: true
21+
22+
- run: dcm analyze --ci-key="${{ secrets.DCM_CI_KEY }}" --email="${{ secrets.DCM_EMAIL }}" lib

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [2.0.0-beta.5]
2+
🚨 Breaking Changes 🚨
3+
* `PushButton` has been updated to support the `ControlSize` enum.
4+
* The `buttonSize` property has been changed to `controlSize`.
5+
* Buttons can now be any of the following sizes: mini, small, regular, or large.
6+
* `PushButton.isSecondary` is now `PushButton.secondary`.
7+
8+
🔄 Updated 🔄
9+
* `PushButton`'s secondary and disabled colors more closely match their native counterparts.
10+
111
## [2.0.0-beta.4]
212
🛠️ Fixed 🛠️
313
* `ToolBar`s in use where a `SideBar` is not present will now have their title's avoid the traffic lights (native window controls).

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -632,23 +632,22 @@ MacosPopupButton<String>(
632632

633633
## PushButton
634634

635-
A push button appears within a view and initiates an instantaneous app-specific action, such as printing a document or
636-
deleting a file. Push buttons contain text—not icons—and often open a separate window, dialog, or app so the user can
635+
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
637636
complete a task. [Learn more](https://developer.apple.com/design/human-interface-guidelines/macos/buttons/push-buttons/)
638637

639638
| Dark Theme | Light Theme |
640-
| ------------------------------------------ | ------------------------------------------ |
641-
| <img src="https://imgur.com/GsShoF6.jpg"/> | <img src="https://imgur.com/klWHTAX.jpg"/> |
642-
| <img src="https://imgur.com/v99ekWA.jpg"/> | <img src="https://imgur.com/hj6uGhI.jpg"/> |
643-
| <img src="https://imgur.com/wt0K6u4.jpg"/> | <img src="https://imgur.com/7khWnwt.jpg"/> |
644-
| <img src="https://imgur.com/TgfjJdQ.jpg"/> | <img src="https://imgur.com/83cEMeP.jpg"/> |
639+
|--------------------------------------------|--------------------------------------------|
640+
| <img src="https://imgur.com/iWNuPqs.png"/> | <img src="https://imgur.com/QPIHrJt.png"/> |
641+
642+
ℹ️ **Note** ℹ️
643+
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.
645644

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

648647
```dart
649648
PushButton(
650649
child: Text('button'),
651-
buttonSize: ButtonSize.large,
650+
controlSize: ControlSize.regular,
652651
onPressed: () {
653652
print('button pressed');
654653
},

analysis_options.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ linter:
55
- use_super_parameters
66

77
analyzer:
8-
plugins:
9-
- dart_code_metrics
108
exclude:
119
- test/mock_canvas.dart
1210
- test/recording_canvas.dart

example/lib/pages/buttons_page.dart

Lines changed: 400 additions & 61 deletions
Large diffs are not rendered by default.

example/lib/pages/dialogs_page.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class _DialogsPageState extends State<DialogsPage> {
3636
child: Column(
3737
children: [
3838
PushButton(
39-
buttonSize: ButtonSize.large,
39+
controlSize: ControlSize.regular,
4040
child: const Text('Show Alert Dialog 1'),
4141
onPressed: () => showMacosAlertDialog(
4242
context: context,
@@ -52,7 +52,7 @@ class _DialogsPageState extends State<DialogsPage> {
5252
),
5353
//horizontalActions: false,
5454
primaryButton: PushButton(
55-
buttonSize: ButtonSize.large,
55+
controlSize: ControlSize.regular,
5656
onPressed: Navigator.of(context).pop,
5757
child: const Text('Primary'),
5858
),
@@ -61,7 +61,7 @@ class _DialogsPageState extends State<DialogsPage> {
6161
),
6262
const SizedBox(height: 16),
6363
PushButton(
64-
buttonSize: ButtonSize.large,
64+
controlSize: ControlSize.regular,
6565
child: const Text('Show Alert Dialog 2'),
6666
onPressed: () => showMacosAlertDialog(
6767
context: context,
@@ -78,13 +78,13 @@ class _DialogsPageState extends State<DialogsPage> {
7878
),
7979
//horizontalActions: false,
8080
primaryButton: PushButton(
81-
buttonSize: ButtonSize.large,
81+
controlSize: ControlSize.regular,
8282
onPressed: Navigator.of(context).pop,
8383
child: const Text('Primary'),
8484
),
8585
secondaryButton: PushButton(
86-
buttonSize: ButtonSize.large,
87-
isSecondary: true,
86+
controlSize: ControlSize.regular,
87+
secondary: true,
8888
onPressed: Navigator.of(context).pop,
8989
child: const Text('Secondary'),
9090
),
@@ -93,7 +93,7 @@ class _DialogsPageState extends State<DialogsPage> {
9393
),
9494
const SizedBox(height: 16),
9595
PushButton(
96-
buttonSize: ButtonSize.large,
96+
controlSize: ControlSize.regular,
9797
child: const Text('Show Alert Dialog 3'),
9898
onPressed: () => showMacosAlertDialog(
9999
context: context,
@@ -110,13 +110,13 @@ class _DialogsPageState extends State<DialogsPage> {
110110
),
111111
horizontalActions: false,
112112
primaryButton: PushButton(
113-
buttonSize: ButtonSize.large,
113+
controlSize: ControlSize.regular,
114114
onPressed: Navigator.of(context).pop,
115115
child: const Text('Primary'),
116116
),
117117
secondaryButton: PushButton(
118-
buttonSize: ButtonSize.large,
119-
isSecondary: true,
118+
controlSize: ControlSize.regular,
119+
secondary: true,
120120
onPressed: Navigator.of(context).pop,
121121
child: const Text('Secondary'),
122122
),
@@ -125,7 +125,7 @@ class _DialogsPageState extends State<DialogsPage> {
125125
),
126126
const SizedBox(height: 16),
127127
PushButton(
128-
buttonSize: ButtonSize.large,
128+
controlSize: ControlSize.regular,
129129
child: const Text('Show Alert Dialog 4'),
130130
onPressed: () => showMacosAlertDialog(
131131
context: context,
@@ -143,13 +143,13 @@ class _DialogsPageState extends State<DialogsPage> {
143143
),
144144
horizontalActions: false,
145145
primaryButton: PushButton(
146-
buttonSize: ButtonSize.large,
146+
controlSize: ControlSize.regular,
147147
onPressed: Navigator.of(context).pop,
148148
child: const Text('Primary'),
149149
),
150150
secondaryButton: PushButton(
151-
buttonSize: ButtonSize.large,
152-
isSecondary: true,
151+
controlSize: ControlSize.regular,
152+
secondary: true,
153153
onPressed: Navigator.of(context).pop,
154154
child: const Text('Secondary'),
155155
),
@@ -159,7 +159,7 @@ class _DialogsPageState extends State<DialogsPage> {
159159
),
160160
const SizedBox(height: 16),
161161
PushButton(
162-
buttonSize: ButtonSize.large,
162+
controlSize: ControlSize.regular,
163163
child: const Text('Show sheet'),
164164
onPressed: () {
165165
showMacosSheet(
@@ -249,7 +249,7 @@ class DemoSheet extends StatelessWidget {
249249
),
250250
const Spacer(),
251251
PushButton(
252-
buttonSize: ButtonSize.large,
252+
controlSize: ControlSize.regular,
253253
child: const Text('Get started'),
254254
onPressed: () => Navigator.of(context).pop(),
255255
),

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ packages:
9797
path: ".."
9898
relative: true
9999
source: path
100-
version: "2.0.0-beta.4"
100+
version: "2.0.0-beta.5"
101101
macos_window_utils:
102102
dependency: transitive
103103
description:

0 commit comments

Comments
 (0)