Skip to content

Commit

Permalink
Fix large text size design
Browse files Browse the repository at this point in the history
  • Loading branch information
martenrebane committed Feb 20, 2024
1 parent 9472779 commit cc6b913
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 84 deletions.
13 changes: 13 additions & 0 deletions MoppApp/MoppApp/AccessibilityUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,17 @@ class AccessibilityUtil {
subview.isAccessibilityElement = isAccessibilityElement
}
}

// Adjust spacing between addressee and "Add" buttons
// Adjust so that the spacing is not too big and also don't overlap each other when font size changes
static func adjustSpacing(preferredContentSizeCategory: UIContentSizeCategory, stackView: UIStackView) {
switch preferredContentSizeCategory {
case .extraSmall, .small, .medium, .large, .extraLarge, .extraExtraLarge:
stackView.spacing = -120
break
default:
stackView.spacing = 0
break
}
}
}
1 change: 1 addition & 0 deletions MoppApp/MoppApp/Container.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,7 @@
</tableViewCellContentView>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<outlet property="addresseeMainStackView" destination="L51-8M-H3Q" id="I3G-tQ-NxO"/>
<outlet property="bottomBorder" destination="Zh4-up-bW7" id="Sra-3Z-Pqi"/>
<outlet property="iconImage" destination="dDJ-k2-19D" id="GkN-af-Kx5"/>
<outlet property="infoLabel" destination="COx-YD-yZM" id="CMT-Lt-Awz"/>
Expand Down
5 changes: 4 additions & 1 deletion MoppApp/MoppApp/ContainerAddresseeCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class ContainerAddresseeCell: UITableViewCell, AddresseeActions {

@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var iconImage: UIImageView!
@IBOutlet weak var addresseeMainStackView: UIStackView!
@IBOutlet weak var bottomBorder: UIView!
@IBOutlet weak var infoLabel: UILabel!
@IBOutlet weak var removeButton: UIButton!
weak var delegate: ContainerAddresseeCellDelegate!
var removeIndex: Int = 0


@IBAction func removeAddressee(_ sender: Any) {
delegate.removeAddressee(index: removeIndex)
UIAccessibility.post(notification: .screenChanged, argument: L(.cryptoRecipientRemoved))
Expand All @@ -52,5 +52,8 @@ class ContainerAddresseeCell: UITableViewCell, AddresseeActions {
removeIndex = index
nameLabel.text = determineName(addressee: addressee)
infoLabel.text = determineInfo(addressee: addressee)

let preferredContentSizeCategory = UIApplication.shared.preferredContentSizeCategory
AccessibilityUtil.adjustSpacing(preferredContentSizeCategory: preferredContentSizeCategory, stackView: addresseeMainStackView)
}
}
16 changes: 1 addition & 15 deletions MoppApp/MoppApp/ContainerFoundAddresseeCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,7 @@ class ContainerFoundAddresseeCell: UITableViewCell, AddresseeActions {
addButton.tintColor = UIColor.moppBase
}

adjustSpacing()
}

