MASSIVELY updated the settings view to actually exist
This commit is contained in:
parent
a42bf2b051
commit
937344a1e9
@ -38,12 +38,11 @@ struct MainView: View {
|
|||||||
|
|
||||||
}
|
}
|
||||||
.toolbar {
|
.toolbar {
|
||||||
// ToolbarItem(placement: .topBarLeading) {
|
ToolbarItem(placement: .topBarLeading) {
|
||||||
// Button(action: {showSettingsView.toggle()}) {
|
Button(action: {showSettingsView.toggle()}) {
|
||||||
// Image(systemName: "gear")
|
Image(systemName: "gear")
|
||||||
// }
|
}
|
||||||
//
|
}
|
||||||
// }
|
|
||||||
// ToolbarItem(placement: .topBarTrailing) {
|
// ToolbarItem(placement: .topBarTrailing) {
|
||||||
// Menu {
|
// Menu {
|
||||||
// Picker(selection: $filterColor) {
|
// Picker(selection: $filterColor) {
|
||||||
|
@ -11,14 +11,25 @@ struct SettingsView: View {
|
|||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
|
|
||||||
// @State private var teleprompterSeparator = "---"
|
// @State private var teleprompterSeparator = "---"
|
||||||
@AppStorage(Preferences.teleprompterSeparator) var teleprompterSeparator: String = "---"
|
|
||||||
|
@AppStorage(Preferences.watchConnectivity) var watchConnectivity = false
|
||||||
|
|
||||||
|
@AppStorage(Preferences.cueDefaultSize) var cueDefaultSize = 25.0
|
||||||
|
|
||||||
|
@AppStorage(Preferences.teleSeparator) var teleprompterSeparator: String = "---"
|
||||||
|
@AppStorage(Preferences.teleDefaultSize) var teleDefaultSize = 45.0
|
||||||
|
@AppStorage(Preferences.teleAutoScroll) var teleAutoScroll = false
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
List {
|
List {
|
||||||
Section {
|
cueCardSettings
|
||||||
TextField(text: $teleprompterSeparator) { Text("Teleprompter Cuecard Separator") }
|
teleprompterSettings
|
||||||
} header: { Text("Teleprompter View") }
|
appleWatchSettings
|
||||||
|
aboutApp
|
||||||
}
|
}
|
||||||
.navigationTitle("Settings")
|
.navigationTitle("Settings")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
@ -29,6 +40,35 @@ struct SettingsView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cueCardSettings: some View {
|
||||||
|
Section {
|
||||||
|
Stepper("Default Text Size: \(cueDefaultSize.formatted())", value: $cueDefaultSize, in: 1...100)
|
||||||
|
} header: { Text("Cue Cards") }
|
||||||
|
}
|
||||||
|
|
||||||
|
var teleprompterSettings: some View {
|
||||||
|
Section {
|
||||||
|
Stepper("Default Text Size: \(teleDefaultSize.formatted())", value: $teleDefaultSize, in: 1...100)
|
||||||
|
Toggle("AutoScroll", isOn: $teleAutoScroll)
|
||||||
|
} header: { Text("Teleprompter") }
|
||||||
|
}
|
||||||
|
|
||||||
|
var appleWatchSettings: some View {
|
||||||
|
Section {
|
||||||
|
Toggle("Enable Watch Connectivity", isOn: $watchConnectivity)
|
||||||
|
if watchConnectivity {
|
||||||
|
Button("Test Watch Connection") {}
|
||||||
|
}
|
||||||
|
|
||||||
|
} header: { Text("Watch") }
|
||||||
|
}
|
||||||
|
|
||||||
|
var aboutApp: some View {
|
||||||
|
Section {
|
||||||
|
LabeledContent("Version", value: "1.0b1")
|
||||||
|
} header: { Text("About") } footer: { Text("Made with love, by bread <3 🇳🇿") }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
|
@ -13,18 +13,19 @@ struct TeleprompterView: View {
|
|||||||
|
|
||||||
@State private var textSize = 45.0
|
@State private var textSize = 45.0
|
||||||
@State private var horizPadding = 15.0
|
@State private var horizPadding = 15.0
|
||||||
|
@State private var scrollSpeed = 0.5
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView {
|
// ScrollView {
|
||||||
Text(project.script)
|
|
||||||
.font(.system(size: textSize))
|
|
||||||
.padding(.horizontal, horizPadding)
|
|
||||||
}
|
|
||||||
// AutoScrollView {
|
|
||||||
// Text(project.script)
|
// Text(project.script)
|
||||||
// .font(.system(size: textSize))
|
// .font(.system(size: textSize))
|
||||||
// .padding(.horizontal, horizPadding)
|
// .padding(.horizontal, horizPadding)
|
||||||
// }
|
// }
|
||||||
|
AutoScrollView(scrollSpeed: scrollSpeed) {
|
||||||
|
Text(project.script)
|
||||||
|
.font(.system(size: textSize))
|
||||||
|
.padding(.horizontal, horizPadding)
|
||||||
|
}
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
Menu { overflowMenu } label: {
|
Menu { overflowMenu } label: {
|
||||||
@ -49,6 +50,9 @@ struct TeleprompterView: View {
|
|||||||
Menu { Stepper("\(horizPadding.formatted())", value: $horizPadding, in: 0...150, step: 5) } label: {
|
Menu { Stepper("\(horizPadding.formatted())", value: $horizPadding, in: 0...150, step: 5) } label: {
|
||||||
Label("Margin", systemImage: "rectangle.portrait.arrowtriangle.2.inward")
|
Label("Margin", systemImage: "rectangle.portrait.arrowtriangle.2.inward")
|
||||||
}
|
}
|
||||||
|
Menu { Stepper("\(scrollSpeed.formatted())", value: $scrollSpeed, in: 0.0...4.0, step: 0.1) } label: {
|
||||||
|
Label("Scroll Speed", systemImage: "arrow.up.and.down.text.horizontal")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,26 +44,24 @@ struct AutoScrollView<Content: View>: View {
|
|||||||
@State private var timer: Timer? = nil
|
@State private var timer: Timer? = nil
|
||||||
|
|
||||||
let content: Content
|
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.content = content()
|
||||||
self.scrollSpeed = scrollSpeed
|
self.scrollSpeed = scrollSpeed
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
ScrollViewReader { proxy in
|
||||||
ScrollView {
|
ScrollView {
|
||||||
VStack {
|
|
||||||
content
|
content
|
||||||
.padding()
|
.id(0) // Assign an ID to the content
|
||||||
.background(GeometryReader { geo in
|
.background(GeometryReader { geo in
|
||||||
Color.clear.onAppear {
|
Color.clear.onAppear {
|
||||||
// Calculate the height of the content
|
|
||||||
let contentHeight = geo.size.height
|
let contentHeight = geo.size.height
|
||||||
startTimer(contentHeight: contentHeight)
|
startTimer(proxy: proxy, contentHeight: contentHeight)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.offset(y: -scrollOffset)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
@ -71,17 +69,18 @@ struct AutoScrollView<Content: View>: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func startTimer(contentHeight: CGFloat) {
|
private func startTimer(proxy: ScrollViewProxy, contentHeight: CGFloat) {
|
||||||
timer?.invalidate() // Invalidate any existing timer
|
timer?.invalidate() // Invalidate any existing timer
|
||||||
timer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) { _ in
|
timer = Timer.scheduledTimer(withTimeInterval: 0.01, repeats: true) { _ in
|
||||||
// Update the scroll offset
|
|
||||||
withAnimation {
|
withAnimation {
|
||||||
scrollOffset += scrollSpeed
|
scrollOffset += scrollSpeed
|
||||||
|
proxy.scrollTo(0, anchor: .bottom)
|
||||||
|
proxy.scrollTo(scrollOffset, anchor: .bottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset scroll offset when it reaches the end
|
// Reset scroll offset when it reaches the end
|
||||||
if scrollOffset >= contentHeight {
|
if scrollOffset >= contentHeight {
|
||||||
scrollOffset = 0
|
stopTimer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,11 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public struct Preferences {
|
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"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user