summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-08-19 13:51:59 +0200
committerAndrej Mihajlov <and@mullvad.net>2020-08-19 13:51:59 +0200
commitc154ceeffa26a7694ed802f4e844cb9c00909a02 (patch)
tree261be2dde17ed7dac00443b68b255e3b64ad8c0e
parent31eb2a41a9fec39f121ec891aee96200fd7990d7 (diff)
parent9a3b840dda18eea9db5441f117663ac278ee3707 (diff)
downloadmullvadvpn-c154ceeffa26a7694ed802f4e844cb9c00909a02.tar.xz
mullvadvpn-c154ceeffa26a7694ed802f4e844cb9c00909a02.zip
Merge branch 'remove-button-blur'
-rw-r--r--ios/MullvadVPN.xcodeproj/project.pbxproj4
-rw-r--r--ios/MullvadVPN/AppButton.swift10
-rw-r--r--ios/MullvadVPN/ConnectViewController.swift39
-rw-r--r--ios/MullvadVPN/DisconnectSplitButton.swift63
-rw-r--r--ios/MullvadVPN/DisconnectSplitButton.xib101
5 files changed, 56 insertions, 161 deletions
diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj
index f5516375e0..cab698a459 100644
--- a/ios/MullvadVPN.xcodeproj/project.pbxproj
+++ b/ios/MullvadVPN.xcodeproj/project.pbxproj
@@ -118,7 +118,6 @@
5888AD87227B17950051EB06 /* SelectLocationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5888AD86227B17950051EB06 /* SelectLocationController.swift */; };
588D2FE3248AC27F00E313F7 /* AsyncOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58E973DD24850EB600096F90 /* AsyncOperation.swift */; };
58906DE02445C7A5002F0673 /* NEProviderStopReason+Debug.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58906DDF2445C7A5002F0673 /* NEProviderStopReason+Debug.swift */; };
- 58907D9324D167B400CFC3F5 /* DisconnectSplitButton.xib in Resources */ = {isa = PBXBuildFile; fileRef = 58907D9224D167B400CFC3F5 /* DisconnectSplitButton.xib */; };
58907D9524D17B4E00CFC3F5 /* DisconnectSplitButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58907D9424D17B4E00CFC3F5 /* DisconnectSplitButton.swift */; };
5896AE7E246ACE65005B36CB /* KeychainAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58FAEDEB245059F000CB0F5B /* KeychainAttributes.swift */; };
5896AE7F246ACE76005B36CB /* Keychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58FAEDF6245088E100CB0F5B /* Keychain.swift */; };
@@ -320,7 +319,6 @@
5888AD82227B11080051EB06 /* SelectLocationCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectLocationCell.swift; sourceTree = "<group>"; };
5888AD86227B17950051EB06 /* SelectLocationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectLocationController.swift; sourceTree = "<group>"; };
58906DDF2445C7A5002F0673 /* NEProviderStopReason+Debug.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NEProviderStopReason+Debug.swift"; sourceTree = "<group>"; };
- 58907D9224D167B400CFC3F5 /* DisconnectSplitButton.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DisconnectSplitButton.xib; sourceTree = "<group>"; };
58907D9424D17B4E00CFC3F5 /* DisconnectSplitButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisconnectSplitButton.swift; sourceTree = "<group>"; };
5894E725236B2801008A2793 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
5896AE83246D5889005B36CB /* CustomDateComponentsFormatting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomDateComponentsFormatting.swift; sourceTree = "<group>"; };
@@ -548,7 +546,6 @@
582BB1B0229569620055B6EF /* CustomNavigationBar.swift */,
58C6B35D22BBBFE3003C19AD /* Data+HexCoding.swift */,
58907D9424D17B4E00CFC3F5 /* DisconnectSplitButton.swift */,
- 58907D9224D167B400CFC3F5 /* DisconnectSplitButton.xib */,
58B9EB142489139B00095626 /* DisplayChainedError.swift */,
5873884C239E6D7E00E96C4E /* EmbeddedViewContainerView.swift */,
58F3C0A3249CB069003E76BE /* HeaderBarView.swift */,
@@ -844,7 +841,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 58907D9324D167B400CFC3F5 /* DisconnectSplitButton.xib in Resources */,
58F3C0A624A50157003E76BE /* relays.json in Resources */,
58CE5E6E224146210008646E /* LaunchScreen.storyboard in Resources */,
58CE5E6B224146210008646E /* Assets.xcassets in Resources */,
diff --git a/ios/MullvadVPN/AppButton.swift b/ios/MullvadVPN/AppButton.swift
index 6a58100c25..ac0fba7b04 100644
--- a/ios/MullvadVPN/AppButton.swift
+++ b/ios/MullvadVPN/AppButton.swift
@@ -129,7 +129,7 @@ private extension UIControl.State {
}
}
- var style: Style = .default {
+ var style: Style {
didSet {
updateButtonBackground()
}
@@ -146,12 +146,20 @@ private extension UIControl.State {
}
}
+ init(style: Style) {
+ self.style = style
+ super.init(frame: .zero)
+ commonInit()
+ }
+
override init(frame: CGRect) {
+ style = .default
super.init(frame: frame)
commonInit()
}
required init?(coder aDecoder: NSCoder) {
+ style = .default
super.init(coder: aDecoder)
commonInit()
}
diff --git a/ios/MullvadVPN/ConnectViewController.swift b/ios/MullvadVPN/ConnectViewController.swift
index 16eafc26c9..5b36d20932 100644
--- a/ios/MullvadVPN/ConnectViewController.swift
+++ b/ios/MullvadVPN/ConnectViewController.swift
@@ -21,10 +21,9 @@ class ConnectViewController: UIViewController, RootContainment, TunnelObserver,
private let logger = Logger(label: "ConnectViewController")
- private let connectButton = makeButton(style: .success)
- private let selectLocationButton = makeButton(style: .translucentNeutral)
- private lazy var selectLocationBlurView = Self.makeBlurButton(button: selectLocationButton)
- private let splitDisconnectButtonView = DisconnectSplitButton(bundle: nil)
+ private let connectButton = AppButton(style: .success)
+ private let selectLocationButton = AppButton(style: .translucentNeutral)
+ private let splitDisconnectButtonView = DisconnectSplitButton()
private let alertPresenter = AlertPresenter()
@@ -60,6 +59,10 @@ class ConnectViewController: UIViewController, RootContainment, TunnelObserver,
override func viewDidLoad() {
super.viewDidLoad()
+ for button in [connectButton, selectLocationButton] {
+ button.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
+ }
+
connectionPanel.collapseButton.addTarget(self, action: #selector(handleConnectionPanelButton(_:)), for: .touchUpInside)
connectButton.addTarget(self, action: #selector(handleConnect(_:)), for: .touchUpInside)
splitDisconnectButtonView.primaryButton.addTarget(self, action: #selector(handleDisconnect(_:)), for: .touchUpInside)
@@ -118,47 +121,25 @@ class ConnectViewController: UIViewController, RootContainment, TunnelObserver,
// MARK: - Private
- private class func makeBlurButton(button: AppButton) -> UIView {
- let effectView = TranslucentButtonBlurView(effect: UIBlurEffect(style: .light))
- effectView.contentView.addSubview(button)
-
- NSLayoutConstraint.activate([
- button.topAnchor.constraint(equalTo: effectView.contentView.topAnchor),
- button.leadingAnchor.constraint(equalTo: effectView.contentView.leadingAnchor),
- button.trailingAnchor.constraint(equalTo: effectView.contentView.trailingAnchor),
- button.bottomAnchor.constraint(equalTo: effectView.contentView.bottomAnchor)
- ])
-
- return effectView
- }
-
- private class func makeButton(style: AppButton.Style) -> AppButton {
- let button = AppButton(type: .custom)
- button.style = style
- button.translatesAutoresizingMaskIntoConstraints = false
- button.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
- return button
- }
-
private func updateButtons() {
switch tunnelState {
case .disconnected:
selectLocationButton.setTitle(NSLocalizedString("Select location", comment: ""), for: .normal)
connectButton.setTitle(NSLocalizedString("Secure connection", comment: ""), for: .normal)
- setArrangedButtons([selectLocationBlurView, connectButton])
+ setArrangedButtons([selectLocationButton, connectButton])
case .connecting:
selectLocationButton.setTitle(NSLocalizedString("Switch location", comment: ""), for: .normal)
splitDisconnectButtonView.primaryButton.setTitle(NSLocalizedString("Cancel", comment: ""), for: .normal)
- setArrangedButtons([selectLocationBlurView, splitDisconnectButtonView])
+ setArrangedButtons([selectLocationButton, splitDisconnectButtonView])
case .connected, .reconnecting, .disconnecting:
selectLocationButton.setTitle(NSLocalizedString("Switch location", comment: ""), for: .normal)
splitDisconnectButtonView.primaryButton.setTitle(NSLocalizedString("Disconnect", comment: ""), for: .normal)
- setArrangedButtons([selectLocationBlurView, splitDisconnectButtonView])
+ setArrangedButtons([selectLocationButton, splitDisconnectButtonView])
}
}
diff --git a/ios/MullvadVPN/DisconnectSplitButton.swift b/ios/MullvadVPN/DisconnectSplitButton.swift
index a52d4e0af1..61ac11579a 100644
--- a/ios/MullvadVPN/DisconnectSplitButton.swift
+++ b/ios/MullvadVPN/DisconnectSplitButton.swift
@@ -9,49 +9,60 @@
import Foundation
import UIKit
-private let kSplitSeparatorWidth = CGFloat(1)
-
class DisconnectSplitButton: UIView {
- @IBOutlet var contentView: UIView!
- @IBOutlet var primaryButton: AppButton!
- @IBOutlet var secondaryButton: AppButton!
+ let primaryButton = AppButton(style: .translucentDangerSplitLeft)
+ var secondaryButton = AppButton(style: .translucentDangerSplitRight)
+
+ private let stackView: UIStackView
private var secondaryButtonObserver: NSObjectProtocol?
- init(bundle: Bundle?) {
- super.init(frame: .zero)
+ init() {
+ stackView = UIStackView(arrangedSubviews: [primaryButton, secondaryButton])
+ stackView.translatesAutoresizingMaskIntoConstraints = false
+ stackView.axis = .horizontal
+ stackView.distribution = .fill
+ stackView.alignment = .fill
+ stackView.spacing = 1
- loadFromNib(bundle: bundle)
- }
+ primaryButton.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
+ primaryButton.setContentHuggingPriority(.defaultLow, for: .horizontal)
+ primaryButton.setContentHuggingPriority(.defaultLow, for: .vertical)
+ primaryButton.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
+ primaryButton.setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
+ secondaryButton.setImage(UIImage(named: "IconReload"), for: .normal)
+ secondaryButton.setContentHuggingPriority(.defaultHigh, for: .horizontal)
+ secondaryButton.setContentHuggingPriority(.defaultHigh, for: .vertical)
+ secondaryButton.setContentCompressionResistancePriority(UILayoutPriority(50), for: .horizontal)
+ secondaryButton.setContentCompressionResistancePriority(UILayoutPriority(50), for: .vertical)
- private func loadFromNib(bundle: Bundle?) {
- let nib = UINib(nibName: "DisconnectSplitButton", bundle: bundle)
- _ = nib.instantiate(withOwner: self, options: nil)
+ super.init(frame: .zero)
- primaryButton.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold)
+ addSubview(stackView)
- contentView.translatesAutoresizingMaskIntoConstraints = false
- addSubview(contentView)
+ secondaryButtonObserver = secondaryButton.observe(\.bounds, options: [.new]) { [weak self] (button, change) in
+ self?.adjustTitleLabelPosition()
+ }
NSLayoutConstraint.activate([
- contentView.leadingAnchor.constraint(equalTo: leadingAnchor),
- contentView.trailingAnchor.constraint(equalTo: trailingAnchor),
- contentView.topAnchor.constraint(equalTo: topAnchor),
- contentView.bottomAnchor.constraint(equalTo: bottomAnchor)
+ stackView.leadingAnchor.constraint(equalTo: leadingAnchor),
+ stackView.trailingAnchor.constraint(equalTo: trailingAnchor),
+ stackView.topAnchor.constraint(equalTo: topAnchor),
+ stackView.bottomAnchor.constraint(equalTo: bottomAnchor),
+
+ primaryButton.heightAnchor.constraint(equalTo: secondaryButton.heightAnchor),
+ secondaryButton.widthAnchor.constraint(equalTo: secondaryButton.heightAnchor)
])
+ }
- secondaryButtonObserver = secondaryButton.observe(\.bounds, options: [.new]) { [weak self] (button, change) in
- self?.adjustTitleLabelPosition()
- }
+ required init?(coder: NSCoder) {
+ fatalError("init(coder:) has not been implemented")
}
private func adjustTitleLabelPosition() {
var contentInsets = AppButton.defaultContentInsets
- contentInsets.left = secondaryButton.frame.width + kSplitSeparatorWidth
+ contentInsets.left = secondaryButton.frame.width + stackView.spacing
contentInsets.right = 0
primaryButton.contentEdgeInsets = contentInsets
diff --git a/ios/MullvadVPN/DisconnectSplitButton.xib b/ios/MullvadVPN/DisconnectSplitButton.xib
deleted file mode 100644
index 6b160f829b..0000000000
--- a/ios/MullvadVPN/DisconnectSplitButton.xib
+++ /dev/null
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
- <device id="retina6_1" orientation="portrait" appearance="light"/>
- <dependencies>
- <deployment identifier="iOS"/>
- <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
- <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
- </dependencies>
- <objects>
- <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="DisconnectSplitButton" customModule="MullvadVPN" customModuleProvider="target">
- <connections>
- <outlet property="contentView" destination="iN0-l3-epB" id="l9N-3B-7an"/>
- <outlet property="primaryButton" destination="PD0-Fv-22K" id="dSp-cI-IXZ"/>
- <outlet property="secondaryButton" destination="2ka-zL-tZX" id="U5c-9n-CJD"/>
- </connections>
- </placeholder>
- <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
- <view contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="iN0-l3-epB">
- <rect key="frame" x="0.0" y="0.0" width="420" height="50"/>
- <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
- <subviews>
- <stackView opaque="NO" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" spacing="1" translatesAutoresizingMaskIntoConstraints="NO" id="LYA-qF-TWz">
- <rect key="frame" x="0.0" y="0.0" width="420" height="50"/>
- <subviews>
- <visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gDt-Zi-SNP" customClass="TranslucentButtonBlurView" customModule="MullvadVPN" customModuleProvider="target">
- <rect key="frame" x="0.0" y="0.0" width="369" height="50"/>
- <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="Z5z-dl-BIA">
- <rect key="frame" x="0.0" y="0.0" width="369" height="50"/>
- <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
- <subviews>
- <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PD0-Fv-22K" userLabel="Primary Button" customClass="AppButton" customModule="MullvadVPN" customModuleProvider="target">
- <rect key="frame" x="0.0" y="0.0" width="369" height="50"/>
- <fontDescription key="fontDescription" type="system" weight="semibold" pointSize="18"/>
- <state key="normal" title="Button"/>
- <userDefinedRuntimeAttributes>
- <userDefinedRuntimeAttribute type="number" keyPath="interfaceBuilderStyle">
- <integer key="value" value="5"/>
- </userDefinedRuntimeAttribute>
- </userDefinedRuntimeAttributes>
- </button>
- </subviews>
- <constraints>
- <constraint firstAttribute="trailing" secondItem="PD0-Fv-22K" secondAttribute="trailing" id="0sb-IJ-x0M"/>
- <constraint firstItem="PD0-Fv-22K" firstAttribute="leading" secondItem="Z5z-dl-BIA" secondAttribute="leading" id="Ah6-1f-VuI"/>
- <constraint firstItem="PD0-Fv-22K" firstAttribute="top" secondItem="Z5z-dl-BIA" secondAttribute="top" id="gfC-T2-1NN"/>
- <constraint firstAttribute="bottom" secondItem="PD0-Fv-22K" secondAttribute="bottom" id="nto-wB-nPC"/>
- </constraints>
- </view>
- <blurEffect style="regular"/>
- </visualEffectView>
- <visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XyY-R3-ytQ" customClass="TranslucentButtonBlurView" customModule="MullvadVPN" customModuleProvider="target">
- <rect key="frame" x="370" y="0.0" width="50" height="50"/>
- <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="N0x-Hd-Pi6">
- <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
- <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
- <subviews>
- <button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" horizontalCompressionResistancePriority="50" verticalCompressionResistancePriority="50" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="2ka-zL-tZX" userLabel="Secondary Button" customClass="AppButton" customModule="MullvadVPN" customModuleProvider="target">
- <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
- <constraints>
- <constraint firstAttribute="width" secondItem="2ka-zL-tZX" secondAttribute="height" multiplier="1:1" id="oBq-BR-iqo"/>
- </constraints>
- <state key="normal" title="Button" image="IconReload"/>
- <userDefinedRuntimeAttributes>
- <userDefinedRuntimeAttribute type="number" keyPath="interfaceBuilderStyle">
- <integer key="value" value="6"/>
- </userDefinedRuntimeAttribute>
- </userDefinedRuntimeAttributes>
- </button>
- </subviews>
- <constraints>
- <constraint firstAttribute="bottom" secondItem="2ka-zL-tZX" secondAttribute="bottom" id="3Sh-gX-GkA"/>
- <constraint firstItem="2ka-zL-tZX" firstAttribute="leading" secondItem="N0x-Hd-Pi6" secondAttribute="leading" id="6ts-lS-vm6"/>
- <constraint firstItem="2ka-zL-tZX" firstAttribute="top" secondItem="N0x-Hd-Pi6" secondAttribute="top" id="8HK-t6-YVW"/>
- <constraint firstAttribute="trailing" secondItem="2ka-zL-tZX" secondAttribute="trailing" id="rvn-tI-FOp"/>
- </constraints>
- </view>
- <blurEffect style="regular"/>
- </visualEffectView>
- </subviews>
- <constraints>
- <constraint firstItem="2ka-zL-tZX" firstAttribute="height" secondItem="PD0-Fv-22K" secondAttribute="height" id="3cN-0n-7HF"/>
- </constraints>
- </stackView>
- </subviews>
- <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
- <constraints>
- <constraint firstItem="LYA-qF-TWz" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="2kj-go-VNG"/>
- <constraint firstAttribute="bottom" secondItem="LYA-qF-TWz" secondAttribute="bottom" id="C7Z-zY-N4F"/>
- <constraint firstAttribute="trailing" secondItem="LYA-qF-TWz" secondAttribute="trailing" id="L01-AG-HOt"/>
- <constraint firstItem="LYA-qF-TWz" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="d9k-Gy-lnD"/>
- </constraints>
- <nil key="simulatedTopBarMetrics"/>
- <nil key="simulatedBottomBarMetrics"/>
- <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
- <point key="canvasLocation" x="142.02898550724638" y="-25.446428571428569"/>
- </view>
- </objects>
- <resources>
- <image name="IconReload" width="512" height="512"/>
- </resources>
-</document>