// Adjust spacing between addressee and "Add" buttons
// Adjust so that the spacing is not too big and also don't overlap each other when font size changes
private func adjustSpacing() {
let preferredContentSizeCategory = UIApplication.shared.preferredContentSizeCategory

switch preferredContentSizeCategory {
case .extraSmall, .small, .medium, .large, .extraLarge, .extraExtraLarge:
addresseeMainStackView.spacing = -120
break
default:
addresseeMainStackView.spacing = 0
break
}
AccessibilityUtil.adjustSpacing(preferredContentSizeCategory: preferredContentSizeCategory, stackView: addresseeMainStackView)
}
}
16 changes: 12 additions & 4 deletions MoppApp/MoppApp/MobileIDChallengeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ class MobileIDChallengeViewController : UIViewController {
var challengeIdAccessibilityLabel = ""
var challengeIdNumbers = Array<Character>()

@IBOutlet weak var cancelButton: ScaledButton!
@IBOutlet weak var cancelButton: ScaledLabel!

@IBAction func cancelSigningButton(_ sender: Any) {

@objc func cancelSigningButton(_ sender: UITapGestureRecognizer) {
printLog("Cancelling Mobile-ID signing")
sessionTimer?.invalidate()
NotificationCenter.default.post(name: .signatureSigningCancelledNotificationName, object: nil)
Expand All @@ -60,15 +61,22 @@ class MobileIDChallengeViewController : UIViewController {
super.viewDidLoad()

helpLabel.text = L(.mobileIdSignHelpTitle)
cancelButton.setTitle(L(.actionAbort))
cancelButton.text = L(.actionAbort)
cancelButton.accessibilityLabel = L(.actionAbort).lowercased()

if let cancelTitleLabel = cancelButton.titleLabel {
if let cancelTitleLabel = cancelButton {
let maxSize: CGFloat = 17
let currentFontSize = cancelTitleLabel.font.pointSize
cancelTitleLabel.font = cancelTitleLabel.font.withSize(min(maxSize, currentFontSize))
}

if !(self.cancelButton.gestureRecognizers?.contains(where: { $0 is UITapGestureRecognizer }) ?? false) {

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.cancelSigningButton(_:)))
self.cancelButton.addGestureRecognizer(tapGesture)
self.cancelButton.isUserInteractionEnabled = true
}

codeLabel.isHidden = true
currentProgress = 0
timeoutProgressView.progress = 0
Expand Down
19 changes: 12 additions & 7 deletions MoppApp/MoppApp/SmartIDChallengeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class SmartIDChallengeViewController : UIViewController {
var isAnnouncementMade = false
var isProgressBarFocused = false

@IBOutlet weak var cancelButton: ScaledButton!
@IBOutlet weak var cancelButton: ScaledLabel!

@IBAction func cancelSigningButton(_ sender: Any) {
printLog("Cancelling Mobile-ID signing")
@objc func cancelSigningButton(_ sender: UITapGestureRecognizer) {
printLog("Cancelling Smart-ID signing")
sessionTimer?.invalidate()
NotificationCenter.default.post(name: .signatureSigningCancelledNotificationName, object: nil)
NotificationCenter.default.removeObserver(self)
Expand All @@ -54,15 +54,22 @@ class SmartIDChallengeViewController : UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
helpLabel.text = L(.smartIdChallengeTitle)
cancelButton.setTitle(L(.actionAbort))
cancelButton.text = L(.actionAbort)
cancelButton.accessibilityLabel = L(.actionAbort).lowercased()

if let cancelTitleLabel = cancelButton.titleLabel {
if let cancelTitleLabel = cancelButton {
let maxSize: CGFloat = 17
let currentFontSize = cancelTitleLabel.font.pointSize
cancelTitleLabel.font = cancelTitleLabel.font.withSize(min(maxSize, currentFontSize))
}

if !(self.cancelButton.gestureRecognizers?.contains(where: { $0 is UITapGestureRecognizer }) ?? false) {

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(self.cancelSigningButton(_:)))
self.cancelButton.addGestureRecognizer(tapGesture)
self.cancelButton.isUserInteractionEnabled = true
}

currentProgress = 0
timeoutProgressView.progress = 0
timeoutProgressView.accessibilityUserInputLabels = [""]
Expand Down Expand Up @@ -232,7 +239,6 @@ class SmartIDChallengeViewController : UIViewController {
self.timeoutProgressView.isAccessibilityElement = true
self.helpLabel.isAccessibilityElement = true
self.cancelButton.isAccessibilityElement = true
self.cancelButton.titleLabel?.isAccessibilityElement = true
codeLabel.accessibilityLabel = getCodeLabelAccessibilityLabel(withProgress: false)
}
}
Expand All @@ -258,7 +264,6 @@ class SmartIDChallengeViewController : UIViewController {
self.timeoutProgressView.isAccessibilityElement = false
self.helpLabel.isAccessibilityElement = false
self.cancelButton.isAccessibilityElement = false
self.cancelButton.titleLabel?.isAccessibilityElement = false
DispatchQueue.main.async {
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
DispatchQueue(label: "codeLabel", qos: .userInitiated).sync {
Expand Down
Loading

0 comments on commit cc6b913

Please sign in to comment.