Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8095f21
start of ui work
brindy Oct 30, 2017
73a5337
show dashboard modally
brindy Oct 30, 2017
357a27a
use embedded view for navigation controller
brindy Oct 30, 2017
22a19da
add transition for showing privacy protection dashboard under omni bar
brindy Oct 31, 2017
584e9f9
add more privacy protection ui and fix a bug with transitions
brindy Oct 31, 2017
2e08d63
add placeholder for toggle
brindy Oct 31, 2017
81d428f
support kerning of text
brindy Oct 31, 2017
6cb746b
Merge branch 'develop' into feature/privacy_protection_dashboard
brindy Oct 31, 2017
6fc18c4
Merge branch 'develop' into feature/privacy_protection_dashboard
brindy Oct 31, 2017
418a39d
add structure for navigating in the privacy protection screens
brindy Nov 1, 2017
51c0092
add more ui setup for privacy protection
brindy Nov 1, 2017
ac7f3b7
show privacy grade and update it when it changes
brindy Nov 2, 2017
d204970
add additional updates to the ui based on site rating
brindy Nov 2, 2017
dd66963
update trackers info on the overview screen
brindy Nov 3, 2017
80802d0
update privacy practices
brindy Nov 3, 2017
58c73b3
disable table selections
brindy Nov 3, 2017
085a802
show upgraded status of the protection
brindy Nov 4, 2017
2026072
fix broken tests and add one for blocked only
brindy Nov 4, 2017
701e04e
remove unused content blocker ui
brindy Nov 5, 2017
132f47a
Merge branch 'develop' into feature/privacy_protection_dashboard
brindy Nov 5, 2017
0a537ac
remove content blocking toggle from settings
brindy Nov 5, 2017
e589b89
address PR feedback
brindy Nov 7, 2017
1fa54b0
more pr feedback and a rename, as discussed
brindy Nov 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add transition for showing privacy protection dashboard under omni bar
  • Loading branch information
brindy committed Oct 31, 2017
commit 22a19da6bf2f79d9f9f9de614585de76f499f186
4 changes: 1 addition & 3 deletions DuckDuckGo/OmniBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ class OmniBar: UIView {
return
}
resignFirstResponder()
if let omniDelegate = omniDelegate {
omniDelegate.onOmniQuerySubmitted(query)
}
omniDelegate?.onOmniQuerySubmitted(query)
}

