damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

RelaySoftwareDetail.swift (2715B)


      1 //
      2 //  RelaySoftwareDetail.swift
      3 //  damus
      4 //
      5 //  Created by eric on 4/1/24.
      6 //
      7 
      8 import SwiftUI
      9 
     10 struct RelaySoftwareDetail: View {
     11     
     12     let nip11: RelayMetadata?
     13     
     14     var body: some View {
     15         HStack(spacing: 15) {
     16             VStack {
     17                 Text("SOFTWARE", comment: "Text label indicating which relay software is used to run this Nostr relay.")
     18                     .font(.caption)
     19                     .fontWeight(.heavy)
     20                     .foregroundColor(DamusColors.mediumGrey)
     21                 
     22                 Image("code")
     23                     .foregroundColor(.gray)
     24                 
     25                 let software = nip11?.software
     26                 let softwareSeparated = software?.components(separatedBy: "/")
     27                 if let softwareShortened = softwareSeparated?.last {
     28                     Text(softwareShortened)
     29                         .font(.subheadline)
     30                         .foregroundColor(.gray)
     31                 } else {
     32                     Text("N/A", comment: "Text label indicating that there is no NIP-11 relay software information found. In English, N/A stands for not applicable.")
     33                         .font(.subheadline)
     34                         .foregroundColor(.gray)
     35                 }
     36             }
     37             
     38             Divider().frame(width: 1)
     39             
     40             VStack {
     41                 Text("VERSION", comment: "Text label indicating which version of the relay software is being run for this Nostr relay.")
     42                     .font(.caption)
     43                     .fontWeight(.heavy)
     44                     .foregroundColor(DamusColors.mediumGrey)
     45                 
     46                 Image("branches")
     47                     .foregroundColor(.gray)
     48 
     49                 if let version = nip11?.version, !version.isEmpty {
     50                     Text(version)
     51                         .font(.subheadline)
     52                         .foregroundColor(.gray)
     53                 } else {
     54                     Text("N/A", comment: "Text label indicating that there is no NIP-11 relay software version information found. In English, N/A stands for not applicable.")
     55                         .font(.subheadline)
     56                         .foregroundColor(.gray)
     57                 }
     58             }
     59         }
     60     }
     61 }
     62 
     63 struct RelaySoftwareDetail_Previews: PreviewProvider {
     64     static var previews: some View {
     65         let metadata = RelayMetadata(name: "name", description: "desc", pubkey: test_pubkey, contact: "contact", supported_nips: [1,2,3], software: "git+https://github.com/hoytech/strfry.git", version: "0.9.6-26-gc0dec7c", limitation: Limitations.empty, payments_url: "https://jb55.com", icon: "", fees: Fees.empty)
     66         RelaySoftwareDetail(nip11: metadata)
     67     }
     68 }