Skip to content

Commit 29f94dc

Browse files
committed
code review.
1 parent bd1bd03 commit 29f94dc

File tree

7 files changed

+69
-82
lines changed

7 files changed

+69
-82
lines changed

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ android {
3131
}
3232
kotlinOptions {
3333
jvmTarget = '1.8'
34+
freeCompilerArgs += [
35+
"-opt-in=com.google.accompanist.pager.ExperimentalPagerApi",
36+
]
3437
}
3538
buildFeatures {
3639
compose true

app/src/main/java/com/commandiron/composeloading/MainActivity.kt

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ package com.commandiron.composeloading
22

33
import android.os.Bundle
44
import androidx.activity.ComponentActivity
5+
import androidx.activity.compose.BackHandler
56
import androidx.activity.compose.setContent
67
import androidx.compose.foundation.background
78
import androidx.compose.foundation.layout.*
9+
import androidx.compose.runtime.Composable
810
import androidx.compose.runtime.rememberCoroutineScope
9-
import androidx.compose.ui.Alignment
1011
import androidx.compose.ui.Modifier
11-
import androidx.compose.ui.graphics.Color
12-
import androidx.compose.ui.unit.dp
1312
import com.commandiron.compose_loading.*
1413
import com.commandiron.composeloading.ui.theme.*
15-
import com.google.accompanist.pager.ExperimentalPagerApi
1614
import com.google.accompanist.pager.HorizontalPager
1715
import com.google.accompanist.pager.rememberPagerState
1816
import kotlinx.coroutines.launch
@@ -27,3 +25,62 @@ class MainActivity : ComponentActivity() {
2725
}
2826
}
2927
}
28+
29+
@Composable
30+
fun ShowScreen() {
31+
val state = rememberPagerState()
32+
val scope = rememberCoroutineScope()
33+
ShowCase(
34+
modifier = Modifier.fillMaxSize(),
35+
state = state,
36+
onNext = {
37+
scope.launch {
38+
state.animateScrollToPage(state.currentPage + 1)
39+
}
40+
},
41+
onBack = {
42+
scope.launch {
43+
state.animateScrollToPage(state.currentPage - 1)
44+
}
45+
}
46+
) {
47+
HorizontalPager(state = state, count = 15) {
48+
when(currentPage){
49+
0 -> { ShowGrid() }
50+
51+
1 -> { RotatingPlane(Modifier.background(BurntOrange).fillMaxSize()) }
52+
53+
2 -> { ChasingDots(Modifier.background(Charcoal).fillMaxSize()) }
54+
55+
3 -> { DoubleBounce(Modifier.background(MountainMeadow).fillMaxSize()) }
56+
57+
4 -> { Wave(Modifier.background(StarCommandBlue).fillMaxSize()) }
58+
59+
5 -> { WanderingCubes( Modifier.background(BattleshipGrey).fillMaxSize()) }
60+
61+
6 -> { Pulse(Modifier.background(MaximumYellowRed).fillMaxSize()) }
62+
63+
7 -> { ChasingTwoDots(Modifier.background(BurntOrange).fillMaxSize()) }
64+
65+
8 -> { ThreeBounce(Modifier.background(GOGreen).fillMaxSize()) }
66+
67+
9 -> { Circle(Modifier.background(BurntOrange).fillMaxSize()) }
68+
69+
10 -> { CubeGrid(Modifier.background(Charcoal).fillMaxSize()) }
70+
71+
11 -> { FadingCircle(Modifier.background(MountainMeadow).fillMaxSize()) }
72+
73+
12 -> { FoldingCube(Modifier.background(StarCommandBlue).fillMaxSize()) }
74+
75+
13 -> { LoadingBar(fakeMillis = 10000) }
76+
77+
14 -> { LoadingDots("Loading") }
78+
}
79+
}
80+
}
81+
BackHandler(enabled = state.currentPage != 0) {
82+
scope.launch {
83+
state.animateScrollToPage(state.currentPage - 1)
84+
}
85+
}
86+
}

app/src/main/java/com/commandiron/composeloading/ShowCase.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import androidx.compose.ui.unit.dp
1414
import com.google.accompanist.pager.ExperimentalPagerApi
1515
import com.google.accompanist.pager.PagerState
1616

17-
@OptIn(ExperimentalPagerApi::class)
1817
@Composable
1918
fun ShowCase(
2019
modifier: Modifier = Modifier,

app/src/main/java/com/commandiron/composeloading/ShowScreen.kt

Lines changed: 0 additions & 74 deletions
This file was deleted.

compose-loading/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ android {
3737

3838
dependencies {
3939
implementation "androidx.compose.ui:ui:$compose_version"
40-
implementation "androidx.compose.material3:material3:1.0.0-alpha13"
40+
implementation "androidx.compose.material3:material3:1.0.0-alpha15"
4141
}

compose-loading/src/main/java/com/commandiron/compose_loading/RotatingPlane.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import androidx.compose.runtime.*
1111
import androidx.compose.ui.Alignment
1212
import androidx.compose.ui.Modifier
1313
import androidx.compose.ui.graphics.Color
14+
import androidx.compose.ui.graphics.RectangleShape
1415
import androidx.compose.ui.graphics.Shape
1516
import androidx.compose.ui.graphics.graphicsLayer
1617
import androidx.compose.ui.unit.DpSize
@@ -25,7 +26,7 @@ fun RotatingPlane(
2526
delayMillis: Int = 0,
2627
size: DpSize = DpSize(30.dp, 30.dp),
2728
color: Color = MaterialTheme.colorScheme.surface,
28-
shape: Shape = Shapes.None,
29+
shape: Shape = RectangleShape,
2930
contentOnPlane: @Composable BoxScope. () -> Unit = {}
3031
) {
3132
val transition = rememberInfiniteTransition()

compose-loading/src/main/java/com/commandiron/compose_loading/Wave.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import androidx.compose.runtime.Composable
99
import androidx.compose.ui.Alignment
1010
import androidx.compose.ui.Modifier
1111
import androidx.compose.ui.graphics.Color
12+
import androidx.compose.ui.graphics.RectangleShape
1213
import androidx.compose.ui.graphics.Shape
1314
import androidx.compose.ui.unit.Dp
1415
import androidx.compose.ui.unit.dp
@@ -22,7 +23,7 @@ fun Wave(
2223
delayMillis: Int = 400,
2324
size: Dp = 24.dp,
2425
color: Color = MaterialTheme.colorScheme.surface,
25-
shape: Shape = Shapes.None,
26+
shape: Shape = RectangleShape,
2627
) {
2728
val transition = rememberInfiniteTransition()
2829

0 commit comments

Comments
 (0)