@IBAction func onClearButtonPressed(_ sender: Any) {
Expand Down
24 changes: 12 additions & 12 deletions DuckDuckGo/PrivacyProtection.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HZv-0z-1Nb">
<rect key="frame" x="0.0" y="75" width="375" height="592"/>
<rect key="frame" x="0.0" y="72" width="375" height="595"/>
<connections>
<segue destination="5UB-cE-Uy8" kind="embed" id="oOS-0o-so6"/>
</connections>
Expand All @@ -41,10 +41,10 @@
<viewLayoutGuide key="safeArea" id="v6o-zV-ube"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Hcq-TC-0vO" userLabel="OmniBar">
<rect key="frame" x="0.0" y="20" width="375" height="55"/>
<rect key="frame" x="0.0" y="20" width="375" height="52"/>
<color key="backgroundColor" red="0.24313725489999999" green="0.25098039220000001" blue="0.27058823529999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="55" id="MNP-vb-ClV"/>
<constraint firstAttribute="height" constant="52" id="MNP-vb-ClV"/>
</constraints>
</view>
</subviews>
Expand Down Expand Up @@ -76,7 +76,7 @@
<objects>
<tableViewController id="7Z1-eg-OWQ" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" bounces="NO" alwaysBounceVertical="YES" dataMode="static" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="NNN-qG-D8F">
<rect key="frame" x="0.0" y="0.0" width="375" height="592"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="595"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<sections>
Expand All @@ -97,43 +97,43 @@
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="www.example.com" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JaN-4M-Ok5">
<rect key="frame" x="20" y="141" width="335" height="20"/>
<rect key="frame" x="20" y="141" width="335" height="23.5"/>
<fontDescription key="fontDescription" name="ProximaNova-Semibold" family="Proxima Nova" pointSize="20"/>
<color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="PRIVACY PROTECTION DISABLED" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sRe-LT-6q8">
<rect key="frame" x="20" y="174" width="335" height="12"/>
<rect key="frame" x="20" y="177.5" width="335" height="14"/>
<fontDescription key="fontDescription" name="ProximaNova-Bold" family="Proxima Nova" pointSize="12"/>
<color key="textColor" red="0.57647058823529407" green="0.57647058823529407" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="PRIVACY PROTECTION PAUSED" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fA2-W3-OZ9" userLabel="PRIVACY PROTECTION PAUSED">
<rect key="frame" x="20" y="174" width="335" height="12"/>
<rect key="frame" x="20" y="177.5" width="335" height="14"/>
<fontDescription key="fontDescription" name="ProximaNova-Bold" family="Proxima Nova" pointSize="12"/>
<color key="textColor" red="0.57647058819999997" green="0.57647058819999997" blue="0.57647058819999997" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7S0-gR-tO5" userLabel="UPGRADE FROM TO">
<rect key="frame" x="107.5" y="174" width="160" height="12"/>
<rect key="frame" x="107.5" y="177.5" width="160" height="12"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="UPGRADED FROM" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nRd-xQ-Adm" userLabel="UPGRADED FROM">
<rect key="frame" x="0.0" y="0.0" width="102.5" height="12"/>
<rect key="frame" x="0.0" y="0.0" width="104" height="14"/>
<fontDescription key="fontDescription" name="ProximaNova-Bold" family="Proxima Nova" pointSize="12"/>
<color key="textColor" red="0.57647058819999997" green="0.57647058819999997" blue="0.57647058819999997" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TO" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="K2B-4E-fgJ" userLabel="TO">
<rect key="frame" x="123.5" y="0.0" width="16" height="12"/>
<rect key="frame" x="125" y="0.0" width="16" height="14"/>
<fontDescription key="fontDescription" name="ProximaNova-Bold" family="Proxima Nova" pointSize="12"/>
<color key="textColor" red="0.57647058819999997" green="0.57647058819999997" blue="0.57647058819999997" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="inline-A" translatesAutoresizingMaskIntoConstraints="NO" id="rrS-VQ-J3G">
<rect key="frame" x="104.5" y="1" width="16" height="10"/>
<rect key="frame" x="106" y="2" width="16" height="10"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="inline-A" translatesAutoresizingMaskIntoConstraints="NO" id="OHa-Rw-ao0">
<rect key="frame" x="142.5" y="1" width="16" height="10"/>
<rect key="frame" x="144" y="2" width="16" height="10"/>
</imageView>
</subviews>
<constraints>
Expand Down
96 changes: 85 additions & 11 deletions DuckDuckGo/PrivacyProtectionDashboardController.swift
Original file line number Diff line number Diff line change
@@ -1,53 +1,127 @@
//
// PrivacyProtectionDashboard.swift
// PrivacyProtectionDashboardController.swift
// DuckDuckGo
//
// Created by Christopher Brind on 30/10/2017.
// Copyright © 2017 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import UIKit
import Core

class PrivacyProtectionDashboardController: UIViewController {

@IBOutlet weak var contentContainer: UIView!
@IBOutlet weak var omniBarContainer: UIView!

weak var omniDelegate: OmniBarDelegate!
weak var siteRating: SiteRating!

override func viewDidLoad() {
super.viewDidLoad()

transitioningDelegate = self

initOmniBar()
}

private func initOmniBar() {
let omniBar = OmniBar.loadFromXib()
omniBar.frame = omniBarContainer.bounds
omniBarContainer.addSubview(omniBar)
omniBar.refreshText(forUrl: siteRating.url)
omniBar.updateSiteRating(siteRating)
omniBar.startBrowsing()
omniBar.omniDelegate = self
}

}

extension PrivacyProtectionDashboardController: OmniBarDelegate {

func onOmniQueryUpdated(_ query: String) {
// no-op
}

func onOmniQuerySubmitted(_ query: String) {
dismiss(animated: true) {
self.omniDelegate.onOmniQuerySubmitted(query)
}
}

func onDismissed() {
// no-op
}

func onSiteRatingPressed() {
dismiss(animated: true)
}

func onMenuPressed() {
dismiss(animated: true) {
self.omniDelegate.onMenuPressed()
}
}

func onBookmarksPressed() {
// shouldn't get called
}

}

extension PrivacyProtectionDashboardController: UIViewControllerTransitioningDelegate {

func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return SlideInFromBelowOmniBarTransitioning()
}

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
return SlideUpBehindOmniBarTransitioning()
}

}

