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

folder hirerarchy alpha version

  • Loading branch information
iccub committed Apr 11, 2019
commit 7926cfe6520ba2087483413f89744c9fcef2dad2
@@ -61,6 +61,9 @@
0A83D9F121B7FFD200245EF0 /* ABPFilterParserData.dat in Resources */ = {isa = PBXBuildFile; fileRef = 0A83D9E921B7FFD100245EF0 /* ABPFilterParserData.dat */; };
0A8C6993225BC7B100988715 /* ToolbarUrlActionsProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A8C6992225BC7B100988715 /* ToolbarUrlActionsProtocol.swift */; };
0A8C699C225BDDC500988715 /* BookmarkEditViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A8C699B225BDDC500988715 /* BookmarkEditViewController.swift */; };
0A8C69AB225CFCAF00988715 /* AddEditBookmarkTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A8C69AA225CFCAF00988715 /* AddEditBookmarkTableViewController.swift */; };
0A8C69B5225DE99700988715 /* BookmarkDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A8C69B4225DE99700988715 /* BookmarkDetailsView.swift */; };
0A8C69BE225E350300988715 /* IndentedImageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A8C69BD225E350300988715 /* IndentedImageTableViewCell.swift */; };
0AA029F8222E899400D6B535 /* Bookmark+Reorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA029F7222E899400D6B535 /* Bookmark+Reorder.swift */; };
0AA4FC392109D685000B173A /* CRUDProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AA4FC382109D685000B173A /* CRUDProtocols.swift */; };
0AAAAC972249174A009A8763 /* SyncAlerts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AAAAC962249174A009A8763 /* SyncAlerts.swift */; };
@@ -1180,6 +1183,9 @@
0A83D9E921B7FFD100245EF0 /* ABPFilterParserData.dat */ = {isa = PBXFileReference; lastKnownFileType = file; path = ABPFilterParserData.dat; sourceTree = "<group>"; };
0A8C6992225BC7B100988715 /* ToolbarUrlActionsProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolbarUrlActionsProtocol.swift; sourceTree = "<group>"; };
0A8C699B225BDDC500988715 /* BookmarkEditViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkEditViewController.swift; sourceTree = "<group>"; };
0A8C69AA225CFCAF00988715 /* AddEditBookmarkTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddEditBookmarkTableViewController.swift; sourceTree = "<group>"; };
0A8C69B4225DE99700988715 /* BookmarkDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarkDetailsView.swift; sourceTree = "<group>"; };
0A8C69BD225E350300988715 /* IndentedImageTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndentedImageTableViewCell.swift; sourceTree = "<group>"; };
0A9B6A3420E6453400712BC9 /* Model8.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model8.xcdatamodel; sourceTree = "<group>"; };
0AA029F7222E899400D6B535 /* Bookmark+Reorder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Bookmark+Reorder.swift"; sourceTree = "<group>"; };
0AA4FC382109D685000B173A /* CRUDProtocols.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CRUDProtocols.swift; sourceTree = "<group>"; };
@@ -3436,6 +3442,9 @@
A198E75020C701ED00334C11 /* HistoryViewController.swift */,
44331DBA22521013007E3E93 /* MenuViewController.swift */,
0A8C6992225BC7B100988715 /* ToolbarUrlActionsProtocol.swift */,
0A8C69AA225CFCAF00988715 /* AddEditBookmarkTableViewController.swift */,
0A8C69B4225DE99700988715 /* BookmarkDetailsView.swift */,
0A8C69BD225E350300988715 /* IndentedImageTableViewCell.swift */,
);
path = Menu;
sourceTree = "<group>";
@@ -5635,8 +5644,10 @@
DD31E0FB1B382B520077078A /* TabPrintPageRenderer.swift in Sources */,
E4CD9E911A6897FB00318571 /* ReaderMode.swift in Sources */,
4422D42321BFCE9200BF1855 /* HttpsEverywhereStats.swift in Sources */,
0A8C69AB225CFCAF00988715 /* AddEditBookmarkTableViewController.swift in Sources */,
27FD2CAD2146C31C00A5A779 /* AddToFavoritesActivity.swift in Sources */,
4422D4E121BFFB7600BF1855 /* filter_block.cc in Sources */,
0A8C69BE225E350300988715 /* IndentedImageTableViewCell.swift in Sources */,
0A1E843D2190A57F0042F782 /* SyncSettingsTableViewController.swift in Sources */,
C615FAE5212AC5E000A8168C /* PrivacyProtectionProtocol.swift in Sources */,
4422D56C21BFFB7F00BF1855 /* bitstate.cc in Sources */,
@@ -5722,6 +5733,7 @@
D31A0FC71A65D6D000DC8C7E /* SearchSuggestClient.swift in Sources */,
4422D4AE21BFFB7600BF1855 /* testutil.cc in Sources */,
0A4BEFD2221E115B0005551A /* NetworkSession.swift in Sources */,
0A8C69B5225DE99700988715 /* BookmarkDetailsView.swift in Sources */,
4422D4F121BFFB7600BF1855 /* c.cc in Sources */,
A83E5AB71C1D993D0026D912 /* UIPasteboardExtensions.swift in Sources */,
C6B81B8A212D84BD00996084 /* ImageCacheType.swift in Sources */,
@@ -0,0 +1,133 @@
// 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 UIKit
import CoreData
import Data

