Skip to content

Commit 1a6e874

Browse files
committed
Update dependencies
1 parent d86da02 commit 1a6e874

File tree

5 files changed

+92
-108
lines changed

5 files changed

+92
-108
lines changed

app/src/main/java/ru/spbu/depnav/ui/MainActivity.kt

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import androidx.activity.SystemBarStyle
2525
import androidx.activity.compose.setContent
2626
import androidx.activity.enableEdgeToEdge
2727
import androidx.compose.foundation.isSystemInDarkTheme
28-
import androidx.compose.runtime.CompositionLocalProvider
2928
import androidx.compose.runtime.LaunchedEffect
3029
import androidx.compose.runtime.getValue
3130
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -47,27 +46,19 @@ class MainActivity : ComponentActivity() {
4746
super.onCreate(savedInstanceState)
4847

4948
setContent {
50-
CompositionLocalProvider(
51-
// Fix for https://issuetracker.google.com/issues/336842920 -- should be removed as
52-
// soon as Compose UI 1.7.0 becomes stable
53-
androidx.lifecycle.compose.LocalLifecycleOwner provides
54-
androidx.compose.ui.platform.LocalLifecycleOwner.current
55-
) {
56-
val themeMode by prefs.themeModeFlow.collectAsStateWithLifecycle()
57-
val darkTheme = when (themeMode) {
58-
ThemeMode.LIGHT -> false
59-
ThemeMode.DARK -> true
60-
ThemeMode.SYSTEM -> isSystemInDarkTheme()
61-
}
62-
63-
LaunchedEffect(darkTheme) {
64-
val style =
65-
SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { darkTheme }
66-
enableEdgeToEdge(style, style)
67-
}
49+
val themeMode by prefs.themeModeFlow.collectAsStateWithLifecycle()
50+
val darkTheme = when (themeMode) {
51+
ThemeMode.LIGHT -> false
52+
ThemeMode.DARK -> true
53+
ThemeMode.SYSTEM -> isSystemInDarkTheme()
54+
}
6855

69-
DepNavTheme(darkTheme = darkTheme) { MapScreen(prefs) }
56+
LaunchedEffect(darkTheme) {
57+
val style = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { darkTheme }
58+
enableEdgeToEdge(style, style)
7059
}
60+
61+
DepNavTheme(darkTheme = darkTheme) { MapScreen(prefs) }
7162
}
7263
}
7364
}

app/src/main/java/ru/spbu/depnav/ui/component/MapSearchBar.kt

Lines changed: 64 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ import androidx.compose.foundation.layout.Spacer
2929
import androidx.compose.foundation.layout.WindowInsets
3030
import androidx.compose.foundation.layout.WindowInsetsSides
3131
import androidx.compose.foundation.layout.asPaddingValues
32-
import androidx.compose.foundation.layout.calculateEndPadding
33-
import androidx.compose.foundation.layout.calculateStartPadding
3432
import androidx.compose.foundation.layout.only
3533
import androidx.compose.foundation.layout.padding
3634
import androidx.compose.foundation.layout.safeDrawing
@@ -50,23 +48,25 @@ import androidx.compose.material3.minimumInteractiveComponentSize
5048
import androidx.compose.runtime.Composable
5149
import androidx.compose.runtime.getValue
5250
import androidx.compose.ui.Modifier
51+
import androidx.compose.ui.platform.LocalDensity
5352
import androidx.compose.ui.platform.LocalFocusManager
5453
import androidx.compose.ui.platform.LocalLayoutDirection
5554
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
5655
import androidx.compose.ui.res.stringResource
5756
import androidx.compose.ui.text.style.TextOverflow
57+
import androidx.compose.ui.util.lerp
5858
import ru.spbu.depnav.R
5959
import ru.spbu.depnav.ui.theme.DEFAULT_PADDING
6060
import ru.spbu.depnav.ui.theme.ON_MAP_SURFACE_ALPHA
6161
import ru.spbu.depnav.ui.viewmodel.SearchResults
6262

