Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace PDFs with SVGs from desktop/.../assets where available #7761

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 10 additions & 2 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
0697D6E728F01513007A9E99 /* TransportMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0697D6E628F01513007A9E99 /* TransportMonitor.swift */; };
06AC116228F94C450037AF9A /* ApplicationConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58BFA5CB22A7CE1F00A6173D /* ApplicationConfiguration.swift */; };
44075DFB2CDA4F7400F61139 /* UDPOverTCPObfuscationSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44075DFA2CDA4F7400F61139 /* UDPOverTCPObfuscationSettingsViewModel.swift */; };
440870822D7A00B70038972F /* UIImage+Assets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440870812D7A00B00038972F /* UIImage+Assets.swift */; };
440870832D809B550038972F /* UIImage+Assets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440870812D7A00B00038972F /* UIImage+Assets.swift */; };
440870842D809C980038972F /* UIImage+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = F062000B2CB7EB5D002E6DB9 /* UIImage+Helpers.swift */; };
440E5AB02CDBD67D00B09614 /* StatefulPreviewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440E5AAF2CDBD67D00B09614 /* StatefulPreviewWrapper.swift */; };
440E5AB42CDCF24500B09614 /* TunnelObfuscationSettingsWatchingObservableObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440E5AB32CDCF24500B09614 /* TunnelObfuscationSettingsWatchingObservableObject.swift */; };
4419AA8B2D2826E5001B13C9 /* DetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4419AA8A2D2826E5001B13C9 /* DetailsView.swift */; };
Expand Down Expand Up @@ -630,10 +633,10 @@
7A9CCCC32A96302800DD6A34 /* ApplicationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9CCCB12A96302800DD6A34 /* ApplicationCoordinator.swift */; };
7A9CCCC42A96302800DD6A34 /* TunnelCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9CCCB22A96302800DD6A34 /* TunnelCoordinator.swift */; };
7A9F28FC2CA69D0C005F2089 /* DAITASettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9F28FB2CA69D04005F2089 /* DAITASettingsTests.swift */; };
7A9F29352CAA8829005F2089 /* AccessMethodsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9F29342CAA8823005F2089 /* AccessMethodsTests.swift */; };
7A9F29392CABFAFC005F2089 /* InfoHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9F29382CABFAEC005F2089 /* InfoHeaderView.swift */; };
7A9F293B2CAC4443005F2089 /* InfoHeaderConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9F293A2CAC4420005F2089 /* InfoHeaderConfig.swift */; };
7A9F293D2CAD2FD5005F2089 /* InfoModalConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9F293C2CAD2FCF005F2089 /* InfoModalConfig.swift */; };
7A9F29352CAA8829005F2089 /* AccessMethodsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9F29342CAA8823005F2089 /* AccessMethodsTests.swift */; };
7A9FA1422A2E3306000B728D /* CheckboxView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9FA1412A2E3306000B728D /* CheckboxView.swift */; };
7A9FA1442A2E3FE5000B728D /* CheckableSettingsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9FA1432A2E3FE5000B728D /* CheckableSettingsCell.swift */; };
7AA130992CFF365D00640DF9 /* ConnectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AA130982CFF365A00640DF9 /* ConnectionView.swift */; };
Expand Down Expand Up @@ -1592,6 +1595,7 @@
06FAE67B28F83CA50033DD93 /* REST.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = REST.swift; sourceTree = "<group>"; };
06FAE67D28F83CA50033DD93 /* RESTTransport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RESTTransport.swift; sourceTree = "<group>"; };
44075DFA2CDA4F7400F61139 /* UDPOverTCPObfuscationSettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UDPOverTCPObfuscationSettingsViewModel.swift; sourceTree = "<group>"; };
440870812D7A00B00038972F /* UIImage+Assets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIImage+Assets.swift"; sourceTree = "<group>"; };
440E5AAF2CDBD67D00B09614 /* StatefulPreviewWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatefulPreviewWrapper.swift; sourceTree = "<group>"; };
440E5AB32CDCF24500B09614 /* TunnelObfuscationSettingsWatchingObservableObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelObfuscationSettingsWatchingObservableObject.swift; sourceTree = "<group>"; };
4419AA8A2D2826E5001B13C9 /* DetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2146,10 +2150,10 @@
7A9CCCB12A96302800DD6A34 /* ApplicationCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplicationCoordinator.swift; sourceTree = "<group>"; };
7A9CCCB22A96302800DD6A34 /* TunnelCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TunnelCoordinator.swift; sourceTree = "<group>"; };
7A9F28FB2CA69D04005F2089 /* DAITASettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DAITASettingsTests.swift; sourceTree = "<group>"; };
7A9F29342CAA8823005F2089 /* AccessMethodsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessMethodsTests.swift; sourceTree = "<group>"; };
7A9F29382CABFAEC005F2089 /* InfoHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoHeaderView.swift; sourceTree = "<group>"; };
7A9F293A2CAC4420005F2089 /* InfoHeaderConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoHeaderConfig.swift; sourceTree = "<group>"; };
7A9F293C2CAD2FCF005F2089 /* InfoModalConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoModalConfig.swift; sourceTree = "<group>"; };
7A9F29342CAA8823005F2089 /* AccessMethodsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessMethodsTests.swift; sourceTree = "<group>"; };
7A9FA1412A2E3306000B728D /* CheckboxView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxView.swift; sourceTree = "<group>"; };
7A9FA1432A2E3FE5000B728D /* CheckableSettingsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckableSettingsCell.swift; sourceTree = "<group>"; };
7AA130982CFF365A00640DF9 /* ConnectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3331,6 +3335,7 @@
5891BF5025E66B1E006D6FB0 /* UIBarButtonItem+KeyboardNavigation.swift */,
587CBFE222807F530028DED3 /* UIColor+Helpers.swift */,
7ABE318C2A1CDD4500DF4963 /* UIFont+Weight.swift */,
440870812D7A00B00038972F /* UIImage+Assets.swift */,
F062000B2CB7EB5D002E6DB9 /* UIImage+Helpers.swift */,
58CEB2FA2AFD13E600E6E088 /* UIListContentConfiguration+Extensions.swift */,
58CEB2FC2AFD19D300E6E088 /* UITableView+ReuseIdentifier.swift */,
Expand Down Expand Up @@ -5833,6 +5838,7 @@
A9A5F9F32ACB05160083449F /* AccountExpirySystemNotificationProvider.swift in Sources */,
A9A5F9F52ACB05160083449F /* NewDeviceNotificationProvider.swift in Sources */,
F09D04B72AE941DA003D4F89 /* OutgoingConnectionProxyTests.swift in Sources */,
440870832D809B550038972F /* UIImage+Assets.swift in Sources */,
F09D04B92AE95111003D4F89 /* OutgoingConnectionProxy.swift in Sources */,
7A6000F92B6273A4001CF0D9 /* AccessMethodViewModel.swift in Sources */,
7ABFB09E2BA316220074A49E /* RelayConstraintsTests.swift in Sources */,
Expand Down Expand Up @@ -5924,6 +5930,7 @@
44DD7D242B6CFFD70005F67F /* StartTunnelOperationTests.swift in Sources */,
44BB5F982BE527F4002520EB /* TunnelState+UI.swift in Sources */,
A9A5FA2B2ACB05160083449F /* CustomDateComponentsFormattingTests.swift in Sources */,
440870842D809C980038972F /* UIImage+Helpers.swift in Sources */,
A9A5FA2C2ACB05160083449F /* DeviceCheckOperationTests.swift in Sources */,
A9A5FA2D2ACB05160083449F /* DurationTests.swift in Sources */,
A9A5FA2E2ACB05160083449F /* FileCacheTests.swift in Sources */,
Expand Down Expand Up @@ -6171,6 +6178,7 @@
F062000C2CB7EB5D002E6DB9 /* UIImage+Helpers.swift in Sources */,
F910A4012D3FF23A002FF3BB /* View+Modifier.swift in Sources */,
7A6389EB2B7FAD7A008E77E1 /* SettingsFieldValidationErrorContentView.swift in Sources */,
440870822D7A00B70038972F /* UIImage+Assets.swift in Sources */,
7A8A19282CF603EB000BCB5B /* SettingsViewControllerFactory.swift in Sources */,
58B26E2A2943545A00D5980C /* NotificationManagerDelegate.swift in Sources */,
7A8A19072CE4E9D3000BCB5B /* SettingsInfoView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ extension UINavigationBar {
}

private func makeNavigationBarAppearance(isTransparent: Bool) -> UINavigationBarAppearance {
let backIndicatorImage = UIImage(named: "IconBack")?.withTintColor(
let backIndicatorImage = UIImage.Buttons.back.withTintColor(
UIColor.NavigationBar.buttonColor,
renderingMode: .alwaysOriginal
)
let backIndicatorTransitionMask = UIImage(named: "IconBackTransitionMask")
let backIndicatorTransitionMask = UIImage.backTransitionMask

let titleTextAttributes: [NSAttributedString.Key: Any] = [
.foregroundColor: UIColor.NavigationBar.titleColor,
Expand Down
11 changes: 9 additions & 2 deletions ios/MullvadVPN/Containers/Root/HeaderBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class HeaderBarView: UIView {
}()

let accountButton: UIButton = {
let button = makeHeaderBarButton(with: UIImage(named: "IconAccount"))
let button = makeHeaderBarButton(with: UIImage.Buttons.account)
button.setAccessibilityIdentifier(.accountButton)
button.accessibilityLabel = NSLocalizedString(
"HEADER_BAR_ACCOUNT_BUTTON_ACCESSIBILITY_LABEL",
Expand All @@ -71,7 +71,7 @@ class HeaderBarView: UIView {
}()

let settingsButton: UIButton = {
let button = makeHeaderBarButton(with: UIImage(named: "IconSettings"))
let button = makeHeaderBarButton(with: UIImage.Buttons.settings)
button.setAccessibilityIdentifier(.settingsButton)
button.accessibilityLabel = NSLocalizedString(
"HEADER_BAR_SETTINGS_BUTTON_ACCESSIBILITY_LABEL",
Expand All @@ -84,7 +84,14 @@ class HeaderBarView: UIView {
return button
}()

class func prepareHeaderBarButtonImage(from image: UIImage) -> UIImage {
let resizeRatio = 24.0 / 20.0
let targetSize = CGSize(width: image.size.width * resizeRatio, height: image.size.height * resizeRatio)
return image // .resizeImage(targetSize: targetSize)
}

class func makeHeaderBarButton(with image: UIImage?) -> IncreasedHitButton {
// let image = image.map { prepareHeaderBarButtonImage(from: $0) }
let buttonImage = image?.withTintColor(UIColor.HeaderBar.buttonColor, renderingMode: .alwaysOriginal)
let disabledButtonImage = image?.withTintColor(
UIColor.HeaderBar.disabledButtonColor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ class RootContainerViewController: UIViewController {
transitionViewButton.removeFromSuperview()
button = transitionViewButton
} else {
button = HeaderBarView.makeHeaderBarButton(with: UIImage(named: "IconAccount"))
button = HeaderBarView.makeHeaderBarButton(with: UIImage.Buttons.account)
button.addTarget(
self,
action: #selector(handleAccountButtonTap),
Expand All @@ -404,7 +404,7 @@ class RootContainerViewController: UIViewController {
transitionViewButton.removeFromSuperview()
button = transitionViewButton
} else {
button = HeaderBarView.makeHeaderBarButton(with: UIImage(named: "IconSettings"))
button = HeaderBarView.makeHeaderBarButton(with: UIImage.Buttons.settings)
button.isEnabled = headerBarView.settingsButton.isEnabled
button.addTarget(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SettingsFieldValidationErrorContentView: UIView, UIContentView {
let contentView = UIStackView()

var icon: UIImageView {
let view = UIImageView(image: UIImage(resource: .iconAlert).withTintColor(.dangerColor))
let view = UIImageView(image: UIImage.Buttons.alert.withTintColor(.dangerColor))
view.heightAnchor.constraint(equalToConstant: 14).isActive = true
view.widthAnchor.constraint(equalTo: view.heightAnchor, multiplier: 1).isActive = true
return view
Expand Down
116 changes: 116 additions & 0 deletions ios/MullvadVPN/Extensions/UIImage+Assets.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
//
// UIImage+Assets.swift
// MullvadVPN
//
// Created by Andrew Bulhak on 2025-03-06.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import UIKit

extension UIImage {
enum Buttons {
// Button images we expect as tightly cropped 24x24 images. The SVGs are 20x20 with a 2px border
static var account: UIImage {
UIImage(named: "IconAccount")!.rescaled(by: 24 / 20)
}

static var alert: UIImage {
UIImage(named: "IconAlert")!.rescaled(by: 24 / 20)
}

static var info: UIImage {
// the info icon was 18x18 cropped
UIImage(named: "IconInfo")!.resizeImage(targetSize: CGSize(width: 21.5, height: 21.5))
}

static var settings: UIImage {
UIImage(named: "IconSettings")!.rescaled(by: 24 / 20)
}

static var back: UIImage {
UIImage(named: "IconBack")!
}

static var copy: UIImage {
UIImage(named: "IconCopy")!
}

static var hide: UIImage {
UIImage(named: "IconObscure")!
}

static var reload: UIImage {
UIImage(named: "IconReload")!
}

static var rightArrow: UIImage {
UIImage(named: "IconArrow")!
}

static var show: UIImage {
UIImage(named: "IconUnobscure")!
}

// the close button, which comes we consume in two sizes, both of which come from the same asset

static var closeSmall: UIImage {
UIImage(named: "IconClose")!.resizeImage(targetSize: CGSize(width: 19, height: 19))
}

static var closeLarge: UIImage {
UIImage(named: "IconClose")!.resizeImage(targetSize: CGSize(width: 29, height: 29))
}
}

enum CellDecoration {
static var chevronRight: UIImage {
UIImage(named: "IconChevron")!
}

static var chevronDown: UIImage {
UIImage(named: "IconChevronDown")!
}

static var chevronUp: UIImage {
UIImage(named: "IconChevronUp")!
}

static var externalLink: UIImage {
UIImage(named: "IconExtlink")!
}

static var tick: UIImage {
UIImage(named: "IconTickSml")!
.resizeImage(targetSize: CGSize(width: 16, height: 16))
}
}

enum Status {
static var failure: UIImage { UIImage(named: "IconFail")! }
static var success: UIImage { UIImage(named: "IconSuccess")! }
}

// miscellaneous images
static var backTransitionMask: UIImage {
UIImage(named: "IconBackTransitionMask")!
}

static var spinner: UIImage {
UIImage(named: "IconSpinner")!
}

static var tick: UIImage {
UIImage(named: "IconTickSml")!
.resizeImage(targetSize: CGSize(width: 24, height: 24))
}

// a utility function to resize an image by an aspect ratio;
// used for compensating for scalable assets' nominal sizes being off
func rescaled(by ratio: CGFloat) -> UIImage {
resizeImage(targetSize: CGSize(
width: size.width * ratio,
height: size.height * ratio
))
}
}
2 changes: 1 addition & 1 deletion ios/MullvadVPN/Extensions/UITextField+Appearance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension UITextField {

func apply(to searchBar: UISearchBar) {
searchBar.setImage(
UIImage(named: "IconCloseSml")?.withTintColor(leftViewTintColor),
UIImage.Buttons.closeSmall.withTintColor(leftViewTintColor),
for: .clear,
state: .normal
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class LatestChangesNotificationProvider: NotificationProvider, InAppNotification

private func createCloseButtonAction() -> InAppNotificationAction {
InAppNotificationAction(
image: UIImage(named: "IconCloseSml"),
image: UIImage.Buttons.closeSmall,
handler: { [weak self] in
self?.invalidate()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class NewDeviceNotificationProvider: NotificationProvider,
),
body: attributedBody,
button: InAppNotificationAction(
image: UIImage(named: "IconCloseSml"),
image: UIImage.Buttons.closeSmall,
handler: { [weak self] in
guard let self else { return }
isNewDeviceRegistered = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "IconAccount.pdf",
"filename" : "icon-account-circle.svg",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Loading
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
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "IconAlert.pdf",
"filename" : "icon-alert-circle.svg",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Loading
Loading