Skip to content

Commit

Permalink
Merge pull request #73 from techbeloved/edge-to-edge
Browse files Browse the repository at this point in the history
update target SDK to 35
  • Loading branch information
odifek authored Dec 30, 2024
2 parents 28f6595 + 243045e commit 9c42b80
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ android {
defaultConfig {
applicationId "com.techbeloved.hymnbook"
minSdkVersion 21
targetSdkVersion 34
targetSdkVersion 35
versionCode 32
versionName "2.3.9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
1 change: 0 additions & 1 deletion shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.BitcodeEmbeddingMode
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType

plugins {
alias(libs.plugins.kotlin.multiplatform)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ package com.techbeloved.hymnbook.shared.ui

import androidx.compose.foundation.layout.RowScope
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
Expand All @@ -22,20 +24,27 @@ internal fun AppTopBar(
modifier: Modifier = Modifier,
showUpButton: Boolean = true,
scrollBehaviour: TopAppBarScrollBehavior? = null,
actions: @Composable() (RowScope.() -> Unit) = {},
actions: @Composable (RowScope.() -> Unit) = {},
) {
TopAppBar(
title = { Text(title) },
navigationIcon = {
if (showUpButton) {
val navigator = LocalNavigator.currentOrThrow
IconButton(onClick = navigator::pop) {
Icon(Icons.Default.ArrowBack, contentDescription = "Navigate up")
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Navigate up")
}
}
},
actions = actions,
modifier = modifier,
scrollBehavior = scrollBehaviour,
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = MaterialTheme.colorScheme.surface,
scrolledContainerColor = MaterialTheme.colorScheme.surface.copy(alpha = 0.5f),
navigationIconContentColor = MaterialTheme.colorScheme.onSurface,
titleContentColor = MaterialTheme.colorScheme.onSurface,
actionIconContentColor = MaterialTheme.colorScheme.onSurfaceVariant,
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.techbeloved.hymnbook.shared.ui.detail

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -39,11 +41,14 @@ internal class SongDetailScreen(private val songbook: String, private val entry:
val pagerState by pagerModel.state.collectAsState()
when (val state = pagerState) {
is SongDetailPagerState.Content -> {
SongPager(state, pageContent = { pageEntry ->
SongPager(state, pageContent = { pageEntry, contentPadding ->
val screenModel =
rememberScreenModel(pageEntry.toString()) { SongDetailScreenModel(pageEntry.id) }
val uiDetail by screenModel.state.collectAsState()
SongDetailUi(uiDetail)
SongDetailUi(
state = uiDetail,
contentPadding = contentPadding,
)
})
}

Expand All @@ -58,7 +63,11 @@ internal class SongDetailScreen(private val songbook: String, private val entry:
}

@Composable
private fun SongDetailUi(state: SongUiDetail, modifier: Modifier = Modifier) {
private fun SongDetailUi(
state: SongUiDetail,
contentPadding: PaddingValues,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier
.fillMaxSize()
Expand All @@ -68,7 +77,8 @@ private fun SongDetailUi(state: SongUiDetail, modifier: Modifier = Modifier) {
CompositionLocalProvider(LocalContentColor provides MaterialTheme.colorScheme.onSurface) {
Text(
state.content,
modifier = Modifier.fillMaxWidth(),
modifier = Modifier.fillMaxWidth()
.padding(contentPadding),
fontFamily = crimsonText,
fontSize = 18.sp,
)
Expand All @@ -81,22 +91,22 @@ private fun SongDetailUi(state: SongUiDetail, modifier: Modifier = Modifier) {
@Composable
private fun SongPager(
state: SongDetailPagerState.Content,
pageContent: @Composable (entry: SongPageEntry) -> Unit,
pageContent: @Composable (entry: SongPageEntry, contentPadding: PaddingValues) -> Unit,
modifier: Modifier = Modifier,
) {
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
topBar = {
AppTopBar("", scrollBehaviour = scrollBehavior)
},
) { paddingValues ->
) { innerPadding ->
HorizontalPager(
state = rememberPagerState(state.initialPage, pageCount = { state.pages.size }),
modifier = modifier.padding(paddingValues),
key = { state.pages[it].id }
key = { state.pages[it].id },
modifier = modifier.consumeWindowInsets(innerPadding)
.nestedScroll(scrollBehavior.nestedScrollConnection),
) { page ->
pageContent(state.pages[page])
pageContent(state.pages[page], innerPadding)
}
}
}

0 comments on commit 9c42b80

Please sign in to comment.