diff --git a/damus.xcodeproj/project.pbxproj b/damus.xcodeproj/project.pbxproj index 3e85bb6..d79d1bb 100644 --- a/damus.xcodeproj/project.pbxproj +++ b/damus.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ 4C75EFB328049D640006080F /* NostrEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C75EFB228049D640006080F /* NostrEvent.swift */; }; 4C75EFB528049D790006080F /* Relay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C75EFB428049D790006080F /* Relay.swift */; }; 4C75EFB728049D990006080F /* RelayPool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C75EFB628049D990006080F /* RelayPool.swift */; }; + 4C75EFB92804A2740006080F /* EventView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C75EFB82804A2740006080F /* EventView.swift */; }; 4CE6DEE727F7A08100C66700 /* damusApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE6DEE627F7A08100C66700 /* damusApp.swift */; }; 4CE6DEE927F7A08100C66700 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE6DEE827F7A08100C66700 /* ContentView.swift */; }; 4CE6DEEB27F7A08200C66700 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4CE6DEEA27F7A08200C66700 /* Assets.xcassets */; }; @@ -54,6 +55,7 @@ 4C75EFB228049D640006080F /* NostrEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NostrEvent.swift; sourceTree = ""; }; 4C75EFB428049D790006080F /* Relay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Relay.swift; sourceTree = ""; }; 4C75EFB628049D990006080F /* RelayPool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayPool.swift; sourceTree = ""; }; + 4C75EFB82804A2740006080F /* EventView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventView.swift; sourceTree = ""; }; 4CE6DEE327F7A08100C66700 /* damus.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = damus.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4CE6DEE627F7A08100C66700 /* damusApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = damusApp.swift; sourceTree = ""; }; 4CE6DEE827F7A08100C66700 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; @@ -99,6 +101,7 @@ children = ( 4C75EFA327FA577B0006080F /* PostView.swift */, 4C75EFAC28049CFB0006080F /* PostButton.swift */, + 4C75EFB82804A2740006080F /* EventView.swift */, ); path = Views; sourceTree = ""; @@ -317,6 +320,7 @@ 4C75EFB728049D990006080F /* RelayPool.swift in Sources */, 4CE6DEE927F7A08100C66700 /* ContentView.swift in Sources */, 4C75EFAD28049CFB0006080F /* PostButton.swift in Sources */, + 4C75EFB92804A2740006080F /* EventView.swift in Sources */, 4C75EFA627FF87A20006080F /* Nostr.swift in Sources */, 4C75EFB328049D640006080F /* NostrEvent.swift in Sources */, 4C75EFB128049D510006080F /* NostrResponse.swift in Sources */, diff --git a/damus/ContentView.swift b/damus/ContentView.swift index e0ae31e..600b384 100644 --- a/damus/ContentView.swift +++ b/damus/ContentView.swift @@ -16,43 +16,6 @@ struct TimestampedProfile { let timestamp: Int64 } -struct EventView: View { - let event: NostrEvent - let profile: Profile? - - var body: some View { - HStack { - if let pic = profile?.picture.flatMap { URL(string: $0) } { - AsyncImage(url: pic) { img in - img.resizable() - } placeholder: { - Color.purple.opacity(0.1) - } - .frame(width: PFP_SIZE, height: PFP_SIZE, alignment: .top) - .cornerRadius(CORNER_RADIUS) - } else { - Color.purple.opacity(0.1) - .frame(width: PFP_SIZE, height: PFP_SIZE, alignment: .top) - .cornerRadius(CORNER_RADIUS) - } - - VStack { - Text(String(profile?.name ?? String(event.pubkey.prefix(16)))) - .bold() - .onTapGesture { - UIPasteboard.general.string = event.pubkey - } - .frame(maxWidth: .infinity, alignment: .leading) - Text(event.content) - .textSelection(.enabled) - .frame(maxWidth: .infinity, alignment: .leading) - Divider() - } - - } - } -} - enum Sheets: Identifiable { case post diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift new file mode 100644 index 0000000..f091274 --- /dev/null +++ b/damus/Views/EventView.swift @@ -0,0 +1,47 @@ +// +// EventView.swift +// damus +// +// Created by William Casarin on 2022-04-11. +// + +import Foundation +import SwiftUI + +struct EventView: View { + let event: NostrEvent + let profile: Profile? + + var body: some View { + HStack { + if let pic = profile?.picture.flatMap { URL(string: $0) } { + AsyncImage(url: pic) { img in + img.resizable() + } placeholder: { + Color.purple.opacity(0.1) + } + .frame(width: PFP_SIZE, height: PFP_SIZE, alignment: .top) + .cornerRadius(CORNER_RADIUS) + } else { + Color.purple.opacity(0.1) + .frame(width: PFP_SIZE, height: PFP_SIZE, alignment: .top) + .cornerRadius(CORNER_RADIUS) + } + + VStack { + Text(String(profile?.name ?? String(event.pubkey.prefix(16)))) + .bold() + .onTapGesture { + UIPasteboard.general.string = event.pubkey + } + .frame(maxWidth: .infinity, alignment: .leading) + Text(event.content) + .textSelection(.enabled) + .frame(maxWidth: .infinity, alignment: .leading) + Divider() + } + + } + } +} +