Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Migrate away from InsetsX #1538

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion common/ui/compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ kotlin {
api(libs.compose.material3.windowsizeclass)
implementation(compose.animation)

api(libs.insetsx)
implementation(libs.uuid)

implementation(libs.paging.compose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
Expand Down Expand Up @@ -54,7 +53,6 @@ import app.tivi.common.compose.ui.RefreshButton
import app.tivi.common.compose.ui.plus
import app.tivi.data.compoundmodels.EntryWithShow
import app.tivi.data.models.Entry
import com.moriatsushi.insetsx.systemBars
import kotlin.math.roundToInt

@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterialApi::class, ExperimentalMaterial3Api::class)
Expand Down Expand Up @@ -117,7 +115,6 @@ fun <E : Entry> EntryGrid(
)
}
},
contentWindowInsets = WindowInsets.systemBars,
modifier = modifier,
) { paddingValues ->
val refreshing = lazyPagingItems.loadState.refresh == LoadStateLoading
Expand Down Expand Up @@ -206,7 +203,7 @@ private fun EntryGridAppBar(
)
}
},
windowInsets = WindowInsets.systemBars
windowInsets = TopAppBarDefaults.windowInsets
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top),
modifier = modifier,
scrollBehavior = scrollBehavior,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ package app.tivi.common.compose

import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.composed
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.moriatsushi.insetsx.systemBars

