Skip to content

Commit

Permalink
Add PopupMenuTheme and improve example (#208)
Browse files Browse the repository at this point in the history
* Add PopupMenuTheme and improve example
  • Loading branch information
Feichtmeier committed Sep 16, 2022
1 parent e792205 commit 046e2b3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
19 changes: 18 additions & 1 deletion example/lib/view/controls_view.dart
Expand Up @@ -179,7 +179,24 @@ class _ControlsViewState extends State<ControlsView>
],
),
),
icon: const Icon(Icons.account_circle_rounded),
icon: const Text('Show Dialog'),
),
],
),
Row(
children: [
PopupMenuButton<String>(
icon: const Text('Show Popup-menu'),
initialValue: 'Hello',
itemBuilder: (context) {
return [
for (final string in ['a', 'b', 'c'])
PopupMenuItem(
value: string,
child: Text(string),
)
];
},
),
],
)
Expand Down
23 changes: 22 additions & 1 deletion lib/src/themes/common_themes.dart
@@ -1,9 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:yaru_colors/yaru_colors.dart';
import 'package:yaru/src/text/text_theme.dart';
import 'package:yaru/src/themes/constants.dart';
import 'package:yaru/src/themes/page_transitions.dart';
import 'package:yaru_colors/yaru_colors.dart';

// AppBar

Expand Down Expand Up @@ -287,6 +287,7 @@ ThemeData createYaruLightTheme({
inputDecorationTheme: inputDecorationTheme,
toggleButtonsTheme: _toggleButtonsTheme,
textSelectionTheme: _createTextSelectionTheme(colorScheme),
popupMenuTheme: _createPopupMenuThemeData(colorScheme, Brightness.light),
);
}

Expand Down Expand Up @@ -336,5 +337,25 @@ ThemeData createYaruDarkTheme({
inputDecorationTheme: inputDecorationTheme,
toggleButtonsTheme: _toggleButtonsTheme,
textSelectionTheme: _createTextSelectionTheme(colorScheme),
popupMenuTheme: _createPopupMenuThemeData(colorScheme, Brightness.dark),
);
}

PopupMenuThemeData _createPopupMenuThemeData(
ColorScheme colorScheme,
Brightness brightness,
) {
return PopupMenuThemeData(
color: brightness == Brightness.dark
? const Color.fromARGB(255, 34, 34, 34)
: Colors.white,
shape: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: colorScheme.onSurface
.withOpacity(brightness == Brightness.light ? 0.3 : 0.2),
width: 1,
),
),
);
}

0 comments on commit 046e2b3

Please sign in to comment.