Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System back goes to history on profile #714

Merged

Conversation

micahmo
Copy link
Member

@micahmo micahmo commented Sep 7, 2023

Pull Request Description

This PR taps into the system back button to navigate from "Saved" to "History" on the profile page. This is an Android-specific thing, but I definitely agree that it makes sense for Back to undo the most recent navigation action, even within a page.

Issue Being Fixed

Issue Number: N/A

Screenshots / Recordings

qemu-system-x86_64_20EtAWrqyj.mp4

Checklist

  • Did you update CHANGELOG.md?
  • Did you use localized strings where applicable?
  • Did you add semanticLabels where applicable for accessibility?

@hjiangsu
Copy link
Member

hjiangsu commented Sep 7, 2023

If this is an Android-specific thing, then I would wrap the setState logic with the Android platform!

e.g.,

if (Platform.isAndroid) {
  setState(() => { ... });
}

@micahmo
Copy link
Member Author

micahmo commented Sep 7, 2023

If this is an Android-specific thing, then I would wrap the setState logic with the Android platform!

Well, maybe I shouldn't say it's Android-specific. Any OS that has a back button as recognized by the BackButtonInterceptor package should use this functionality. 😊 Realistically it's probably just Android, but it's nice to let the package handle that detection for us. I think the less custom code the better. Also note that we use BackButtonInterceptor several other places already and don't have explicit OS checks.

BackButtonInterceptor.add(_handleBack);

FutureOr<bool> _handleBack(bool stopDefaultButtonEvent, RouteInfo info) async {
if (context.read<ThunderBloc>().state.isFabOpen) {
context.read<ThunderBloc>().add(const OnFabToggle(false));
}
if (currentCommunityBloc != null) {

@hjiangsu
Copy link
Member

hjiangsu commented Sep 7, 2023

Ahh okay, that makes a bit more sense!

@hjiangsu hjiangsu merged commit 5161e5f into thunder-app:develop Sep 7, 2023
@micahmo micahmo deleted the feature/back-to-history-profile branch September 7, 2023 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants