Skip to content

Commit

Permalink
Revert "Use fragment-compose content"
Browse files Browse the repository at this point in the history
This reverts commit 42f4e3d.
  • Loading branch information
LordRaydenMK committed Oct 3, 2024
1 parent 9ceab7c commit 6c79317
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle"
implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycle"
implementation 'androidx.fragment:fragment-ktx:1.8.0'
implementation 'androidx.fragment:fragment-compose:1.8.0'
def nav_version = "2.7.7"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package io.github.lordraydenmk.superheroesapp.superheroes.superherodetails

import android.os.Bundle
import android.view.View
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.fragment.compose.content
import androidx.lifecycle.Lifecycle.State
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
Expand Down Expand Up @@ -32,17 +33,17 @@ class SuperheroDetailsFragment : Fragment(R.layout.fragment_compose) {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val composeView = view as ComposeView
composeView.setViewCompositionStrategy(DisposeOnViewTreeLifecycleDestroyed)

val module = object : SuperheroDetailsModule,
AppModule by requireActivity().appModule(),
ViewModelAlgebra<SuperheroDetailsViewState, SuperheroDetailsEffect> by viewModel {}

val actions = Channel<SuperheroDetailsAction>(Channel.UNLIMITED)

handleEffects()

with(module) {
content {
composeView.setContent {
SuperheroDetailsScreen(
stateFlow = viewState,
initialState = Loading,
Expand All @@ -57,6 +58,8 @@ class SuperheroDetailsFragment : Fragment(R.layout.fragment_compose) {
}
}
}

handleEffects()
}

private fun handleEffects() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package io.github.lordraydenmk.superheroesapp.superheroes.superheroslist

import android.os.Bundle
import android.view.View
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.fragment.compose.content
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
Expand All @@ -26,17 +27,17 @@ class SuperheroesFragment : Fragment(R.layout.fragment_compose) {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val composeView = view as ComposeView
composeView.setViewCompositionStrategy(DisposeOnViewTreeLifecycleDestroyed)

val module: SuperheroesModule = object : SuperheroesModule,
AppModule by requireActivity().appModule(),
ViewModelAlgebra<SuperheroesViewState, SuperheroesEffect> by viewModel {}

val actions = Channel<SuperheroesAction>(Channel.UNLIMITED)

handleEffects()

with(module) {
content {
composeView.setContent {
SuperheroesScreen(
stateFlow = viewState,
initialValue = Loading,
Expand All @@ -50,6 +51,8 @@ class SuperheroesFragment : Fragment(R.layout.fragment_compose) {
}
}
}

handleEffects()
}

private fun handleEffects() {
Expand Down

0 comments on commit 6c79317

Please sign in to comment.