Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Road to Single Activity

yurihondo
September 12, 2024

Road to Single Activity

Over the last few years, the number of projects using Jetpack Compose is increasing.
Our project at U-NEXT is one example: we previously used AndroidView to build our UI, but we recently adopted Compose and revamped our UI architecture, including the screen transition mechanism, by using Navigation Compose.

However, we faced several problems afterwards.
Specifically, our app uses a Navigation Bar/Rail with separate tabs (Top-level Destinations) for each major function, so the NavGraph is divided into those units.
However, due to the specifications allowing each function to closely collaborate with each other, screen transitions across functions occur frequently.
Furthermore, some of these screens are called by deep links, so the screen transitions are very complex.
Until now, this problem was solved by sharing such screens between multiple Activities, but this required reconfiguring Local Composition and having a NavGraph for each Activity, which increased operational costs.

Therefore, we decided for such cases to abandon the solution of using Activities sharing screens, and instead took another step in revamping the UI architecture by making full use of Navigation Compose, aiming for a Single Activity.

In this session, based on examples from our own projects, I will introduce the following points in detail, with a focus on how to use Navigation Compose.
- How to gradually migrate UI architecture from AndroidView to Compose
- Examples of app development with complex screen transition specifications

Keywords
- Navigation Compose
- Nested NavGraph
- Common NavGraph
- Type safe navigation
- Default argument
- Multi back stack management
- Top-level Destination’s back stack management
- Navigation Bar/Rail control with WindowInset consideration
- Screen Transition by Deep links
- Compose Destinations (OSS)

yurihondo

September 12, 2024
Tweet

More Decks by yurihondo

Other Decks in Technology

Transcript

  1. About me yurihondo Software Engineer@U-NEXT Moving in with the in-laws

    next month - wish me luck! X : yurihondo @yuyuyuyuyuri
  2. Covered Topics • Gradual Migration from AndroidView to Compose Using

    Navigation • Examples of Using Navigation in Apps with Complex Screen Transitions
  3. NOT Covered Topics • Basics of Navigation Setup and More

    • Knowledge for Migrating Layouts to Compose
  4. The cost of multiple Activities 1. Common Settings: Cost of

    setting things like CompositionLocal across all Activities 2. NavHost: Cost of implementing NavHost for each Activity
  5. The cost of multiple Activities 1. Common Settings: Cost of

    setting things like CompositionLocal across all Activities 2. NavHost: Cost of implementing NavHost for each Activity Improve app maintainability and scalability
  6. Migration Step1: Abolish Fragments and migrate the app to Full-Navigation

    Step2: Switch to a Single Activity architecture
  7. NavGraph Activity Screen (Composable) Nested NavGraph Proceed in phases 1.

    Convert screens to Composables, then create and integrate them into the NavGraph 2. Integration of the created NavGraphs.
  8. Good-bye Fragment Phase 1: Graphs by Feature Phase 2-1: Graph

    Integration Phase 2-2: Adapting to App Specifics
  9. Good-bye Fragment Phase 1: Graphs by Feature Phase 2-1: Graph

    Integration Phase 2-2: Adapting to App Specifics
  10. Screen Screen Activity Container (Fragment) Screen (Fragment) Screen (Composable) Activity

    Screen (Composable) NavGraph Container (Fragment) Phase 1
  11. Can be added as a NavGraph destination, but can't navigate

    back to the original NavHost's destination from the target Activity.
  12. NavGraphへ 集約 NavGraph 作成 Screen Compose化 1 2 3 Completed

    Compose Conversion and NavGraph Definition for All Screens
  13. Good-bye Fragment Phase 1: Graphs by Feature Phase 2-1: Graph

    Integration Phase 2-2: Adapting to App Specifics
  14. Good-bye Fragment Phase 1: Graphs by Feature Phase 2-1: Graph

    Integration Phase 2-2: Adapting to App Specifics
  15. Video Graph Book Graph Search Graph Library Graph ❶ ❷

    • Tab-Graph Mapping • Graph Switching Process
  16. If BackStackEntry is the StartRoute of a Graph, it should

    navigate to the previous Tab (Graph).
  17. Effect of the Work • Reduced workload and issues related

    to adding new screens • Deeper understanding of Navigation implementation Lessons Learned • The challenge of balancing Navigation principles with custom UX • Tailoring Navigation to better fit our environment