-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpasContentView.swift
56 lines (48 loc) · 1.9 KB
/
pasContentView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import SwiftUI
struct pasContentView: View {
@State private var mboxFilePath: String = ""
@State private var outputDirectory: String = "/Users/zzs/ExtractedFiles"
@State private var isExtracting: Bool = false
@State private var extractionCompleted: Bool = false
@State private var extractedFilesCount: Int = 0
var body: some View {
VStack {
Text("Select .mbox File and Extract Base64 Sections")
.font(.headline)
HStack {
TextField("Selected .mbox File", text: $mboxFilePath)
.disabled(true)
Button("Select File") {
let openPanel = NSOpenPanel()
openPanel.canChooseFiles = true
openPanel.canChooseDirectories = false
openPanel.allowsMultipleSelection = false
openPanel.allowedFileTypes = ["mbox"]
if openPanel.runModal() == .OK {
if let selectedFile = openPanel.url?.path {
mboxFilePath = selectedFile
}
}
}
}
Button("Extract XLSX Attachments") {
isExtracting = true
extractionCompleted = false
extractedFilesCount = 0
DispatchQueue.global(qos: .userInitiated).async {
let count = extractXLSXAttachmentsBasedOnXAttachmentId(fromMboxFile: mboxFilePath)
DispatchQueue.main.async {
extractedFilesCount = count
isExtracting = false
extractionCompleted = true
}
}
}
.disabled(mboxFilePath.isEmpty || isExtracting)
if extractionCompleted {
Text("Extraction Completed: \(extractedFilesCount) XLSX files extracted.")
}
}
.padding()
}
}