Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu 2.0 #1058

Merged
merged 42 commits into from Jun 6, 2019
Merged

Menu 2.0 #1058

Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
57860c2
MVP for iPhone
iccub Apr 2, 2019
d2a4044
Migrate urlbar items to stackview
iccub Apr 3, 2019
0e2a935
Better naming and file separation for toolbar objects
iccub Apr 3, 2019
799f2c7
WIP: menu actions
iccub Apr 6, 2019
1f25420
Long press actions: dismissal and refactor.
iccub Apr 8, 2019
2cb5750
Remove HomeViewController
iccub Apr 8, 2019
191f371
BookmarksVC cleanup: remove unused code
iccub Apr 8, 2019
7926cfe
folder hirerarchy alpha version
iccub Apr 11, 2019
17afd7d
Make separator line work.
iccub Apr 11, 2019
bbdaa80
Add bookmark mvp, can add at root level.
iccub Apr 14, 2019
7d19867
Merge branch 'development' of github.com:brave/brave-ios into feature…
iccub Apr 14, 2019
ea4f0d8
Adding bookmark works.
iccub Apr 15, 2019
c3a737a
Add folders mvp
iccub Apr 15, 2019
ee76b6a
xcode 10.2
iccub Apr 15, 2019
f06a617
Correct buttons when adding a folder.
iccub Apr 16, 2019
02dab4c
Dismiss view when bookmark is selected.
iccub Apr 16, 2019
c0d29cd
Support editing modes in AddEditBookmarkVC
iccub Apr 16, 2019
736fc5e
Edit without saving location mvp.
iccub Apr 16, 2019
5138870
Edit bookmark location mvp
iccub Apr 17, 2019
ada5f14
Fetch favicon to bookmark details
iccub Apr 17, 2019
134d4a9
whitespace
iccub Apr 17, 2019
d68cad8
Add localized strings
iccub Apr 17, 2019
c022eb5
Edit improvements, title for add/edit screen
iccub Apr 17, 2019
7e30962
Remove unused BookmarkEditViewController
iccub Apr 17, 2019
f781004
Update image assets.
iccub Apr 17, 2019
1d5d612
Make folder detail height equal to folder hierarchy cells height.
iccub Apr 17, 2019
e6c7a1c
Harden against sync changes.
iccub Apr 17, 2019
93c9a24
Make updated url bar work with safe area insets
iccub Apr 17, 2019
880de9e
Show share menu popover at correct location.
iccub Apr 17, 2019
40f11b9
Design feedback from James.
iccub Apr 18, 2019
99b171f
Bookmark/folder detail views refactor.
iccub Apr 18, 2019
0bf5ddc
Header view refactor.
iccub Apr 18, 2019
c57f709
AddEditBookmarkTableViewController refactor.
iccub Apr 19, 2019
1d9e0c3
MenuViewController refactor.
iccub Apr 19, 2019
de90bd1
final touches
iccub Apr 19, 2019
32e1e30
Fix unit tests.
iccub Apr 19, 2019
bc45a12
review
iccub Apr 23, 2019
f7fd274
Make folderCellTag private
iccub Apr 23, 2019
839602c
Merge branch 'development' of github.com:brave/brave-ios into feature…
iccub Apr 23, 2019
8ad53f3
Swift 4.2 conformance
iccub Apr 23, 2019
21d08ed
Fix title helper function
iccub Apr 23, 2019
76ab847
Set syncParentUUID when updating location.
iccub Apr 23, 2019
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Harden against sync changes.

  • Loading branch information
iccub committed Apr 17, 2019
commit e6c7a1cfa030701930029e233ec8e99b579b243a
@@ -87,6 +87,7 @@
0AEFB84922244135007AF600 /* AdblockDebugMenuTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEFB84822244135007AF600 /* AdblockDebugMenuTableViewController.swift */; };
0AEFB8532226D7C5007AF600 /* AdblockResourcesMappings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEFB8522226D7C5007AF600 /* AdblockResourcesMappings.swift */; };
0AEFB88722299E6A007AF600 /* AdblockerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEFB88622299E6A007AF600 /* AdblockerType.swift */; };
0AF0411B2267C61100EBF982 /* ManagedObjectExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF0411A2267C61100EBF982 /* ManagedObjectExtensions.swift */; };
0AF3B4ED213D8E3300695962 /* CoreDataTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF3B4E5213D8E3200695962 /* CoreDataTestCase.swift */; };
0AF3B4EE213D8E3300695962 /* HistoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF3B4E6213D8E3200695962 /* HistoryTests.swift */; };
0AF3B4EF213D8E3300695962 /* DomainTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AF3B4E7213D8E3200695962 /* DomainTests.swift */; };
@@ -1210,6 +1211,7 @@
0AEFB84822244135007AF600 /* AdblockDebugMenuTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdblockDebugMenuTableViewController.swift; sourceTree = "<group>"; };
0AEFB8522226D7C5007AF600 /* AdblockResourcesMappings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdblockResourcesMappings.swift; sourceTree = "<group>"; };
0AEFB88622299E6A007AF600 /* AdblockerType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdblockerType.swift; sourceTree = "<group>"; };
0AF0411A2267C61100EBF982 /* ManagedObjectExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManagedObjectExtensions.swift; sourceTree = "<group>"; };
0AF3B4E5213D8E3200695962 /* CoreDataTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreDataTestCase.swift; sourceTree = "<group>"; };
0AF3B4E6213D8E3200695962 /* HistoryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistoryTests.swift; sourceTree = "<group>"; };
0AF3B4E7213D8E3200695962 /* DomainTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DomainTests.swift; sourceTree = "<group>"; };
@@ -3255,6 +3257,7 @@
5D1DC51520AC9AFA00905E5A /* Data.h */,
5D1DC51620AC9AFA00905E5A /* Info.plist */,
59B6912721B695A400E9388E /* InfoPlist.strings */,
0AF0411A2267C61100EBF982 /* ManagedObjectExtensions.swift */,
);
indentWidth = 4;
path = Data;
@@ -5431,6 +5434,7 @@
5D1DC57220AE005400905E5A /* JSInjector.swift in Sources */,
5D1DC55920AE004600905E5A /* Bookmark.swift in Sources */,
5D1DC55B20AE004600905E5A /* Domain.swift in Sources */,
0AF0411B2267C61100EBF982 /* ManagedObjectExtensions.swift in Sources */,
0AA4FC392109D685000B173A /* CRUDProtocols.swift in Sources */,
5D1DC56B20AE005400905E5A /* SyncCrypto.swift in Sources */,
5D1DC55F20AE004600905E5A /* Model.xcdatamodeld in Sources */,
@@ -64,6 +64,17 @@ class AddEditBookmarkTableViewController: UITableViewController {
}
}