6363
// These are basically copied from SearchBar implementation
64-
private val ACTIVATION_ENTER_SPEC = tween<Float>(
64+
private val EXPANSION_ENTER_SPEC = tween<Float>(
6565
durationMillis = 600,
6666
delayMillis = 100,
6767
easing = CubicBezierEasing(0.05f, 0.7f, 0.1f, 1.0f)
6868
)
69-
private val ACTIVATION_EXIT_SPEC = tween<Float>(
69+
private val EXPANSION_EXIT_SPEC = tween<Float>(
7070
durationMillis = 350,
7171
delayMillis = 100,
7272
easing = CubicBezierEasing(0.0f, 1.0f, 0.0f, 1.0f)
@@ -76,81 +76,59 @@ private val ACTIVATION_EXIT_SPEC = tween<Float>(
7676
* Search bar for querying map markers on [ru.spbu.depnav.ui.screen.MapScreen].
7777
*/
7878
@Composable
79-
@Suppress(
80-
"LongMethod", // No point in further shrinking
81-
"LongParameterList" // Considered OK for a composable
82-
)
79+
@Suppress("LongParameterList") // Considered OK for a composable
8380
@OptIn(ExperimentalMaterial3Api::class)
8481
fun MapSearchBar(
8582
query: String,
8683
onQueryChange: (String) -> Unit,
8784
mapTitle: String,
88-
active: Boolean,
89-
onActiveChange: (Boolean) -> Unit,
85+
expanded: Boolean,
86+
onExpandedChange: (Boolean) -> Unit,
9087
results: SearchResults,
9188
onResultClick: (Int) -> Unit,
9289
onMenuClick: () -> Unit,
9390
modifier: Modifier = Modifier
9491
) {
95-
val activationAnimationProgress by animateFloatAsState(
96-
targetValue = if (active) 1f else 0f,
97-
animationSpec = if (active) ACTIVATION_ENTER_SPEC else ACTIVATION_EXIT_SPEC,
98-
label = "Map search bar activation animation progress"
92+
val expansionAnimationProgress by animateFloatAsState(
93+
targetValue = if (expanded) 1f else 0f,
94+
animationSpec = if (expanded) EXPANSION_ENTER_SPEC else EXPANSION_EXIT_SPEC,
95+
label = "Map search bar expansion animation progress"
9996
)
10097

101-
val (insetsStartPadding, insetsEndPadding) = with(WindowInsets.safeDrawing.asPaddingValues()) {
102-
val layoutDirection = LocalLayoutDirection.current
103-
calculateStartPadding(layoutDirection) to calculateEndPadding(layoutDirection)
104-
}
105-
106-
val outerStartPadding = insetsStartPadding * (1 - activationAnimationProgress)
107-
val outerEndPadding = insetsEndPadding * (1 - activationAnimationProgress)
108-
val innerStartPadding = insetsStartPadding * activationAnimationProgress
109-
val innerEndPadding = insetsEndPadding * activationAnimationProgress
110-
111-
val focusManager = LocalFocusManager.current
112-
113-
val containerColorAlpha =
114-
ON_MAP_SURFACE_ALPHA + (1 - ON_MAP_SURFACE_ALPHA) * activationAnimationProgress
115-
11698
SearchBar(
117-
query = query,
118-
onQueryChange = onQueryChange,
119-
onSearch = { focusManager.clearFocus() },
120-
active = active,
121-
onActiveChange = onActiveChange,
122-
modifier = Modifier
123-
.run {
124-
if (active) padding(start = outerStartPadding, end = outerEndPadding)
125-
else windowInsetsPadding(WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal))
126-
}
127-
.then(modifier),
128-
placeholder = {
129-
Text(
130-
stringResource(R.string.search_on_map, mapTitle),
131-
overflow = TextOverflow.Ellipsis,
132-
maxLines = 1
133-
)
134-
},
135-
leadingIcon = {
136-
AnimatedLeadingIcon(
137-
active,
138-
onMenuClick = onMenuClick,
139-
modifier = Modifier.padding(start = innerStartPadding),
140-
onNavigateBackClick = { onActiveChange(false) }
141-
)
142-
},
143-
trailingIcon = {
144-
AnimatedTrailingIcon(
145-
active,
146-
query.isEmpty(),
147-
onClearClick = { onQueryChange("") },
148-
modifier = Modifier.padding(end = innerEndPadding)
149-
)
99+
inputField = {
100+
SearchBarDefaults.InputField(
101+
query = query,
102+
onQueryChange = onQueryChange,
103+
onSearch = with(LocalFocusManager.current) { { clearFocus() } },
104+
expanded = expanded,
105+
onExpandedChange = onExpandedChange,
106+
modifier = Modifier.windowInsetsPadding(
107+
WindowInsets.safeDrawing.only(WindowInsetsSides.Horizontal) *
108+
expansionAnimationProgress
109+
),
110+
placeholder = { Placeholder(mapTitle) },
111+
leadingIcon = {
112+
AnimatedLeadingIcon(
113+
expanded,
114+
onMenuClick = onMenuClick,
115+
onNavigateBackClick = { onExpandedChange(false) }
116+
)
117+
},
118+
trailingIcon = {
119+
AnimatedTrailingIcon(
120+
expanded,
121+
query.isEmpty(),
122+
onClearClick = { onQueryChange("") }
123+
)
124+
})
150125
},
126+
expanded = expanded,
127+
onExpandedChange = onExpandedChange,
128+
modifier = modifier,
151129
colors = SearchBarDefaults.colors(
152130
containerColor = MaterialTheme.colorScheme.surfaceVariant.copy(
153-
alpha = containerColorAlpha
131+
alpha = lerp(ON_MAP_SURFACE_ALPHA, 1f, expansionAnimationProgress)
154132
)
155133
)
156134
) {
@@ -160,22 +138,37 @@ fun MapSearchBar(
160138
results,
161139
onScroll = { onTop -> keyboard?.apply { if (onTop) show() else hide() } },
162140
onResultClick = {
163-
onActiveChange(false)
141+
onExpandedChange(false)
164142
onResultClick(it)
165143
},
166144
modifier = Modifier
145+
.windowInsetsPadding(WindowInsets.safeDrawing)
167146
.padding(horizontal = DEFAULT_PADDING * 1.5f)
168-
.padding(
169-
start = innerStartPadding,
170-
end = innerEndPadding,
171-
bottom = WindowInsets.safeDrawing
172-
.asPaddingValues()
173-
.calculateBottomPadding()
174-
)
175147
)
176148
}
177149
}
178150

151+
@Composable
152+
operator fun WindowInsets.times(num: Float): WindowInsets {
153+
val paddings = asPaddingValues(LocalDensity.current)
154+
val layoutDirection = LocalLayoutDirection.current
155+
return WindowInsets(
156+
paddings.calculateLeftPadding(layoutDirection) * num,
157+
paddings.calculateTopPadding() * num,
158+
paddings.calculateRightPadding(layoutDirection) * num,
159+
paddings.calculateBottomPadding() * num
160+
)
161+
}
162+
163+
@Composable
164+
private fun Placeholder(mapTitle: String) {
165+
Text(
166+
stringResource(R.string.search_on_map, mapTitle),
167+
overflow = TextOverflow.Ellipsis,
168+
maxLines = 1
169+
)
170+
}
171+
179172
@Composable
180173
private fun AnimatedLeadingIcon(
181174
searchBarActive: Boolean,

app/src/main/java/ru/spbu/depnav/ui/screen/MapScreen.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ private fun BoxScope.AnimatedSearchBar(
218218
onResultClick: (Int) -> Unit,
219219
onMenuClick: () -> Unit
220220
) {
221-
var searchBarActive by rememberSaveable { mutableStateOf(false) }
221+
var searchBarExpanded by rememberSaveable { mutableStateOf(false) }
222222
if (!visible) {
223-
searchBarActive = false
223+
searchBarExpanded = false
224224
}
225225

226-
if (!searchBarActive && query.isNotEmpty()) {
226+
if (!searchBarExpanded && query.isNotEmpty()) {
227227
onQueryChange("")
228228
}
229229

@@ -236,16 +236,16 @@ private fun BoxScope.AnimatedSearchBar(
236236
exit = slideOutVertically(targetOffsetY = { -it }) + fadeOut()
237237
) {
238238
val horizontalPadding by animateDpAsState(
239-
if (searchBarActive) 0.dp else DEFAULT_PADDING,
239+
if (searchBarExpanded) 0.dp else DEFAULT_PADDING,
240240
label = "Map search bar horizontal padding"
241241
)
242242

243243
MapSearchBar(
244244
query = query,
245245
onQueryChange = onQueryChange,
246246
mapTitle = mapTitle,
247-
active = searchBarActive,
248-
onActiveChange = { searchBarActive = it },
247+
expanded = searchBarExpanded,
248+
onExpandedChange = { searchBarExpanded = it },
249249
results = searchResults,
250250
onResultClick = onResultClick,
251251
onMenuClick = onMenuClick,

gradle/libs.versions.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[versions]
22

3-
kotlin = "2.0.20"
4-
kspPlugin = "2.0.20-1.0.24"
5-
hilt = "2.52"
6-
lifecycle = "2.8.4"
3+
kotlin = "2.1.10"
4+
kspPlugin = "2.1.10-1.0.29"
5+
hilt = "2.55"
6+
lifecycle = "2.8.7"
77
room = "2.6.1"
88

99

@@ -20,15 +20,15 @@ androidx-room-compiler = { group = "androidx.room", name = "room-compiler", vers
2020
google-dagger-hilt = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
2121
google-dagger-hiltCompiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" }
2222

23-
androidx-compose-bom = "androidx.compose:compose-bom:2024.08.00"
23+
androidx-compose-bom = "androidx.compose:compose-bom:2025.01.01"
2424
androidx-compose-material3 = { module = "androidx.compose.material3:material3" }
2525
androidx-compose-ui = { module = "androidx.compose.ui:ui" }
2626
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
2727
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
2828

29-
androidx-core-ktx = "androidx.core:core-ktx:1.13.1"
30-
androidx-activity-compose = "androidx.activity:activity-compose:1.9.1"
31-
plrapps-mapcompose = "ovh.plrapps:mapcompose:2.12.6"
29+
androidx-core-ktx = "androidx.core:core-ktx:1.15.0"
30+
androidx-activity-compose = "androidx.activity:activity-compose:1.10.0"
31+
plrapps-mapcompose = "ovh.plrapps:mapcompose:2.14.0"
3232

3333
junit = "junit:junit:4.13.2"
3434
androidx-test-runner = "androidx.test:runner:1.6.2"
@@ -38,7 +38,7 @@ androidx-test-extJunit = "androidx.test.ext:junit:1.2.1"
3838

3939
[plugins]
4040

41-
android-application = { id = "com.android.application", version = "8.5.2" }
41+
android-application = { id = "com.android.application", version = "8.8.0" }
4242
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
4343
jetbrains-kotlin-plugin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
4444
google-dagger-hilt-android = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Tue Aug 27 22:36:14 CEST 2024
1+
#Sat Feb 01 19:06:21 CET 2025
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)