Skip to content

Commit b2a2bb6

Browse files
committed
Added ktfmtFormat for code formatting.
1 parent a07defa commit b2a2bb6

File tree

293 files changed

+13878
-16384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

293 files changed

+13878
-16384
lines changed

animations/canvas/src/main/java/com/guru/composecookbook/canvas/MultiStateAnimationCircleFilledCanvas.kt

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,30 @@ import androidx.compose.ui.unit.dp
1212
import com.guru.composecookbook.theme.green500
1313

1414
@Composable
15-
fun MultiStateAnimationCircleFilledCanvas(
16-
color: Color = green500,
17-
radiusEnd: Float = 200f
18-
) {
19-
val transition = rememberInfiniteTransition()
20-
val floatAnim by transition.animateFloat(
21-
initialValue = 10f,
22-
targetValue = radiusEnd,
23-
animationSpec = infiniteRepeatable(tween(1200), RepeatMode.Reverse)
15+
fun MultiStateAnimationCircleFilledCanvas(color: Color = green500, radiusEnd: Float = 200f) {
16+
val transition = rememberInfiniteTransition()
17+
val floatAnim by
18+
transition.animateFloat(
19+
initialValue = 10f,
20+
targetValue = radiusEnd,
21+
animationSpec = infiniteRepeatable(tween(1200), RepeatMode.Reverse)
2422
)
25-
Canvas(modifier = Modifier.padding(16.dp)) {
26-
val centerOffset = Offset(10f, 10f)
27-
drawCircle(
28-
color = color.copy(alpha = 0.8f),
29-
radius = floatAnim,
30-
center = centerOffset,
31-
)
32-
drawCircle(
33-
color = color.copy(alpha = 0.4f),
34-
radius = floatAnim / 2,
35-
center = centerOffset,
36-
)
37-
drawCircle(
38-
color = color.copy(alpha = 0.2f),
39-
radius = floatAnim / 4,
40-
center = centerOffset,
41-
)
42-
}
43-
}
23+
Canvas(modifier = Modifier.padding(16.dp)) {
24+
val centerOffset = Offset(10f, 10f)
25+
drawCircle(
26+
color = color.copy(alpha = 0.8f),
27+
radius = floatAnim,
28+
center = centerOffset,
29+
)
30+
drawCircle(
31+
color = color.copy(alpha = 0.4f),
32+
radius = floatAnim / 2,
33+
center = centerOffset,
34+
)
35+
drawCircle(
36+
color = color.copy(alpha = 0.2f),
37+
radius = floatAnim / 4,
38+
center = centerOffset,
39+
)
40+
}
41+
}

animations/canvas/src/main/java/com/guru/composecookbook/canvas/MultiStateAnimationCircleStrokeCanvas.kt

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,30 @@ import com.guru.composecookbook.theme.green500
1515

1616
@Composable
1717
fun MultiStateAnimationCircleStrokeCanvas() {
18-
val transition = rememberInfiniteTransition()
19-
val animatedFloat by transition.animateFloat(
20-
initialValue = 0f,
21-
targetValue = 360f,
22-
animationSpec = infiniteRepeatable(tween(800), RepeatMode.Restart)
18+
val transition = rememberInfiniteTransition()
19+
val animatedFloat by
20+
transition.animateFloat(
21+
initialValue = 0f,
22+
targetValue = 360f,
23+
animationSpec = infiniteRepeatable(tween(800), RepeatMode.Restart)
2324
)
24-
val stroke = Stroke(8f)
25-
Canvas(
26-
modifier = Modifier
27-
.padding(16.dp)
28-
.size(100.dp)
29-
) {
30-
val diameter = size.minDimension
31-
val radius = diameter / 2f
32-
val insideRadius = radius - stroke.width
33-
val topLeftOffset = Offset(10f, 10f)
34-
val size = Size(insideRadius * 2, insideRadius * 2)
35-
var rotationAngle = animatedFloat - 50f
36-
drawArc(
37-
color = green500,
38-
startAngle = rotationAngle,
39-
sweepAngle = 150f,
40-
topLeft = topLeftOffset,
41-
size = size,
42-
useCenter = false,
43-
style = stroke,
44-
)
45-
rotationAngle += 40
46-
}
47-
}
25+
val stroke = Stroke(8f)
26+
Canvas(modifier = Modifier.padding(16.dp).size(100.dp)) {
27+
val diameter = size.minDimension
28+
val radius = diameter / 2f
29+
val insideRadius = radius - stroke.width
30+
val topLeftOffset = Offset(10f, 10f)
31+
val size = Size(insideRadius * 2, insideRadius * 2)
32+
var rotationAngle = animatedFloat - 50f
33+
drawArc(
34+
color = green500,
35+
startAngle = rotationAngle,
36+
sweepAngle = 150f,
37+
topLeft = topLeftOffset,
38+
size = size,
39+
useCenter = false,
40+
style = stroke,
41+
)
42+
rotationAngle += 40
43+
}
44+
}

animations/lottie/src/main/java/com/guru/composecookbook/lottie/LottieCryptoLoadingView.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import androidx.compose.ui.unit.dp
99

1010
@Composable
1111
fun LottieCryptoLoadingView(context: Context) {
12-
LottieLoadingView(
13-
context = context,
14-
file = "cryptoload.json",
15-
modifier = Modifier
16-
.fillMaxWidth()
17-
.height(150.dp)
18-
)
12+
LottieLoadingView(
13+
context = context,
14+
file = "cryptoload.json",
15+
modifier = Modifier.fillMaxWidth().height(150.dp)
16+
)
1917
}

animations/lottie/src/main/java/com/guru/composecookbook/lottie/LottieFoodView.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import androidx.compose.ui.unit.dp
99

1010
@Composable
1111
fun LottieFoodView(context: Context) {
12-
LottieLoadingView(
13-
context = context,
14-
file = "food.json",
15-
modifier = Modifier
16-
.fillMaxWidth()
17-
.height(200.dp)
18-
)
12+
LottieLoadingView(
13+
context = context,
14+
file = "food.json",
15+
modifier = Modifier.fillMaxWidth().height(200.dp)
16+
)
1917
}

animations/lottie/src/main/java/com/guru/composecookbook/lottie/LottieLoaderLoadingView.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import androidx.compose.ui.unit.dp
99

1010
@Composable
1111
fun LottieLoaderLoadingView(context: Context) {
12-
LottieLoadingView(
13-
context = context,
14-
file = "loader.json",
15-
modifier = Modifier
16-
.fillMaxWidth()
17-
.height(200.dp)
18-
)
12+
LottieLoadingView(
13+
context = context,
14+
file = "loader.json",
15+
modifier = Modifier.fillMaxWidth().height(200.dp)
16+
)
1917
}

animations/lottie/src/main/java/com/guru/composecookbook/lottie/LottieLoadingView.kt

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,28 @@ import com.airbnb.lottie.compose.LottieAnimation
1010
import com.airbnb.lottie.compose.LottieCompositionSpec
1111
import com.airbnb.lottie.compose.rememberLottieComposition
1212

13-
1413
@Composable
1514
fun LottieLoadingView(
16-
context: Context,
17-
file: String,
18-
modifier: Modifier = Modifier,
19-
iterations: Int = 10
15+
context: Context,
16+
file: String,
17+
modifier: Modifier = Modifier,
18+
iterations: Int = 10
2019
) {
21-
val composition by rememberLottieComposition(LottieCompositionSpec.Asset(file))
22-
LottieAnimation(
23-
composition,
24-
modifier = modifier.defaultMinSize(300.dp),
25-
iterations = iterations
26-
)
27-
28-
// OLD ANDROID VIEW IMPLEMENTATION
29-
// val lottieView = remember {
30-
// LottieAnimationView(context).apply {
31-
// setAnimation(file)
32-
// repeatCount = ValueAnimator.INFINITE
33-
// }
34-
// }
35-
// AndroidView(
36-
// { lottieView },
37-
// modifier = modifier
38-
// ) {
39-
// it.playAnimation()
40-
// }
20+
val composition by rememberLottieComposition(LottieCompositionSpec.Asset(file))
21+
LottieAnimation(composition, modifier = modifier.defaultMinSize(300.dp), iterations = iterations)
4122

23+
// OLD ANDROID VIEW IMPLEMENTATION
24+
// val lottieView = remember {
25+
// LottieAnimationView(context).apply {
26+
// setAnimation(file)
27+
// repeatCount = ValueAnimator.INFINITE
28+
// }
29+
// }
30+
// AndroidView(
31+
// { lottieView },
32+
// modifier = modifier
33+
// ) {
34+
// it.playAnimation()
35+
// }
4236

4337
}

animations/lottie/src/main/java/com/guru/composecookbook/lottie/LottieWorkingLoadingView.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import androidx.compose.ui.unit.dp
99

1010
@Composable
1111
fun LottieWorkingLoadingView(context: Context) {
12-
LottieLoadingView(
13-
context = context,
14-
file = "working.json",
15-
modifier = Modifier
16-
.fillMaxWidth()
17-
.height(250.dp)
18-
)
12+
LottieLoadingView(
13+
context = context,
14+
file = "working.json",
15+
modifier = Modifier.fillMaxWidth().height(250.dp)
16+
)
1917
}

0 commit comments

Comments
 (0)