Skip to content

refactor: navigation and bottom sheet 2#685

Open
tvillega wants to merge 1 commit into
eddyizm:developmentfrom
tvillega:refactor-navigation-and-bottom-sheet-2
Open

refactor: navigation and bottom sheet 2#685
tvillega wants to merge 1 commit into
eddyizm:developmentfrom
tvillega:refactor-navigation-and-bottom-sheet-2

Conversation

@tvillega
Copy link
Copy Markdown
Contributor

Follow-up of #491.

What's new

  • BottomSheetController moved to com.cappielloantonio.tempo.navigation as its behavior depends on it.
  • NavigationController now exposes (through a getter) the original controller function it wraps.
  • BottomSheetController is now exposed (through a getter) from the activity.
  • Improved legibility of the code by grouping chains of calls into variables.
  • Introduce new getters for fragments to use through a BaseFragment fragment.
    • getNavigationController()
    • getBottomSheetController()
    • getNavController()

The goal is to mimic the behavior of getActivity(), which is available globally in the fragment context.

What's deprecated

The following global, public variables from MainActivity:

  • navController
  • bottomSheetBheavior

Are no longer required to be global nor public and are candidate for removal. Fragments must now inherit from BaseFragment to interact with Navigation and BottomSheet to stop polluting MainActivity with functions.

What's safe to remove

The following public functions:

  • setBottomSheetInPeek()
  • setBottomSheetVisibility()
  • collapseBottomSheetDelayed()
  • expandBottomSheet()
  • setBottomSheetDraggableState()
  • animateBottomSheet()
  • setBottomNavigationBarVisibility()
  • setNavigationDrawerLock()
  • isNavigationDrawerLocked()
  • toggleNavigationDrawerLockOnOrientationChange()
  • setSystemBarsVisibility()

Are now only wrappers from the Navigation and BottomSheet controllers and can be removed from MainActivity. Unfortunately, this requires to modify all the fragments in com.cappielloantonio.tempo.ui.fragment for them to inherit from BaseFragment and stop summoning the methods from MainActivity.


By encapsulating the Navigation and BottomSheet the code will become more legible and, hence, maintainable.

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.

1 participant