object Layout {
val bodyMargin: Dp
Expand All @@ -42,9 +41,8 @@ object Layout {

fun Modifier.bodyWidth() = fillMaxWidth()
.composed {
padding(
windowInsetsPadding(
WindowInsets.systemBars
.only(WindowInsetsSides.Horizontal)
.asPaddingValues(),
.only(WindowInsetsSides.Horizontal),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.compose.animation.Crossfade
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.only
import androidx.compose.material3.ExperimentalMaterial3Api
Expand All @@ -26,7 +25,6 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import app.tivi.data.models.TraktUser
import com.moriatsushi.insetsx.systemBars

/**
* A wrapper around [TopAppBar] which allows some [bottomContent] below the bar, but within the same
Expand Down Expand Up @@ -60,7 +58,7 @@ fun TopAppBarWithBottomContent(
titleContentColor = LocalContentColor.current,
actionIconContentColor = LocalContentColor.current,
),
windowInsets = WindowInsets.systemBars
windowInsets = TopAppBarDefaults.windowInsets
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top),
)
bottomContent?.invoke(this)
Expand All @@ -82,7 +80,7 @@ fun TiviRootScreenAppBar(
) {
TopAppBar(
modifier = modifier,
windowInsets = WindowInsets.systemBars
windowInsets = TopAppBarDefaults.windowInsets
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top),
scrollBehavior = scrollBehavior,
title = { Text(text = title) },
Expand Down
2 changes: 0 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ google-firebase-analytics = "com.google.firebase:firebase-analytics-ktx:21.3.0"
google-firebase-crashlytics = "com.google.firebase:firebase-crashlytics-ktx:18.4.1"
google-firebase-perf = "com.google.firebase:firebase-perf-ktx:20.4.1"

insetsx = "com.moriatsushi.insetsx:insetsx:0.1.0-alpha10"

imageloader = "io.github.qdsfdhvh:image-loader:1.6.7"

junit = "junit:junit:4.13.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package app.tivi.developer.log

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
Expand All @@ -20,6 +19,7 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -32,7 +32,6 @@ import androidx.compose.ui.unit.sp
import app.tivi.common.compose.LocalStrings
import app.tivi.screens.DevLogScreen
import app.tivi.util.Severity
import com.moriatsushi.insetsx.systemBars
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
Expand Down Expand Up @@ -72,11 +71,10 @@ internal fun DevLog(
)
}
},
windowInsets = WindowInsets.systemBars
windowInsets = TopAppBarDefaults.windowInsets
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top),
)
},
contentWindowInsets = WindowInsets.systemBars,
modifier = modifier,
) { contentPadding ->
LazyColumn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package app.tivi.settings.developer

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
Expand All @@ -18,13 +17,13 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import app.tivi.common.compose.LocalStrings
import app.tivi.common.compose.ui.CheckboxPreference
import app.tivi.common.compose.ui.Preference
import app.tivi.screens.DevSettingsScreen
import com.moriatsushi.insetsx.systemBars
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
Expand Down Expand Up @@ -64,11 +63,10 @@ internal fun DevSettings(
)
}
},
windowInsets = WindowInsets.systemBars
windowInsets = TopAppBarDefaults.windowInsets
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top),
)
},
contentWindowInsets = WindowInsets.systemBars,
modifier = modifier,
) { contentPadding ->
LazyColumn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
Expand Down Expand Up @@ -75,7 +74,6 @@ import app.tivi.data.traktauth.TraktAuthState
import app.tivi.overlays.showInDialog
import app.tivi.screens.AccountScreen
import app.tivi.screens.DiscoverScreen
import com.moriatsushi.insetsx.systemBars
import com.slack.circuit.overlay.LocalOverlayHost
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.screen.Screen
Expand Down Expand Up @@ -191,7 +189,6 @@ internal fun Discover(
)
}
},
contentWindowInsets = WindowInsets.systemBars,
modifier = modifier,
) { paddingValues ->
val refreshState = rememberPullRefreshState(refreshing = false, onRefresh = refresh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.layout.windowInsetsTopHeight
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
Expand Down Expand Up @@ -82,7 +83,6 @@ import app.tivi.data.models.Season
import app.tivi.overlays.showInDialog
import app.tivi.screens.EpisodeDetailsScreen
import app.tivi.screens.EpisodeTrackScreen
import com.moriatsushi.insetsx.statusBars
import com.slack.circuit.overlay.LocalOverlayHost
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.screen.Screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
Expand Down Expand Up @@ -84,7 +83,6 @@ import app.tivi.data.traktauth.TraktAuthState
import app.tivi.overlays.showInDialog
import app.tivi.screens.AccountScreen
import app.tivi.screens.LibraryScreen
import com.moriatsushi.insetsx.systemBars
import com.slack.circuit.overlay.LocalOverlayHost
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.screen.Screen
Expand Down Expand Up @@ -198,7 +196,6 @@ internal fun Library(
)
}
},
contentWindowInsets = WindowInsets.systemBars,
modifier = modifier.fillMaxSize(),
) { paddingValues ->
val refreshState = rememberPullRefreshState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package app.tivi.settings.licenses

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
Expand All @@ -19,12 +18,12 @@ import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import app.tivi.common.compose.LocalStrings
import app.tivi.common.compose.ui.Preference
import app.tivi.screens.LicensesScreen
import com.moriatsushi.insetsx.systemBars
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
Expand Down Expand Up @@ -64,11 +63,10 @@ internal fun Licenses(
)
}
},
windowInsets = WindowInsets.systemBars
windowInsets = TopAppBarDefaults.windowInsets
.only(WindowInsetsSides.Horizontal + WindowInsetsSides.Top),
)
},
contentWindowInsets = WindowInsets.systemBars,
modifier = modifier,
) { contentPadding ->
LazyColumn(
Expand Down
16 changes: 8 additions & 8 deletions ui/root/src/commonMain/kotlin/app/tivi/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ import androidx.compose.foundation.layout.exclude
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeContent
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.layout.windowInsetsBottomHeight
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
import androidx.compose.material.icons.filled.Subscriptions
Expand All @@ -24,14 +28,14 @@ import androidx.compose.material.icons.filled.Weekend
import androidx.compose.material.icons.outlined.VideoLibrary
import androidx.compose.material.icons.outlined.Weekend
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationDrawerItem
import androidx.compose.material3.NavigationRail
import androidx.compose.material3.NavigationRailItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.ScaffoldDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.windowsizeclass.WindowHeightSizeClass
import androidx.compose.material3.windowsizeclass.WindowSizeClass
Expand All @@ -51,10 +55,6 @@ import app.tivi.screens.DiscoverScreen
import app.tivi.screens.LibraryScreen
import app.tivi.screens.SearchScreen
import app.tivi.screens.UpNextScreen
import com.moriatsushi.insetsx.navigationBars
import com.moriatsushi.insetsx.safeContentPadding
import com.moriatsushi.insetsx.statusBars
import com.moriatsushi.insetsx.systemBars
import com.slack.circuit.backstack.SaveableBackStack
import com.slack.circuit.backstack.isAtRoot
import com.slack.circuit.foundation.NavigableCircuitContent
Expand Down Expand Up @@ -99,7 +99,8 @@ internal fun Home(
}
},
// We let content handle the status bar
contentWindowInsets = WindowInsets.systemBars.exclude(WindowInsets.statusBars),
contentWindowInsets = ScaffoldDefaults.contentWindowInsets
.exclude(WindowInsets.statusBars),
modifier = modifier,
) { paddingValues ->
Row(
Expand Down Expand Up @@ -206,12 +207,11 @@ private fun HomeNavigationDrawer(
) {
Column(
modifier = modifier
.safeContentPadding()
.windowInsetsPadding(WindowInsets.safeContent)
.padding(16.dp)
.widthIn(max = 280.dp),
) {
for (item in navigationItems) {
@OptIn(ExperimentalMaterial3Api::class)
NavigationDrawerItem(
icon = {
Icon(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
Expand Down Expand Up @@ -53,8 +55,6 @@ import app.tivi.common.compose.ui.SearchTextField
import app.tivi.common.compose.ui.plus
import app.tivi.data.models.TiviShow
import app.tivi.screens.SearchScreen
import com.moriatsushi.insetsx.statusBarsPadding
import com.moriatsushi.insetsx.systemBars
import com.slack.circuit.runtime.CircuitContext
import com.slack.circuit.runtime.screen.Screen
import com.slack.circuit.runtime.ui.Ui
Expand Down Expand Up @@ -129,7 +129,7 @@ internal fun Search(
Box(
Modifier
.padding(horizontal = Layout.bodyMargin, vertical = 8.dp)
.statusBarsPadding()
.windowInsetsPadding(WindowInsets.statusBars)
.bodyWidth(),
) {
var searchQuery by remember { mutableStateOf(TextFieldValue(state.query)) }
Expand Down Expand Up @@ -157,7 +157,6 @@ internal fun Search(
)
}
},
contentWindowInsets = WindowInsets.systemBars,
modifier = modifier,
) { padding ->
if (state.searchResults.isEmpty() && !state.refreshing) {
Expand Down
Loading