@@ -33,21 +33,25 @@ fun StoryboardNotes(storyboard: StoryboardState, notes: StoryboardNotes, modifie
3333 }
3434
3535 Row (modifier = Modifier .fillMaxWidth().padding(top = 16 .dp)) {
36- val currentIndex = storyboard.currentIndex
3736 Column (modifier = Modifier .weight(1f ), horizontalAlignment = Alignment .CenterHorizontally ) {
3837 Text (" Current Frame" )
39- ClickableScenePreview (storyboard, currentIndex)
38+ ClickableScenePreview (storyboard, storyboard. currentIndex)
4039 SceneAnimationProgressIndicator (storyboard)
4140 }
4241 Spacer (Modifier .width(16 .dp))
4342 Column (modifier = Modifier .weight(1f ), horizontalAlignment = Alignment .CenterHorizontally ) {
4443 Text (" Next Frame" )
45- val targetIndex = storyboard.targetIndex
46- if (targetIndex != currentIndex) {
47- ClickableScenePreview (storyboard, targetIndex)
48-
44+ val nextIndex by derivedStateOf {
45+ val i = storyboard.storyboard.indices.binarySearch(storyboard.currentIndex)
46+ require(i >= 0 ) { " targetIndex not found in storyboard" }
47+ storyboard.storyboard.indices.getOrNull(i + 1 )
48+ }
49+ nextIndex?.let {
50+ ClickableScenePreview (storyboard, it)
4951 }
5052 }
53+ // TODO previous frame?
54+ // TODO highlight frame which is being advanced to?
5155 }
5256
5357 if (notes.tabs.isNotEmpty()) {
@@ -111,11 +115,22 @@ private fun ClickableScenePreview(
111115@Composable
112116private fun SceneAnimationProgressIndicator (storyboard : StoryboardState ) {
113117 Row {
118+ val advancementDistance = storyboard.advancementDistance
114119 val advancementProgress = storyboard.advancementProgress
115- val color = if (advancementProgress == 1f ) Color .Green else Color .Red
116- Spacer (Modifier .height(2 .dp).weight(advancementProgress).background(color))
117- if (advancementProgress < 1f ) {
118- Spacer (Modifier .weight(1f - advancementProgress))
120+ when {
121+ advancementProgress == advancementDistance -> {
122+ Spacer (Modifier .height(2 .dp).weight(1f ).background(Color .Green ))
123+ }
124+
125+ else -> {
126+ val complete = advancementProgress.toInt() / advancementDistance
127+ val partial = (advancementProgress % 1f ) / advancementDistance
128+ val remaining = 1f - complete - partial
129+
130+ if (complete > 0f ) Spacer (Modifier .height(2 .dp).weight(complete).background(Color .Green ))
131+ if (partial > 0f ) Spacer (Modifier .height(2 .dp).weight(partial).background(Color .Red ))
132+ if (remaining > 0f ) Spacer (Modifier .height(2 .dp).weight(remaining).background(Color .DarkGray ))
133+ }
119134 }
120135 }
121136}
0 commit comments