mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Update support for new popup menu
This commit is contained in:
@ -7,50 +7,21 @@ class CodegenPopupMenu extends StatelessWidget {
|
||||
super.key,
|
||||
required this.value,
|
||||
this.onChanged,
|
||||
this.items,
|
||||
});
|
||||
|
||||
final CodegenLanguage value;
|
||||
final void Function(CodegenLanguage? value)? onChanged;
|
||||
final List<CodegenLanguage>? items;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final double boxLength = context.isCompactWindow ? 150 : 220;
|
||||
return PopupMenuButton<CodegenLanguage>(
|
||||
final double width = context.isCompactWindow ? 150 : 220;
|
||||
return ADPopupMenu<CodegenLanguage>(
|
||||
value: value.label,
|
||||
values: CodegenLanguage.values.map((e) => (e, e.label)),
|
||||
width: width,
|
||||
tooltip: "Select Code Generation Language",
|
||||
surfaceTintColor: kColorTransparent,
|
||||
constraints: BoxConstraints(minWidth: boxLength),
|
||||
itemBuilder: (BuildContext context) => items!
|
||||
.map((item) => PopupMenuItem<CodegenLanguage>(
|
||||
value: item,
|
||||
child: Text(
|
||||
item.label,
|
||||
style: kTextStylePopupMenuItem,
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
onSelected: onChanged,
|
||||
child: Container(
|
||||
width: boxLength,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
value.label,
|
||||
style: kTextStylePopupMenuItem,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.unfold_more,
|
||||
size: 16,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
onChanged: onChanged,
|
||||
isOutlined: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user