This repository has been archived by the owner. It is now read-only.
Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
239 additions
and 42 deletions.
- +4 −0 Client.xcodeproj/project.pbxproj
- +9 −1 Cliqz/Extensions/BrowserViewController/Privacy.swift
- +6 −0 Cliqz/Extensions/StringExtension.swift
- +17 −0 Cliqz/HomePanel/VPN/VPNCountryController.swift
- +107 −0 Cliqz/HomePanel/VPN/VPNInfoView.swift
- +40 −31 Cliqz/HomePanel/VPN/VPNViewController.swift
- +23 −0 Cliqz/Resources/Paid.xcassets/VPN/Protection_X.imageset/Contents.json
- BIN Cliqz/Resources/Paid.xcassets/VPN/Protection_X.imageset/Protection_X.png
- BIN Cliqz/Resources/Paid.xcassets/VPN/Protection_X.imageset/Protection_X@2x.png
- BIN Cliqz/Resources/Paid.xcassets/VPN/Protection_X.imageset/Protection_X@3x.png
- +23 −0 Cliqz/Resources/Paid.xcassets/VPN/VPN_Checkmark.imageset/Contents.json
- BIN Cliqz/Resources/Paid.xcassets/VPN/VPN_Checkmark.imageset/VPN_Checkmark.png
- BIN Cliqz/Resources/Paid.xcassets/VPN/VPN_Checkmark.imageset/VPN_Checkmark@2x.png
- BIN Cliqz/Resources/Paid.xcassets/VPN/VPN_Checkmark.imageset/VPN_Checkmark@3x.png
- +9 −5 Cliqz/Upgrade&Payment/View/ButtonWithUnderlinedText.swift
- +1 −5 Podfile.lock
| @@ -0,0 +1,107 @@ | ||
| // | ||
| // VPNInfoView.swift | ||
| // Client | ||
| // | ||
| // Created by Mahmoud Adam on 4/1/19. | ||
| // Copyright © 2019 Cliqz. All rights reserved. | ||
| // | ||
| import UIKit | ||
|
|
||
| class UILabelWithIcon: UIView { | ||
| let label = UILabel() | ||
| let iconView = UIImageView() | ||
| let font = UIFont.systemFont(ofSize: 18, weight: .medium) | ||
| var width: CGFloat = 0 | ||
|
|
||
| init(text: String, icon: UIImage? = nil) { | ||
| super.init(frame: CGRect.zero) | ||
| self.label.text = text | ||
| self.label.font = font | ||
| self.label.textAlignment = .center | ||
|
|
||
| self.addSubview(label) | ||
| self.addSubview(iconView) | ||
|
|
||
| setConstrains(text.width(usingFont: font) + 10) | ||
| self.updateIcon(icon) | ||
| } | ||
|
|
||
| func setConstrains(_ textWidth: CGFloat) { | ||
| width = textWidth + 11 | ||
| label.snp.makeConstraints { (make) in | ||
| make.centerY.trailing.equalToSuperview() | ||
| make.width.equalTo(textWidth) | ||
| } | ||
|
|
||
| iconView.snp.makeConstraints { (make) in | ||
| make.centerY.leading.equalToSuperview() | ||
| make.size.equalTo(11) | ||
| } | ||
| } | ||
|
|
||
| func updateIcon( _ icon: UIImage?) { | ||
| self.iconView.image = icon | ||
| } | ||
|
|
||
| func updateTextColor(_ textColor: UIColor) { | ||
| label.textColor = textColor | ||
| } | ||
|
|
||
|
|
||
| required init?(coder aDecoder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
| } | ||
|
|
||
| class VPNInfoView: UIView { | ||
|
|
||
| let vpnInfoLabel1 = UILabelWithIcon(text: NSLocalizedString("Protection from hackers", tableName: "Lumen", comment: "[VPN] Protection from hackers")) | ||
| let vpnInfoLabel2 = UILabelWithIcon(text: NSLocalizedString("Video streaming from other countries", tableName: "Lumen", comment: "[VPN] Video streaming from other countries")) | ||
|
|
||
|
|
||
| init() { | ||
| super.init(frame: CGRect.zero) | ||
| self.addSubview(vpnInfoLabel1) | ||
| self.addSubview(vpnInfoLabel2) | ||
| setConstrains() | ||
| } | ||
|
|
||
| required init?(coder aDecoder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| func updateView(_ isVPNConnected: Bool) { | ||
| if isVPNConnected { | ||
| vpnInfoLabel1.updateTextColor(UIColor.white) | ||
| vpnInfoLabel1.updateIcon(UIImage(named: "VPN_Checkmark")) | ||
|
|
||
| vpnInfoLabel2.updateTextColor(UIColor.white) | ||
| vpnInfoLabel2.updateIcon(UIImage(named: "VPN_Checkmark")) | ||
|
|
||
| } else { | ||
| vpnInfoLabel1.updateTextColor(UIColor.gray) | ||
| vpnInfoLabel1.updateIcon(UIImage(named: "Protection_X")) | ||
|
|
||
| vpnInfoLabel2.updateTextColor(UIColor.gray) | ||
| vpnInfoLabel2.updateIcon(UIImage(named: "Protection_X")) | ||
| } | ||
| } | ||
|
|
||
| private func setConstrains() { | ||
| vpnInfoLabel1.snp.makeConstraints { (make) in | ||
| make.centerX.equalToSuperview() | ||
| make.centerY.equalToSuperview().offset(-15) | ||
| make.height.equalTo(20) | ||
| make.width.equalTo(vpnInfoLabel1.width) | ||
| } | ||
|
|
||
| vpnInfoLabel2.snp.makeConstraints { (make) in | ||
| make.centerX.equalToSuperview() | ||
| make.centerY.equalToSuperview().offset(15) | ||
| make.height.equalTo(20) | ||
| make.width.equalTo(vpnInfoLabel2.width) | ||
| } | ||
| } | ||
|
|
||
| } |
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "Protection_X.png", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "Protection_X@2x.png", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "idiom" : "universal", | ||
| "filename" : "Protection_X@3x.png", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "version" : 1, | ||
| "author" : "xcode" | ||
| } | ||
| } |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.