Skip to content

Commit

Permalink
Merge pull request #739 from chrisbanes/cb/compose-7001724
Browse files Browse the repository at this point in the history
Update to Compose SNAPSHOT 7001724
  • Loading branch information
chrisbanes committed Dec 1, 2020
2 parents a8b5377 + 26042f3 commit 5e700c8
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 18 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/app/tivi/buildsrc/dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object Libs {
}

object Accompanist {
private const val version = "0.3.4.compose-6994167-SNAPSHOT"
private const val version = "0.3.4.compose-7001724-SNAPSHOT"
const val coil = "dev.chrisbanes.accompanist:accompanist-coil:$version"
const val insets = "dev.chrisbanes.accompanist:accompanist-insets:$version"
}
Expand Down Expand Up @@ -168,7 +168,7 @@ object Libs {
}

object Compose {
const val snapshot = "6994167"
const val snapshot = "7001724"
const val version = "1.0.0-SNAPSHOT"

@get:JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ package app.tivi.common.compose

import androidx.compose.runtime.Composable
import com.google.android.material.composethemeadapter.MdcTheme
import dev.chrisbanes.accompanist.insets.ProvideWindowInsets

/**
* Just groups some common Compose content setup
*/
@Composable
inline fun TiviContentSetup(noinline content: @Composable () -> Unit) {
MdcTheme {
ProvideWindowInsets {
content()
}
content()
}
}
13 changes: 11 additions & 2 deletions ui-account/src/main/java/app/tivi/account/AccountUiFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import app.tivi.extensions.navigateToNavDestination
import app.tivi.util.TiviDateFormatter
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import dagger.hilt.android.AndroidEntryPoint
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
import dev.chrisbanes.accompanist.insets.ViewWindowInsetObserver
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.consumeAsFlow
Expand All @@ -52,11 +54,18 @@ class AccountUiFragment : BottomSheetDialogFragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = ComposeView(requireContext()).apply {
): View = ComposeView(requireContext()).apply {
layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT)

// We use ViewWindowInsetObserver rather than ProvideWindowInsets
// See: https://github.com/chrisbanes/accompanist/issues/155
val windowInsets = ViewWindowInsetObserver(this).start()

setContent {
Providers(AmbientTiviDateFormatter provides tiviDateFormatter) {
Providers(
AmbientTiviDateFormatter provides tiviDateFormatter,
AmbientWindowInsets provides windowInsets,
) {
TiviContentSetup {
val viewState by viewModel.liveData.observeAsState()
if (viewState != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import app.tivi.common.compose.AmbientTiviDateFormatter
import app.tivi.common.compose.TiviContentSetup
import app.tivi.util.TiviDateFormatter
import dagger.hilt.android.AndroidEntryPoint
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
import dev.chrisbanes.accompanist.insets.ViewWindowInsetObserver
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.consumeAsFlow
Expand All @@ -55,10 +57,15 @@ class DiscoverFragment : Fragment() {
): View? = ComposeView(requireContext()).apply {
layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)

// We use ViewWindowInsetObserver rather than ProvideWindowInsets
// See: https://github.com/chrisbanes/accompanist/issues/155
val windowInsets = ViewWindowInsetObserver(this).start()

setContent {
Providers(
AmbientTiviDateFormatter provides tiviDateFormatter,
AmbientDiscoverTextCreator provides textCreator
AmbientDiscoverTextCreator provides textCreator,
AmbientWindowInsets provides windowInsets,
) {
TiviContentSetup {
val viewState by viewModel.liveData.observeAsState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import app.tivi.extensions.viewModelProviderFactoryOf
import app.tivi.util.TiviDateFormatter
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import dagger.hilt.android.AndroidEntryPoint
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
import dev.chrisbanes.accompanist.insets.ViewWindowInsetObserver
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.consumeAsFlow
Expand Down Expand Up @@ -70,11 +72,18 @@ class EpisodeDetailsFragment : BottomSheetDialogFragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = ComposeView(requireContext()).apply {
): View = ComposeView(requireContext()).apply {
layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)

// We use ViewWindowInsetObserver rather than ProvideWindowInsets
// See: https://github.com/chrisbanes/accompanist/issues/155
val windowInsets = ViewWindowInsetObserver(this).start()

setContent {
Providers(AmbientTiviDateFormatter provides tiviDateFormatter) {
Providers(
AmbientTiviDateFormatter provides tiviDateFormatter,
AmbientWindowInsets provides windowInsets,
) {
TiviContentSetup {
val viewState by viewModel.liveData.observeAsState()
if (viewState != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import app.tivi.common.compose.TiviContentSetup
import app.tivi.home.HomeTextCreator
import app.tivi.util.TiviDateFormatter
import dagger.hilt.android.AndroidEntryPoint
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
import dev.chrisbanes.accompanist.insets.ViewWindowInsetObserver
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.consumeAsFlow
Expand All @@ -58,10 +60,15 @@ class FollowedFragment : Fragment() {
): View? = ComposeView(requireContext()).apply {
layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)

// We use ViewWindowInsetObserver rather than ProvideWindowInsets
// See: https://github.com/chrisbanes/accompanist/issues/155
val windowInsets = ViewWindowInsetObserver(this).start()

setContent {
Providers(
AmbientTiviDateFormatter provides tiviDateFormatter,
AmbientHomeTextCreator provides homeTextCreator,
AmbientWindowInsets provides windowInsets,
) {
TiviContentSetup {
val viewState by viewModel.liveData.observeAsState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import app.tivi.common.compose.paging.collectAsLazyPagingItems
import app.tivi.home.HomeTextCreator
import app.tivi.util.TiviDateFormatter
import dagger.hilt.android.AndroidEntryPoint
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
import dev.chrisbanes.accompanist.insets.ViewWindowInsetObserver
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.consumeAsFlow
Expand All @@ -60,10 +62,15 @@ class PopularShowsFragment : Fragment() {
// Just a small optimization to start the data fetch quicker.
val pagedList = viewModel.pagedList

// We use ViewWindowInsetObserver rather than ProvideWindowInsets
// See: https://github.com/chrisbanes/accompanist/issues/155
val windowInsets = ViewWindowInsetObserver(this).start()

setContent {
Providers(
AmbientTiviDateFormatter provides tiviDateFormatter,
AmbientHomeTextCreator provides homeTextCreator,
AmbientWindowInsets provides windowInsets,
) {
TiviContentSetup {
Popular(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import app.tivi.common.compose.paging.collectAsLazyPagingItems
import app.tivi.home.HomeTextCreator
import app.tivi.util.TiviDateFormatter
import dagger.hilt.android.AndroidEntryPoint
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
import dev.chrisbanes.accompanist.insets.ViewWindowInsetObserver
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.consumeAsFlow
Expand All @@ -60,10 +62,15 @@ class RecommendedShowsFragment : Fragment() {
// Just a small optimization to start the data fetch quicker.
val pagedList = viewModel.pagedList

// We use ViewWindowInsetObserver rather than ProvideWindowInsets
// See: https://github.com/chrisbanes/accompanist/issues/155
val windowInsets = ViewWindowInsetObserver(this).start()

setContent {
Providers(
AmbientTiviDateFormatter provides tiviDateFormatter,
AmbientHomeTextCreator provides homeTextCreator,
AmbientWindowInsets provides windowInsets,
) {
TiviContentSetup {
Recommended(
Expand Down
21 changes: 15 additions & 6 deletions ui-search/src/main/java/app/tivi/home/search/SearchFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import androidx.compose.runtime.Providers
import androidx.compose.runtime.getValue
import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.ui.platform.ComposeView
Expand All @@ -32,6 +33,8 @@ import androidx.navigation.fragment.findNavController
import app.tivi.common.compose.LogCompositions
import app.tivi.common.compose.TiviContentSetup
import dagger.hilt.android.AndroidEntryPoint
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
import dev.chrisbanes.accompanist.insets.ViewWindowInsetObserver
import kotlinx.coroutines.channels.Channel

@AndroidEntryPoint
Expand Down Expand Up @@ -61,13 +64,19 @@ internal class SearchFragment : Fragment() {
): View? = ComposeView(requireContext()).apply {
layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)

// We use ViewWindowInsetObserver rather than ProvideWindowInsets
// See: https://github.com/chrisbanes/accompanist/issues/155
val windowInsets = ViewWindowInsetObserver(this).start()

setContent {
TiviContentSetup {
val viewState by viewModel.liveData.observeAsState()
if (viewState != null) {
LogCompositions("ViewState observeAsState")
Search(viewState!!) { action ->
pendingActions.offer(action)
Providers(AmbientWindowInsets provides windowInsets) {
TiviContentSetup {
val viewState by viewModel.liveData.observeAsState()
if (viewState != null) {
LogCompositions("ViewState observeAsState")
Search(viewState!!) { action ->
pendingActions.offer(action)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import app.tivi.common.compose.TiviContentSetup
import app.tivi.extensions.viewModelProviderFactoryOf
import app.tivi.util.TiviDateFormatter
import dagger.hilt.android.AndroidEntryPoint
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
import dev.chrisbanes.accompanist.insets.ViewWindowInsetObserver
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.consumeAsFlow
Expand Down Expand Up @@ -69,8 +71,15 @@ class ShowDetailsFragment : Fragment() {
): View? = ComposeView(requireContext()).apply {
layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)

// We use ViewWindowInsetObserver rather than ProvideWindowInsets
// See: https://github.com/chrisbanes/accompanist/issues/155
val windowInsets = ViewWindowInsetObserver(this).start()

setContent {
Providers(AmbientShowDetailsTextCreator provides textCreator) {
Providers(
AmbientShowDetailsTextCreator provides textCreator,
AmbientWindowInsets provides windowInsets,
) {
TiviContentSetup {
val viewState by viewModel.liveData.observeAsState()
if (viewState != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import app.tivi.common.compose.paging.collectAsLazyPagingItems
import app.tivi.home.HomeTextCreator
import app.tivi.util.TiviDateFormatter
import dagger.hilt.android.AndroidEntryPoint
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
import dev.chrisbanes.accompanist.insets.ViewWindowInsetObserver
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.consumeAsFlow
Expand All @@ -60,10 +62,15 @@ class TrendingShowsFragment : Fragment() {
// Just a small optimization to start the data fetch quicker.
val pagedList = viewModel.pagedList

// We use ViewWindowInsetObserver rather than ProvideWindowInsets
// See: https://github.com/chrisbanes/accompanist/issues/155
val windowInsets = ViewWindowInsetObserver(this).start()

setContent {
Providers(
AmbientTiviDateFormatter provides tiviDateFormatter,
AmbientHomeTextCreator provides homeTextCreator,
AmbientWindowInsets provides windowInsets,
) {
TiviContentSetup {
Trending(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import app.tivi.common.compose.TiviContentSetup
import app.tivi.home.HomeTextCreator
import app.tivi.util.TiviDateFormatter
import dagger.hilt.android.AndroidEntryPoint
import dev.chrisbanes.accompanist.insets.AmbientWindowInsets
import dev.chrisbanes.accompanist.insets.ViewWindowInsetObserver
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.consumeAsFlow
Expand All @@ -58,10 +60,15 @@ class WatchedFragment : Fragment() {
): View? = ComposeView(requireContext()).apply {
layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)

// We use ViewWindowInsetObserver rather than ProvideWindowInsets
// See: https://github.com/chrisbanes/accompanist/issues/155
val windowInsets = ViewWindowInsetObserver(this).start()

setContent {
Providers(
AmbientTiviDateFormatter provides tiviDateFormatter,
AmbientHomeTextCreator provides homeTextCreator,
AmbientWindowInsets provides windowInsets,
) {
TiviContentSetup {
val viewState by viewModel.liveData.observeAsState()
Expand Down

0 comments on commit 5e700c8

Please sign in to comment.