Skip to content

Commit

Permalink
wip on right to left support: megaphone location/direction
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight committed Oct 16, 2024
1 parent f828a92 commit abc5119
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
27 changes: 25 additions & 2 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
config.showFormForScreenshots = true
config.configureWidget = { widget in
if args.contains("--io.sentry.iOS-Swift.auto-inject-user-feedback-widget") {
widget.labelText = "Report Jank"
if Locale.current.languageCode == "ar" { // arabic
widget.labelText = ""
} else if Locale.current.languageCode == "ur" { // urdu
widget.labelText = "نستعلیق"
} else if Locale.current.languageCode == "he" { // hebrew
widget.labelText = "עִבְרִית‎"
} else if Locale.current.languageCode == "hi" { // Hindi
widget.labelText = "नागरि"
} else {
widget.labelText = "Report Jank"
}
widget.widgetAccessibilityLabel = "io.sentry.iOS-Swift.button.report-jank"
widget.layoutUIOffset = layoutOffset
} else {
Expand All @@ -195,7 +205,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
config.configureTheme = { theme in
let fontSize: CGFloat = 40
theme.font = UIFont(name: "HelveticaNeue", size: fontSize) ?? UIFont.systemFont(ofSize: fontSize)

let fontFamily: String
if Locale.current.languageCode == "ar" { // arabic; ar_EG
fontFamily = "Damascus"
} else if Locale.current.languageCode == "ur" { // urdu; ur_PK
fontFamily = "NotoNastaliq"
} else if Locale.current.languageCode == "he" { // hebrew; he_IL
fontFamily = "Arial Hebrew"
} else if Locale.current.languageCode == "hi" { // Hindi; hi_IN
fontFamily = "DevanagariSangamMN"
} else {
fontFamily = "ChalkboardSE-Regular"
}
theme.font = UIFont(name: fontFamily, size: fontSize) ?? UIFont.systemFont(ofSize: fontSize)
theme.outlineColor = .purple
theme.foreground = .purple
theme.background = .purple.withAlphaComponent(0.1)
Expand Down
6 changes: 6 additions & 0 deletions Sources/Sentry/NSLocale+Sentry.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ + (BOOL)timeIs24HourFormat
return is24Hour;
}

+ (BOOL)isRightToLeftLanguage
{
return [NSLocale characterDirectionForLanguage:NSLocale.currentLocale.languageCode]
== NSLocaleLanguageDirectionRightToLeft;
}

@end
1 change: 1 addition & 0 deletions Sources/Sentry/include/NSLocale+Sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
@interface SentryLocale : NSObject

+ (BOOL)timeIs24HourFormat;
+ (BOOL)isRightToLeftLanguage;

@end
1 change: 1 addition & 0 deletions Sources/Sentry/include/SentryPrivate.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Sentry internal headers that are needed for swift code
#import "NSLocale+Sentry.h"
#import "SentryDispatchQueueWrapper.h"
#import "SentryNSDataUtils.h"
#import "SentryRandom.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ class SentryUserFeedbackWidgetButtonMegaphoneIconView: UIView {
layer.addSublayer(svgLayer)
translatesAutoresizingMaskIntoConstraints = false

var transform = CATransform3DIdentity
if config.scaleFactor != 1 {
layer.transform = CATransform3DMakeScale(config.scaleFactor, config.scaleFactor, 0)
transform = CATransform3DConcat(transform, CATransform3DMakeScale(config.scaleFactor, config.scaleFactor, 0))
}

if SentryLocale.isRightToLeftLanguage() {

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / Build SwiftUITestSample Sample

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 15 (17.2) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (15.2) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (15.2) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (15.2) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (15.2) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (15.2) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (15.2) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (15.2) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (15.2) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (15.2) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (15.2) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / Release Build of iOS Swift

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / Release Build of iOS Swift

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 8 (15.5) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 8 (15.5) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 8 (15.5) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 8 (15.5) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 8 (15.5) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 8 (15.5) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 8 (15.5) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 8 (15.5) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 8 (15.5) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 8 (15.5) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for ios_objc on Simulators

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 14 (16.4) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (16.1) Simulator

cannot find 'SentryLocale' in scope

Check failure on line 33 in Sources/Swift/Integrations/UserFeedback/SentryUserFeedbackWidgetButtonMegaphoneIconView.swift

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (16.1) Simulator

cannot find 'SentryLocale' in scope
transform = CATransform3DConcat(transform, CATransform3DMakeScale(-1, 1, 1))
}

layer.transform = transform
}

required init?(coder: NSCoder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class SentryUserFeedbackWidgetButtonView: UIView {
if hasText {
let paddingDifference = (scaledLeftPadding - padding) / 2
let spacingDifference = scaledSpacing - spacing
let increasedIconLeftPadAmountDueToScaling = config.widgetConfig.showIcon ? paddingDifference + iconSizeDifference + spacingDifference : 0
let increasedIconLeftPadAmountDueToScaling: CGFloat = config.widgetConfig.showIcon ? SentryLocale.isRightToLeftLanguage() ? paddingDifference : paddingDifference + iconSizeDifference + spacingDifference : 0

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

View workflow job for this annotation

GitHub Actions / Build SwiftUITestSample Sample

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 15 (17.2) Simulator

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 15 (17.2) Simulator

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / Release Build of iOS Swift

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / Release Build of iOS Swift

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / UI Tests for ios_objc on Simulators

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / UI Tests for ios_objc on Simulators

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / UI Tests for ios_objc on Simulators

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / UI Tests for ios_objc on Simulators

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / UI Tests for iOS-Swift iPhone 14 (16.4) Simulator

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / Build app and test runner

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (16.1) Simulator

cannot find 'SentryLocale' in scope

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

View workflow job for this annotation

GitHub Actions / UI Tests for SwiftUI on iPhone 8 (16.1) Simulator

cannot find 'SentryLocale' in scope
lozengeLayer.transform = CATransform3DTranslate(lozengeLayer.transform, -increasedIconLeftPadAmountDueToScaling, -padding * config.paddingScaleFactor, 0)
} else {
lozengeLayer.transform = CATransform3DTranslate(lozengeLayer.transform, -iconSizeDifference, -iconSizeDifference, 0)
Expand Down

0 comments on commit abc5119

Please sign in to comment.