Skip to content

Commit

Permalink
fix arabic vertical centering/padding
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight committed Oct 18, 2024
1 parent f028d5b commit 4254b59
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SentryUserFeedbackWidgetButtonView: UIView {

Check warning on line 57 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift#L54-L57

Added lines #L54 - L57 were not covered by tests
if config.widgetConfig.showIcon {
addSubview(megaphone)

Check warning on line 59 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift#L59

Added line #L59 was not covered by tests
let megaphoneCenteringConstraint = config.theme.font.familyName == "Damascus" ? megaphone.centerYAnchor.constraint(equalTo: label.bottomAnchor, constant: -config.textEffectiveHeightCenter + (config.theme.font.capHeight - config.theme.font.ascender)) : megaphone.centerYAnchor.constraint(equalTo: label.firstBaselineAnchor, constant: -config.textEffectiveHeightCenter)
let megaphoneCenteringConstraint = config.theme.font.familyName == "Damascus" ? megaphone.centerYAnchor.constraint(equalTo: label.centerYAnchor, constant: -(config.theme.font.capHeight - config.theme.font.ascender)) : megaphone.centerYAnchor.constraint(equalTo: label.firstBaselineAnchor, constant: -config.textEffectiveHeightCenter)
constraints.append(contentsOf: [
label.leadingAnchor.constraint(equalTo: megaphone.trailingAnchor, constant: spacing * config.scaleFactor),
megaphoneCenteringConstraint
Expand Down Expand Up @@ -142,8 +142,8 @@ class SentryUserFeedbackWidgetButtonView: UIView {
let iconWidthAdditions = config.widgetConfig.showIcon ? scaledLeftPadding + scaledIconSize + scaledSpacing : padding
finalSize.width += iconWidthAdditions + padding

Check warning on line 144 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift#L143-L144

Added lines #L143 - L144 were not covered by tests
let lozengeHalfHeight = config.theme.font.familyName == "Damascus" ? (config.theme.font.lineHeight / 2) : (config.theme.font.ascender - config.textEffectiveHeightCenter)
finalSize.height = 2 * (lozengeHalfHeight) + 2 * padding * config.paddingScaleFactor
let lozengeHeight = config.theme.font.familyName == "Damascus" ? config.theme.font.lineHeight : (2 * (config.theme.font.ascender - config.textEffectiveHeightCenter))
finalSize.height = lozengeHeight + 2 * padding * config.paddingScaleFactor

Check warning on line 146 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift#L146

Added line #L146 was not covered by tests
}

let radius: CGFloat = finalSize.height / 2
Expand Down Expand Up @@ -172,8 +172,8 @@ class SentryUserFeedbackWidgetButtonView: UIView {
let paddingDifference = (scaledLeftPadding - padding) / 2
let spacingDifference = scaledSpacing - spacing

Check warning on line 173 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift#L172-L173

Added lines #L172 - L173 were not covered by tests
let increasedIconLeftPadAmountDueToScaling: CGFloat = config.widgetConfig.showIcon ? SentryLocale.isRightToLeftLanguage() ? paddingDifference : paddingDifference + iconSizeDifference + spacingDifference : 0
let yTranslation = config.theme.font.familyName == "Damascus" ? -(config.theme.font.capHeight + padding) / 2 : -padding
lozengeLayer.transform = CATransform3DTranslate(lozengeLayer.transform, -increasedIconLeftPadAmountDueToScaling, yTranslation * config.paddingScaleFactor, 0)
let yTranslation = config.theme.font.familyName == "Damascus" ? -(padding * config.paddingScaleFactor + (config.theme.font.capHeight - config.theme.font.ascender) * config.paddingScaleFactor) : (-padding * config.paddingScaleFactor)
lozengeLayer.transform = CATransform3DTranslate(lozengeLayer.transform, -increasedIconLeftPadAmountDueToScaling, yTranslation, 0)

Check warning on line 176 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift#L176

Added line #L176 was not covered by tests
} else {
lozengeLayer.transform = CATransform3DTranslate(lozengeLayer.transform, -iconSizeDifference, -iconSizeDifference, 0)

Check warning on line 178 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonView.swift#L178

Added line #L178 was not covered by tests
}
Expand Down

0 comments on commit 4254b59

Please sign in to comment.