-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathDeepLinkTestView.swift
More file actions
119 lines (105 loc) 路 4.34 KB
/
Copy pathDeepLinkTestView.swift
File metadata and controls
119 lines (105 loc) 路 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//
// DeepLinkTestView.swift
// Example
//
// Created by DebugSwift on 13/02/26.
//
import SwiftUI
struct DeepLinkTestView: View {
let url: URL?
@Environment(\.presentationMode) var presentationMode
var body: some View {
NavigationView {
VStack(spacing: 30) {
Image(systemName: "link.circle.fill")
.font(.system(size: 100))
.foregroundColor(.green)
Text("Deep Link Opened!")
.font(.title)
.fontWeight(.bold)
if let url = url {
VStack(alignment: .leading, spacing: 15) {
Text("URL Details:")
.font(.headline)
.foregroundColor(.primary)
DetailRow(label: "Scheme:", value: url.scheme ?? "N/A")
DetailRow(label: "Host:", value: url.host ?? "N/A")
DetailRow(label: "Path:", value: url.path.isEmpty ? "/" : url.path)
if let query = url.query, !query.isEmpty {
DetailRow(label: "Query:", value: query)
}
if let components = URLComponents(url: url, resolvingAgainstBaseURL: false),
let queryItems = components.queryItems, !queryItems.isEmpty {
VStack(alignment: .leading, spacing: 8) {
Text("Parameters:")
.font(.subheadline)
.fontWeight(.semibold)
.foregroundColor(.secondary)
ForEach(queryItems, id: \.name) { item in
HStack {
Text(item.name)
.font(.caption)
.foregroundColor(.secondary)
Spacer()
Text(item.value ?? "")
.font(.caption)
.foregroundColor(.primary)
}
.padding(.horizontal, 8)
}
}
.padding(.top, 8)
}
}
.padding(20)
.background(Color.secondary.opacity(0.1))
.cornerRadius(12)
.padding(.horizontal)
} else {
Text("No URL information available")
.font(.subheadline)
.foregroundColor(.secondary)
}
Spacer()
Button(action: {
presentationMode.wrappedValue.dismiss()
}) {
Text("Close")
.font(.headline)
.foregroundColor(.white)
.frame(maxWidth: .infinity)
.padding()
.background(Color.blue)
.cornerRadius(10)
}
.padding(.horizontal)
.padding(.bottom, 30)
}
.padding(.top, 40)
.navigationBarTitle("Deep Link Test", displayMode: .inline)
.navigationBarItems(trailing: Button("Done") {
presentationMode.wrappedValue.dismiss()
})
}
}
}
struct DetailRow: View {
let label: String
let value: String
var body: some View {
VStack(alignment: .leading, spacing: 4) {
Text(label)
.font(.caption)
.fontWeight(.semibold)
.foregroundColor(.secondary)
Text(value)
.font(.body)
.foregroundColor(.primary)
}
}
}
struct DeepLinkTestView_Previews: PreviewProvider {
static var previews: some View {
DeepLinkTestView(url: URL(string: "debugswift://test?id=123&name=example"))
}
}