Unverified Commit cd98c49c authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Some changes needed to PlatformMenuBar before the MenuBar implementation change lands. (#109556)

parent bacab7ee
...@@ -73,12 +73,12 @@ class _MyMenuBarAppState extends State<MyMenuBarApp> { ...@@ -73,12 +73,12 @@ class _MyMenuBarAppState extends State<MyMenuBarApp> {
// │ └ There's a million things I haven't done, but just you wait. // │ └ There's a million things I haven't done, but just you wait.
// └ Quit // └ Quit
return PlatformMenuBar( return PlatformMenuBar(
menus: <MenuItem>[ menus: <PlatformMenuItem>[
PlatformMenu( PlatformMenu(
label: 'Flutter API Sample', label: 'Flutter API Sample',
menus: <MenuItem>[ menus: <PlatformMenuItem>[
PlatformMenuItemGroup( PlatformMenuItemGroup(
members: <MenuItem>[ members: <PlatformMenuItem>[
PlatformMenuItem( PlatformMenuItem(
label: 'About', label: 'About',
onSelected: () { onSelected: () {
...@@ -88,7 +88,7 @@ class _MyMenuBarAppState extends State<MyMenuBarApp> { ...@@ -88,7 +88,7 @@ class _MyMenuBarAppState extends State<MyMenuBarApp> {
], ],
), ),
PlatformMenuItemGroup( PlatformMenuItemGroup(
members: <MenuItem>[ members: <PlatformMenuItem>[
PlatformMenuItem( PlatformMenuItem(
onSelected: () { onSelected: () {
_handleMenuSelection(MenuSelection.showMessage); _handleMenuSelection(MenuSelection.showMessage);
...@@ -98,7 +98,7 @@ class _MyMenuBarAppState extends State<MyMenuBarApp> { ...@@ -98,7 +98,7 @@ class _MyMenuBarAppState extends State<MyMenuBarApp> {
), ),
PlatformMenu( PlatformMenu(
label: 'Messages', label: 'Messages',
menus: <MenuItem>[ menus: <PlatformMenuItem>[
PlatformMenuItem( PlatformMenuItem(
label: 'I am not throwing away my shot.', label: 'I am not throwing away my shot.',
shortcut: const SingleActivator(LogicalKeyboardKey.digit1, meta: true), shortcut: const SingleActivator(LogicalKeyboardKey.digit1, meta: true),
......
...@@ -406,7 +406,7 @@ class SystemChannels { ...@@ -406,7 +406,7 @@ class SystemChannels {
/// encoding the list of top level menu items in window "0", which each /// encoding the list of top level menu items in window "0", which each
/// have a hierarchy of `Map<String, Object?>` containing the required /// have a hierarchy of `Map<String, Object?>` containing the required
/// data, sent via a [StandardMessageCodec]. It is typically generated from /// data, sent via a [StandardMessageCodec]. It is typically generated from
/// a list of [MenuItem]s, and ends up looking like this example: /// a list of [PlatformMenuItem]s, and ends up looking like this example:
/// ///
/// ```dart /// ```dart
/// Map<String, Object?> menu = <String, Object?>{ /// Map<String, Object?> menu = <String, Object?>{
......
...@@ -163,9 +163,9 @@ void main() { ...@@ -163,9 +163,9 @@ void main() {
const MaterialApp( const MaterialApp(
home: Material( home: Material(
child: PlatformMenuBar( child: PlatformMenuBar(
menus: <MenuItem>[], menus: <PlatformMenuItem>[],
child: PlatformMenuBar( child: PlatformMenuBar(
menus: <MenuItem>[], menus: <PlatformMenuItem>[],
child: SizedBox(), child: SizedBox(),
), ),
), ),
...@@ -180,7 +180,7 @@ void main() { ...@@ -180,7 +180,7 @@ void main() {
shortcut: SingleActivator(LogicalKeyboardKey.keyA), shortcut: SingleActivator(LogicalKeyboardKey.keyA),
); );
const PlatformMenuBar menuBar = PlatformMenuBar( const PlatformMenuBar menuBar = PlatformMenuBar(
menus: <MenuItem>[item], menus: <PlatformMenuItem>[item],
child: SizedBox(), child: SizedBox(),
); );
...@@ -205,14 +205,14 @@ void main() { ...@@ -205,14 +205,14 @@ void main() {
); );
}); });
}); });
group('PlatformMenuBarItem', () { group('MenuBarItem', () {
testWidgets('diagnostics', (WidgetTester tester) async { testWidgets('diagnostics', (WidgetTester tester) async {
const PlatformMenuItem childItem = PlatformMenuItem( const PlatformMenuItem childItem = PlatformMenuItem(
label: 'label', label: 'label',
); );
const PlatformMenu item = PlatformMenu( const PlatformMenu item = PlatformMenu(
label: 'label', label: 'label',
menus: <MenuItem>[childItem], menus: <PlatformMenuItem>[childItem],
); );
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
...@@ -258,19 +258,19 @@ const List<String> subMenu2 = <String>[ ...@@ -258,19 +258,19 @@ const List<String> subMenu2 = <String>[
'Sub Menu 20', 'Sub Menu 20',
]; ];
List<MenuItem> createTestMenus({ List<PlatformMenuItem> createTestMenus({
void Function(String)? onActivate, void Function(String)? onActivate,
void Function(String)? onOpen, void Function(String)? onOpen,
void Function(String)? onClose, void Function(String)? onClose,
Map<String, MenuSerializableShortcut> shortcuts = const <String, MenuSerializableShortcut>{}, Map<String, MenuSerializableShortcut> shortcuts = const <String, MenuSerializableShortcut>{},
bool includeStandard = false, bool includeStandard = false,
}) { }) {
final List<MenuItem> result = <MenuItem>[ final List<PlatformMenuItem> result = <PlatformMenuItem>[
PlatformMenu( PlatformMenu(
label: mainMenu[0], label: mainMenu[0],
onOpen: onOpen != null ? () => onOpen(mainMenu[0]) : null, onOpen: onOpen != null ? () => onOpen(mainMenu[0]) : null,
onClose: onClose != null ? () => onClose(mainMenu[0]) : null, onClose: onClose != null ? () => onClose(mainMenu[0]) : null,
menus: <MenuItem>[ menus: <PlatformMenuItem>[
PlatformMenuItem( PlatformMenuItem(
label: subMenu0[0], label: subMenu0[0],
onSelected: onActivate != null ? () => onActivate(subMenu0[0]) : null, onSelected: onActivate != null ? () => onActivate(subMenu0[0]) : null,
...@@ -282,9 +282,9 @@ List<MenuItem> createTestMenus({ ...@@ -282,9 +282,9 @@ List<MenuItem> createTestMenus({
label: mainMenu[1], label: mainMenu[1],
onOpen: onOpen != null ? () => onOpen(mainMenu[1]) : null, onOpen: onOpen != null ? () => onOpen(mainMenu[1]) : null,
onClose: onClose != null ? () => onClose(mainMenu[1]) : null, onClose: onClose != null ? () => onClose(mainMenu[1]) : null,
menus: <MenuItem>[ menus: <PlatformMenuItem>[
PlatformMenuItemGroup( PlatformMenuItemGroup(
members: <MenuItem>[ members: <PlatformMenuItem>[
PlatformMenuItem( PlatformMenuItem(
label: subMenu1[0], label: subMenu1[0],
onSelected: onActivate != null ? () => onActivate(subMenu1[0]) : null, onSelected: onActivate != null ? () => onActivate(subMenu1[0]) : null,
...@@ -296,9 +296,9 @@ List<MenuItem> createTestMenus({ ...@@ -296,9 +296,9 @@ List<MenuItem> createTestMenus({
label: subMenu1[1], label: subMenu1[1],
onOpen: onOpen != null ? () => onOpen(subMenu1[1]) : null, onOpen: onOpen != null ? () => onOpen(subMenu1[1]) : null,
onClose: onClose != null ? () => onClose(subMenu1[1]) : null, onClose: onClose != null ? () => onClose(subMenu1[1]) : null,
menus: <MenuItem>[ menus: <PlatformMenuItem>[
PlatformMenuItemGroup( PlatformMenuItemGroup(
members: <MenuItem>[ members: <PlatformMenuItem>[
PlatformMenuItem( PlatformMenuItem(
label: subSubMenu10[0], label: subSubMenu10[0],
onSelected: onActivate != null ? () => onActivate(subSubMenu10[0]) : null, onSelected: onActivate != null ? () => onActivate(subSubMenu10[0]) : null,
...@@ -307,7 +307,7 @@ List<MenuItem> createTestMenus({ ...@@ -307,7 +307,7 @@ List<MenuItem> createTestMenus({
], ],
), ),
PlatformMenuItemGroup( PlatformMenuItemGroup(
members: <MenuItem>[ members: <PlatformMenuItem>[
PlatformMenuItem( PlatformMenuItem(
label: subSubMenu10[1], label: subSubMenu10[1],
onSelected: onActivate != null ? () => onActivate(subSubMenu10[1]) : null, onSelected: onActivate != null ? () => onActivate(subSubMenu10[1]) : null,
...@@ -321,7 +321,7 @@ List<MenuItem> createTestMenus({ ...@@ -321,7 +321,7 @@ List<MenuItem> createTestMenus({
shortcut: shortcuts[subSubMenu10[2]], shortcut: shortcuts[subSubMenu10[2]],
), ),
PlatformMenuItemGroup( PlatformMenuItemGroup(
members: <MenuItem>[ members: <PlatformMenuItem>[
PlatformMenuItem( PlatformMenuItem(
label: subSubMenu10[3], label: subSubMenu10[3],
onSelected: onActivate != null ? () => onActivate(subSubMenu10[3]) : null, onSelected: onActivate != null ? () => onActivate(subSubMenu10[3]) : null,
...@@ -342,7 +342,7 @@ List<MenuItem> createTestMenus({ ...@@ -342,7 +342,7 @@ List<MenuItem> createTestMenus({
label: mainMenu[2], label: mainMenu[2],
onOpen: onOpen != null ? () => onOpen(mainMenu[2]) : null, onOpen: onOpen != null ? () => onOpen(mainMenu[2]) : null,
onClose: onClose != null ? () => onClose(mainMenu[2]) : null, onClose: onClose != null ? () => onClose(mainMenu[2]) : null,
menus: <MenuItem>[ menus: <PlatformMenuItem>[
PlatformMenuItem( PlatformMenuItem(
// Always disabled. // Always disabled.
label: subMenu2[0], label: subMenu2[0],
...@@ -355,7 +355,7 @@ List<MenuItem> createTestMenus({ ...@@ -355,7 +355,7 @@ List<MenuItem> createTestMenus({
label: mainMenu[3], label: mainMenu[3],
onOpen: onOpen != null ? () => onOpen(mainMenu[2]) : null, onOpen: onOpen != null ? () => onOpen(mainMenu[2]) : null,
onClose: onClose != null ? () => onClose(mainMenu[2]) : null, onClose: onClose != null ? () => onClose(mainMenu[2]) : null,
menus: <MenuItem>[], menus: <PlatformMenuItem>[],
), ),
]; ];
return result; return result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment