diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2021-11-04 10:53:22 +0100 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2021-11-04 10:53:22 +0100 |
| commit | 198861449e9aab65e6de496c3aa3eeaa4a89aefa (patch) | |
| tree | 14737b9da91d7dc786fbd28894a5a0b6aea7bcd8 | |
| parent | ab10241a35aa5fe59b9007bf781e86d69c22bba0 (diff) | |
| parent | 6d48300aef45d392f1c439fe3fb35b179164c11b (diff) | |
| download | mullvadvpn-198861449e9aab65e6de496c3aa3eeaa4a89aefa.tar.xz mullvadvpn-198861449e9aab65e6de496c3aa3eeaa4a89aefa.zip | |
Merge branch 'fix-rtl-crash'
| -rw-r--r-- | ios/MullvadVPN/AppButton.swift | 41 | ||||
| -rw-r--r-- | ios/MullvadVPN/Assets.xcassets/IconArrow.imageset/Contents.json | 9 | ||||
| -rw-r--r-- | ios/MullvadVPN/Assets.xcassets/IconExtlink.imageset/Contents.json | 13 | ||||
| -rw-r--r-- | ios/MullvadVPN/DisconnectSplitButton.swift | 14 | ||||
| -rw-r--r-- | ios/MullvadVPN/SettingsCell.swift | 1 | ||||
| -rw-r--r-- | ios/MullvadVPN/SpinnerActivityIndicatorView.swift | 9 | ||||
| -rw-r--r-- | ios/MullvadVPN/TranslucentButtonBlurView.swift | 10 |
7 files changed, 54 insertions, 43 deletions
diff --git a/ios/MullvadVPN/AppButton.swift b/ios/MullvadVPN/AppButton.swift index a22bf818b1..e6ff62a07f 100644 --- a/ios/MullvadVPN/AppButton.swift +++ b/ios/MullvadVPN/AppButton.swift @@ -50,7 +50,7 @@ private extension UIControl.State { } /// A subclass that implements the button that visually look like URL links on the web -@IBDesignable class LinkButton: CustomButton { +class LinkButton: CustomButton { override init(frame: CGRect) { super.init(frame: frame) @@ -97,7 +97,7 @@ private extension UIControl.State { } /// A subclass that implements action buttons used across the app -@IBDesignable class AppButton: CustomButton { +class AppButton: CustomButton { var defaultContentInsets: UIEdgeInsets { switch traitCollection.userInterfaceIdiom { @@ -132,9 +132,9 @@ private extension UIControl.State { case .translucentNeutral: return UIImage(named: "TranslucentNeutralButton") case .translucentDangerSplitLeft: - return UIImage(named: "TranslucentDangerSplitLeftButton") + return UIImage(named: "TranslucentDangerSplitLeftButton")?.imageFlippedForRightToLeftLayoutDirection() case .translucentDangerSplitRight: - return UIImage(named: "TranslucentDangerSplitRightButton") + return UIImage(named: "TranslucentDangerSplitRightButton")?.imageFlippedForRightToLeftLayoutDirection() } } } @@ -145,17 +145,6 @@ private extension UIControl.State { } } - @IBInspectable var interfaceBuilderStyle: Int { - get { - return self.style.rawValue - } - set { - if let style = Style(rawValue: newValue) { - self.style = style - } - } - } - var overrideContentEdgeInsets = false init(style: Style) { @@ -170,10 +159,8 @@ private extension UIControl.State { commonInit() } - required init?(coder aDecoder: NSCoder) { - style = .default - super.init(coder: aDecoder) - commonInit() + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") } private func commonInit() { @@ -228,7 +215,7 @@ private extension UIControl.State { } /// A custom `UIButton` subclass that implements additional layouts for the image -@IBDesignable class CustomButton: UIButton { +class CustomButton: UIButton { var imageAlignment: ButtonImageAlignment = .leading { didSet { @@ -353,6 +340,20 @@ private extension UIControl.State { titleRect.origin.x = contentRect.midX - titleRect.width * 0.5 imageRect.origin.x = titleRect.maxX + inlineImageSpacing + case (.right, .left): + titleRect.origin.x = contentRect.maxX - titleRect.width + imageRect.origin.x = titleRect.minX - imageRect.width - inlineImageSpacing + + case (.right, .leftFixed): + imageRect.origin.x = contentRect.minX + titleRect.origin.x = contentRect.maxX - titleRect.width + + case (.right, .rightFixed): + imageRect.origin.x = contentRect.maxX - imageRect.width + titleRect.origin.x = imageRect.width > 0 + ? imageRect.minX - inlineImageSpacing - titleRect.width + : contentRect.maxX - titleRect.width + default: fatalError() } diff --git a/ios/MullvadVPN/Assets.xcassets/IconArrow.imageset/Contents.json b/ios/MullvadVPN/Assets.xcassets/IconArrow.imageset/Contents.json index 6001465c6c..458e0814f2 100644 --- a/ios/MullvadVPN/Assets.xcassets/IconArrow.imageset/Contents.json +++ b/ios/MullvadVPN/Assets.xcassets/IconArrow.imageset/Contents.json @@ -1,15 +1,16 @@ { "images" : [ { + "filename" : "IconArrow.pdf", "idiom" : "universal", - "filename" : "IconArrow.pdf" + "language-direction" : "left-to-right" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 }, "properties" : { "preserves-vector-representation" : true } -}
\ No newline at end of file +} diff --git a/ios/MullvadVPN/Assets.xcassets/IconExtlink.imageset/Contents.json b/ios/MullvadVPN/Assets.xcassets/IconExtlink.imageset/Contents.json index fa42250c83..b95842ff5d 100644 --- a/ios/MullvadVPN/Assets.xcassets/IconExtlink.imageset/Contents.json +++ b/ios/MullvadVPN/Assets.xcassets/IconExtlink.imageset/Contents.json @@ -1,16 +1,17 @@ { "images" : [ { + "filename" : "IconExtlink.pdf", "idiom" : "universal", - "filename" : "IconExtlink.pdf" + "language-direction" : "left-to-right" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 }, "properties" : { - "template-rendering-intent" : "template", - "preserves-vector-representation" : true + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" } -}
\ No newline at end of file +} diff --git a/ios/MullvadVPN/DisconnectSplitButton.swift b/ios/MullvadVPN/DisconnectSplitButton.swift index 6f7c399c42..4a7f18a369 100644 --- a/ios/MullvadVPN/DisconnectSplitButton.swift +++ b/ios/MullvadVPN/DisconnectSplitButton.swift @@ -42,7 +42,7 @@ class DisconnectSplitButton: UIView { stackView.alignment = .fill stackView.spacing = 1 - secondaryButton.setImage(UIImage(named: "IconReload"), for: .normal) + secondaryButton.setImage(UIImage(named: "IconReload")?.imageFlippedForRightToLeftLayoutDirection(), for: .normal) primaryButton.overrideContentEdgeInsets = true secondaryButtonWidthConstraint = secondaryButton.widthAnchor.constraint(equalToConstant: 0) @@ -86,8 +86,16 @@ class DisconnectSplitButton: UIView { private func adjustTitleLabelPosition() { var contentInsets = primaryButton.defaultContentInsets - contentInsets.left = stackView.spacing + self.secondaryButtonSize.width - contentInsets.right = 0 + + let offset = stackView.spacing + self.secondaryButtonSize.width + + if case .leftToRight = effectiveUserInterfaceLayoutDirection { + contentInsets.left = offset + contentInsets.right = 0 + } else { + contentInsets.left = 0 + contentInsets.right = offset + } primaryButton.contentEdgeInsets = contentInsets } diff --git a/ios/MullvadVPN/SettingsCell.swift b/ios/MullvadVPN/SettingsCell.swift index 8e25b9c387..e1ee83f99e 100644 --- a/ios/MullvadVPN/SettingsCell.swift +++ b/ios/MullvadVPN/SettingsCell.swift @@ -104,6 +104,7 @@ class SettingsCell: UITableViewCell { let configuration = UIImage.SymbolConfiguration(pointSize: 11, weight: .bold) let chevron = UIImage(systemName: "chevron.right", withConfiguration: configuration)? .withTintColor(.white, renderingMode: .alwaysOriginal) + .imageFlippedForRightToLeftLayoutDirection() button.setImage(chevron, for: .normal) } else { diff --git a/ios/MullvadVPN/SpinnerActivityIndicatorView.swift b/ios/MullvadVPN/SpinnerActivityIndicatorView.swift index eed3b40b08..14bc1f5348 100644 --- a/ios/MullvadVPN/SpinnerActivityIndicatorView.swift +++ b/ios/MullvadVPN/SpinnerActivityIndicatorView.swift @@ -11,7 +11,7 @@ import UIKit private let kRotationAnimationKey = "rotation" private let kAnimationDuration = 0.6 -@IBDesignable class SpinnerActivityIndicatorView: UIView { +class SpinnerActivityIndicatorView: UIView { enum Style { case small, medium, large @@ -38,7 +38,7 @@ private let kAnimationDuration = 0.6 } /// Thickness of the front and back circles - @IBInspectable var thickness: CGFloat = 6 { + var thickness: CGFloat = 6 { didSet { setLayersThickness() } @@ -82,9 +82,8 @@ private let kAnimationDuration = 0.6 commonInit() } - required init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - commonInit() + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") } deinit { diff --git a/ios/MullvadVPN/TranslucentButtonBlurView.swift b/ios/MullvadVPN/TranslucentButtonBlurView.swift index 8146acd9a4..982e6f86dc 100644 --- a/ios/MullvadVPN/TranslucentButtonBlurView.swift +++ b/ios/MullvadVPN/TranslucentButtonBlurView.swift @@ -28,7 +28,7 @@ class TranslucentButtonBlurView: UIVisualEffectView { ]) layer.cornerRadius = kButtonCornerRadius - layer.maskedCorners = button.style.cornerMask + layer.maskedCorners = button.style.cornerMask(effectiveUserInterfaceLayoutDirection) layer.masksToBounds = true } @@ -38,11 +38,11 @@ class TranslucentButtonBlurView: UIVisualEffectView { } private extension AppButton.Style { - var cornerMask: CACornerMask { - switch self { - case .translucentDangerSplitLeft: + func cornerMask(_ userInterfaceLayoutDirection: UIUserInterfaceLayoutDirection) -> CACornerMask { + switch (self, userInterfaceLayoutDirection) { + case (.translucentDangerSplitLeft, .leftToRight), (.translucentDangerSplitRight, .rightToLeft): return [.layerMinXMinYCorner, .layerMinXMaxYCorner] - case .translucentDangerSplitRight: + case (.translucentDangerSplitRight, .leftToRight), (.translucentDangerSplitLeft, .rightToLeft): return [.layerMaxXMinYCorner, .layerMaxXMaxYCorner] default: return [ |
