diff options
-rw-r--r-- | iTexSnip/Views/MenuBarView.swift | 74 | ||||
-rw-r--r-- | iTexSnip/Views/PreferencesView.swift | 37 |
2 files changed, 56 insertions, 55 deletions
diff --git a/iTexSnip/Views/MenuBarView.swift b/iTexSnip/Views/MenuBarView.swift index 4face4d..ba27840 100644 --- a/iTexSnip/Views/MenuBarView.swift +++ b/iTexSnip/Views/MenuBarView.swift @@ -38,7 +38,7 @@ struct MenuBarView: View { @Environment(\.modelContext) var modelContext @State var model: TexTellerModel? @Query(sort: \ImageSnippet.dateModifed, order: .reverse) var snippets: [ImageSnippet] - @AppStorage("loadModelOnStart") var loadModelOnStart: Bool = true + @AppStorage("loadModelOnStart") var loadModelOnStart: Bool = true let columns = [ GridItem(.flexible(), spacing: 16), @@ -100,17 +100,17 @@ struct MenuBarView: View { Spacer() }.task { - if loadModelOnStart { - do { - if self.model == nil { - let mymodel = try await TexTellerModel.asyncInit() - self.model = mymodel - print("Loaded da model") - } - } catch { - print("Failed to load da model: \(error)") - } + if loadModelOnStart { + do { + if self.model == nil { + let mymodel = try await TexTellerModel.asyncInit() + self.model = mymodel + print("Loaded da model") + } + } catch { + print("Failed to load da model: \(error)") } + } } } } @@ -125,17 +125,17 @@ struct MenuBarView: View { if panel.runModal() == .OK { if let url = panel.url, let image = NSImage(contentsOf: url) { let newSnippet = ImageSnippet(image: image) - if self.loadModelOnStart == false { - do { - if self.model == nil { - let mymodel = try TexTellerModel() - self.model = mymodel - print("Loaded model on demand") - } - } catch { - print("Failed to load da model: \(error)") - } + if self.loadModelOnStart == false { + do { + if self.model == nil { + let mymodel = try TexTellerModel() + self.model = mymodel + print("Loaded model on demand") + } + } catch { + print("Failed to load da model: \(error)") } + } do { if self.model != nil { let latex = try self.model!.texIt(image) @@ -146,9 +146,9 @@ struct MenuBarView: View { } catch { print("Failed to save new snippet: \(error)") } - if self.loadModelOnStart == false { - self.model = nil - } + if self.loadModelOnStart == false { + self.model = nil + } } } } @@ -184,17 +184,17 @@ struct MenuBarView: View { if FileManager.default.fileExists(atPath: tempPath) { if let screenshotImage = NSImage(contentsOfFile: tempPath) { let newSnippet = ImageSnippet(image: screenshotImage) - if self.loadModelOnStart == false { - do { - if self.model == nil { - let mymodel = try TexTellerModel() - self.model = mymodel - print("Loaded model on demand") - } - } catch { - print("Failed to load da model: \(error)") - } + if self.loadModelOnStart == false { + do { + if self.model == nil { + let mymodel = try TexTellerModel() + self.model = mymodel + print("Loaded model on demand") + } + } catch { + print("Failed to load da model: \(error)") } + } do { if self.model != nil { let latex = try self.model!.texIt(screenshotImage) @@ -205,9 +205,9 @@ struct MenuBarView: View { } catch { print("Failed to add snippet: \(error)") } - if (self.loadModelOnStart == false) { - self.model = nil - } + if self.loadModelOnStart == false { + self.model = nil + } } else { print("Failed to get image...") } diff --git a/iTexSnip/Views/PreferencesView.swift b/iTexSnip/Views/PreferencesView.swift index 1f9d514..2e1cc38 100644 --- a/iTexSnip/Views/PreferencesView.swift +++ b/iTexSnip/Views/PreferencesView.swift @@ -8,23 +8,24 @@ import SwiftUI struct PreferencesView: View { - @AppStorage("apiEndpoint") var apiEndpoint: String = "https://snippetfeedback.itexsnip.navan.dev/rate_snippet" - @AppStorage("loadModelOnStart") var loadModelOnStart: Bool = true - @AppStorage("showOriginalImage") var showOriginalImage: Bool = false - - var body: some View { - Form { - Section(header: Text("API Settings")) { - TextField("Rating API Endpoint", text: $apiEndpoint) - .textFieldStyle(RoundedBorderTextFieldStyle()) - } - - Section(header: Text("Application Settings")) { - Toggle("Load model on app start", isOn: $loadModelOnStart) - Toggle("Show original image by default", isOn: $showOriginalImage) - } - } - .padding(20) - .frame(width: 400, height: 200) + @AppStorage("apiEndpoint") var apiEndpoint: String = + "https://snippetfeedback.itexsnip.navan.dev/rate_snippet" + @AppStorage("loadModelOnStart") var loadModelOnStart: Bool = true + @AppStorage("showOriginalImage") var showOriginalImage: Bool = false + + var body: some View { + Form { + Section(header: Text("API Settings")) { + TextField("Rating API Endpoint", text: $apiEndpoint) + .textFieldStyle(RoundedBorderTextFieldStyle()) + } + + Section(header: Text("Application Settings")) { + Toggle("Load model on app start", isOn: $loadModelOnStart) + Toggle("Show original image by default", isOn: $showOriginalImage) + } } + .padding(20) + .frame(width: 400, height: 200) + } } |