aboutsummaryrefslogtreecommitdiff
path: root/iTexSnip
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2024-10-22 23:22:25 -0600
committerNavan Chauhan <navanchauhan@gmail.com>2024-10-22 23:22:25 -0600
commit6df95ba6282a4d0864a10cdee7f00f8cde061135 (patch)
tree4daad0ccd056e949c122c06ceb4c9e190d7ba38c /iTexSnip
parentd5a52a1f01e9b1af5e3ea1dfd7d45865c97c9ade (diff)
swift-format
Diffstat (limited to 'iTexSnip')
-rw-r--r--iTexSnip/Views/MenuBarView.swift74
-rw-r--r--iTexSnip/Views/PreferencesView.swift37
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)
+ }
}