Skip to content

Commit d6c52cd

Browse files
authored
Update EditorView.swift
1 parent 460ee83 commit d6c52cd

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

lara/views/EditorView.swift

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,42 @@ import SwiftUI
22
import QuickLook
33

44
struct EditorView: View {
5-
// Assuming laramgr exists elsewhere in your project
6-
//@ObservedObject private var mgr = laramgr.shared
7-
8-
private let path = "/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist"
9-
private let modurl: URL
10-
5+
@State private var modurl: URL
116
@State private var mgXML: String = ""
127
@State private var status: String?
138
@State private var previewURL: URL?
9+
@State private var fileURL: String = "/var/containers/Shared/SystemGroup/systemgroup.com.apple.mobilegestaltcache/Library/Caches/com.apple.MobileGestalt.plist"
1410

1511
init() {
1612
let docs = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
17-
// Use 'self.modurl' to distinguish from the property name
18-
self.modurl = docs.appendingPathComponent("MobileGestalt.plist")
13+
_modurl = State(initialValue: docs.appendingPathComponent("MobileGestalt.plist"))
1914
}
2015

2116
var body: some View {
2217
NavigationStack {
2318
List {
19+
Section {
20+
TextField("File URL", text: $fileURL)
21+
Button("Load and Copy") {
22+
let docs = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
23+
let lastComponent = URL(fileURLWithPath: fileURL).lastPathComponent
24+
self.modurl = docs.appendingPathComponent(lastComponent)
25+
load()
26+
}
27+
}
2428
Section {
2529
ScrollView {
2630
Text(mgXML)
2731
.font(.system(size: 13, design: .monospaced))
2832
.lineSpacing(1)
29-
.frame(height: 250)
33+
.frame(minHeight: 250)
3034
}
3135

3236
Button("View") {
3337
previewURL = modurl
3438
}
3539
} header: {
36-
Text("com.apple.MobileGestalt.plist")
40+
Text("File Preview")
3741
}
3842
}
3943
.navigationTitle("MobileGestalt")
@@ -52,7 +56,9 @@ struct EditorView: View {
5256

5357
private func load() {
5458
let fm = FileManager.default
55-
let sysURL = URL(fileURLWithPath: path)
59+
let sysURL = URL(fileURLWithPath: fileURL)
60+
61+
mgXML = ""
5662

5763
if !fm.fileExists(atPath: modurl.path) {
5864
do {

0 commit comments

Comments
 (0)