- Fixes and improvements for iOS app · KodaKoder/fsnotes@ad6a857 · GitHub
Skip to content

Commit ad6a857

Browse files
committed
- Fixes and improvements for iOS app
1 parent 57616ef commit ad6a857

6 files changed

Lines changed: 36 additions & 11 deletions

File tree

FSNotes iOS/EditorViewController.swift

Lines changed: 4 additions & 2 deletions

FSNotes iOS/View/EditTextView.swift

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,24 @@ class EditTextView: UITextView, UITextViewDelegate {
4545
}
4646

4747
override func caretRect(for position: UITextPosition) -> CGRect {
48-
var superRect = super.caretRect(for: position)
49-
guard let font = self.font else { return superRect }
48+
var caretRect = super.caretRect(for: position)
49+
let characterIndex = offset(from: beginningOfDocument, to: position)
5050

51-
// "descender" is expressed as a negative value,
52-
// so to add its height you must subtract its value
53-
superRect.size.height = font.pointSize - font.descender
54-
return superRect
51+
guard layoutManager.isValidGlyphIndex(characterIndex) else {
52+
return caretRect
53+
}
54+
55+
let glyphIndex = layoutManager.glyphIndexForCharacter(at: characterIndex)
56+
let usedLineFragment = layoutManager.lineFragmentUsedRect(forGlyphAt: glyphIndex, effectiveRange: nil)
57+
58+
guard !usedLineFragment.isEmpty else {
59+
return caretRect
60+
}
61+
62+
caretRect.origin.y = usedLineFragment.origin.y + textContainerInset.top
63+
caretRect.size.height = usedLineFragment.size.height - CGFloat(UserDefaultsManagement.editorLineSpacing) / 2
64+
65+
return caretRect
5566
}
5667

5768
override func scrollRectToVisible(_ rect: CGRect, animated: Bool) {

FSNotes iOS/ViewController+More.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,14 @@ extension ViewController: UIDocumentPickerDelegate {
318318
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action: UIAlertAction!) in
319319
}))
320320

321-
self.dismiss(animated: true, completion: nil)
322-
mvc.present(alert, animated: true, completion: nil)
321+
if selectedProject.isExternal {
322+
let bookmark = SandboxBookmark.sharedInstance()
323+
bookmark.remove(url: selectedProject.url)
324+
325+
mvc.sidebarTableView.removeRows(projects: [selectedProject])
326+
} else {
327+
mvc.present(alert, animated: true, completion: nil)
328+
}
323329
}
324330

325331
private func renameFolder() {

FSNotes iOS/ViewController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,9 @@ class ViewController: UIViewController, UISearchBarDelegate, UIGestureRecognizer
941941

942942
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
943943
let evc = UIApplication.getEVC()
944+
if UserDefaultsManagement.previewMode {
945+
evc.togglePreview()
946+
}
944947
evc.editArea.becomeFirstResponder()
945948
}
946949
}

FSNotes iOS/ru.lproj/Localizable.strings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
"Rename folder" = "Переименовать папку";
201201

202202
/* Popover table */
203-
"Rename folder:" = "Удалить папку:";
203+
"Rename folder:" = "Переименовать папку:";
204204

205205
/* No comment provided by engineer. */
206206
"Rename note:" = "Переименовать заметку:";

FSNotesCore/Core macOS/Extensions/UserDefaultsManagement+.swift

Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)