MASSIVELY updated the settings view to actually exist
This commit is contained in:
@@ -11,29 +11,29 @@ import SwiftData
|
||||
//struct AutoScrollView<Content: View>: View {
|
||||
// let content: Content
|
||||
// var scrollSpeed: Double = 15.0
|
||||
//
|
||||
//
|
||||
// @State private var offset: Double = 0.0
|
||||
//
|
||||
//
|
||||
// init(scrollSpeed: Double = 0, @ViewBuilder _ content: () -> Content) {
|
||||
// self.content = content()
|
||||
// self.scrollSpeed = scrollSpeed
|
||||
// }
|
||||
//
|
||||
//
|
||||
// var body: some View {
|
||||
// ScrollView {
|
||||
// content
|
||||
// .offset(y: offset)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// func startScrolling() {
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// func stopScrolling() {
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// mutating func setScrollSpeed(_ speed: Double) {
|
||||
// self.scrollSpeed = speed
|
||||
// }
|
||||
@@ -44,48 +44,47 @@ struct AutoScrollView<Content: View>: View {
|
||||
@State private var timer: Timer? = nil
|
||||
|
||||
let content: Content
|
||||
var scrollSpeed: CGFloat = 0.5 // Adjust this value to control the scroll speed
|
||||
var scrollSpeed: CGFloat // Adjust this value to control the scroll speed
|
||||
|
||||
init(scrollSpeed: Double = 0.7, @ViewBuilder _ content: () -> Content) {
|
||||
init(scrollSpeed: Double = 1.0, @ViewBuilder _ content: () -> Content) {
|
||||
self.content = content()
|
||||
self.scrollSpeed = scrollSpeed
|
||||
}
|
||||
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack {
|
||||
ScrollViewReader { proxy in
|
||||
ScrollView {
|
||||
content
|
||||
.padding()
|
||||
.id(0) // Assign an ID to the content
|
||||
.background(GeometryReader { geo in
|
||||
Color.clear.onAppear {
|
||||
// Calculate the height of the content
|
||||
let contentHeight = geo.size.height
|
||||
startTimer(contentHeight: contentHeight)
|
||||
startTimer(proxy: proxy, contentHeight: contentHeight)
|
||||
}
|
||||
})
|
||||
.offset(y: -scrollOffset)
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
stopTimer()
|
||||
}
|
||||
}
|
||||
|
||||
private func startTimer(contentHeight: CGFloat) {
|
||||
|
||||
private func startTimer(proxy: ScrollViewProxy, contentHeight: CGFloat) {
|
||||
timer?.invalidate() // Invalidate any existing timer
|
||||
timer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) { _ in
|
||||
// Update the scroll offset
|
||||
withAnimation {
|
||||
scrollOffset += scrollSpeed
|
||||
proxy.scrollTo(0, anchor: .bottom)
|
||||
proxy.scrollTo(scrollOffset, anchor: .bottom)
|
||||
}
|
||||
|
||||
|
||||
// Reset scroll offset when it reaches the end
|
||||
if scrollOffset >= contentHeight {
|
||||
scrollOffset = 0
|
||||
stopTimer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func stopTimer() {
|
||||
timer?.invalidate()
|
||||
timer = nil
|
||||
@@ -99,8 +98,8 @@ struct AutoScrollView<Content: View>: View {
|
||||
container.mainContext.insert(PreviewData.project)
|
||||
|
||||
return AutoScrollView {
|
||||
Text(PreviewData.project.script)
|
||||
.font(.system(size: 45))
|
||||
.padding(.horizontal)
|
||||
}
|
||||
Text(PreviewData.project.script)
|
||||
.font(.system(size: 45))
|
||||
.padding(.horizontal)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,5 +8,11 @@
|
||||
import Foundation
|
||||
|
||||
public struct Preferences {
|
||||
static let teleprompterSeparator = "teleprompterSeparator"
|
||||
static let teleSeparator = "teleSeparator"
|
||||
static let teleDefaultSize = "teleDefaultSize"
|
||||
static let teleAutoScroll = "teleAutoScroll"
|
||||
|
||||
static let watchConnectivity = "watchConnectivity"
|
||||
|
||||
static let cueDefaultSize = "cueDefaultSize"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user