|
|
@@ -140,10 +140,65 @@ struct MoreMenuView: View {
|
|
|
showAlert = true
|
|
|
return
|
|
|
}
|
|
|
- let avc = UIActivityViewController(activityItems: files, applicationActivities: nil)
|
|
|
+
|
|
|
+ let noticeView = ShareLogNoticeView(
|
|
|
+ onCancel: {
|
|
|
+ UIApplication.shared.topMost?.dismiss(animated: true)
|
|
|
+ },
|
|
|
+ onShare: { noticeText in
|
|
|
+ let presenter = UIApplication.shared.topMost
|
|
|
+ presenter?.dismiss(animated: true) {
|
|
|
+ presentLogShareSheet(noticeText: noticeText, logFiles: files)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ let host = UIHostingController(rootView: noticeView)
|
|
|
+ host.overrideUserInterfaceStyle = Storage.shared.appearanceMode.value.userInterfaceStyle
|
|
|
+ host.modalPresentationStyle = .formSheet
|
|
|
+ UIApplication.shared.topMost?.present(host, animated: true)
|
|
|
+ }
|
|
|
+
|
|
|
+ private func presentLogShareSheet(noticeText: String, logFiles: [URL]) {
|
|
|
+ var items: [Any] = logFiles
|
|
|
+ if let noticeURL = writeShareNoticeFile(text: noticeText) {
|
|
|
+ items.insert(noticeURL, at: 0)
|
|
|
+ }
|
|
|
+ let avc = UIActivityViewController(activityItems: items, applicationActivities: nil)
|
|
|
UIApplication.shared.topMost?.present(avc, animated: true)
|
|
|
}
|
|
|
|
|
|
+ private func writeShareNoticeFile(text: String) -> URL? {
|
|
|
+ let formatter = DateFormatter()
|
|
|
+ formatter.dateFormat = "yyyy-MM-dd_HHmm"
|
|
|
+ let timestamp = formatter.string(from: Date())
|
|
|
+
|
|
|
+ let version = AppVersionManager().version()
|
|
|
+ let branchAndSha = BuildDetails.default.branchAndSha
|
|
|
+
|
|
|
+ let body = text.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
|
|
+ ? "(no description provided)"
|
|
|
+ : text
|
|
|
+
|
|
|
+ let contents = """
|
|
|
+ LoopFollow Log Share Notice
|
|
|
+ Date: \(ISO8601DateFormatter().string(from: Date()))
|
|
|
+ App version: \(version) (\(branchAndSha))
|
|
|
+
|
|
|
+ User description:
|
|
|
+ \(body)
|
|
|
+ """
|
|
|
+
|
|
|
+ let url = FileManager.default.temporaryDirectory
|
|
|
+ .appendingPathComponent("ShareNotice_\(timestamp).txt")
|
|
|
+ do {
|
|
|
+ try contents.write(to: url, atomically: true, encoding: .utf8)
|
|
|
+ return url
|
|
|
+ } catch {
|
|
|
+ LogManager.shared.log(category: .general, message: "Failed to write share notice file: \(error)")
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private func fetchVersionInfo() async {
|
|
|
let mgr = AppVersionManager()
|
|
|
let (latest, newer, blacklisted) = await mgr.checkForNewVersionAsync()
|