mirror of
https://github.com/neon443/RNG_Swift.git
synced 2026-03-11 06:49:12 +00:00
fix vendor lookup
minor ui
This commit is contained in:
@@ -17,9 +17,13 @@ struct IPView: View {
|
||||
Text("IPv6").tag(6)
|
||||
}
|
||||
.pickerStyle(SegmentedPickerStyle())
|
||||
Text(ip)
|
||||
.contentTransition(.numericText())
|
||||
}
|
||||
Text(ip)
|
||||
.font(.system(size: 30))
|
||||
.foregroundColor(.gray)
|
||||
.frame(height: 40)
|
||||
.contentTransition(.numericText())
|
||||
.monospaced()
|
||||
Button {
|
||||
withAnimation {
|
||||
ip = generateIPv(ipType)
|
||||
|
||||
@@ -11,22 +11,20 @@ import SwiftUI
|
||||
struct MACView: View {
|
||||
@State var mac: String = ""
|
||||
@State var maclook: String = ""
|
||||
@State var looking: Bool = false
|
||||
var body: some View {
|
||||
Button("test") {
|
||||
mac = "1c:57:dc:7f:d4:ce"
|
||||
Task {
|
||||
maclook = await maclookup(mac)
|
||||
}
|
||||
}
|
||||
|
||||
List {
|
||||
HStack {
|
||||
Label("Vendor", systemImage: "building.2.fill")
|
||||
Spacer()
|
||||
if looking {
|
||||
ProgressView()
|
||||
} else {
|
||||
Text(maclook)
|
||||
.bold()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text(mac)
|
||||
.font(.system(size: 30))
|
||||
@@ -39,7 +37,9 @@ struct MACView: View {
|
||||
mac = generateMAC()
|
||||
}
|
||||
Task {
|
||||
looking = true
|
||||
maclook = await maclookup(mac)
|
||||
looking = false
|
||||
}
|
||||
} label: {
|
||||
Text("Generate")
|
||||
@@ -74,12 +74,11 @@ func maclookup(_ mac: String) async -> String {
|
||||
let result = String(data: data, encoding: .utf8) ?? "Lookup Error"
|
||||
if result.contains("{") {
|
||||
let dict = try JSONDecoder().decode([String: [String: String]].self, from: data)
|
||||
if let dict = dict["error"] {
|
||||
print(dict["detail"] as Any)
|
||||
if let dict = dict["errors"] {
|
||||
return "\(dict["detail"]!)"
|
||||
}
|
||||
}
|
||||
|
||||
return "sd"
|
||||
return result
|
||||
} catch {
|
||||
print(error.localizedDescription)
|
||||
return "Lookup Error"
|
||||
|
||||
Reference in New Issue
Block a user