Skip to content

Commit a727ca2

Browse files
authored
Release TypeType Android 1.7.0-beta.9 (#47)
2 parents bd480de + d927e04 commit a727ca2

5 files changed

Lines changed: 51 additions & 35 deletions

File tree

‎app/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ android {
2626
applicationId = "dev.typetype.android"
2727
minSdk = 23
2828
targetSdk = 37
29-
versionCode = 10707
30-
versionName = "1.7.0-beta.8"
29+
versionCode = 10708
30+
versionName = "1.7.0-beta.9"
3131
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3232
resValue("string", "app_name", "TypeType")
3333
}

‎app/src/main/java/dev/typetype/android/AppNavigation.kt‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ internal fun AppTopBar(
142142

143143
@Composable
144144
internal fun AppBottomBar(
145-
currentDestination: NavDestination?,
146-
fallbackTabRouteQualifiedName: String?,
145+
selectedTabRouteQualifiedName: String?,
147146
onTabClick: (TopLevelTab) -> Unit,
148147
tabs: List<TopLevelTab> = topLevelTabs,
149148
modifier: Modifier = Modifier,
@@ -155,10 +154,10 @@ internal fun AppBottomBar(
155154
containerColor = MaterialTheme.colorScheme.surface,
156155
) {
157156
tabs.forEach { tab: TopLevelTab ->
158-
val selected = tab.isSelected(currentDestination, fallbackTabRouteQualifiedName, tabs)
157+
val selected = tab.route::class.qualifiedName == selectedTabRouteQualifiedName
159158
NavigationBarItem(
160159
selected = selected,
161-
onClick = { if (!currentDestination.matchesRoute(tab.route)) onTabClick(tab) },
160+
onClick = { onTabClick(tab) },
162161
icon = { Icon(painterResource(tab.iconRes), contentDescription = null) },
163162
label = { Text(stringResource(tab.labelRes)) },
164163
)
@@ -169,8 +168,7 @@ internal fun AppBottomBar(
169168

170169
@Composable
171170
internal fun AppNavigationRail(
172-
currentDestination: NavDestination?,
173-
fallbackTabRouteQualifiedName: String?,
171+
selectedTabRouteQualifiedName: String?,
174172
onTabClick: (TopLevelTab) -> Unit,
175173
tabs: List<TopLevelTab> = topLevelTabs,
176174
modifier: Modifier = Modifier,
@@ -184,10 +182,10 @@ internal fun AppNavigationRail(
184182
) {
185183
Spacer(Modifier.weight(1f))
186184
tabs.forEach { tab: TopLevelTab ->
187-
val selected = tab.isSelected(currentDestination, fallbackTabRouteQualifiedName, tabs)
185+
val selected = tab.route::class.qualifiedName == selectedTabRouteQualifiedName
188186
NavigationRailItem(
189187
selected = selected,
190-
onClick = { if (!currentDestination.matchesRoute(tab.route)) onTabClick(tab) },
188+
onClick = { onTabClick(tab) },
191189
icon = { Icon(painterResource(tab.iconRes), contentDescription = null) },
192190
label = { Text(stringResource(tab.labelRes)) },
193191
)
@@ -220,16 +218,6 @@ private fun ProfileAvatarButton(
220218
}
221219
}
222220

223-
private fun TopLevelTab.isSelected(
224-
destination: NavDestination?,
225-
fallbackRouteName: String?,
226-
tabs: List<TopLevelTab>,
227-
): Boolean {
228-
val direct = destination.matchesRoute(route)
229-
val anyDirect = tabs.any { destination.matchesRoute(it.route) }
230-
return direct || (!anyDirect && route::class.qualifiedName == fallbackRouteName)
231-
}
232-
233221
internal fun NavDestination?.matchesRoute(route: Any): Boolean {
234222
val destination = this ?: return false
235223
return when (route) {

‎app/src/main/java/dev/typetype/android/AppShell.kt‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fun AppShell(
9090
currentDestination?.hasRoute<SearchRoute>() == true ||
9191
currentDestination?.hasRoute<NotificationsRoute>() == true
9292
)
93-
var activeTabRoute by rememberSaveable { mutableStateOf<String?>(null) }
93+
var selectedTabRoute by rememberSaveable { mutableStateOf<String?>(null) }
9494
var isPlayerFullscreen by remember { mutableStateOf(false) }
9595
var playerTransitionProgress by remember { mutableFloatStateOf(0f) }
9696
val playerHostState by playerHostController.state.collectAsStateWithLifecycle()
@@ -103,9 +103,13 @@ fun AppShell(
103103
)
104104
LaunchedEffect(currentDestination) {
105105
topLevelTabs.firstOrNull { currentDestination.matchesRoute(it.route) }?.let {
106-
activeTabRoute = it.route::class.qualifiedName
106+
selectedTabRoute = it.route::class.qualifiedName
107107
}
108108
}
109+
val selectedTabRouteQualifiedName = selectedTabRoute
110+
?: topLevelTabs.firstOrNull { currentDestination.matchesRoute(it.route) }
111+
?.route
112+
?.let { it::class.qualifiedName }
109113

110114
val mediaController = rememberMediaController().value
111115
val snackbarHostState = remember { SnackbarHostState() }
@@ -119,10 +123,10 @@ fun AppShell(
119123
Row(modifier = Modifier.fillMaxSize()) {
120124
if (usesNavigationRail && showsNavigation && appChromeVisible) {
121125
AppNavigationRail(
122-
currentDestination = currentDestination,
123-
fallbackTabRouteQualifiedName = activeTabRoute,
126+
selectedTabRouteQualifiedName = selectedTabRouteQualifiedName,
124127
onTabClick = { tab: TopLevelTab ->
125-
navController.navigateTopLevel(tab.route, activeTabRoute)
128+
selectedTabRoute = tab.route::class.qualifiedName
129+
navController.navigateTopLevel(tab.route, selectedTabRoute)
126130
},
127131
tabs = navigationTabs,
128132
)
@@ -163,10 +167,10 @@ fun AppShell(
163167
bottomBar = {
164168
if (!usesNavigationRail && showsNavigation) {
165169
AppBottomBar(
166-
currentDestination = currentDestination,
167-
fallbackTabRouteQualifiedName = activeTabRoute,
170+
selectedTabRouteQualifiedName = selectedTabRouteQualifiedName,
168171
onTabClick = { tab: TopLevelTab ->
169-
navController.navigateTopLevel(tab.route, activeTabRoute)
172+
selectedTabRoute = tab.route::class.qualifiedName
173+
navController.navigateTopLevel(tab.route, selectedTabRoute)
170174
},
171175
tabs = navigationTabs,
172176
modifier = Modifier.playerChrome(phoneChromeAlpha),

‎app/src/main/java/dev/typetype/android/feature/player/components/PlayerControls.kt‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import androidx.compose.foundation.layout.Row
88
import androidx.compose.foundation.layout.fillMaxWidth
99
import androidx.compose.foundation.layout.height
1010
import androidx.compose.foundation.layout.WindowInsets
11-
import androidx.compose.foundation.layout.navigationBarsIgnoringVisibility
11+
import androidx.compose.foundation.layout.navigationBars
1212
import androidx.compose.foundation.layout.padding
1313
import androidx.compose.foundation.layout.size
1414
import androidx.compose.foundation.layout.statusBars
@@ -56,6 +56,7 @@ fun PlayerControls(
5656
)
5757
BottomScrim(
5858
compact = compactControls,
59+
isFullscreen = isFullscreen,
5960
modifier = Modifier.align(Alignment.BottomCenter),
6061
)
6162
PlayerTopBar(
@@ -99,11 +100,17 @@ fun PlayerControls(
99100
.align(Alignment.BottomCenter)
100101
.fillMaxWidth()
101102
.testTag(PLAYER_BOTTOM_CONTROLS_TAG)
102-
.windowInsetsPadding(WindowInsets.navigationBarsIgnoringVisibility)
103+
.then(
104+
if (isFullscreen) {
105+
Modifier
106+
} else {
107+
Modifier.windowInsetsPadding(WindowInsets.navigationBars)
108+
},
109+
)
103110
.padding(
104111
start = if (isFullscreen) 12.dp else 4.dp,
105112
end = if (isFullscreen) 8.dp else 4.dp,
106-
bottom = if (isFullscreen) 12.dp else 0.dp,
113+
bottom = if (isFullscreen) 6.dp else 0.dp,
107114
),
108115
)
109116
}
@@ -124,11 +131,21 @@ private fun TopScrim(compact: Boolean, modifier: Modifier = Modifier) {
124131
}
125132

126133
@Composable
127-
private fun BottomScrim(compact: Boolean, modifier: Modifier = Modifier) {
134+
private fun BottomScrim(
135+
compact: Boolean,
136+
isFullscreen: Boolean,
137+
modifier: Modifier = Modifier,
138+
) {
128139
Box(
129140
modifier = modifier
130141
.fillMaxWidth()
131-
.height(if (compact) 88.dp else 152.dp)
142+
.height(
143+
when {
144+
isFullscreen -> 116.dp
145+
compact -> 88.dp
146+
else -> 152.dp
147+
},
148+
)
132149
.background(
133150
Brush.verticalGradient(
134151
colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.72f)),
@@ -157,7 +174,7 @@ private fun BottomBar(
157174
},
158175
)
159176
.padding(start = if (isFullscreen) 8.dp else 2.dp, end = 2.dp),
160-
verticalAlignment = Alignment.CenterVertically,
177+
verticalAlignment = Alignment.Bottom,
161178
) {
162179
PlayerTimeBar(
163180
player = player,

‎app/src/main/java/dev/typetype/android/feature/player/components/PlayerSurfaceBox.kt‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,15 @@ internal fun PlayerSurfaceBox(
127127
LaunchedEffect(accessibleControls) {
128128
if (accessibleControls) controlsVisible = true
129129
}
130-
LaunchedEffect(controlsVisible, playbackStatus.isPlaying, accessibleControls) {
130+
val isSeekDragging = gestureState.dragMode.value == DragMode.Seek
131+
LaunchedEffect(
132+
controlsVisible,
133+
playbackStatus.isPlaying,
134+
accessibleControls,
135+
isSeekDragging,
136+
) {
131137
if (controlsVisible && playbackStatus.isPlaying && !accessibleControls) {
138+
if (isSeekDragging) return@LaunchedEffect
132139
delay(AUTO_HIDE_DELAY_MS)
133140
controlsVisible = false
134141
}

0 commit comments

Comments
 (0)