Skip to content

Commit 34b6270

Browse files
authored
refactor to tidy up things (#99)
* replace deprecated function used in TikTokPlayer.kt * Add label for animation preview * Refactor package directive * Rename file (previously typo) and refactor collection chain call * remove unnecessary parentheses * collapse empty tag * refactor mutable to immutable variable
1 parent 3fb6e80 commit 34b6270

File tree

11 files changed

+20
-21
lines changed

11 files changed

+20
-21
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<activity
1818
android:name=".ui.templates.TemplatesActivity"
1919
android:label="@string/title_activity_templates"
20-
android:theme="@style/Theme.ComposeCookBook.NoActionBar"></activity>
20+
android:theme="@style/Theme.ComposeCookBook.NoActionBar" />
2121
<activity
2222
android:name=".ui.home.advancelists.AdvanceListsActivity"
2323
android:label="@string/title_activity_advance_lists"

app/src/main/java/com/guru/composecookbook/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.guru.composecookbook
22

3-
import AnimationScreen
3+
import com.guru.composecookbook.ui.animation.AnimationScreen
44
import FaIcons
55
import android.os.Bundle
66
import androidx.activity.ComponentActivity

app/src/main/java/com/guru/composecookbook/ui/animation/AnimationScreen.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
package com.guru.composecookbook.ui.animation
2+
13
import androidx.compose.foundation.layout.Spacer
24
import androidx.compose.foundation.layout.padding
35
import androidx.compose.foundation.lazy.LazyColumn
@@ -14,10 +16,6 @@ import androidx.compose.ui.Modifier
1416
import androidx.compose.ui.platform.testTag
1517
import androidx.compose.ui.unit.dp
1618
import com.guru.composecookbook.colorpicker.ColorPicker
17-
import com.guru.composecookbook.ui.animation.AnimatableSuspendedAnimations
18-
import com.guru.composecookbook.ui.animation.AnimationsForStates
19-
import com.guru.composecookbook.ui.animation.AnimationsWithVisibilityApi
20-
import com.guru.composecookbook.ui.animation.TransitionAnimationsWithMultipleStates
2119
import com.guru.composecookbook.ui.utils.RotateIcon
2220
import com.guru.composecookbook.ui.utils.TestTags
2321
import com.guru.composecookbook.ui.utils.TitleText

app/src/main/java/com/guru/composecookbook/ui/animation/TransitionsAnimations.kt

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

3-
import MyAnimationState
43
import androidx.compose.animation.animateColor
54
import androidx.compose.animation.core.*
65
import androidx.compose.foundation.layout.Spacer
@@ -46,10 +45,11 @@ fun MultiStateColorPositionAnimation() {
4645
val midColor = purple
4746
val endColor = orange
4847

49-
val transition = updateTransition(targetState = animationState)
48+
val transition = updateTransition(targetState = animationState, label = "transition")
5049

5150
val animatedColor by transition.animateColor(
52-
transitionSpec = { tween(500) }
51+
transitionSpec = { tween(500) },
52+
label = "animatedColor",
5353
) { state ->
5454
when (state) {
5555
MyAnimationState.START -> startColor
@@ -59,7 +59,8 @@ fun MultiStateColorPositionAnimation() {
5959
}
6060

6161
val position by transition.animateDp(
62-
transitionSpec = { tween(500) }
62+
transitionSpec = { tween(500) },
63+
label = "position",
6364
) { state ->
6465
when (state) {
6566
MyAnimationState.START -> 0.dp
@@ -125,4 +126,4 @@ fun FloatMultiStateAnimationCircleCanvas(color: Color = green500, radiusEnd: Flo
125126
Spacer(modifier = Modifier.height(100.dp))
126127
MultiStateAnimationCircleFilledCanvas(color, radiusEnd)
127128
Spacer(modifier = Modifier.height(100.dp))
128-
}
129+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fun ConstraintLayoutDemos() {
4242
val tweet = DemoDataProvider.tweet
4343
GmailListItem(tweet) {}
4444
Spacer(modifier = Modifier.height(20.dp))
45-
val tweet2 = DemoDataProvider.tweetList.filter { it.tweetImageId > 0 }.first()
45+
val tweet2 = DemoDataProvider.tweetList.first { it.tweetImageId > 0 }
4646
YoutubeListItem(tweet2)
4747
Spacer(modifier = Modifier.height(20.dp))
4848
MyWalletCard()

app/src/main/java/com/guru/composecookbook/ui/home/customfling/FlingListSettingsActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fun SettingsContent(onback: () -> Unit, onApply: () -> Unit) {
110110

111111

112112
@Composable
113-
private fun BaseView(isDarkTheme: Boolean, content: @Composable() () -> Unit) {
113+
private fun BaseView(isDarkTheme: Boolean, content: @Composable () -> Unit) {
114114
ComposeCookBookTheme(isDarkTheme) {
115115
content()
116116
}

app/src/main/java/com/guru/composecookbook/ui/home/lists/ListViewActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ListViewActivity : ComponentActivity() {
6060
}
6161

6262
@Composable
63-
fun BaseView(isDarkTheme: Boolean, content: @Composable() () -> Unit) {
63+
fun BaseView(isDarkTheme: Boolean, content: @Composable () -> Unit) {
6464
ComposeCookBookTheme(isDarkTheme) {
6565
content()
6666
}

app/src/main/java/com/guru/composecookbook/ui/home/tabslayout/TabLayout.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private enum class DemoTabs(val value: String) {
3535
@Composable
3636
fun TabLayout() {
3737
val tabsName = remember { DemoTabs.values().map { it.value } }
38-
var selectedIndex = remember { mutableStateOf(DemoTabs.APPLE.ordinal) }
38+
val selectedIndex = remember { mutableStateOf(DemoTabs.APPLE.ordinal) }
3939
val icons = listOf(Icons.Default.Info, Icons.Default.Person, Icons.Default.ShoppingCart)
4040

4141
Column {
@@ -83,7 +83,7 @@ fun TabLayout() {
8383
@Composable
8484
fun ScrollableListOfTabs() {
8585
val tweets = remember { DemoDataProvider.tweetList.filter { it.tweetImageId > 0 } }
86-
var selectedIndex = remember { mutableStateOf(0) }
86+
val selectedIndex = remember { mutableStateOf(0) }
8787
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
8888
ScrollableTabRow(
8989
selectedTabIndex = selectedIndex.value,

app/src/main/java/com/guru/composecookbook/ui/learnwidgets/SwipeButton.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ fun SwipeButton(
5454
val dragOffset = remember { mutableStateOf(0f) }
5555

5656
val collapsed = swipeButtonState == SwipeButtonState.COLLAPSED
57-
var swiped = swipeButtonState == SwipeButtonState.SWIPED
57+
val swiped = swipeButtonState == SwipeButtonState.SWIPED
5858

5959
Surface(
6060
modifier = modifier,

components/fab/src/main/java/com/guru/composecookbook/fab/AnimatingFabContent.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fun AnimatingFabContent(
3737
extended: Boolean = true
3838
) {
3939
val currentState = if (extended) ExpandableFabStates.Extended else ExpandableFabStates.Collapsed
40-
val transition = updateTransition(targetState = currentState)
40+
val transition = updateTransition(targetState = currentState, label = "transition")
4141
val duration = 200
4242
val opacityAnim = transition.animateFloat(
4343
transitionSpec = {
@@ -56,7 +56,7 @@ fun AnimatingFabContent(
5656
}
5757
else -> snap()
5858
}
59-
}
59+
}, label = "opacityAnim"
6060
) {
6161
when (it) {
6262
ExpandableFabStates.Collapsed -> 0f
@@ -80,7 +80,7 @@ fun AnimatingFabContent(
8080
}
8181
else -> snap()
8282
}
83-
}
83+
}, label = "widthAnimation"
8484
) {
8585
when (it) {
8686
ExpandableFabStates.Collapsed -> 0f

0 commit comments

Comments
 (0)