Skip to content

Commit a1d6b7a

Browse files
authored
Added additional swiftUI control support and verification app (#20)
1 parent af09e98 commit a1d6b7a

File tree

80 files changed

+644
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+644
-7
lines changed

.github/workflows/create_jira.yml

100644100755
File mode changed.

.gitignore

100644100755
File mode changed.

.vscode/settings.json

100644100755
File mode changed.

CODE_OF_CONDUCT.md

100644100755
File mode changed.

Examples/BasicExample/BasicExample.xcodeproj/project.pbxproj

100644100755
File mode changed.

Examples/BasicExample/BasicExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata

100644100755
File mode changed.

Examples/BasicExample/BasicExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

100644100755
+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"kind" : "remoteSourceControl",
3434
"location" : "https://github.com/segmentio/substrata-swift.git",
3535
"state" : {
36-
"revision" : "93f36ace19f4ed5a47d2e57a7edd9de92c18a37b",
37-
"version" : "2.0.5"
36+
"revision" : "bfcdf83b3fdd49e70a32c9fceb7426c044d5c5c9",
37+
"version" : "2.0.6"
3838
}
3939
}
4040
],

Examples/BasicExample/BasicExample.xcodeproj/xcshareddata/xcschemes/BasicExample.xcscheme

100644100755
File mode changed.

Examples/BasicExample/BasicExample/.DS_Store

100644100755
File mode changed.

Examples/BasicExample/BasicExample/Assets.xcassets/AccentColor.colorset/Contents.json

100644100755
File mode changed.

Examples/BasicExample/BasicExample/Assets.xcassets/AppIcon.appiconset/Contents.json

100644100755
File mode changed.

Examples/BasicExample/BasicExample/Assets.xcassets/Contents.json

100644100755
File mode changed.

Examples/BasicExample/BasicExample/BasicExampleApp.swift

100644100755
File mode changed.

Examples/BasicExample/BasicExample/ContentView.swift

100644100755
File mode changed.

Examples/BasicExample/BasicExample/Preview Content/Preview Assets.xcassets/Contents.json

100644100755
File mode changed.

Examples/BasicExample/BasicExample/myFallback.js

100644100755
File mode changed.

Examples/SwiftUIControlTest

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit bbdcc11da8b531345bec8ac1941d67327429677b

LICENSE

100644100755
File mode changed.

Package.resolved

100644100755
File mode changed.

Package.swift

100644100755
File mode changed.

README.md

100644100755
File mode changed.

RELEASING.md

100644100755
File mode changed.

Sources/AnalyticsLive/Filters/DestinationFilters.swift

100644100755
File mode changed.

Sources/AnalyticsLive/Filters/MetricsPlugin.swift

100644100755
File mode changed.

Sources/AnalyticsLive/LivePlugins/AnalyticsJS.swift

100644100755
File mode changed.

Sources/AnalyticsLive/LivePlugins/Bundler.swift

100644100755
File mode changed.

Sources/AnalyticsLive/LivePlugins/EmbeddedJS.swift

100644100755
File mode changed.

Sources/AnalyticsLive/LivePlugins/LivePlugin.swift

100644100755
File mode changed.

Sources/AnalyticsLive/LivePlugins/LivePlugins.swift

100644100755
File mode changed.

Sources/AnalyticsLive/LivePlugins/Utils.swift

100644100755
File mode changed.

Sources/AnalyticsLive/Signals/.DS_Store

100644100755
File mode changed.

Sources/AnalyticsLive/Signals/AutoTracking/.DS_Store

100644100755
File mode changed.

Sources/AnalyticsLive/Signals/AutoTracking/SignalsNetworkTracking.swift

100644100755
File mode changed.

Sources/AnalyticsLive/Signals/AutoTracking/SignalsScreenTracking.swift

100644100755
File mode changed.

Sources/AnalyticsLive/Signals/AutoTracking/SignalsTapTracking.swift

100644100755
File mode changed.

Sources/AnalyticsLive/Signals/AutoTracking/SwiftUI/Annotations.swift

100644100755
File mode changed.

Sources/AnalyticsLive/Signals/AutoTracking/SwiftUI/Description.swift

100644100755
File mode changed.

Sources/AnalyticsLive/Signals/AutoTracking/SwiftUI/SignalButton.swift

100644100755
+21-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ extension LocalizedStringKey {
1515
}
1616
}
1717

18+
extension View {
19+
static func extractLabel<V: View>(_ label: V, _ file: String? = nil, _ function: String? = nil, _ line: Int? = nil) -> String {
20+
let s = String(describing: label)
21+
var result: String
22+
23+
let label = describe(label: s)
24+
if let label {
25+
result = label
26+
} else {
27+
if let file, let function, let line {
28+
result = "Unknown Label @ \(file), \(function), line \(line)"
29+
} else {
30+
result = "Unknown Label"
31+
}
32+
}
33+
return result
34+
}
35+
}
36+
1837
public protocol SignalingUI {
1938
static func controlType() -> String
2039
}
@@ -44,7 +63,7 @@ public struct SignalButton<Label>: SignalingUI, View where Label : View {
4463
return sui
4564
}
4665

