Skip to content

Commit

Permalink
Merge f24bd66 into 01bdff8
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Nov 14, 2024
2 parents 01bdff8 + f24bd66 commit 8060f3f
Show file tree
Hide file tree
Showing 11 changed files with 755 additions and 120 deletions.
14 changes: 8 additions & 6 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
uiForm.messagePlaceholder = "Describe the nature of the jank. Its essence, if you will."
}
config.configureTheme = { theme in
let fontSize: CGFloat = 25

let fontFamily: String
if Locale.current.languageCode == "ar" { // arabic; ar_EG
fontFamily = "Damascus"
Expand All @@ -219,15 +217,19 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
} else {
fontFamily = "ChalkboardSE-Regular"
}
theme.font = UIFont(name: fontFamily, size: fontSize) ?? UIFont.systemFont(ofSize: fontSize)
theme.outlineColor = .purple
theme.fontFamily = fontFamily
theme.outlineStyle = .init(outlineColor: .purple)
theme.foreground = .purple
theme.background = .purple.withAlphaComponent(0.1)
theme.background = .init(red: 0.95, green: 0.9, blue: 0.95, alpha: 1)
theme.submitBackground = .orange
theme.submitForeground = .purple
theme.buttonBackground = .purple
theme.buttonForeground = .white
}
config.onSubmitSuccess = { info in
let name = info["name"] ?? "$shakespearean_insult_name"
let alert = UIAlertController(title: "Thanks?", message: "We have enough jank of our own, we really didn't need yours too, \(name).", preferredStyle: .alert)
alert.addAction(.init(title: "Derp", style: .default))
alert.addAction(.init(title: "Deal with it 🕶️", style: .default))
self.window?.rootViewController?.present(alert, animated: true)
}
config.onSubmitError = { error in
Expand Down
8 changes: 8 additions & 0 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,8 @@
84AEB46A2C2F97FC007E46E1 /* ArrayAccesses.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AEB4682C2F9673007E46E1 /* ArrayAccesses.swift */; };
84AF45A629A7FFA500FBB177 /* SentryProfiledTracerConcurrency.h in Headers */ = {isa = PBXBuildFile; fileRef = 84AF45A429A7FFA500FBB177 /* SentryProfiledTracerConcurrency.h */; };
84AF45A729A7FFA500FBB177 /* SentryProfiledTracerConcurrency.mm in Sources */ = {isa = PBXBuildFile; fileRef = 84AF45A529A7FFA500FBB177 /* SentryProfiledTracerConcurrency.mm */; };
84B0DFF42CD2CF64007FB332 /* SentryUserFeedbackForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B0DFF32CD2CF64007FB332 /* SentryUserFeedbackForm.swift */; };
84B0E0072CD963FD007FB332 /* SentryIconography.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B0E0062CD963F9007FB332 /* SentryIconography.swift */; };
84B7FA3529B285FC00AD93B1 /* Sentry.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63AA759B1EB8AEF500D153DE /* Sentry.framework */; };
84B7FA3C29B2876F00AD93B1 /* TestConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BAF3DD6243DD4A1008A5414 /* TestConstants.swift */; };
84B7FA3D29B2879C00AD93B1 /* libSentryTestUtils.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8431F00A29B284F200D8DC56 /* libSentryTestUtils.a */; };
Expand Down Expand Up @@ -1765,6 +1767,8 @@
84AEB4682C2F9673007E46E1 /* ArrayAccesses.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrayAccesses.swift; sourceTree = "<group>"; };
84AF45A429A7FFA500FBB177 /* SentryProfiledTracerConcurrency.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryProfiledTracerConcurrency.h; path = ../include/SentryProfiledTracerConcurrency.h; sourceTree = "<group>"; };
84AF45A529A7FFA500FBB177 /* SentryProfiledTracerConcurrency.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryProfiledTracerConcurrency.mm; sourceTree = "<group>"; };
84B0DFF32CD2CF64007FB332 /* SentryUserFeedbackForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUserFeedbackForm.swift; sourceTree = "<group>"; };
84B0E0062CD963F9007FB332 /* SentryIconography.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryIconography.swift; sourceTree = "<group>"; };
84B7FA3B29B2866200AD93B1 /* SentryTestUtils-ObjC-BridgingHeader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryTestUtils-ObjC-BridgingHeader.h"; sourceTree = "<group>"; };
84BA62262CAE2EEF0049F636 /* SentryUserFeedbackWidgetButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUserFeedbackWidgetButtonView.swift; sourceTree = "<group>"; };
84C47B2B2A09239100DAEB8A /* .codecov.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .codecov.yml; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2105,6 +2109,7 @@
621D9F2D2B9B030E003D94DE /* Helper */ = {
isa = PBXGroup;
children = (
84B0E0062CD963F9007FB332 /* SentryIconography.swift */,
D8739CF62BECFF86007D2F66 /* Log */,
621F61F02BEA073A005E654F /* SentryEnabledFeaturesBuilder.swift */,
621D9F2E2B9B0320003D94DE /* SentryCurrentDateProvider.swift */,
Expand Down Expand Up @@ -3519,6 +3524,7 @@
84CFA4CB2C9E0CA3008DA5F4 /* SentryUserFeedbackIntegration.h */,
84CFA4CC2C9E0CA3008DA5F4 /* SentryUserFeedbackIntegration.m */,
84CFA4C92C9DF884008DA5F4 /* SentryUserFeedbackWidget.swift */,
84B0DFF32CD2CF64007FB332 /* SentryUserFeedbackForm.swift */,
84BA62262CAE2EEF0049F636 /* SentryUserFeedbackWidgetButtonView.swift */,
84E13B832CBF1D91003B52EC /* SentryUserFeedbackWidgetButtonMegaphoneIconView.swift */,
);
Expand Down Expand Up @@ -4684,6 +4690,7 @@
7BECF42826145CD900D9826E /* SentryMechanismMeta.m in Sources */,
8E7C982F2693D56000E6336C /* SentryTraceHeader.m in Sources */,
63FE715F20DA4C1100CDBAE8 /* SentryCrashID.c in Sources */,
84B0E0072CD963FD007FB332 /* SentryIconography.swift in Sources */,
7DB3A687238EA75E00A2D442 /* SentryHttpTransport.m in Sources */,
63FE70D520DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.m in Sources */,
D80CD8D12B751442002F710B /* HTTPHeaderSanitizer.swift in Sources */,
Expand All @@ -4699,6 +4706,7 @@
629428802CB3BF69002C454C /* SwizzleClassNameExclude.swift in Sources */,
638DC9A11EBC6B6400A66E41 /* SentryRequestOperation.m in Sources */,
63AA767A1EB8D20500D153DE /* SentryLogC.m in Sources */,
84B0DFF42CD2CF64007FB332 /* SentryUserFeedbackForm.swift in Sources */,
6344DDBA1EC3115C00D9160D /* SentryCrashReportConverter.m in Sources */,
D8739CF32BECF70F007D2F66 /* SentryLevel.swift in Sources */,
63FE70FD20DA4C1000CDBAE8 /* SentryCrashCachedData.c in Sources */,
Expand Down
215 changes: 215 additions & 0 deletions Sources/Swift/Helper/SentryIconography.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
import CoreGraphics

extension CGMutablePath {
func addSVGArc(startPoint: CGPoint, xyRadii: CGFloat, clockwise: Bool, endPoint: CGPoint) {
let midX: CGFloat = (startPoint.x + endPoint.x) / 2
let midY: CGFloat = (startPoint.y + endPoint.y) / 2
let d: CGFloat = sqrt(pow(endPoint.x - startPoint.x, 2) + pow(endPoint.y - startPoint.y, 2))
let h: CGFloat = sqrt(pow(xyRadii, 2) - pow(d / 2, 2))
let orientation: CGFloat = clockwise ? 1 : -1

let centerX = midX + orientation * h * (startPoint.y - endPoint.y) / d
let centerY = midY + orientation * h * (endPoint.x - startPoint.x) / d
let centerPoint = CGPoint(x: centerX, y: centerY)

let startAngleAtan2X = startPoint.x - centerX
let startAngleAtan2Y = startPoint.y - centerY
let startAngle: CGFloat = atan2(startAngleAtan2Y, startAngleAtan2X)

let endAngleAtan2X = endPoint.x - centerX
let endAngleAtan2Y = endPoint.y - centerY
let endAngle: CGFloat = atan2(endAngleAtan2Y, endAngleAtan2X)

addArc(center: centerPoint, radius: xyRadii, startAngle: startAngle, endAngle: endAngle, clockwise: !clockwise)
}
}

extension CGPoint {
func translated(x: CGFloat = 0, y: CGFloat = 0) -> CGPoint {
.init(x: self.x + x, y: self.y + y)
}
}

struct SentryIconography {
static let logo = {
let path = CGMutablePath()

// M29,2.26
var point: CGPoint = .init(x: 29, y: 2.26)
path.move(to: point)

// a4.67,4.67,0,0,0-8,0
var endpoint: CGPoint = point.translated(x: -8)
path.addSVGArc(startPoint: point, xyRadii: 4.67, clockwise: false, endPoint: endpoint)
point = endpoint

// L14.42,13.53
endpoint = .init(x: 14.42, y: 13.53)
path.addLine(to: endpoint)
point = endpoint

// A32.21,32.21,0,0,1,32.17,40.19
endpoint = .init(x: 32.17, y: 40.19)
path.addSVGArc(startPoint: point, xyRadii: 32.21, clockwise: true, endPoint: endpoint)
point = endpoint

// H27.55
endpoint = .init(x: 27.55, y: point.y)
path.addLine(to: endpoint)
point = endpoint

// A27.68,27.68,0,0,0,12.09,17.47
endpoint = .init(x: 12.09, y: 17.47)
path.addSVGArc(startPoint: point, xyRadii: 27.68, clockwise: false, endPoint: endpoint)
point = endpoint

// L6,28
endpoint = CGPoint(x: 6, y: 28)
path.addLine(to: endpoint)
point = endpoint

// a15.92,15.92,0,0,1,9.23,12.17
endpoint = point.translated(x: 9.23, y: 12.17)
path.addSVGArc(startPoint: point, xyRadii: 15.92, clockwise: true, endPoint: endpoint)
point = endpoint

// H4.62
endpoint = .init(x: 4.62, y: point.y)
path.addLine(to: endpoint)
point = endpoint

// A.76.76,0,0,1,4,39.06
endpoint = .init(x: 4, y: 39.06)
path.addSVGArc(startPoint: point, xyRadii: 0.76, clockwise: true, endPoint: endpoint)
point = endpoint

// l2.94-5
endpoint = point.translated(x: 2.94, y: -5)
path.addLine(to: endpoint)
point = endpoint

// a10.74,10.74,0,0,0-3.36-1.9
endpoint = point.translated(x: -3.36, y: -1.9)
path.addSVGArc(startPoint: point, xyRadii: 10.74, clockwise: false, endPoint: endpoint)
point = endpoint

// l-2.91,5
endpoint = point.translated(x: -2.91, y: 5)
path.addLine(to: endpoint)
point = endpoint

// a4.54,4.54,0,0,0,1.69,6.24
endpoint = point.translated(x: 1.69, y: 6.24)
path.addSVGArc(startPoint: point, xyRadii: 4.54, clockwise: false, endPoint: endpoint)
point = endpoint

// A4.66,4.66,0,0,0,4.62,44
endpoint = .init(x: 4.62, y: 44)
path.addSVGArc(startPoint: point, xyRadii: 4.66, clockwise: false, endPoint: endpoint)
point = endpoint

// H19.15
endpoint = CGPoint(x: 19.15, y: point.y)
path.addLine(to: endpoint)
point = endpoint

// a19.4,19.4,0,0,0-8-17.31
endpoint = point.translated(x: -8, y: -17.31)
path.addSVGArc(startPoint: point, xyRadii: 19.4, clockwise: false, endPoint: endpoint)
point = endpoint

// l2.31-4
endpoint = point.translated(x: 2.31, y: -4)
path.addLine(to: endpoint)
point = endpoint

// A23.87,23.87,0,0,1,23.76,44
endpoint = .init(x: 23.76, y: 44)
path.addSVGArc(startPoint: point, xyRadii: 23.87, clockwise: true, endPoint: endpoint)
point = endpoint

// H36.07
endpoint = CGPoint(x: 36.07, y: point.y)
path.addLine(to: endpoint)
point = endpoint

// a35.88,35.88,0,0,0-16.41-31.8
endpoint = point.translated(x: -16.41, y: -31.8)
path.addSVGArc(startPoint: point, xyRadii: 35.88, clockwise: false, endPoint: endpoint)
point = endpoint

// l4.67-8
endpoint = point.translated(x: 4.67, y: -8)
path.addLine(to: endpoint)
point = endpoint

// a.77.77,0,0,1,1.05-.27
endpoint = point.translated(x: 1.05, y: -0.27)
path.addSVGArc(startPoint: point, xyRadii: 0.77, clockwise: true, endPoint: endpoint)
point = endpoint

// c.53.29,20.29,34.77,20.66,35.17
var c1 = point.translated(x: 0.53, y: 0.29)
var c2 = point.translated(x: 20.29, y: 34.77)
endpoint = point.translated(x: 20.66, y: 35.17)
path.addCurve(to: endpoint, control1: c1, control2: c2)
point = endpoint

// a.76.76,0,0,1-.68,1.13
endpoint = point.translated(x: -0.68, y: 1.13)
path.addSVGArc(startPoint: point, xyRadii: 0.76, clockwise: true, endPoint: endpoint)
point = endpoint

// H40.6
endpoint = CGPoint(x: 40.6, y: point.y)
path.addLine(to: endpoint)
point = endpoint

// q.09,1.91,0,3.81
c1 = .init(x: point.x + 0.09, y: point.y + 1.91)
endpoint = .init(x: point.x, y: point.y + 3.81)
path.addQuadCurve(to: endpoint, control: c1)
point = endpoint

// h4.78
endpoint = .init(x: point.x + 4.78, y: point.y)
path.addLine(to: endpoint)
point = endpoint

// A4.59,4.59,0,0,0,50,39.43
endpoint = .init(x: 50, y: 39.43)
path.addSVGArc(startPoint: point, xyRadii: 4.59, clockwise: false, endPoint: endpoint)
point = endpoint

// a4.49,4.49,0,0,0-.62-2.28
endpoint = point.translated(x: -0.62, y: -2.28)
path.addSVGArc(startPoint: point, xyRadii: 4.49, clockwise: false, endPoint: endpoint)
point = endpoint

// Z
path.closeSubpath()

return path
}()

static let megaphone = {
let path = CGMutablePath()

path.move(to: CGPoint(x: 1, y: 3))
path.addLine(to: CGPoint(x: 7, y: 3))
path.addLine(to: CGPoint(x: 10, y: 1))
path.addLine(to: CGPoint(x: 12, y: 1))
path.addLine(to: CGPoint(x: 12, y: 11))
path.addLine(to: CGPoint(x: 10, y: 11))
path.addLine(to: CGPoint(x: 7, y: 9))
path.addLine(to: CGPoint(x: 1, y: 9))
path.closeSubpath()

path.addRect(CGRect(x: 2, y: 9, width: 3.5, height: 6))

path.move(to: CGPoint(x: 12, y: 6))
path.addRelativeArc(center: CGPoint(x: 12, y: 6), radius: 3, startAngle: -(.pi / 2), delta: .pi)

return path
}()
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,34 @@ public class SentryUserFeedbackConfiguration: NSObject {
}()

/// The ratio of the configured font size to the system default font size, to know how large to scale things like the icon and lozenge shape.
lazy var scaleFactor: CGFloat = {
lazy var scaleFactor = calculateScaleFactor()

func calculateScaleFactor() -> CGFloat {
let fontSize = theme.font.pointSize
guard fontSize > 0 else {
return 1
}

return fontSize / UIFont.systemFontSize
}()
}

/// Too much padding as the font size grows larger makes the button look weird with lots of negative space. Keeping the padding constant looks weird if the text is too small. So, scale it down below system default font sizes, but keep it fixed with larger font sizes.
lazy var paddingScaleFactor: CGFloat = {
lazy var paddingScaleFactor = calculatePaddingScaleFactor()

func calculatePaddingScaleFactor() -> CGFloat {
scaleFactor > 1 ? 1 : scaleFactor
}()
}

func recalculateScaleFactors() {
scaleFactor = calculateScaleFactor()
paddingScaleFactor = calculatePaddingScaleFactor()
}

// MARK: Layout

let padding: CGFloat = 16
let spacing: CGFloat = 8
let margin: CGFloat = 32
}

#endif // os(iOS) && !SENTRY_NO_UIKIT
Loading

0 comments on commit 8060f3f

Please sign in to comment.