Did some autoscroll stuff but will probably shelve that for now..?
This commit is contained in:
parent
9cf6674de8
commit
a42bf2b051
@ -1,16 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict/>
|
||||||
<key>aps-environment</key>
|
|
||||||
<string>development</string>
|
|
||||||
<key>com.apple.developer.icloud-container-identifiers</key>
|
|
||||||
<array>
|
|
||||||
<string>iCloud.xyz.breadone.oncue</string>
|
|
||||||
</array>
|
|
||||||
<key>com.apple.developer.icloud-services</key>
|
|
||||||
<array>
|
|
||||||
<string>CloudKit</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
</plist>
|
||||||
|
@ -20,6 +20,11 @@ struct TeleprompterView: View {
|
|||||||
.font(.system(size: textSize))
|
.font(.system(size: textSize))
|
||||||
.padding(.horizontal, horizPadding)
|
.padding(.horizontal, horizPadding)
|
||||||
}
|
}
|
||||||
|
// AutoScrollView {
|
||||||
|
// Text(project.script)
|
||||||
|
// .font(.system(size: textSize))
|
||||||
|
// .padding(.horizontal, horizPadding)
|
||||||
|
// }
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
Menu { overflowMenu } label: {
|
Menu { overflowMenu } label: {
|
||||||
|
@ -8,34 +8,87 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import SwiftData
|
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
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
struct AutoScrollView<Content: View>: View {
|
struct AutoScrollView<Content: View>: View {
|
||||||
|
@State private var scrollOffset: CGFloat = 0
|
||||||
|
@State private var timer: Timer? = nil
|
||||||
|
|
||||||
let content: Content
|
let content: Content
|
||||||
var scrollSpeed: Double = 15.0
|
var scrollSpeed: CGFloat = 0.5 // Adjust this value to control the scroll speed
|
||||||
|
|
||||||
@State private var offset: Double = 0.0
|
init(scrollSpeed: Double = 0.7, @ViewBuilder _ content: () -> Content) {
|
||||||
|
|
||||||
init(scrollSpeed: Double = 0, @ViewBuilder _ content: () -> Content) {
|
|
||||||
self.content = content()
|
self.content = content()
|
||||||
self.scrollSpeed = scrollSpeed
|
self.scrollSpeed = scrollSpeed
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
|
VStack {
|
||||||
content
|
content
|
||||||
.offset(y: offset)
|
.padding()
|
||||||
|
.background(GeometryReader { geo in
|
||||||
|
Color.clear.onAppear {
|
||||||
|
// Calculate the height of the content
|
||||||
|
let contentHeight = geo.size.height
|
||||||
|
startTimer(contentHeight: contentHeight)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.offset(y: -scrollOffset)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onDisappear {
|
||||||
|
stopTimer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func startScrolling() {
|
private func startTimer(contentHeight: CGFloat) {
|
||||||
|
timer?.invalidate() // Invalidate any existing timer
|
||||||
|
timer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) { _ in
|
||||||
|
// Update the scroll offset
|
||||||
|
withAnimation {
|
||||||
|
scrollOffset += scrollSpeed
|
||||||
}
|
}
|
||||||
|
|
||||||
func stopScrolling() {
|
// Reset scroll offset when it reaches the end
|
||||||
|
if scrollOffset >= contentHeight {
|
||||||
|
scrollOffset = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mutating func setScrollSpeed(_ speed: Double) {
|
private func stopTimer() {
|
||||||
self.scrollSpeed = speed
|
timer?.invalidate()
|
||||||
|
timer = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user