summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPN/Views/ScaledSegmentedControl.swift
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2025-09-03 16:18:43 +0200
committerBug Magnet <marco.nikic@mullvad.net>2025-09-10 11:39:22 +0200
commite9d1241c079c95f5f59444d09665e3367bba3ddd (patch)
treedb5bf64282ab295b68cd85ec3248f2b1feec5a38 /ios/MullvadVPN/Views/ScaledSegmentedControl.swift
parente76d2cf8a791c318b2357d781bbcda23d605d214 (diff)
downloadmullvadvpn-e9d1241c079c95f5f59444d09665e3367bba3ddd.tar.xz
mullvadvpn-e9d1241c079c95f5f59444d09665e3367bba3ddd.zip
Rewrite the multihop segmented control in SwiftUI
Diffstat (limited to 'ios/MullvadVPN/Views/ScaledSegmentedControl.swift')
-rw-r--r--ios/MullvadVPN/Views/ScaledSegmentedControl.swift61
1 files changed, 0 insertions, 61 deletions
diff --git a/ios/MullvadVPN/Views/ScaledSegmentedControl.swift b/ios/MullvadVPN/Views/ScaledSegmentedControl.swift
deleted file mode 100644
index ab477a3be5..0000000000
--- a/ios/MullvadVPN/Views/ScaledSegmentedControl.swift
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// ScaledSegmentedControl.swift
-// MullvadVPN
-//
-// Created by Mojgan on 2025-07-02.
-// Copyright © 2025 Mullvad VPN AB. All rights reserved.
-//
-import UIKit
-
-final class ScaledSegmentedControl: UISegmentedControl {
- private let textStyle: UIFont.TextStyle
- private let fontWeight: UIFont.Weight
-
- init(textStyle: UIFont.TextStyle = .body, weight: UIFont.Weight = .regular) {
- self.textStyle = textStyle
- self.fontWeight = weight
- super.init(frame: .zero)
- applyTextAttributes()
- subscribeToDynamicType()
- }
-
- required init?(coder: NSCoder) {
- self.textStyle = .body
- self.fontWeight = .regular
- super.init(coder: coder)
- applyTextAttributes()
- subscribeToDynamicType()
- }
-
- override func insertSegment(withTitle title: String?, at segment: Int, animated: Bool) {
- super.insertSegment(withTitle: title, at: segment, animated: animated)
- applyTextAttributes()
- }
-
- private func applyTextAttributes() {
- let font = UIFont.preferredFont(forTextStyle: textStyle).withWeight(fontWeight)
- let attributes: [NSAttributedString.Key: Any] = [
- .font: font,
- .foregroundColor: UIColor.primaryTextColor,
- ]
- setTitleTextAttributes(attributes, for: .normal)
- setTitleTextAttributes(attributes, for: .selected)
- }
-
- private func subscribeToDynamicType() {
- NotificationCenter.default.addObserver(
- self,
- selector: #selector(contentSizeChanged),
- name: UIContentSizeCategory.didChangeNotification,
- object: nil
- )
- }
-
- @objc private func contentSizeChanged() {
- applyTextAttributes()
- }
-
- deinit {
- NotificationCenter.default.removeObserver(self)
- }
-}