Update support for new popup menu

This commit is contained in:
Ashita Prasad
2024-12-15 07:39:28 +05:30
parent c24fddddd4
commit f186f5401b
6 changed files with 97 additions and 251 deletions

View File

@ -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,
);
}
}