fileprivate struct AnimationConstants {
static let duration = 0.3
static let tyOffset = CGFloat(20.0)
}

class SlideInFromBelowOmniBarTransitioning: NSObject, UIViewControllerAnimatedTransitioning {
fileprivate class SlideUpBehindOmniBarTransitioning: NSObject, UIViewControllerAnimatedTransitioning {

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let containerView = transitionContext.containerView
guard let toController = transitionContext.viewController(forKey: .to) else { return }
guard let fromController = transitionContext.viewController(forKey: .from) as? PrivacyProtectionDashboardController else { return }

containerView.insertSubview(toController.view, at: 0)

struct Constants {
static let duration = 0.3
static let tyOffset = CGFloat(20.0)
UIView.animate(withDuration: AnimationConstants.duration, animations: {
fromController.contentContainer.transform.ty = -fromController.contentContainer.frame.size.height - fromController.omniBarContainer.frame.height - AnimationConstants.tyOffset
}, completion: { (value: Bool) in
transitionContext.completeTransition(true)
})
}

func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return AnimationConstants.duration
}

}

fileprivate class SlideInFromBelowOmniBarTransitioning: NSObject, UIViewControllerAnimatedTransitioning {

func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
let containerView = transitionContext.containerView
containerView.blur(style: .dark)

guard let toController = transitionContext.viewController(forKey: .to) as? PrivacyProtectionDashboardController else { return }

Expand All @@ -56,9 +130,9 @@ class SlideInFromBelowOmniBarTransitioning: NSObject, UIViewControllerAnimatedTr
let toColor = toController.view.backgroundColor
toController.view.backgroundColor = UIColor.clear

toController.contentContainer.transform.ty = -toController.contentContainer.frame.size.height - toController.omniBarContainer.frame.height - Constants.tyOffset
toController.contentContainer.transform.ty = -toController.contentContainer.frame.size.height - toController.omniBarContainer.frame.height - AnimationConstants.tyOffset

UIView.animate(withDuration: Constants.duration, animations: {
UIView.animate(withDuration: AnimationConstants.duration, animations: {
toController.contentContainer.transform.ty = 0
}, completion: { (value: Bool) in
toController.view.backgroundColor = toColor
Expand All @@ -67,7 +141,7 @@ class SlideInFromBelowOmniBarTransitioning: NSObject, UIViewControllerAnimatedTr
}

func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return Constants.duration
return AnimationConstants.duration
}

}
9 changes: 9 additions & 0 deletions DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ class TabViewController: WebViewController {
resetNavigationBar()
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

if let controller = segue.destination as? PrivacyProtectionDashboardController {
controller.omniDelegate = chromeDelegate.omniBar.omniDelegate
controller.siteRating = siteRating
}

}

private func addContentBlockerConfigurationObserver() {
NotificationCenter.default.addObserver(self, selector: #selector(onContentBlockerConfigurationChanged), name: ContentBlockerConfigurationChangedNotification.name, object: nil)
}
Expand Down
13 changes: 12 additions & 1 deletion DuckDuckGo/WhitelistManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
// WhitelistManager.swift
// DuckDuckGo
//
// Created by Christopher Brind on 19/10/2017.
// Copyright © 2017 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation

Expand Down