Skip to content

Commit

Permalink
Merge pull request #30 from binayshaw7777/develop
Browse files Browse the repository at this point in the history
Develop -> Master
  • Loading branch information
binayshaw7777 authored Jan 8, 2025
2 parents 422bc0e + 2bab31b commit 73b6e7a
Show file tree
Hide file tree
Showing 10 changed files with 480 additions and 25 deletions.
66 changes: 55 additions & 11 deletions .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 91 additions & 5 deletions app/src/main/java/com/binayshaw7777/kotstep/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package com.binayshaw7777.kotstep

import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -23,6 +26,7 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.filled.PlayArrow
import androidx.compose.material.icons.outlined.KeyboardArrowRight
import androidx.compose.material3.Button
import androidx.compose.material3.DropdownMenu
Expand Down Expand Up @@ -52,6 +56,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
Expand All @@ -61,6 +66,7 @@ import com.binayshaw7777.kotstep.model.LineType
import com.binayshaw7777.kotstep.model.StepDefaults
import com.binayshaw7777.kotstep.model.StepStyle
import com.binayshaw7777.kotstep.model.dashed
import com.binayshaw7777.kotstep.model.fleet
import com.binayshaw7777.kotstep.model.iconHorizontal
import com.binayshaw7777.kotstep.model.iconVertical
import com.binayshaw7777.kotstep.model.iconVerticalWithLabel
Expand Down Expand Up @@ -104,16 +110,19 @@ fun MainPreview() {

var totalSteps by rememberSaveable { mutableIntStateOf(5) }
var currentStep by rememberSaveable { mutableFloatStateOf(-1f) }
var isPlaying by remember { mutableStateOf(true) }

var showCheckMark by remember { mutableStateOf(true) }
var showStepStroke by remember { mutableStateOf(true) }
var showDoneOnPartialCompletion by remember { mutableStateOf(true) }
var expanded by remember { mutableStateOf(false) }
var expandedShapeMenu by remember { mutableStateOf(false) }
var currentStepperType by remember { mutableStateOf(StepperOptions.HORIZONTAL_DASHED_STEPPER) }
var currentStepperType by remember { mutableStateOf(StepperOptions.HORIZONTAL_FLEET_STEPPER) }
var currentStepperItemShape by remember { mutableStateOf(StepperItemShape.CIRCLE_SHAPE) }
var stepItemSize by remember { mutableIntStateOf(35) }
var lineThickness by rememberSaveable { mutableIntStateOf(6) }
val icons = remember { mutableStateListOf<ImageVector>() }
val durations = remember { mutableStateListOf<Long>() }
val trailingLabels = remember { mutableStateListOf<(@Composable () -> Unit)?>() }
var lineSize by remember { mutableIntStateOf(20) }
var showLineStyleSheet by remember { mutableStateOf(false) }
Expand All @@ -140,10 +149,16 @@ fun MainPreview() {
LaunchedEffect(totalSteps) {
icons.clear()
icons.addAll(Utils.getIcons(totalSteps))
durations.clear()
durations.addAll(Utils.getDuration(totalSteps))
trailingLabels.clear()
trailingLabels.addAll(Utils.getLabels(totalSteps))
}

LaunchedEffect(isPlaying) {
Log.d("MainActivity", "Is Playing: $isPlaying")
}

LaunchedEffect(currentStep) {
println("Current Step: $currentStep")
}
Expand Down Expand Up @@ -191,7 +206,18 @@ fun MainPreview() {
Column(
Modifier
.padding(16.dp)
.verticalScroll(rememberScrollState())) {
// .pointerInput(Unit) {
// awaitEachGesture {
// awaitFirstDown()
// isPlaying = false
// do {
// val event = awaitPointerEvent()
// } while (event.changes.any { it.pressed })
// isPlaying = true
// }
// }
.verticalScroll(rememberScrollState())
) {
Text(
text = "Line Size in DP: $lineSize",
modifier = Modifier.padding(vertical = 4.dp)
Expand Down Expand Up @@ -401,6 +427,19 @@ fun MainPreview() {
)
}
)
DropdownMenuItem(
text = { Text("Horizontal Fleet Stepper") },
onClick = {
currentStepperType = StepperOptions.HORIZONTAL_FLEET_STEPPER
expanded = false
},
leadingIcon = {
Icon(
Icons.Outlined.KeyboardArrowRight,
contentDescription = null
)
}
)
DropdownMenuItem(
text = { Text("Horizontal NUMBERED Stepper") },
onClick = {
Expand Down Expand Up @@ -609,6 +648,25 @@ fun MainPreview() {
) { it.toast(context) }
}

StepperOptions.HORIZONTAL_FLEET_STEPPER -> {
HorizontalStepper(
style = fleet(
totalSteps = totalSteps,
currentStep = currentStep,
stepStyle = stepStyle,
isPlaying = isPlaying,
duration = Utils.getDuration(totalSteps),
onStepComplete = {
if (currentStep < totalSteps) {
currentStep++
}
}
)
) {
it.toast(context)
}
}

StepperOptions.HORIZONTAL_NUMBERED_STEPPER -> {
HorizontalStepper(
style = numberedHorizontal(
Expand Down Expand Up @@ -775,13 +833,16 @@ fun MainPreview() {
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceAround) {

AnimatedVisibility(
visible = currentStep >= -0.75f,
visible = if (currentStepperType == StepperOptions.HORIZONTAL_FLEET_STEPPER) currentStep >= 1 else currentStep >= -0.75f,
enter = fadeIn(),
exit = fadeOut()
) {
Button(
onClick = {
currentStep -= 0.25f
currentStep -= if (currentStepperType == StepperOptions.HORIZONTAL_FLEET_STEPPER)
1f
else
0.25f
}
) {
Text(text = "Previous")
Expand All @@ -790,14 +851,39 @@ fun MainPreview() {

Spacer(Modifier.weight(1f))

IconButton(
onClick = {
isPlaying = isPlaying.not()
},
// modifier = Modifier
// .pointerInput(Unit) {
// awaitEachGesture {
// awaitFirstDown()
// isPlaying = false
//
// do {
// val event = awaitPointerEvent()
// } while (event.changes.any { it.pressed })
//
// isPlaying = true
// }
// }
) {
Icon(imageVector = Icons.Default.PlayArrow, contentDescription = null)
}

Spacer(Modifier.weight(1f))

AnimatedVisibility(
visible = currentStep < totalSteps.toFloat(),
enter = fadeIn(),
exit = fadeOut()
) {
Button(
onClick = {
if (currentStep == -1f) {
if (currentStepperType == StepperOptions.HORIZONTAL_FLEET_STEPPER) {
currentStep += 1f
} else if (currentStep == -1f) {
currentStep = 0f
} else {
currentStep += 0.25f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ enum class StepperOptions {
HORIZONTAL_TAB_STEPPER,
HORIZONTAL_ICON_STEPPER,
HORIZONTAL_DASHED_STEPPER,
HORIZONTAL_FLEET_STEPPER,
VERTICAL_ICON_STEPPER,
VERTICAL_TAB_STEPPER,
VERTICAL_NUMBERED_STEPPER,
VERTICAL_NUMBERED_LABEL_STEPPER,
VERTICAL_ICON_LABEL_STEPPER,
VERTICAL_TAB_LABEL_STEPPER
VERTICAL_TAB_LABEL_STEPPER,
}
15 changes: 15 additions & 0 deletions app/src/main/java/com/binayshaw7777/kotstep/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ object Utils {
).subList(0, limit)
}

fun getDuration(limit: Int) : List<Long> {
return listOf(
5_000L,
10_000L,
5_000,
25_000L,
12_000L,
26_000L,
15_000L,
11_000L,
26_000L,
18_000L
).subList(0, limit)
}

fun getLabels(limit: Int) = listOf<@Composable (() -> Unit)?>(
{ Text("Ordered") },
{
Expand Down
2 changes: 1 addition & 1 deletion kotstep/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ publishing {
register<MavenPublication>("release") {
groupId = "com.github.binayshaw7777"
artifactId = "KotStep"
version = "2.2.3"
version = "2.3.0"

afterEvaluate {
from(components["release"])
Expand Down
Loading

0 comments on commit 73b6e7a

Please sign in to comment.