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

feat: Navigation icon clicked scroll to top #1391

Merged
merged 1 commit into from
Mar 27, 2019
Merged

feat: Navigation icon clicked scroll to top #1391

merged 1 commit into from
Mar 27, 2019

Conversation

anhanh11001
Copy link
Contributor

Details:

  • In the MainActivity, bottom navigation callback on actionReselectedListener is called to handle scroll link to the top of the current fragment (EventsFragment and OrdersUnderUserFragment)

Fixes #1387

Screenshots for the change:

@fossasia fossasia deleted a comment Mar 24, 2019
@fossasia fossasia deleted a comment Mar 24, 2019
@fossasia fossasia deleted a comment Mar 24, 2019
@fossasia fossasia deleted a comment from addiegupta Mar 24, 2019
@fossasia fossasia deleted a comment from addiegupta Mar 24, 2019
@fossasia fossasia deleted a comment from anhanh11001 Mar 24, 2019
@anhanh11001
Copy link
Contributor Author

@iamareebjamal please review

@iamareebjamal
Copy link
Member

Ask for peer reviews first, please

@anhanh11001
Copy link
Contributor Author

@iamareebjamal Oh sorry
@liveHarshit can you please review this PR?

Copy link
Member

@liveHarshit liveHarshit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -208,4 +209,6 @@ class EventsFragment : Fragment() {
rootView.swiperefresh?.setOnRefreshListener(null)
super.onStop()
}

fun scrollToTop() = rootView.eventsNestedScrollView.smoothScrollTo(1, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create an interface with this function

val hostFragment = supportFragmentManager.findFragmentById(R.id.frameContainer)
if (hostFragment is NavHostFragment) {
val currentFragment = hostFragment.childFragmentManager.fragments.first()
when (item.itemId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just check if the fragment is implementing the interface and call the function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have followed your guidelines and made the changes

Details:
ScrollToTop interface is created so that appropriate fragments will implement. In the MainActivity, bottom navigation callback on actionReselectedListener is called to handle scroll link to the top of the current fragment (EventsFragment and OrdersUnderUserFragment)

Fixes #1387
@iamareebjamal iamareebjamal merged commit 0446638 into fossasia:development Mar 27, 2019
@anhanh11001 anhanh11001 deleted the 1387_scroll_top branch June 20, 2019 13:56
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.

3 participants