Skip to content

Commit

Permalink
fix(YaruPopupMenuButton): Wrong background color (#876)
Browse files Browse the repository at this point in the history
* fix(YaruPopupMenuButton): Wrong background color
Fixes #875
  • Loading branch information
Feichtmeier committed Mar 5, 2024
1 parent 91bf92b commit 34f0e65
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 21 deletions.
67 changes: 47 additions & 20 deletions example/lib/pages/popup_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,7 @@ class _PopupPageState extends State<PopupPage> {
spacing: 10,
runSpacing: 10,
children: [
YaruPopupMenuButton<MyEnum>(
initialValue: myEnum,
onSelected: (v) {
setState(() {
myEnum = v;
});
},
child: Text(myEnum.name),
itemBuilder: (context) {
return [
for (final value in MyEnum.values)
PopupMenuItem(
value: value,
child: Text(
value.name,
),
),
];
},
),
_buildPopup(),
YaruPopupMenuButton<MyEnum>(
onSelected: (value) {
if (enumSet.contains(value)) {
Expand Down Expand Up @@ -79,10 +60,56 @@ class _PopupPageState extends State<PopupPage> {
];
},
),
Card(
child: Column(
children: [
const Padding(
padding: EdgeInsets.all(8.0),
child: Text('With custom style'),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: _buildPopup(
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100),
),
backgroundColor: YaruColors.prussianGreen,
foregroundColor: Colors.yellow,
),
),
),
],
),
),
],
),
);
}

YaruPopupMenuButton<MyEnum> _buildPopup({ButtonStyle? style}) {
return YaruPopupMenuButton<MyEnum>(
style: style,
initialValue: myEnum,
onSelected: (v) {
setState(() {
myEnum = v;
});
},
child: Text(myEnum.name),
itemBuilder: (context) {
return [
for (final value in MyEnum.values)
PopupMenuItem(
value: value,
child: Text(
value.name,
),
),
];
},
);
}
}

enum MyEnum {
Expand Down
1 change: 0 additions & 1 deletion lib/src/widgets/yaru_popup_menu_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class YaruPopupMenuButton<T> extends StatelessWidget {
clipBehavior: Clip.antiAlias,
shape: shape,
child: PopupMenuButton(
color: style?.foregroundColor?.resolve({}),
iconColor: style?.foregroundColor?.resolve({}),
enabled: enabled,
elevation: elevation,
Expand Down

0 comments on commit 34f0e65

Please sign in to comment.