47-
static func extractLabel(_ label: Label, _ file: String? = nil, _ function: String? = nil, _ line: Int? = nil) -> String {
66+
/*static func extractLabel(_ label: Label, _ file: String? = nil, _ function: String? = nil, _ line: Int? = nil) -> String {
4867
let s = String(describing: label)
4968
var result: String
5069

@@ -59,7 +78,7 @@ public struct SignalButton<Label>: SignalingUI, View where Label : View {
5978
}
6079
}
6180
return result
62-
}
81+
}*/
6382

6483
@inline(__always)
6584
static public func controlType() -> String {

Sources/AnalyticsLive/Signals/AutoTracking/SwiftUI/SignalNavigation.swift

100644100755
File mode changed.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
//
2+
// SignalPicker.swift
3+
// AnalyticsLive
4+
//
5+
// Created by Brandon Sneed on 2/3/25.
6+
//
7+
8+
import SwiftUI
9+
10+
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *)
11+
public struct SignalPicker<Label, SelectionValue, Content>: SignalingUI, View
12+
where Label: View, SelectionValue: Hashable, Content: View {
13+
14+
let sui: SwiftUI.Picker<Label, SelectionValue, Content>
15+
let signalLabel: Any?
16+
let signalSelection: Binding<SelectionValue>
17+
18+
public var body: some View {
19+
if #available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) {
20+
return sui.onChange(of: signalSelection.wrappedValue) { newValue in
21+
let title: String?
22+
if let localizedKey = signalLabel as? LocalizedStringKey {
23+
title = localizedKey.string
24+
} else if let stringValue = signalLabel as? String {
25+
title = stringValue
26+
} else {
27+
title = describeWith(options: [signalLabel])
28+
}
29+
30+
let signal = InteractionSignal(
31+
component: Self.controlType(),
32+
title: title,
33+
data: ["value": String(describing: newValue)]
34+
)
35+
Signals.emit(signal: signal, source: .autoSwiftUI)
36+
}
37+
} else {
38+
return sui
39+
}
40+
}
41+
42+
@inline(__always)
43+
static public func controlType() -> String {
44+
return "Picker"
45+
}
46+
47+
static func extractLabel(_ label: Label, _ file: String? = nil, _ function: String? = nil, _ line: Int? = nil) -> String {
48+
let s = String(describing: label)
49+
var result: String
50+
51+
let label = describe(label: s)
52+
if let label {
53+
result = label
54+
} else {
55+
if let file, let function, let line {
56+
result = "Unknown Label @ \(file), \(function), line \(line)"
57+
} else {
58+
result = "Unknown Label"
59+
}
60+
}
61+
return result
62+
}
63+
}
64+
65+
// MARK: - Basic Initializers
66+
extension SignalPicker {
67+
public init(
68+
selection: Binding<SelectionValue>,
69+
@ViewBuilder content: () -> Content,
70+
@ViewBuilder label: () -> Label
71+
) {
72+
self.sui = SwiftUI.Picker(
73+
selection: selection,
74+
content: content,
75+
label: label
76+
)
77+
self.signalSelection = selection
78+
self.signalLabel = Self.extractLabel(label())
79+
}
80+
}
81+
82+
// MARK: - Text Label Variants
83+
extension SignalPicker where Label == Text {
84+
public init(
85+
_ titleKey: LocalizedStringKey,
86+
selection: Binding<SelectionValue>,
87+
@ViewBuilder content: () -> Content
88+
) {
89+
self.sui = SwiftUI.Picker(
90+
titleKey,
91+
selection: selection,
92+
content: content
93+
)
94+
self.signalSelection = selection
95+
self.signalLabel = titleKey
96+
}
97+
98+
public init<S>(
99+
_ title: S,
100+
selection: Binding<SelectionValue>,
101+
@ViewBuilder content: () -> Content
102+
) where S: StringProtocol {
103+
self.sui = SwiftUI.Picker(
104+
title,
105+
selection: selection,
106+
content: content
107+
)
108+
self.signalSelection = selection
109+
self.signalLabel = String(title)
110+
}
111+
}
112+
113+
// MARK: - Deprecated Variants
114+
extension SignalPicker where Label == Text {
115+
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter")
116+
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter")
117+
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter")
118+
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter")
119+
public init(
120+
_ titleKey: LocalizedStringKey,
121+
selection: Binding<SelectionValue>,
122+
@ViewBuilder content: () -> Content,
123+
onCommit: @escaping () -> Void
124+
) {
125+
self.sui = SwiftUI.Picker(
126+
titleKey,
127+
selection: selection,
128+
content: content
129+
)
130+
self.signalSelection = selection
131+
self.signalLabel = titleKey
132+
}
133+
134+
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter")
135+
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter")
136+
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter")
137+
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter")
138+
public init<S>(
139+
_ title: S,
140+
selection: Binding<SelectionValue>,
141+
@ViewBuilder content: () -> Content,
142+
onCommit: @escaping () -> Void
143+
) where S: StringProtocol {
144+
self.sui = SwiftUI.Picker(
145+
title,
146+
selection: selection,
147+
content: content
148+
)
149+
self.signalSelection = selection
150+
self.signalLabel = String(title)
151+
}
152+
}

Sources/AnalyticsLive/Signals/AutoTracking/SwiftUI/SignalSecureField.swift

100644100755
File mode changed.

0 commit comments

Comments
 (0)