Skip to content
Snippets Groups Projects
Commit 9c20d22b authored by Dennis Abrikossov's avatar Dennis Abrikossov
Browse files

Merge branch '10-feature-larare-visa-instruktion' into 'Development'

Resolve "FEATURE:Lärare-visa-instruktion"

Closes #10

See merge request !15
parents 0bae2179 084aaeb4
No related branches found
No related tags found
4 merge requests!18Merging dev into main,!17Merge Dev into main,!16Sprint 1 done, mergin to main,!15Resolve "FEATURE:Lärare-visa-instruktion"
...@@ -58,6 +58,7 @@ import androidx.compose.animation.core.FastOutSlowInEasing ...@@ -58,6 +58,7 @@ import androidx.compose.animation.core.FastOutSlowInEasing
import androidx.compose.animation.core.tween import androidx.compose.animation.core.tween
import androidx.compose.animation.core.LinearEasing import androidx.compose.animation.core.LinearEasing
import androidx.compose.animation.animateColorAsState import androidx.compose.animation.animateColorAsState
import androidx.compose.runtime.mutableDoubleStateOf
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
...@@ -717,8 +718,6 @@ fun UserButtons( ...@@ -717,8 +718,6 @@ fun UserButtons(
{ {
loopCounter-- loopCounter--
curr = loopStartIndex curr = loopStartIndex
println("should jump back to " + curr ) println("should jump back to " + curr )
} }
else else
...@@ -815,11 +814,11 @@ private fun addActionToSequenceBar(action: BaseAction, actionsInSequenceBar: Mut ...@@ -815,11 +814,11 @@ private fun addActionToSequenceBar(action: BaseAction, actionsInSequenceBar: Mut
if (action.name == "LOOP") { if (action.name == "LOOP") {
// For LOOP, add LOOP START and LOOP END together // For LOOP, add LOOP START and LOOP END together
// TODO: LOOP setting action settings are defind in two seperet areas HERE and in ActionsData.kt // TODO: LOOP setting action settings are defind in two seperet areas HERE and in ActionsData.kt
val loopStart = SpecialAction(id = 2, name = "LOOP START", isActive = mutableStateOf(true), isReorderable = true, data = mutableStateOf("1"), icon = mutableStateOf(Icons.Outlined.Repeat), cardColor = mutableStateOf(specialActionColor), duration = 0f) val loopStart = SpecialAction(id = 2, name = "LOOP START", isActive = mutableStateOf(true), isReorderable = true, data = mutableStateOf("1"), icon = mutableStateOf(Icons.Outlined.Repeat), cardColor = mutableStateOf(specialActionColor), duration = 0f, actionScale = mutableDoubleStateOf(1.0))
val loopEnd = SpecialAction(id = 2, name = "LOOP END", isActive = mutableStateOf(true), isReorderable = true, data = mutableStateOf(""), icon = mutableStateOf(Icons.Outlined.Repeat), cardColor = mutableStateOf(specialActionColor), duration = 0f) val loopEnd = SpecialAction(id = 2, name = "LOOP END", isActive = mutableStateOf(true), isReorderable = true, data = mutableStateOf(""), icon = mutableStateOf(Icons.Outlined.Repeat), cardColor = mutableStateOf(specialActionColor), duration = 0f, actionScale = mutableDoubleStateOf(1.0))
val copiedLoopStart = loopStart.copy(data = mutableStateOf(loopStart.data.value), icon = mutableStateOf(loopStart.icon.value)) val copiedLoopStart = loopStart.clone()
val copiedLoopEnd = loopEnd.copy(data = mutableStateOf(loopEnd.data.value), icon = mutableStateOf(loopEnd.icon.value)) val copiedLoopEnd = loopEnd.clone()
actionsInSequenceBar.add(copiedLoopStart) actionsInSequenceBar.add(copiedLoopStart)
actionsInSequenceBar.add(copiedLoopEnd) actionsInSequenceBar.add(copiedLoopEnd)
...@@ -828,12 +827,8 @@ private fun addActionToSequenceBar(action: BaseAction, actionsInSequenceBar: Mut ...@@ -828,12 +827,8 @@ private fun addActionToSequenceBar(action: BaseAction, actionsInSequenceBar: Mut
{ {
// For normal actions, create a copy with fresh mutable states so each action is independent // For normal actions, create a copy with fresh mutable states so each action is independent
val copiedAction = when (action) { val copiedAction = when (action) {
is MoveAction -> action.copy(data = mutableStateOf(action.data.value), remainingDuration = mutableFloatStateOf(action.remainingDuration.value)) is MoveAction -> action.clone()
is SpecialAction -> action.copy( is SpecialAction -> action.clone()
data = mutableStateOf(action.data.value),
cardColor = mutableStateOf(action.cardColor.value),
icon = mutableStateOf(action.icon.value)
)
else -> action else -> action
} }
...@@ -887,9 +882,12 @@ private suspend fun executeActionWithCountdown( ...@@ -887,9 +882,12 @@ private suspend fun executeActionWithCountdown(
) { ) {
// Reset duration at start of execution // Reset duration at start of execution
action.remainingDuration.value = action.duration action.remainingDuration.value = action.duration
action.width.value = 210.dp
action.height.value = 200.dp
action.actionScale.value = 1.6
// Start countdown in parallel with action execution // Start countdown in parallel with action execution
scope.launch { val thred = scope.launch {
while (action.remainingDuration.value > 0) { while (action.remainingDuration.value > 0) {
delay(100) // Update every 100ms delay(100) // Update every 100ms
action.remainingDuration.value = (action.remainingDuration.value - 0.1f) action.remainingDuration.value = (action.remainingDuration.value - 0.1f)
...@@ -904,5 +902,11 @@ private suspend fun executeActionWithCountdown( ...@@ -904,5 +902,11 @@ private suspend fun executeActionWithCountdown(
} }
// Wait for the full duration // Wait for the full duration
delay((action.duration * 1000).toLong()) //delay((action.duration * 1000).toLong())
thred.join()
//delay(1000)
action.width.value = 160.dp
action.height.value = 150.dp
action.actionScale.value = 1.0
} }
\ No newline at end of file
...@@ -5,9 +5,12 @@ import androidx.compose.runtime.mutableStateListOf ...@@ -5,9 +5,12 @@ import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.* import androidx.compose.material.icons.outlined.*
import androidx.compose.runtime.mutableDoubleStateOf
import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
/** /**
* Defines a set of colors used for action components. * Defines a set of colors used for action components.
...@@ -25,7 +28,7 @@ val inActiveColor = Color(0xff8A8A8A) // Color indicating an inactive state ...@@ -25,7 +28,7 @@ val inActiveColor = Color(0xff8A8A8A) // Color indicating an inactive state
* - `MoveAction` instances are active by default. * - `MoveAction` instances are active by default.
* - `SpecialAction` instances are inactive by default, except for the "Loop" action, which starts as active. * - `SpecialAction` instances are inactive by default, except for the "Loop" action, which starts as active.
*/ */
interface BaseAction { interface BaseAction: Cloneable {
val id: Int // A unique identifier for each action val id: Int // A unique identifier for each action
val name: String // The name of the action val name: String // The name of the action
var duration: Float // Expected duration of action var duration: Float // Expected duration of action
...@@ -34,10 +37,13 @@ interface BaseAction { ...@@ -34,10 +37,13 @@ interface BaseAction {
var isReorderable: Boolean // Determines if the action can be reordered var isReorderable: Boolean // Determines if the action can be reordered
var data: MutableState<String> // Stores data related to the action var data: MutableState<String> // Stores data related to the action
var icon: MutableState<ImageVector> // The icon displayed for the action var icon: MutableState<ImageVector> // The icon displayed for the action
var cardColor: MutableState<Color> // The color of the action's visual container var cardColor: MutableState<Color> // The color of the action's visual container
} var height: MutableState<Dp>
var width: MutableState<Dp>
var actionScale: MutableState<Double>
public override fun clone(): BaseAction
}
/** /**
* These data classes implement `BaseAction` and can define their own specific attributes. * These data classes implement `BaseAction` and can define their own specific attributes.
*/ */
...@@ -50,8 +56,29 @@ data class MoveAction( ...@@ -50,8 +56,29 @@ data class MoveAction(
override var remainingDuration: MutableState<Float> = mutableFloatStateOf(duration), override var remainingDuration: MutableState<Float> = mutableFloatStateOf(duration),
override var data: MutableState<String>, override var data: MutableState<String>,
override var icon: MutableState<ImageVector>, override var icon: MutableState<ImageVector>,
override var cardColor: MutableState<Color> = mutableStateOf(moveActionColor) // Default value, used unless explicitly overridden override var cardColor: MutableState<Color> = mutableStateOf(moveActionColor), // Default value, used unless explicitly overridden
) : BaseAction override var height: MutableState<Dp> = mutableStateOf(150.dp),
override var width: MutableState<Dp> = mutableStateOf(160.dp),
override var actionScale: MutableState<Double> = mutableDoubleStateOf(1.0)
) : BaseAction {
override fun clone(): MoveAction {
return MoveAction(
id = this.id,
name = this.name,
isActive = mutableStateOf(this.isActive.value),
isReorderable = this.isReorderable,
duration = this.duration,
remainingDuration = mutableFloatStateOf(this.remainingDuration.value),
data = mutableStateOf(this.data.value),
icon = mutableStateOf(this.icon.value),
cardColor = mutableStateOf(this.cardColor.value),
height = mutableStateOf(this.height.value),
width = mutableStateOf(this.width.value),
actionScale = mutableDoubleStateOf(this.actionScale.value)
)
}
}
data class SpecialAction( data class SpecialAction(
override val id: Int, override val id: Int,
...@@ -63,8 +90,30 @@ data class SpecialAction( ...@@ -63,8 +90,30 @@ data class SpecialAction(
override var data: MutableState<String>, override var data: MutableState<String>,
override var icon: MutableState<ImageVector>, override var icon: MutableState<ImageVector>,
override var cardColor: MutableState<Color> = mutableStateOf(specialActionColor), // Default value, used unless explicitly overridden override var cardColor: MutableState<Color> = mutableStateOf(specialActionColor), // Default value, used unless explicitly overridden
override var height: MutableState<Dp> = mutableStateOf(150.dp),
override var width: MutableState<Dp> = mutableStateOf(160.dp),
override var actionScale: MutableState<Double> = mutableDoubleStateOf(1.0),
val iconRotation: MutableState<Float> = mutableStateOf(0f) val iconRotation: MutableState<Float> = mutableStateOf(0f)
) : BaseAction ) : BaseAction {
override fun clone(): SpecialAction {
return SpecialAction(
id = this.id,
name = this.name,
duration = this.duration,
remainingDuration = mutableFloatStateOf(this.remainingDuration.value),
isActive = mutableStateOf(this.isActive.value),
isReorderable = this.isReorderable,
data = mutableStateOf(this.data.value),
icon = mutableStateOf(this.icon.value),
cardColor = mutableStateOf(this.cardColor.value),
height = mutableStateOf(this.height.value),
width = mutableStateOf(this.width.value),
actionScale = mutableDoubleStateOf(this.actionScale.value),
iconRotation = mutableStateOf(this.iconRotation.value)
)
}
}
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment