Skip to content

Commit

Permalink
fix: popup menu, nav, pop (#8089)
Browse files Browse the repository at this point in the history
Signed-off-by: fufesou <shuanglongchen@yeah.net>
  • Loading branch information
fufesou committed May 18, 2024
1 parent d3eaa66 commit 72d59af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
6 changes: 5 additions & 1 deletion flutter/lib/common/widgets/peer_tab_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ class _PeerTabPageState extends State<PeerTabPage>
currentValue: model.isVisibleEnabled[tabIndex],
setter: (show) async {
model.setTabVisible(tabIndex, show);
cancelFunc();
// Do not hide the current menu (checkbox)
// cancelFunc();
},
enabled: (!isOptVisiableFixed).obs));
}
Expand Down Expand Up @@ -821,6 +822,9 @@ class _PeerViewDropdownState extends State<PeerViewDropdown> {
k: kOptionPeerCardUiType,
v: peerCardUiType.value.index.toString(),
);
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
}
}),
),
Expand Down
30 changes: 10 additions & 20 deletions flutter/lib/desktop/widgets/popup_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,13 @@ abstract class MenuEntrySwitchBase<T> extends MenuEntryBase<T> {
RxBool get curOption;
Future<void> setOption(bool? option);

tryPop(BuildContext context) {
if (dismissOnClicked && Navigator.canPop(context)) {
Navigator.pop(context);
super.dismissCallback?.call();
}
}

@override
List<mod_menu.PopupMenuEntry<T>> build(
BuildContext context, MenuConfig conf) {
Expand Down Expand Up @@ -485,13 +492,7 @@ abstract class MenuEntrySwitchBase<T> extends MenuEntryBase<T> {
value: curOption.value,
onChanged: isEnabled
? (v) {
if (super.dismissOnClicked &&
Navigator.canPop(context)) {
Navigator.pop(context);
if (super.dismissCallback != null) {
super.dismissCallback!();
}
}
tryPop(context);
setOption(v);
}
: null,
Expand All @@ -501,13 +502,7 @@ abstract class MenuEntrySwitchBase<T> extends MenuEntryBase<T> {
value: curOption.value,
onChanged: isEnabled
? (v) {
if (super.dismissOnClicked &&
Navigator.canPop(context)) {
Navigator.pop(context);
if (super.dismissCallback != null) {
super.dismissCallback!();
}
}
tryPop(context);
setOption(v);
}
: null,
Expand All @@ -518,12 +513,7 @@ abstract class MenuEntrySwitchBase<T> extends MenuEntryBase<T> {
])),
onPressed: isEnabled
? () {
if (super.dismissOnClicked && Navigator.canPop(context)) {
Navigator.pop(context);
if (super.dismissCallback != null) {
super.dismissCallback!();
}
}
tryPop(context);
setOption(!curOption.value);
}
: null,
Expand Down

0 comments on commit 72d59af

Please sign in to comment.