Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Styles #16

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
120 changes: 94 additions & 26 deletions Client.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file modified Client/Assets/Images.xcassets/AppIcon.appiconset/icon-29.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon.appiconset/icon-29@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon.appiconset/icon-29@3x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon.appiconset/icon-40.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon.appiconset/icon-40@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon.appiconset/icon-40@3x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon.appiconset/icon-60.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon.appiconset/icon-60@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon.appiconset/icon-60@3x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon.appiconset/icon-76.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon.appiconset/icon-76@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon_Beta.appiconset/icon-29.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Client/Assets/Images.xcassets/AppIcon_Beta.appiconset/icon-40.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "nav-search@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "nav-search@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
4 changes: 4 additions & 0 deletions Client/Assets/Images.xcassets/qr.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "QR@2x.png",
Expand Down
15 changes: 7 additions & 8 deletions Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1472,11 +1472,11 @@ extension BrowserViewController: TabToolbarDelegate, PhotonActionSheetProtocol {
showBackForwardList()
}

func tabToolbarDidPressReload(_ tabToolbar: TabToolbarProtocol, button: UIButton) {
func tabToolbarDidPressDynamic(_ tabToolbar: TabToolbarProtocol, button: UIButton) {
tabManager.selectedTab?.reload()
}

func tabToolbarDidLongPressReload(_ tabToolbar: TabToolbarProtocol, button: UIButton) {
func tabToolbarDidLongPressDynamic(_ tabToolbar: TabToolbarProtocol, button: UIButton) {
guard let tab = tabManager.selectedTab, tab.webView?.url != nil && (tab.getHelper(name: ReaderMode.name()) as? ReaderMode)?.state != .active else {
return
}
Expand Down Expand Up @@ -1510,6 +1510,10 @@ extension BrowserViewController: TabToolbarDelegate, PhotonActionSheetProtocol {
func tabToolbarDidPressStop(_ tabToolbar: TabToolbarProtocol, button: UIButton) {
tabManager.selectedTab?.stop()
}

func tabToolbarDidPressSearch(_ tabToolbar: TabToolbarProtocol, button: UIButton) {

}

func tabToolbarDidPressForward(_ tabToolbar: TabToolbarProtocol, button: UIButton) {
tabManager.selectedTab?.goForward()
Expand Down Expand Up @@ -1873,12 +1877,7 @@ extension BrowserViewController: TabManagerDelegate {
}

fileprivate func updateTabCountUsingTabManager(_ tabManager: TabManager, animated: Bool = true) {
if let selectedTab = tabManager.selectedTab {
let count = selectedTab.isPrivate ? tabManager.privateTabs.count : tabManager.normalTabs.count
toolbar?.updateTabCount(count, animated: animated)
urlBar.updateTabCount(count, animated: !urlBar.inOverlayMode)
topTabsViewController?.updateTabCount(count, animated: animated)
}

}
}

Expand Down
56 changes: 55 additions & 1 deletion Client/Frontend/Browser/TabScrollController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ class TabScrollingController: NSObject {
fileprivate var isZoomedOut: Bool = false
fileprivate var lastZoomedScale: CGFloat = 0
fileprivate var isUserZoom: Bool = false

fileprivate var isDragging: Bool = false
fileprivate var adjustWithScroll: Bool = false
fileprivate var adjustWithDrag: Bool = false {
didSet {
dragStartY = scrollView?.contentOffset.y ?? 0
}
}
fileprivate var dragStartY: CGFloat = 0
fileprivate var previousScrollOffset: CGFloat = 0

fileprivate var headerTopOffset: CGFloat = 0 {
didSet {
headerTopConstraint?.update(offset: headerTopOffset)
Expand Down Expand Up @@ -305,6 +314,51 @@ extension TabScrollingController: UIScrollViewDelegate {
}
}
}

func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
if tabIsLoading() || isBouncingAtBottom() {
return
}

// Check if we should keep animation moving with scroll speed.
if fabsf(Float(velocity.y)) < 0.8 && checkScrollHeightIsLargeEnoughForScrolling() {
previousScrollOffset = scrollView.contentOffset.y
adjustWithScroll = true
}
else if checkScrollHeightIsLargeEnoughForScrolling() {
adjustWithScroll = false
// scrolling too fast, keeps animation smooth.
if scrollDirection == .up {
showToolbars(animated: true)
} else if scrollDirection == .down {
hideToolbars(animated: true)
}
}

adjustWithDrag = false
}

func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
adjustWithScroll = false
adjustWithDrag = true
}

func scrollViewDidScroll(_ scrollView: UIScrollView) {
let offset = scrollView.contentOffset.y
if tabIsLoading() || isBouncingAtBottom() || offset <= 0 {
return
}

if adjustWithScroll {
let delta = scrollView.contentOffset.y - previousScrollOffset
scrollWithDelta(delta)
previousScrollOffset = scrollView.contentOffset.y
}
else if adjustWithDrag && dragStartY - offset > topScrollHeight * 2 {
adjustWithScroll = true
previousScrollOffset = scrollView.contentOffset.y
}
}

func scrollViewDidZoom(_ scrollView: UIScrollView) {
// Only mess with the zoom level if the user did not initate the zoom via a zoom gesture
Expand Down
66 changes: 29 additions & 37 deletions Client/Frontend/Browser/TabToolbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,26 @@ import Shared

protocol TabToolbarProtocol: class {
weak var tabToolbarDelegate: TabToolbarDelegate? { get set }
var tabsButton: TabsButton { get }
var tabsButton: ToolbarButton { get }
var menuButton: ToolbarButton { get }
var forwardButton: ToolbarButton { get }
var backButton: ToolbarButton { get }
var stopReloadButton: ToolbarButton { get }
var dynamicButton: ToolbarButton { get }
var actionButtons: [Themeable & UIButton] { get }

func updateBackStatus(_ canGoBack: Bool)
func updateForwardStatus(_ canGoForward: Bool)
func updateReloadStatus(_ isLoading: Bool)
func updatePageStatus(_ isWebPage: Bool)
func updateTabCount(_ count: Int, animated: Bool)
}

protocol TabToolbarDelegate: class {
func tabToolbarDidPressBack(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidPressForward(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidLongPressBack(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidLongPressForward(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidPressReload(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidLongPressReload(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidPressStop(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidLongPressDynamic(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidPressDynamic(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidPressMenu(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidPressTabs(_ tabToolbar: TabToolbarProtocol, button: UIButton)
func tabToolbarDidLongPressTabs(_ tabToolbar: TabToolbarProtocol, button: UIButton)
Expand All @@ -42,16 +40,16 @@ open class TabToolbarHelper: NSObject {

let ImageReload = UIImage.templateImageNamed("nav-refresh")
let ImageStop = UIImage.templateImageNamed("nav-stop")

var loading: Bool = false {
didSet {
if loading {
toolbar.stopReloadButton.setImage(ImageStop, for: .normal)
toolbar.stopReloadButton.accessibilityLabel = NSLocalizedString("Stop", comment: "Accessibility Label for the tab toolbar Stop button")
} else {
toolbar.stopReloadButton.setImage(ImageReload, for: .normal)
toolbar.stopReloadButton.accessibilityLabel = NSLocalizedString("Reload", comment: "Accessibility Label for the tab toolbar Reload button")
}
// if loading {
// toolbar.dynamicButton.setImage(ImageStop, for: .normal)
// toolbar.dynamicButton.accessibilityLabel = NSLocalizedString("Stop", comment: "Accessibility Label for the tab toolbar Stop button")
// } else {
// toolbar.dynamicButton.setImage(ImageReload, for: .normal)
// toolbar.dynamicButton.accessibilityLabel = NSLocalizedString("Reload", comment: "Accessibility Label for the tab toolbar Reload button")
// }
}
}

Expand All @@ -75,15 +73,17 @@ open class TabToolbarHelper: NSObject {
toolbar.forwardButton.addGestureRecognizer(longPressGestureForwardButton)
toolbar.forwardButton.addTarget(self, action: #selector(TabToolbarHelper.didClickForward), for: UIControlEvents.touchUpInside)

toolbar.stopReloadButton.setImage(UIImage.templateImageNamed("nav-refresh"), for: .normal)
toolbar.stopReloadButton.accessibilityLabel = NSLocalizedString("Reload", comment: "Accessibility Label for the tab toolbar Reload button")
let longPressGestureStopReloadButton = UILongPressGestureRecognizer(target: self, action: #selector(TabToolbarHelper.didLongPressStopReload(_:)))
toolbar.stopReloadButton.addGestureRecognizer(longPressGestureStopReloadButton)
toolbar.stopReloadButton.addTarget(self, action: #selector(TabToolbarHelper.didClickStopReload), for: UIControlEvents.touchUpInside)
toolbar.dynamicButton.setImage(UIImage.templateImageNamed("nav-search"), for: .normal)
toolbar.dynamicButton.accessibilityLabel = NSLocalizedString("Dynamic", comment: "Accessibility Label for the tab toolbar Dynamic button")
let longPressGestureDynamicButton = UILongPressGestureRecognizer(target: self, action: #selector(TabToolbarHelper.didLongPressDynamic(_:)))
toolbar.dynamicButton.addGestureRecognizer(longPressGestureDynamicButton)
toolbar.dynamicButton.addTarget(self, action: #selector(TabToolbarHelper.didClickDynamic), for: UIControlEvents.touchUpInside)

toolbar.tabsButton.addTarget(self, action: #selector(TabToolbarHelper.didClickTabs), for: .touchUpInside)
toolbar.tabsButton.setImage(UIImage.templateImageNamed("nav-tabs"), for: .normal)
toolbar.tabsButton.accessibilityLabel = NSLocalizedString("Tabs", comment: "Accessibility Label for the tab toolbar Menu button")
let longPressGestureTabsButton = UILongPressGestureRecognizer(target: self, action: #selector(TabToolbarHelper.didLongPressTabs(_:)))
toolbar.tabsButton.addGestureRecognizer(longPressGestureTabsButton)
toolbar.tabsButton.addTarget(self, action: #selector(TabToolbarHelper.didClickTabs), for: UIControlEvents.touchUpInside)

toolbar.menuButton.contentMode = UIViewContentMode.center
toolbar.menuButton.setImage(UIImage.templateImageNamed("nav-menu"), for: .normal)
Expand Down Expand Up @@ -125,17 +125,13 @@ open class TabToolbarHelper: NSObject {
toolbar.tabToolbarDelegate?.tabToolbarDidPressMenu(toolbar, button: toolbar.menuButton)
}

func didClickStopReload() {
if loading {
toolbar.tabToolbarDelegate?.tabToolbarDidPressStop(toolbar, button: toolbar.stopReloadButton)
} else {
toolbar.tabToolbarDelegate?.tabToolbarDidPressReload(toolbar, button: toolbar.stopReloadButton)
}
func didClickDynamic() {
toolbar.tabToolbarDelegate?.tabToolbarDidPressDynamic(toolbar, button: toolbar.dynamicButton)
}

func didLongPressStopReload(_ recognizer: UILongPressGestureRecognizer) {
func didLongPressDynamic(_ recognizer: UILongPressGestureRecognizer) {
if recognizer.state == UIGestureRecognizerState.began && !loading {
toolbar.tabToolbarDelegate?.tabToolbarDidLongPressReload(toolbar, button: toolbar.stopReloadButton)
toolbar.tabToolbarDelegate?.tabToolbarDidLongPressDynamic(toolbar, button: toolbar.dynamicButton)
}
}

Expand Down Expand Up @@ -195,18 +191,18 @@ extension ToolbarButton: Themeable {
class TabToolbar: UIView {
weak var tabToolbarDelegate: TabToolbarDelegate?

let tabsButton = TabsButton()
let tabsButton = ToolbarButton()
let menuButton = ToolbarButton()
let forwardButton = ToolbarButton()
let backButton = ToolbarButton()
let stopReloadButton = ToolbarButton()
let dynamicButton = ToolbarButton()
let actionButtons: [Themeable & UIButton]

var helper: TabToolbarHelper?
private let contentView = UIStackView()

fileprivate override init(frame: CGRect) {
actionButtons = [backButton, forwardButton, stopReloadButton, tabsButton, menuButton]
actionButtons = [backButton, forwardButton, menuButton, dynamicButton, tabsButton]
super.init(frame: frame)
setupAccessibility()

Expand All @@ -228,7 +224,7 @@ class TabToolbar: UIView {
private func setupAccessibility() {
backButton.accessibilityIdentifier = "TabToolbar.backButton"
forwardButton.accessibilityIdentifier = "TabToolbar.forwardButton"
stopReloadButton.accessibilityIdentifier = "TabToolbar.stopReloadButton"
dynamicButton.accessibilityIdentifier = "TabToolbar.dynamicButton"
tabsButton.accessibilityIdentifier = "TabToolbar.tabsButton"
menuButton.accessibilityIdentifier = "TabToolbar.menuButton"
accessibilityNavigationStyle = .combined
Expand Down Expand Up @@ -272,11 +268,7 @@ extension TabToolbar: TabToolbarProtocol {
}

func updatePageStatus(_ isWebPage: Bool) {
stopReloadButton.isEnabled = isWebPage
}

func updateTabCount(_ count: Int, animated: Bool) {
tabsButton.updateTabCount(count, animated: animated)
dynamicButton.isEnabled = isWebPage
}
}

Expand Down
16 changes: 8 additions & 8 deletions Client/Frontend/Browser/TabTrayButtonExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ extension UIButton {
}
}

extension TabsButton {
static func tabTrayButton() -> TabsButton {
let tabsButton = TabsButton()
tabsButton.countLabel.text = "0"
tabsButton.accessibilityLabel = NSLocalizedString("Show Tabs", comment: "Accessibility Label for the tabs button in the tab toolbar")
return tabsButton
}
}
//extension TabsButton {
// static func tabTrayButton() -> TabsButton {
// let tabsButton = TabsButton()
// tabsButton.accessibilityLabel = NSLocalizedString("Show Tabs", comment: "Accessibility Label for the tabs button in the tab toolbar")
// return tabsButton
// }
//}

13 changes: 3 additions & 10 deletions Client/Frontend/Browser/TopTabsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class TopTabsViewController: UIViewController {
return collectionView
}()

fileprivate lazy var tabsButton: TabsButton = {
let tabsButton = TabsButton.tabTrayButton()
fileprivate lazy var tabsButton: ToolbarButton = {
let tabsButton = ToolbarButton()
tabsButton.addTarget(self, action: #selector(TopTabsViewController.tabsTrayTapped), for: UIControlEvents.touchUpInside)
tabsButton.accessibilityIdentifier = "TopTabsViewController.tabsButton"
return tabsButton
Expand Down Expand Up @@ -157,7 +157,6 @@ class TopTabsViewController: UIViewController {
if let currentTab = tabManager.selectedTab {
applyTheme(currentTab.isPrivate ? .Private : .Normal)
}
updateTabCount(tabStore.count, animated: false)
}

func switchForegroundStatus(isInForeground reveal: Bool) {
Expand All @@ -171,10 +170,6 @@ class TopTabsViewController: UIViewController {
}
}

func updateTabCount(_ count: Int, animated: Bool = true) {
self.tabsButton.updateTabCount(count, animated: animated)
}

func tabsTrayTapped() {
delegate?.topTabsDidPressTabs()
}
Expand Down Expand Up @@ -250,9 +245,7 @@ class TopTabsViewController: UIViewController {
extension TopTabsViewController: Themeable {
func applyTheme(_ theme: Theme) {
tabsButton.applyTheme(theme)
tabsButton.titleBackgroundColor = view.backgroundColor ?? UIColor.Defaults.GreyH
tabsButton.textColor = UIColor.Defaults.GreyD


isPrivate = (theme == Theme.Private)
privateModeButton.applyTheme(theme)
privateModeButton.tintColor = UIColor.TopTabs.PrivateModeTint.colorFor(theme)
Expand Down