Start working on an autoscroll view and did some icloud stuff
This commit is contained in:
53
Shared/AutoScrollView.swift
Normal file
53
Shared/AutoScrollView.swift
Normal file
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// AutoScrollView.swift
|
||||
// OnCue
|
||||
//
|
||||
// Created by Pradyun Setti on 23/06/2024.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
let config = ModelConfiguration(isStoredInMemoryOnly: true)
|
||||
let container = try! ModelContainer(for: OCProject.self, configurations: config)
|
||||
|
||||
container.mainContext.insert(PreviewData.project)
|
||||
|
||||
return AutoScrollView {
|
||||
Text(PreviewData.project.script)
|
||||
.font(.system(size: 45))
|
||||
.padding(.horizontal)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user