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

MacosPopupButton (closes #176) #177

Merged
merged 20 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5936b8d
feat(package): create `MacosPopupButton`, feat(demo): add `MacosPopup…
whiplashoo Jan 18, 2022
3660f15
fix(package): cleanup `MacosPopupButton` class properties that are no…
whiplashoo Jan 18, 2022
97fe860
docs(package): improve documentation for `MacosPopupButton`'s properties
whiplashoo Jan 18, 2022
b763af6
fix(package): improve up/down caret design in `MacosPopupButton` to m…
whiplashoo Jan 18, 2022
a52c0fc
add debugFillProperties to `MacosPopupButton`
whiplashoo Jan 18, 2022
556e254
test(package): add popup_button_test.dart
whiplashoo Jan 19, 2022
02b27a5
docs(package): add documentation for `MacosPopupButton`
whiplashoo Jan 19, 2022
1745ef8
chore(package): update changelog and version
whiplashoo Jan 19, 2022
8285a4a
chore: fix unnecessary imports
whiplashoo Feb 27, 2022
9d1ff99
Merge branch 'dev' into macos_popup_button
GroovinChip Mar 6, 2022
0bf7ded
Update example/macos/Podfile.lock
GroovinChip Mar 6, 2022
7dd179d
add `MacosPopupButtonTheme` and `MacosPopupButtonThemeData` classes w…
whiplashoo Mar 7, 2022
aff69e2
test: add tests for MacosPopupTheme classes
whiplashoo Mar 7, 2022
fd7b063
chore: cleanup project files, revert example theme
whiplashoo Mar 8, 2022
d085f03
Update lib/src/buttons/popup_button.dart
GroovinChip Mar 8, 2022
0f9d7b4
Update lib/src/buttons/popup_button.dart
GroovinChip Mar 8, 2022
8e4f6ea
Update lib/src/buttons/popup_button.dart
GroovinChip Mar 8, 2022
f913b6e
Update lib/src/buttons/popup_button.dart
GroovinChip Mar 8, 2022
d0e7b8d
Merge branch 'dev' into macos_popup_button
GroovinChip Mar 8, 2022
7d4b039
Update pubspec.yaml
GroovinChip Mar 8, 2022
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 CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [0.11.0]
* New Widget: `MacosPopupButton`

## [0.10.1]
* Added support for transparent sidebar. Please note that changes to `MainFlutterWindow.swift` are required for this to work. [(#175)](https://github.com/GroovinChip/macos_ui/pull/175)

Expand Down
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,46 @@ MacosRadioButton(
),
```

## Pop-Up Button

A pop-up button (often referred to as a pop-up menu) is a type of button that, when clicked, displays a menu containing a list of mutually exclusive choices. The menu appears on top of the button. Like other types of menus, a pop-up button’s menu can include separators and symbols like checkmarks. After the menu is revealed, it remains open until the user chooses a menu item, clicks outside of the menu, switches to another app, or quits the app; or until the system displays an alert. [Learn more](https://developer.apple.com/design/human-interface-guidelines/macos/buttons/pop-up-buttons/)

The type `T` of the `MacosPopupButton` is the type of the value that each pop-up menu item represents. All the entries in a given menu must represent values with consistent types. Typically, an `enum` is used. Each `MacosPopupMenuItem` in items must be specialized with that same type argument.

The `onChanged` callback should update a state variable that defines the pop-up menu's value. It should also call `State.setState` to rebuild the pop-up button with the new value.

When there are menu items that cannot be displayed within the available menu constraints, a caret is shown at the top or bottom of the open menu to signal that there are items that are not currently visible.

The menu can also be navigated with the up/down keys and an item selected with the Return key.

| Dark Theme | Light Theme |
| ------------------------------------------ | ------------------------------------------ |
| <img src="https://imgur.com/ov0kzJC.jpg"/> | <img src="https://imgur.com/buhYEo1.jpg"/> |
| <img src="https://imgur.com/BOEH59L.jpg"/> | <img src="https://imgur.com/61S7DSX.jpg"/> |
| <img src="https://imgur.com/zY0d8RF.jpg"/> | <img src="https://imgur.com/W4CMa5z.jpg"/> |

Here's an example of how to create a basic pop-up button:

```dart
String popupValue = 'One';

MacosPopupButton<String>(
value: popupValue,
onChanged: (String? newValue) {
setState(() {
popupValue = newValue!;
});
},
items: <String>['One', 'Two', 'Three', 'Four']
.map<MacosPopupMenuItem<String>>((String value) {
return MacosPopupMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
```

## 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 complete a task. [Learn more](https://developer.apple.com/design/human-interface-guidelines/macos/buttons/push-buttons/)
Expand Down
76 changes: 76 additions & 0 deletions example/lib/pages/buttons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class ButtonsPage extends StatefulWidget {
}

class _ButtonsPageState extends State<ButtonsPage> {
String popupValue = 'One';
String languagePopupValue = 'English';

@override
Widget build(BuildContext context) {
return MacosScaffold(
Expand Down Expand Up @@ -164,6 +167,42 @@ class _ButtonsPageState extends State<ButtonsPage> {
},
),
const SizedBox(height: 20),
const Text('MacosPopupButton'),
const SizedBox(height: 8),
MacosPopupButton<String>(
value: popupValue,
onChanged: (String? newValue) {
setState(() {
popupValue = newValue!;
});
},
items: <String>['One', 'Two', 'Three', 'Four']
.map<MacosPopupMenuItem<String>>((String value) {
return MacosPopupMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
const SizedBox(height: 20),
const Text('MacosPopupButton (large list)'),
const SizedBox(height: 8),
MacosPopupButton<String>(
value: languagePopupValue,
onChanged: (String? newValue) {
setState(() {
languagePopupValue = newValue!;
});
},
items:
languages.map<MacosPopupMenuItem<String>>((String value) {
return MacosPopupMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
),
const SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expand Down Expand Up @@ -227,3 +266,40 @@ class _ButtonsPageState extends State<ButtonsPage> {
);
}
}

const languages = [
"Mandarin Chinese",
"Spanish",
"English",
"Hindi/Urdu",
"Arabic",
"Bengali",
"Portuguese",
"Russian",
"Japanese",
"German",
"Thai",
"Greek",
"Nepali",
"Punjabi",
"Wu",
"French",
"Telugu",
"Vietnamese",
"Marathi",
"Korean",
"Tamil",
"Italian",
"Turkish",
"Cantonese/Yue",
"Urdu",
"Javanese",
"Egyptian Arabic",
"Gujarati",
"Iranian Persian",
"Indonesian",
"Polish",
"Ukrainian",
"Romanian",
"Dutch"
];
2 changes: 1 addition & 1 deletion example/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c

COCOAPODS: 1.11.2
COCOAPODS: 1.10.2
GroovinChip marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.10.1"
version: "0.11.0"
matcher:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions lib/macos_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export 'src/buttons/back_button.dart';
export 'src/buttons/checkbox.dart';
export 'src/buttons/help_button.dart';
export 'src/buttons/icon_button.dart';
export 'src/buttons/popup_button.dart';
export 'src/buttons/push_button.dart';
export 'src/buttons/radio_button.dart';
export 'src/buttons/switch.dart';
Expand Down
Loading