Add paid relay details
This commit is contained in:
@@ -172,6 +172,7 @@
|
||||
4CE8794E2996B16A00F758CC /* RelayToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE8794D2996B16A00F758CC /* RelayToggle.swift */; };
|
||||
4CE879502996B2BD00F758CC /* RelayStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE8794F2996B2BD00F758CC /* RelayStatus.swift */; };
|
||||
4CE879522996B68900F758CC /* RelayType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE879512996B68900F758CC /* RelayType.swift */; };
|
||||
4CE879552996BAB900F758CC /* RelayPaidDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE879542996BAB900F758CC /* RelayPaidDetail.swift */; };
|
||||
4CEE2AED2805B22500AB5EEF /* NostrRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CEE2AEC2805B22500AB5EEF /* NostrRequest.swift */; };
|
||||
4CEE2AF1280B216B00AB5EEF /* EventDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CEE2AF0280B216B00AB5EEF /* EventDetailView.swift */; };
|
||||
4CEE2AF3280B25C500AB5EEF /* ProfilePicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CEE2AF2280B25C500AB5EEF /* ProfilePicView.swift */; };
|
||||
@@ -467,6 +468,7 @@
|
||||
4CE8794D2996B16A00F758CC /* RelayToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayToggle.swift; sourceTree = "<group>"; };
|
||||
4CE8794F2996B2BD00F758CC /* RelayStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayStatus.swift; sourceTree = "<group>"; };
|
||||
4CE879512996B68900F758CC /* RelayType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayType.swift; sourceTree = "<group>"; };
|
||||
4CE879542996BAB900F758CC /* RelayPaidDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayPaidDetail.swift; sourceTree = "<group>"; };
|
||||
4CEE2AE72804F57C00AB5EEF /* libsecp256k1.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libsecp256k1.a; sourceTree = "<group>"; };
|
||||
4CEE2AEC2805B22500AB5EEF /* NostrRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NostrRequest.swift; sourceTree = "<group>"; };
|
||||
4CEE2AF0280B216B00AB5EEF /* EventDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventDetailView.swift; sourceTree = "<group>"; };
|
||||
@@ -773,6 +775,7 @@
|
||||
4CAAD8AE29888A9B00060CEA /* Relays */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4CE879532996BA0000F758CC /* Detail */,
|
||||
4CB55EF2295E5D59007FD187 /* RecommendedRelayView.swift */,
|
||||
4C06670028FC7C5900038D2A /* RelayView.swift */,
|
||||
4CAAD8AF29888AD200060CEA /* RelayConfigView.swift */,
|
||||
@@ -937,6 +940,14 @@
|
||||
path = Relays;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
4CE879532996BA0000F758CC /* Detail */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4CE879542996BAB900F758CC /* RelayPaidDetail.swift */,
|
||||
);
|
||||
path = Detail;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
4CEE2AE62804F57B00AB5EEF /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -1305,6 +1316,7 @@
|
||||
4CACA9D5280C31E100D9BBE8 /* ReplyView.swift in Sources */,
|
||||
F7908E92298B0F0700AB113A /* RelayDetailView.swift in Sources */,
|
||||
4C3A1D332960DB0500558C0F /* Markdown.swift in Sources */,
|
||||
4CE879552996BAB900F758CC /* RelayPaidDetail.swift in Sources */,
|
||||
4CF0ABD42980996B00D66079 /* Report.swift in Sources */,
|
||||
4C06670B28FDE64700038D2A /* damus.c in Sources */,
|
||||
3AAA95CC298E07E900F3D526 /* DeepLPlan.swift in Sources */,
|
||||
|
||||
@@ -41,6 +41,7 @@ struct RelayMetadata: Codable {
|
||||
let software: String?
|
||||
let version: String?
|
||||
let limitation: Limitations?
|
||||
let payments_url: String?
|
||||
|
||||
var is_paid: Bool {
|
||||
return limitation?.payment_required ?? false
|
||||
|
||||
33
damus/Views/Relays/Detail/RelayPaidDetail.swift
Normal file
33
damus/Views/Relays/Detail/RelayPaidDetail.swift
Normal file
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// RelayPaidDetail.swift
|
||||
// damus
|
||||
//
|
||||
// Created by William Casarin on 2023-02-10.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct RelayPaidDetail: View {
|
||||
let payments_url: String?
|
||||
|
||||
@Environment(\.openURL) var openURL
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
RelayType(is_paid: true)
|
||||
if let url = payments_url.flatMap({ URL(string: $0) }) {
|
||||
Button(action: {
|
||||
openURL(url)
|
||||
}, label: {
|
||||
Text("\(url)")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct RelayPaidDetail_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
RelayPaidDetail(payments_url: "https://jb55.com")
|
||||
}
|
||||
}
|
||||
@@ -22,44 +22,46 @@ struct RelayDetailView: View {
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if let nip11 {
|
||||
Form {
|
||||
if let pubkey = nip11.pubkey {
|
||||
Section(NSLocalizedString("Admin", comment: "Label to display relay contact user.")) {
|
||||
UserView(damus_state: state, pubkey: pubkey)
|
||||
}
|
||||
}
|
||||
Section(NSLocalizedString("Relay", comment: "Label to display relay address.")) {
|
||||
HStack {
|
||||
Text(relay)
|
||||
Spacer()
|
||||
RelayStatus(pool: state.pool, relay: relay)
|
||||
}
|
||||
}
|
||||
Section(NSLocalizedString("Description", comment: "Label to display relay description.")) {
|
||||
FieldText(nip11.description)
|
||||
}
|
||||
Section(NSLocalizedString("Contact", comment: "Label to display relay contact information.")) {
|
||||
FieldText(nip11.contact)
|
||||
}
|
||||
Section(NSLocalizedString("Software", comment: "Label to display relay software.")) {
|
||||
FieldText(nip11.software)
|
||||
}
|
||||
Section(NSLocalizedString("Version", comment: "Label to display relay software version.")) {
|
||||
FieldText(nip11.version)
|
||||
}
|
||||
if let nips = nip11.supported_nips, nips.count > 0 {
|
||||
Section(NSLocalizedString("Supported NIPs", comment: "Label to display relay's supported NIPs.")) {
|
||||
Text(nipsList(nips: nips))
|
||||
}
|
||||
Form {
|
||||
if let pubkey = nip11.pubkey {
|
||||
Section(NSLocalizedString("Admin", comment: "Label to display relay contact user.")) {
|
||||
UserView(damus_state: state, pubkey: pubkey)
|
||||
}
|
||||
}
|
||||
Section(NSLocalizedString("Relay", comment: "Label to display relay address.")) {
|
||||
HStack {
|
||||
Text(relay)
|
||||
Spacer()
|
||||
RelayStatus(pool: state.pool, relay: relay)
|
||||
}
|
||||
}
|
||||
if nip11.is_paid {
|
||||
Section(content: {
|
||||
RelayPaidDetail(payments_url: nip11.payments_url)
|
||||
}, header: {
|
||||
Text("Paid Relay")
|
||||
}, footer: {
|
||||
Text("This is a paid relay, you must pay for posts to be accepted.")
|
||||
})
|
||||
}
|
||||
|
||||
Section(NSLocalizedString("Description", comment: "Label to display relay description.")) {
|
||||
FieldText(nip11.description)
|
||||
}
|
||||
Section(NSLocalizedString("Contact", comment: "Label to display relay contact information.")) {
|
||||
FieldText(nip11.contact)
|
||||
}
|
||||
Section(NSLocalizedString("Software", comment: "Label to display relay software.")) {
|
||||
FieldText(nip11.software)
|
||||
}
|
||||
Section(NSLocalizedString("Version", comment: "Label to display relay software version.")) {
|
||||
FieldText(nip11.version)
|
||||
}
|
||||
if let nips = nip11.supported_nips, nips.count > 0 {
|
||||
Section(NSLocalizedString("Supported NIPs", comment: "Label to display relay's supported NIPs.")) {
|
||||
Text(nipsList(nips: nips))
|
||||
}
|
||||
}
|
||||
} else if let errorString {
|
||||
Text(errorString)
|
||||
.foregroundColor(.red)
|
||||
.font(.caption)
|
||||
} else {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
.onReceive(handle_notify(.switched_timeline)) { notif in
|
||||
@@ -88,7 +90,7 @@ struct RelayDetailView: View {
|
||||
|
||||
struct RelayDetailView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let metadata = RelayMetadata(name: "name", description: "desc", pubkey: "pubkey", contact: "contact", supported_nips: [1,2,3], software: "software", version: "version", limitation: Limitations.empty)
|
||||
let metadata = RelayMetadata(name: "name", description: "desc", pubkey: "pubkey", contact: "contact", supported_nips: [1,2,3], software: "software", version: "version", limitation: Limitations.empty, payments_url: "https://jb55.com")
|
||||
RelayDetailView(state: test_damus_state(), relay: "relay", nip11: metadata)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user