Note格式化后按钮变为复制并打开备忘录
This commit is contained in:
@@ -17,6 +17,7 @@ class FormatNoteViewController: UIViewController {
|
|||||||
private var resetButton: UIBarButtonItem!
|
private var resetButton: UIBarButtonItem!
|
||||||
private var rightBarButtonMode: RightBarButtonMode = .paste
|
private var rightBarButtonMode: RightBarButtonMode = .paste
|
||||||
private var isCloudFormatted = false
|
private var isCloudFormatted = false
|
||||||
|
private var isNoteFormatted = false
|
||||||
|
|
||||||
private enum RightBarButtonMode {
|
private enum RightBarButtonMode {
|
||||||
case paste
|
case paste
|
||||||
@@ -120,7 +121,9 @@ class FormatNoteViewController: UIViewController {
|
|||||||
textView.text = ""
|
textView.text = ""
|
||||||
rightBarButtonMode = .paste
|
rightBarButtonMode = .paste
|
||||||
isCloudFormatted = false
|
isCloudFormatted = false
|
||||||
|
isNoteFormatted = false
|
||||||
iCloudButton.setTitle("iCloud 格式化", for: .normal)
|
iCloudButton.setTitle("iCloud 格式化", for: .normal)
|
||||||
|
noteButton.setTitle("Note 格式化", for: .normal)
|
||||||
updateRightBarButtonItem()
|
updateRightBarButtonItem()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,9 +161,22 @@ class FormatNoteViewController: UIViewController {
|
|||||||
showEmptyAlert()
|
showEmptyAlert()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
textView.text = formatForNote(textView.text)
|
if isNoteFormatted {
|
||||||
rightBarButtonMode = .reset
|
copyAndOpenNotes()
|
||||||
updateRightBarButtonItem()
|
} else {
|
||||||
|
textView.text = formatForNote(textView.text)
|
||||||
|
isNoteFormatted = true
|
||||||
|
noteButton.setTitle("复制并打开备忘录", for: .normal)
|
||||||
|
rightBarButtonMode = .reset
|
||||||
|
updateRightBarButtonItem()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func copyAndOpenNotes() {
|
||||||
|
UIPasteboard.general.string = textView.text
|
||||||
|
guard let url = URL(string: "mobilenotes://") else { return }
|
||||||
|
guard UIApplication.shared.canOpenURL(url) else { return }
|
||||||
|
UIApplication.shared.open(url, options: [:], completionHandler: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func formatForCloud(_ text: String) -> String {
|
private func formatForCloud(_ text: String) -> String {
|
||||||
|
|||||||
Reference in New Issue
Block a user