From 702fa8253667b53eb1b6733efdadc8507611af82 Mon Sep 17 00:00:00 2001 From: glushchenko Date: Sun, 14 Jul 2024 11:41:22 +0300 Subject: [PATCH] - Fixes and improvements --- FSNotes iOS/ViewController+More.swift | 16 ++ FSNotes iOS/ViewController.swift | 4 +- FSNotes.xcodeproj/project.pbxproj | 4 +- FSNotes/Base.lproj/Main.storyboard | 230 +++++++++--------- .../PreferencesWebViewController.swift | 9 +- FSNotes/ViewController.swift | 2 - .../Core macOS/Extensions/NSColor+.swift | 2 +- 7 files changed, 141 insertions(+), 126 deletions(-) diff --git a/FSNotes iOS/ViewController+More.swift b/FSNotes iOS/ViewController+More.swift index 71d556938..c9a33e2be 100644 --- a/FSNotes iOS/ViewController+More.swift +++ b/FSNotes iOS/ViewController+More.swift @@ -510,6 +510,8 @@ extension ViewController: UIDocumentPickerDelegate { items.append(UIBarButtonItem.flexibleSpace()) items.append(UIBarButtonItem(image: moveImage, style: .plain, target: self, action: #selector(moveNotes))) toolbarItems = items + + hideNewButton() } navigationController?.toolbar.tintColor = UIColor.mainTheme @@ -518,6 +520,14 @@ extension ViewController: UIDocumentPickerDelegate { } } + public func hideNewButton() { + getButton(tag: 1)?.isHidden = true + } + + public func showNewButton() { + getButton(tag: 1)?.isHidden = false + } + public func configureSidebarNavMenu() { if let sidebarItem = UIApplication.getVC().lastSidebarItem { configureNavMenu(for: sidebarItem) @@ -530,6 +540,7 @@ extension ViewController: UIDocumentPickerDelegate { notesTable.turnOffEditing() configureSidebarNavMenu() + showNewButton() navigationController?.setToolbarHidden(true, animated: true) } @@ -540,6 +551,7 @@ extension ViewController: UIDocumentPickerDelegate { notesTable.turnOffEditing() configureSidebarNavMenu() + showNewButton() navigationController?.setToolbarHidden(true, animated: true) } @@ -550,6 +562,7 @@ extension ViewController: UIDocumentPickerDelegate { notesTable.turnOffEditing() configureSidebarNavMenu() + showNewButton() navigationController?.setToolbarHidden(true, animated: true) } @@ -560,6 +573,7 @@ extension ViewController: UIDocumentPickerDelegate { notesTable.turnOffEditing() configureSidebarNavMenu() + showNewButton() navigationController?.setToolbarHidden(true, animated: true) } @@ -570,6 +584,8 @@ extension ViewController: UIDocumentPickerDelegate { configureSidebarNavMenu() navigationController?.setToolbarHidden(true, animated: true) + + showNewButton() } private func createFolder(selectedProject: Project?) { diff --git a/FSNotes iOS/ViewController.swift b/FSNotes iOS/ViewController.swift index c5139ad45..8637b7c56 100644 --- a/FSNotes iOS/ViewController.swift +++ b/FSNotes iOS/ViewController.swift @@ -452,9 +452,9 @@ class ViewController: UIViewController, UISearchBarDelegate, UIGestureRecognizer let projectsLoading = Date() let results = storage.getProjectDiffs() - storage.loadNotesCloudPins() OperationQueue.main.addOperation { + storage.loadNotesCloudPins() self.sidebarTableView.removeRows(projects: results.0) self.sidebarTableView.insertRows(projects: results.1) } @@ -1031,7 +1031,7 @@ class ViewController: UIViewController, UISearchBarDelegate, UIGestureRecognizer self.view.addSubview(button) } - private func getButton(tag: Int) -> UIButton? { + public func getButton(tag: Int) -> UIButton? { for sub in self.view.subviews { if sub.tag == tag { diff --git a/FSNotes.xcodeproj/project.pbxproj b/FSNotes.xcodeproj/project.pbxproj index eef9432ac..f061023ee 100644 --- a/FSNotes.xcodeproj/project.pbxproj +++ b/FSNotes.xcodeproj/project.pbxproj @@ -4557,7 +4557,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 632; + CURRENT_PROJECT_VERSION = 633; DEVELOPMENT_TEAM = 866P6MTE92; EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES; ENABLE_HARDENED_RUNTIME = YES; @@ -4597,7 +4597,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 632; + CURRENT_PROJECT_VERSION = 633; DEPLOYMENT_LOCATION = NO; DEVELOPMENT_TEAM = 866P6MTE92; EMBED_ASSET_PACKS_IN_PRODUCT_BUNDLE = YES; diff --git a/FSNotes/Base.lproj/Main.storyboard b/FSNotes/Base.lproj/Main.storyboard index c76a52bdb..98a8b84ef 100644 --- a/FSNotes/Base.lproj/Main.storyboard +++ b/FSNotes/Base.lproj/Main.storyboard @@ -188,13 +188,13 @@ CA - + - + @@ -962,7 +962,7 @@ CA - + @@ -1001,7 +1001,7 @@ CA - + @@ -1009,7 +1009,7 @@ CA - + @@ -1059,7 +1059,7 @@ CA - + @@ -1067,7 +1067,7 @@ CA - + @@ -1079,7 +1079,7 @@ CA - + @@ -1129,7 +1129,7 @@ CA - + @@ -1137,7 +1137,7 @@ CA - + @@ -1145,7 +1145,7 @@ CA - + @@ -1271,7 +1271,7 @@ CA - + @@ -1374,7 +1374,7 @@ CA - + @@ -1392,7 +1392,7 @@ CA - + @@ -1413,7 +1413,7 @@ CA - + @@ -1443,7 +1443,7 @@ CA - + @@ -1608,7 +1608,7 @@ CA - + @@ -1640,7 +1640,7 @@ CA - + @@ -1737,7 +1737,7 @@ CA - + @@ -1778,7 +1778,7 @@ CA - + @@ -1800,7 +1800,7 @@ CA - + @@ -1835,7 +1835,7 @@ CA - + @@ -1912,7 +1912,7 @@ CA - - + @@ -2186,7 +2186,7 @@ CA - + @@ -2257,7 +2257,7 @@ CA - + @@ -2332,7 +2332,7 @@ CA - + @@ -2343,7 +2343,7 @@ CA - + @@ -2351,7 +2351,7 @@ CA - + @@ -2359,7 +2359,7 @@ CA - + @@ -2377,7 +2377,7 @@ CA - + @@ -2398,7 +2398,7 @@ Gw - + @@ -2409,7 +2409,7 @@ Gw - + @@ -2420,7 +2420,7 @@ Gw - + @@ -2519,7 +2519,7 @@ Gw - + @@ -2530,7 +2530,7 @@ Gw - + @@ -2556,7 +2556,7 @@ All rights reserved. - + @@ -2569,7 +2569,7 @@ Olena Hlushcneko - + @@ -2577,7 +2577,7 @@ Olena Hlushcneko - + @@ -2588,7 +2588,7 @@ Olena Hlushcneko - + @@ -2596,7 +2596,7 @@ Olena Hlushcneko - + @@ -2604,7 +2604,7 @@ Olena Hlushcneko - + @@ -2615,7 +2615,7 @@ Olena Hlushcneko - + @@ -2655,7 +2655,7 @@ Olena Hlushcneko - + @@ -2691,7 +2691,7 @@ Olena Hlushcneko - + @@ -2805,7 +2805,7 @@ Olena Hlushcneko - + @@ -2813,7 +2813,7 @@ Olena Hlushcneko - + @@ -2827,7 +2827,7 @@ Olena Hlushcneko - + @@ -2835,7 +2835,7 @@ Olena Hlushcneko - + @@ -2926,7 +2926,7 @@ Olena Hlushcneko - + @@ -2934,7 +2934,7 @@ Olena Hlushcneko - + @@ -2969,7 +2969,7 @@ Olena Hlushcneko - + @@ -2980,7 +2980,7 @@ Olena Hlushcneko - + @@ -3014,7 +3014,7 @@ Olena Hlushcneko - + @@ -3022,7 +3022,7 @@ Olena Hlushcneko - + @@ -3030,7 +3030,7 @@ Olena Hlushcneko - + @@ -3157,7 +3157,7 @@ Olena Hlushcneko - + @@ -3175,7 +3175,7 @@ Olena Hlushcneko - + @@ -3183,7 +3183,7 @@ Olena Hlushcneko - + @@ -3197,7 +3197,7 @@ Olena Hlushcneko - + @@ -3249,7 +3249,7 @@ Olena Hlushcneko - + @@ -3257,7 +3257,7 @@ Olena Hlushcneko - + @@ -3274,7 +3274,7 @@ Olena Hlushcneko - + @@ -3282,7 +3282,7 @@ Olena Hlushcneko - + @@ -3310,7 +3310,7 @@ Olena Hlushcneko - + @@ -3327,7 +3327,7 @@ Olena Hlushcneko - + @@ -3335,7 +3335,7 @@ Olena Hlushcneko - + @@ -3343,7 +3343,7 @@ Olena Hlushcneko - + @@ -3410,7 +3410,7 @@ Olena Hlushcneko - + @@ -3429,7 +3429,7 @@ Olena Hlushcneko - + @@ -3443,7 +3443,7 @@ Olena Hlushcneko - + @@ -3454,7 +3454,7 @@ Olena Hlushcneko - + @@ -3589,7 +3589,7 @@ Olena Hlushcneko - + @@ -3611,7 +3611,7 @@ Olena Hlushcneko - + @@ -3660,7 +3660,7 @@ Olena Hlushcneko - + @@ -3668,7 +3668,7 @@ Olena Hlushcneko - + @@ -3723,7 +3723,7 @@ Olena Hlushcneko - + @@ -3759,7 +3759,7 @@ Olena Hlushcneko - + @@ -3767,7 +3767,7 @@ Olena Hlushcneko - + @@ -3775,7 +3775,7 @@ Olena Hlushcneko - + @@ -3793,7 +3793,7 @@ Olena Hlushcneko - + @@ -3844,7 +3844,7 @@ Olena Hlushcneko - + @@ -3862,7 +3862,7 @@ Olena Hlushcneko - + @@ -4040,7 +4040,7 @@ Olena Hlushcneko - + @@ -4141,7 +4141,7 @@ Olena Hlushcneko - + @@ -4184,7 +4184,7 @@ Olena Hlushcneko - + @@ -4232,7 +4232,7 @@ Olena Hlushcneko - + @@ -4240,7 +4240,7 @@ Olena Hlushcneko - + @@ -4284,7 +4284,7 @@ Olena Hlushcneko - + @@ -4292,7 +4292,7 @@ Olena Hlushcneko - + @@ -4306,7 +4306,7 @@ Olena Hlushcneko - + @@ -4335,7 +4335,7 @@ Olena Hlushcneko - + @@ -4488,7 +4488,7 @@ Olena Hlushcneko - + @@ -4506,7 +4506,7 @@ Olena Hlushcneko - + @@ -4527,7 +4527,7 @@ Olena Hlushcneko - + @@ -4592,7 +4592,7 @@ Olena Hlushcneko - + @@ -4600,7 +4600,7 @@ Olena Hlushcneko - + @@ -4608,7 +4608,7 @@ Olena Hlushcneko - + @@ -4619,7 +4619,7 @@ Olena Hlushcneko - + @@ -4633,7 +4633,7 @@ Olena Hlushcneko - + @@ -4661,7 +4661,7 @@ Olena Hlushcneko - + @@ -4669,7 +4669,7 @@ Olena Hlushcneko - + @@ -4680,7 +4680,7 @@ Olena Hlushcneko - + @@ -4688,7 +4688,7 @@ Olena Hlushcneko - + @@ -4699,7 +4699,7 @@ Olena Hlushcneko - + @@ -4710,7 +4710,7 @@ Olena Hlushcneko - + @@ -4718,7 +4718,7 @@ Olena Hlushcneko - + @@ -4726,7 +4726,7 @@ Olena Hlushcneko - + @@ -4743,7 +4743,7 @@ Olena Hlushcneko - + @@ -4754,7 +4754,7 @@ Olena Hlushcneko - + @@ -4768,7 +4768,7 @@ Olena Hlushcneko - + @@ -4796,7 +4796,7 @@ Olena Hlushcneko - + @@ -4817,7 +4817,7 @@ Olena Hlushcneko - + diff --git a/FSNotes/Preferences/PreferencesWebViewController.swift b/FSNotes/Preferences/PreferencesWebViewController.swift index a542b8a44..ad05ee2eb 100644 --- a/FSNotes/Preferences/PreferencesWebViewController.swift +++ b/FSNotes/Preferences/PreferencesWebViewController.swift @@ -23,8 +23,8 @@ class PreferencesWebViewController: NSViewController, NSTextFieldDelegate { passphrase.stringValue = UserDefaultsManagement.sftpPassphrase if let accessData = UserDefaultsManagement.sftpAccessData, - let bookmarks = NSKeyedUnarchiver.unarchiveObject(with: accessData) as? [URL: Data] { - + let bookmarks = try? NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSDictionary.self, NSURL.self, NSData.self], from: accessData) as? [URL: Data] { + for bookmark in bookmarks { rsaPath.url = bookmark.key break @@ -116,7 +116,7 @@ class PreferencesWebViewController: NSViewController, NSTextFieldDelegate { } } - let data = NSKeyedArchiver.archivedData(withRootObject: bookmarks) + let data = try? NSKeyedArchiver.archivedData(withRootObject: bookmarks, requiringSecureCoding: true) UserDefaultsManagement.sftpAccessData = data self.rsaPath.url = openPanel.urls[0] @@ -129,7 +129,8 @@ class PreferencesWebViewController: NSViewController, NSTextFieldDelegate { var privateKeyURL: URL? if let accessData = UserDefaultsManagement.sftpAccessData, - let bookmarks = NSKeyedUnarchiver.unarchiveObject(with: accessData) as? [URL: Data] { + let bookmarks = try? NSKeyedUnarchiver.unarchivedObject(ofClasses: [NSDictionary.self, NSURL.self, NSData.self], from: accessData) as? [URL: Data] { + for bookmark in bookmarks { if bookmark.key.path.hasSuffix(".pub") { publicKeyURL = bookmark.key diff --git a/FSNotes/ViewController.swift b/FSNotes/ViewController.swift index 4072d63ce..96e4cfc4e 100644 --- a/FSNotes/ViewController.swift +++ b/FSNotes/ViewController.swift @@ -1620,8 +1620,6 @@ class ViewController: EditorViewController, } let resorted = storage.sortNotes(noteList: notesTableView.noteList, filter: self.search.stringValue, project: projects?.first) - let indexes = updatedNotes.compactMap({ _, note in resorted.firstIndex(where: { $0 === note }) }) - let newIndexes = IndexSet(indexes) notesTableView.beginUpdates() let nowPinned = updatedNotes.filter { _, note in note.isPinned } diff --git a/FSNotesCore/Core macOS/Extensions/NSColor+.swift b/FSNotesCore/Core macOS/Extensions/NSColor+.swift index b51e96664..a207417df 100644 --- a/FSNotesCore/Core macOS/Extensions/NSColor+.swift +++ b/FSNotesCore/Core macOS/Extensions/NSColor+.swift @@ -51,7 +51,7 @@ public extension NSColor { } var hexString: String { - guard let rgbColor = usingColorSpaceName(NSColorSpaceName.calibratedRGB) else { + guard let rgbColor = usingColorSpace(.deviceRGB) else { return "#FFFFFF" } let red = Int(round(rgbColor.redComponent * 0xFF))