/// Making sure the folder we are saving to still exists.
/// This could happen if the folder got deleted by another device in sync chain.
var exists: Bool {
// Root level and favorites locations are permanent, only custom folder needs to be checked.
switch self {
case .folder(let folder):
return folder.existsInPersistentStore()
default:
return false
}
}
}

private enum DataSourcePresentationMode {
@@ -81,10 +92,6 @@ class AddEditBookmarkTableViewController: UITableViewController {
}

let frc: NSFetchedResultsController<Bookmark>

//let action: AddEditBookmarkTableViewController.Action
//let type: AddEditBookmarkTableViewController.BookmarkType
let mode: AddEditBookmarkTableViewController.Mode

lazy var saveButton: UIBarButtonItem = {
@@ -140,10 +147,6 @@ class AddEditBookmarkTableViewController: UITableViewController {
tableView.contentInset = UIEdgeInsets(top: 36, left: 0, bottom: 0, right: 0)

frc.delegate = self
try? frc.performFetch()
sortedFolders = sortFolders()

tableView.reloadData()

switch mode {
case .newBookmark(_, _): title = Strings.NewBookmarkTitle
@@ -155,6 +158,20 @@ class AddEditBookmarkTableViewController: UITableViewController {

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
reloadData()
}

func reloadData() {
try? frc.performFetch()
sortedFolders = sortFolders()

// If the bookmark we save to was deleted, UI needs an update
// and a fallback location.
if !location.exists {
location = .rootLevel
}

tableView.reloadData()
}

typealias IndentedFolder = (Bookmark, indentationLevel: Int)
@@ -203,6 +220,10 @@ class AddEditBookmarkTableViewController: UITableViewController {

guard let title = bookmarkDetailsView.titleTextField.text else { return earlyReturn() }

if !location.exists {
location = .rootLevel
}

switch mode {
case .newBookmark(_, _):
guard let urlString = bookmarkDetailsView.urlTextField?.text,
@@ -235,6 +256,8 @@ class AddEditBookmarkTableViewController: UITableViewController {
return earlyReturn()
}

if !bookmark.existsInPersistentStore() { break }

switch location {
case .rootLevel:
bookmark.updateWithNewLocation(customTitle: title, url: urlString, location: nil)
@@ -246,6 +269,7 @@ class AddEditBookmarkTableViewController: UITableViewController {
}

case .editFolder(let folder):
if !folder.existsInPersistentStore() { break }

switch location {
case .rootLevel:
@@ -425,9 +449,6 @@ extension AddEditBookmarkTableViewController: NSFetchedResultsControllerDelegate
func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {

// Possible performance bottleneck
try? frc.performFetch()
sortedFolders = sortFolders()

tableView.reloadData()
reloadData()
}
}
@@ -0,0 +1,17 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
import Foundation
import CoreData

public extension NSManagedObject {
/// Returns true if the object still exists in the persistent store.
func existsInPersistentStore() -> Bool {
// `isDeleted` is set to true if the object is going to be deleted
// on the next context save.
// After the save happens, managedObjectContext is set to nil.
// This conditional should catch both deletion states.
return !isDeleted && managedObjectContext != nil
}
}
@@ -523,7 +523,9 @@ extension Bookmark {
if isFolder {
removeFolderAndSendSyncRecords(uuid: syncUUID)
} else {
Sync.shared.sendSyncRecords(action: .delete, records: [self])
DataController.perform(context: context) { context in
Sync.shared.sendSyncRecords(action: .delete, records: [self], context: context)

This comment has been minimized.

Copy link
@iccub

iccub Apr 19, 2019

Author Contributor

A bit out of scope of this PR but this was throwing threading errors so fixed it

}
}
}

@@ -547,7 +549,7 @@ extension Bookmark {
allBookmarks.append(contentsOf: allNestedBookmarks)
}

Sync.shared.sendSyncRecords(action: .delete, records: allBookmarks)
Sync.shared.sendSyncRecords(action: .delete, records: allBookmarks, context: context)

bookmarkOnCorrectContext.deleteInternal(context: .existing(context))
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.