class AddEditBookmarkTableViewController: UITableViewController {

enum Mode {
case addBookmark(title: String, url: URL)
case addFolder(title: String)
case editBookmark(bookmark: Bookmark)
case editFolder(folder: Bookmark)
}

let frc: NSFetchedResultsController<Bookmark>

let mode: Mode

init(mode: AddEditBookmarkTableViewController.Mode) {
frc = Bookmark.foldersFrc()
self.mode = mode

super.init(style: .grouped)


}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func viewDidLoad() {
super.viewDidLoad()

// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem
tableView.rowHeight = 44
tableView.cellLayoutMarginsFollowReadableWidth = false

let bookmarkDetailsView = BookmarkDetailsView()
bookmarkDetailsView.translatesAutoresizingMaskIntoConstraints = false

tableView.tableHeaderView = bookmarkDetailsView

bookmarkDetailsView.snp.makeConstraints {
$0.width.equalTo(self.view)
$0.top.equalTo(self.view)
$0.centerX.equalTo(self.view)
}

tableView.contentInset = UIEdgeInsets(top: 36, left: 0, bottom: 0, right: 0)

bookmarkDetailsView.layoutIfNeeded()

//tableView.tableFooterView = UIView()
frc.delegate = self

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

tableView.reloadData()


}

var allFolders = [Bookmark]()
var sortedFolders = [IndentedFolder]()

typealias IndentedFolder = (Bookmark, indentationLevel: Int)

func sortFolders(parentID: NSManagedObjectID? = nil, indentationLevel: Int = 0) -> [IndentedFolder] {
guard let objects = frc.fetchedObjects else { return [] }

var s = [IndentedFolder]()

objects.filter { $0.parentFolder?.objectID == parentID }.forEach {
s.append(($0, indentationLevel: indentationLevel))
s.append(contentsOf: sortFolders(parentID: $0.objectID, indentationLevel: indentationLevel + 1))
}

return s
}

var testToggle = false

// MARK: - Table view data source
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 16
}

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return sortedFolders.count
}

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "Title"
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
testToggle = !testToggle
tableView.deselectRow(at: indexPath, animated: true)
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = IndentedImageTableViewCell()

let indentedFolder = sortedFolders[indexPath.row]

cell.folderName.text = indentedFolder.0.displayTitle

//cell.textLabel?.text = indentedFolder.0.displayTitle
//cell.imageView?.image = #imageLiteral(resourceName: "bookmarks_folder_hollow")
cell.indentationLevel = indentedFolder.indentationLevel



return cell
}


}

extension AddEditBookmarkTableViewController: NSFetchedResultsControllerDelegate {
}
@@ -0,0 +1,97 @@
// 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 UIKit
import SnapKit

class BookmarkDetailsView: UIView {

let mainStackView = UIStackView().then {
$0.axis = .vertical
$0.spacing = 8
}

let contentStackView = UIStackView().then {
$0.spacing = 8
$0.setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
$0.alignment = .center
}

let faviconImageView = UIImageView().then {
$0.image = #imageLiteral(resourceName: "defaultTopSiteIcon")
$0.contentMode = .scaleAspectFit
}

let textFieldsStackView = UIStackView().then {
$0.axis = .vertical
$0.spacing = 8
}

let titleTextField = UITextField().then {
$0.placeholder = "Title"
$0.clearButtonMode = .whileEditing
$0.translatesAutoresizingMaskIntoConstraints = false
}

let urlTextField = UITextField().then {
$0.placeholder = "Address"
$0.keyboardType = .webSearch
$0.autocorrectionType = .no
$0.autocapitalizationType = .none
$0.smartDashesType = .no
$0.clearButtonMode = .whileEditing
$0.translatesAutoresizingMaskIntoConstraints = false
}

var spacerLine: UIView {
let view = UIView()
view.backgroundColor = .lightGray
view.translatesAutoresizingMaskIntoConstraints = false
view.addConstraint(NSLayoutConstraint(item: view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 0.5))

return view
}

override init(frame: CGRect) {
super.init(frame: frame)

backgroundColor = .white

addSubview(mainStackView)

mainStackView.addArrangedSubview(spacerLine)
mainStackView.addArrangedSubview(contentStackView)
mainStackView.addArrangedSubview(spacerLine)

textFieldsStackView.addArrangedSubview(titleTextField)
textFieldsStackView.addArrangedSubview(spacerLine)
textFieldsStackView.addArrangedSubview(urlTextField)

//urlTextField.setContentCompressionResistancePriority(.defaultLow, for: .vertical)

contentStackView.addArrangedSubview(faviconImageView)
contentStackView.addArrangedSubview(textFieldsStackView)

faviconImageView.setContentHuggingPriority(.defaultHigh, for: .horizontal)

//backgroundColor = .red
mainStackView.snp.makeConstraints {
$0.edges.equalTo(self)
}

// spacerLine.snp.makeConstraints {
// $0.height.equalTo(0.3)
// }
// faviconImageView.snp.makeConstraints {
// $0.width.equalTo(48)
// }
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.