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

Edit bookmark location mvp

  • Loading branch information
iccub committed Apr 17, 2019
commit 5138870ab978685a8d61964c930bc8d3c52efc77
@@ -218,13 +218,32 @@ class AddEditBookmarkTableViewController: UITableViewController {

delegate?.didSelectFolder()
case .editBookmark(let bookmark):
guard let urlString = bookmarkDetailsView.urlTextField?.text else {
guard let urlString = bookmarkDetailsView.urlTextField?.text,
let url = URL(string: urlString) else {
return earlyReturn()
}

bookmark.update(customTitle: title, url: urlString)
switch location {
case .rootLevel:
bookmark.updateWithNewLocation(customTitle: title, url: urlString, location: nil)
case .favorites:
bookmark.delete()
Bookmark.addFavorite(url: url, title: title)
case .folder(let folder):
bookmark.updateWithNewLocation(customTitle: title, url: urlString, location: folder)
}

case .editFolder(let folder):
folder.update(customTitle: title, url: nil)
folder.updateWithNewLocation(customTitle: title, url: nil, location: folder)

switch location {
case .rootLevel:
folder.updateWithNewLocation(customTitle: title, url: nil, location: nil)
case .favorites:
fatalError("Folders can't be saved to favorites")
case .folder(let folderSaveLocation):
folder.updateWithNewLocation(customTitle: title, url: nil, location: folderSaveLocation)
}
}

if let nc = navigationController, nc.childViewControllers.count > 1 {
@@ -297,7 +316,7 @@ class AddEditBookmarkTableViewController: UITableViewController {
}

var favoritesCell: IndentedImageTableViewCell {
let cell = IndentedImageTableViewCell(image: #imageLiteral(resourceName: "bookmark"))
let cell = IndentedImageTableViewCell(image: #imageLiteral(resourceName: "menu-Bookmark"))
cell.folderName.text = "Favorites"
cell.tag = Location.favoritesTag
if case .favorites = location, presentationMode == .folderHierarchy {
@@ -92,7 +92,7 @@ class MenuViewController: UITableViewController {
let nc = SettingsNavigationController(rootViewController: vc)
nc.modalPresentationStyle = .formSheet

nc.navigationBar.topItem?.leftBarButtonItem =
nc.navigationBar.topItem?.rightBarButtonItem =
UIBarButtonItem(barButtonSystemItem: .done, target: nc, action: #selector(SettingsNavigationController.done))

dismiss(animated: true)

This comment has been minimized.

Copy link
@jhreis

jhreis Apr 22, 2019

Contributor

Maybe just call dismissView()?

@@ -125,7 +125,7 @@ class MenuViewController: UITableViewController {
let nc = SettingsNavigationController(rootViewController: vc)
nc.modalPresentationStyle = .formSheet

nc.navigationBar.topItem?.leftBarButtonItem =
nc.navigationBar.topItem?.rightBarButtonItem =
UIBarButtonItem(barButtonSystemItem: .done, target: nc, action: #selector(SettingsNavigationController.done))

dismiss(animated: true)
@@ -138,7 +138,7 @@ class MenuViewController: UITableViewController {
let nc = SettingsNavigationController(rootViewController: vc)
nc.modalPresentationStyle = .formSheet

nc.navigationBar.topItem?.leftBarButtonItem =
nc.navigationBar.topItem?.rightBarButtonItem =
UIBarButtonItem(barButtonSystemItem: .done, target: nc, action: #selector(SettingsNavigationController.done))

dismiss(animated: true)
@@ -152,6 +152,17 @@ public final class Bookmark: NSManagedObject, WebsitePresentable, Syncable, CRUD
updateInternal(customTitle: customTitle, url: url)
}

enum SaveLocation {
case keep
case new(location: Bookmark?)
}

public func updateWithNewLocation(customTitle: String?, url: String?, location: Bookmark?) {

This comment has been minimized.

Copy link
@jhreis

jhreis Apr 22, 2019

Contributor

This is almost identical to update( above. Should abstract implementation. This could honestly even be a string helper.
Something super generic would be:
containsCharacters(in: CharacterSet) -> Bool

and could call:
myText.containsCharacters(in: .whitespacesAndNewlines.invert())

Otherwise could do something more like:
hasVisibleCharacters

Lastly, since this logic is only really used in this class, could just create a private function 😆

This comment has been minimized.

Copy link
@iccub

iccub Apr 23, 2019

Author Contributor

Made a private function

let isTitleEmpty = customTitle?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == true

This comment has been minimized.

Copy link
@jhreis

jhreis Apr 22, 2019

Contributor

If we flip this conditional, it will auto check for nil and empty:

let containsText = customTitle?.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false
if !containsText { return }
if customTitle == nil || isTitleEmpty { return }
updateInternal(customTitle: customTitle, url: url, location: .new(location: location))
}

public class func migrateBookmarkOrders() {
DataController.perform { context in
migrateOrder(forFavorites: true, context: context)
@@ -331,6 +342,7 @@ extension Bookmark {

private func updateInternal(customTitle: String?, url: String?, newSyncOrder: String? = nil,
save: Bool = true, sendToSync: Bool = true,
location: SaveLocation = .keep,
context: WriteContext = .new) {

DataController.perform(context: context) { context in
@@ -353,14 +365,27 @@ extension Bookmark {
}
}

// Checking if syncOrder has changed is imporant here for performance reasons.
// Currently to do bookmark sorting right, we have to grab all bookmarks in a given directory
// and update their order which is a costly operation.
if newSyncOrder != nil && bookmarkToUpdate.syncOrder != newSyncOrder {
bookmarkToUpdate.syncOrder = newSyncOrder
Bookmark.setOrderForAllBookmarksOnGivenLevel(parent: bookmarkToUpdate.parentFolder, forFavorites: bookmarkToUpdate.isFavorite, context: context)
switch location {
case .keep:
// Checking if syncOrder has changed is imporant here for performance reasons.
// Currently to do bookmark sorting right, we have to grab all bookmarks in a given directory
// and update their order which is a costly operation.
if newSyncOrder != nil && bookmarkToUpdate.syncOrder != newSyncOrder {
bookmarkToUpdate.syncOrder = newSyncOrder
Bookmark.setOrderForAllBookmarksOnGivenLevel(parent: bookmarkToUpdate.parentFolder, forFavorites: bookmarkToUpdate.isFavorite, context: context)
}
case .new(let newParent):
var parentOnCorrectContext: Bookmark?
if let newParent = newParent {
parentOnCorrectContext = context.object(with: newParent.objectID) as? Bookmark
}
bookmarkToUpdate.parentFolder = parentOnCorrectContext
bookmarkToUpdate.newSyncOrder(forFavorites: bookmarkToUpdate.isFavorite, context: context)
Bookmark.setOrderForAllBookmarksOnGivenLevel(parent: bookmarkToUpdate.parentFolder,
forFavorites: bookmarkToUpdate.isFavorite,
context: context)
}

if !bookmarkToUpdate.isFavorite && sendToSync {
Sync.shared.sendSyncRecords(action: .update, records: [bookmarkToUpdate], context: context)
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.