@@ -3,7 +3,7 @@ import SwiftUI
33struct PrompterView : View {
44 @ObservedObject var viewModel : PrompterViewModel
55
6- // Measure content height to loop or stop appropriately
6+ // Measure content height to stop appropriately
77 @State private var contentHeight : CGFloat = 0
88
99 // Tracks whether we paused due to hover and what the previous play state was
@@ -212,6 +212,18 @@ struct PrompterContentView: View {
212212 }
213213 }
214214
215+ // Progress bar on the right side
216+ if viewModel. showProgressBar {
217+ HStack {
218+ Spacer ( )
219+ ProgressBarView (
220+ currentOffset: viewModel. offset,
221+ totalHeight: contentHeight,
222+ theme: viewModel. prompterTheme
223+ )
224+ }
225+ }
226+
215227 // Hover controls overlay
216228 if showControls && viewModel. showHoverControls {
217229 VStack {
@@ -368,6 +380,7 @@ struct PrompterContentView: View {
368380 }
369381}
370382
383+ // MARK: - Height reader
371384private struct HeightReader : View {
372385 @Binding var height : CGFloat
373386 var body : some View {
@@ -380,3 +393,35 @@ private struct HeightReader: View {
380393 }
381394 }
382395}
396+
397+
398+ // MARK: - Progress bar
399+ struct ProgressBarView : View {
400+ let currentOffset : CGFloat
401+ let totalHeight : CGFloat
402+ let theme : PrompterTheme
403+
404+ private var progress : Double {
405+ guard totalHeight > 0 else { return 0 }
406+ return min ( max ( Double ( currentOffset / totalHeight) , 0 ) , 1.0 )
407+ }
408+
409+ var body : some View {
410+ GeometryReader { geo in
411+ ZStack ( alignment: . top) {
412+ RoundedRectangle ( cornerRadius: 2 )
413+ . fill ( theme. textColor. opacity ( 0.15 ) )
414+ . frame ( width: 4 )
415+ RoundedRectangle ( cornerRadius: 2 ) // Progres
416+ . fill ( theme. textColor. opacity ( 0.6 ) )
417+ . frame ( width: 4 , height: geo. size. height * progress)
418+ }
419+ . frame ( maxHeight: . infinity)
420+ }
421+ . frame ( width: 4 )
422+ . padding ( . trailing, 8 )
423+ . padding ( . vertical, 8 )
424+ . allowsHitTesting ( false )
425+ }
426+ }
427+
0 commit comments