Skip to content

Commit 7b7e8a1

Browse files
authored
Change variable name to remove nameShadowed warning (#95)
* Change variable name to remove `nameShadowed` warning * Fix HomeScreenTest.kt by adding `@ExperimentalAnimationApi` to setUp
1 parent 7aba22b commit 7b7e8a1

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

app/src/androidTest/java/com/guru/composecookbook/ui/home/HomeScreenTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.guru.composecookbook.ui.home
22

3+
import androidx.compose.animation.ExperimentalAnimationApi
34
import androidx.compose.foundation.ExperimentalFoundationApi
45
import androidx.compose.material.ExperimentalMaterialApi
56
import androidx.compose.runtime.mutableStateOf
@@ -22,6 +23,7 @@ class HomeScreenTest {
2223
@get: Rule
2324
val composeAndroidTestRule = createAndroidComposeRule<MainActivity>()
2425

26+
@ExperimentalAnimationApi
2527
@ExperimentalFoundationApi
2628
@ExperimentalMaterialApi
2729
@Before

app/src/main/java/com/guru/composecookbook/ui/home/advancelists/SwipeableLists.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@ import kotlin.math.roundToInt
3636
@ExperimentalMaterialApi
3737
@Composable
3838
fun SwipeableLists() {
39-
val albums by mutableStateOf(AlbumsDataProvider.albums)
39+
val albums by remember {
40+
mutableStateOf(AlbumsDataProvider.albums)
41+
}
4042
LazyColumn {
4143
itemsIndexed(
4244
items = albums,
4345
itemContent = { index, album ->
4446
SwipeableListItem(index, album) { index ->
4547

4648
}
47-
})
49+
}
50+
)
4851
}
4952
}
5053

components/charts/src/main/java/com/guru/composecookbook/charts/Charts.kt

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,20 @@ fun LineChart(
148148

149149
Canvas(modifier = modifier.padding(8.dp)) {
150150
val path = Path()
151-
val xbounds = Pair(0f, xTarget)
152-
val ybounds = getBounds(yValues)
153-
val scaleX = size.width / (xbounds.second - xbounds.first)
154-
val scaleY = size.height / (ybounds.second - ybounds.first)
155-
val yMove = ybounds.first * scaleY
151+
val xBounds = Pair(0f, xTarget)
152+
val yBounds = getBounds(yValues)
153+
val scaleX = size.width / (xBounds.second - xBounds.first)
154+
val scaleY = size.height / (yBounds.second - yBounds.first)
155+
val yMove = yBounds.first * scaleY
156156

157157
(0..min(yValues.size - 1, x.value.toInt())).forEach { value ->
158-
val x = value * scaleX
159-
val y = size.height - (yValues[value] * scaleY) + yMove
158+
val xPoint = value * scaleX
159+
val yPoint = size.height - (yValues[value] * scaleY) + yMove
160160
if (value == 0) {
161-
path.moveTo(0f, y)
161+
path.moveTo(0f, yPoint)
162162
return@forEach
163163
}
164-
path.lineTo(x, y)
164+
path.lineTo(xPoint, yPoint)
165165
}
166166

167167
drawPath(
@@ -194,16 +194,21 @@ fun BarCharts(
194194
}
195195

196196
Canvas(modifier = modifier.padding(horizontal = 8.dp)) {
197-
val xbounds = Pair(0f, xTarget)
198-
val ybounds = getBounds(yValues)
199-
val scaleX = size.width / (xbounds.second - xbounds.first)
200-
val scaleY = size.height / (ybounds.second - ybounds.first)
201-
val yMove = ybounds.first * scaleY
197+
val xBounds = Pair(0f, xTarget)
198+
val yBounds = getBounds(yValues)
199+
val scaleX = size.width / (xBounds.second - xBounds.first)
200+
val scaleY = size.height / (yBounds.second - yBounds.first)
201+
val yMove = yBounds.first * scaleY
202202

203203
(0..min(yValues.size - 1, x.value.toInt())).forEach { value ->
204-
val x = value * scaleX
205-
val y = size.height - (yValues[value] * scaleY) + yMove
206-
drawBar(topLeft = Offset(x, y), width = barWidth, height = size.height - y, barColors)
204+
val xOffset = value * scaleX
205+
val yOffset = size.height - (yValues[value] * scaleY) + yMove
206+
drawBar(
207+
topLeft = Offset(xOffset, yOffset),
208+
width = barWidth,
209+
height = size.height - yOffset,
210+
barColors
211+
)
207212
}
208213
}
209214
}

demos/datingapp/src/main/java/com/guru/composecookbook/datingapp/components/home/DatingHomeScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ fun DatingHomeScreen() {
6565
start = 16.dp,
6666
end = 16.dp
6767
),
68-
{ _, album ->
68+
onSwiped = { _, swipedAlbum ->
6969
if (persons.isNotEmpty()) {
70-
persons.remove(album)
70+
persons.remove(swipedAlbum)
7171
if (persons.isEmpty()) {
7272
listEmpty.value = true
7373
}

demos/spotify/src/main/java/com/guru/composecookbook/spotify/ui/home/SpotifyActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ fun SpotifyBottomNavigation(spotifyNavItemState: MutableState<SpotifyNavType>) {
8787

8888
@Composable
8989
fun SpotifyBodyContent(spotifyNavType: SpotifyNavType) {
90-
Crossfade(targetState = spotifyNavType) { spotifyNavType ->
91-
when (spotifyNavType) {
90+
Crossfade(targetState = spotifyNavType) { navType ->
91+
when (navType) {
9292
SpotifyNavType.HOME -> SpotifyHome()
9393
SpotifyNavType.SEARCH -> SpotifySearchScreen()
9494
SpotifyNavType.LIBRARY -> SpotifyPlayList()

0 commit comments

Comments
 (0)