option collapse toolbar

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2023-06-11 15:28:41 +08:00
parent f72ed0d3e5
commit 844e7420de
38 changed files with 51 additions and 17 deletions

View File

@@ -450,22 +450,17 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
@override
Widget build(BuildContext context) {
final enableStyle = TextStyle(
final style = TextStyle(
color: Theme.of(context).textTheme.titleLarge?.color,
fontSize: MenuConfig.fontSize,
fontWeight: FontWeight.normal);
final disableStyle = TextStyle(
color: Colors.grey,
fontSize: MenuConfig.fontSize,
fontWeight: FontWeight.normal);
List<PopupMenuEntry> items = List.empty(growable: true);
items.add(PopupMenuItem(
enabled: false,
child: Text(translate("Sort by"), style: disableStyle)));
enabled: false, child: Text(translate("Sort by"), style: style)));
for (var e in PeerSortType.values) {
items.add(PopupMenuItem(
child: Obx(() => getRadio(
Text(translate(e), style: enableStyle), e, peerSort.value,
child: Obx(() =>
getRadio(Text(translate(e), style: style), e, peerSort.value,
(String? v) async {
if (v != null) {
peerSort.value = v;
@@ -477,6 +472,7 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
}))));
}
var menuPos = RelativeRect.fromLTRB(0, 0, 0, 0);
return InkWell(
child: Icon(
Icons.sort,
@@ -485,14 +481,14 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
onTapDown: (details) {
final x = details.globalPosition.dx;
final y = details.globalPosition.dy;
final menuPos = RelativeRect.fromLTRB(x, y, x, y);
showMenu(
context: context,
position: menuPos,
items: items,
elevation: 8,
);
menuPos = RelativeRect.fromLTRB(x, y, x, y);
},
onTap: () => showMenu(
context: context,
position: menuPos,
items: items,
elevation: 8,
),
);
}
}