1
0
mirror of git://jb55.com/damus synced 2024-09-30 00:40:45 +00:00

move EventView to its own file

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin 2022-04-11 10:53:43 -07:00
parent 28790ccfab
commit bf4743253f
3 changed files with 51 additions and 37 deletions

View File

@ -16,6 +16,7 @@
4C75EFB328049D640006080F /* NostrEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C75EFB228049D640006080F /* NostrEvent.swift */; }; 4C75EFB328049D640006080F /* NostrEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C75EFB228049D640006080F /* NostrEvent.swift */; };
4C75EFB528049D790006080F /* Relay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C75EFB428049D790006080F /* Relay.swift */; }; 4C75EFB528049D790006080F /* Relay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C75EFB428049D790006080F /* Relay.swift */; };
4C75EFB728049D990006080F /* RelayPool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C75EFB628049D990006080F /* RelayPool.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 */; }; 4CE6DEE727F7A08100C66700 /* damusApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE6DEE627F7A08100C66700 /* damusApp.swift */; };
4CE6DEE927F7A08100C66700 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE6DEE827F7A08100C66700 /* ContentView.swift */; }; 4CE6DEE927F7A08100C66700 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE6DEE827F7A08100C66700 /* ContentView.swift */; };
4CE6DEEB27F7A08200C66700 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4CE6DEEA27F7A08200C66700 /* Assets.xcassets */; }; 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 = "<group>"; }; 4C75EFB228049D640006080F /* NostrEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NostrEvent.swift; sourceTree = "<group>"; };
4C75EFB428049D790006080F /* Relay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Relay.swift; sourceTree = "<group>"; }; 4C75EFB428049D790006080F /* Relay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Relay.swift; sourceTree = "<group>"; };
4C75EFB628049D990006080F /* RelayPool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayPool.swift; sourceTree = "<group>"; }; 4C75EFB628049D990006080F /* RelayPool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayPool.swift; sourceTree = "<group>"; };
4C75EFB82804A2740006080F /* EventView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventView.swift; sourceTree = "<group>"; };
4CE6DEE327F7A08100C66700 /* damus.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = damus.app; sourceTree = BUILT_PRODUCTS_DIR; }; 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 = "<group>"; }; 4CE6DEE627F7A08100C66700 /* damusApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = damusApp.swift; sourceTree = "<group>"; };
4CE6DEE827F7A08100C66700 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; }; 4CE6DEE827F7A08100C66700 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@ -99,6 +101,7 @@
children = ( children = (
4C75EFA327FA577B0006080F /* PostView.swift */, 4C75EFA327FA577B0006080F /* PostView.swift */,
4C75EFAC28049CFB0006080F /* PostButton.swift */, 4C75EFAC28049CFB0006080F /* PostButton.swift */,
4C75EFB82804A2740006080F /* EventView.swift */,
); );
path = Views; path = Views;
sourceTree = "<group>"; sourceTree = "<group>";
@ -317,6 +320,7 @@
4C75EFB728049D990006080F /* RelayPool.swift in Sources */, 4C75EFB728049D990006080F /* RelayPool.swift in Sources */,
4CE6DEE927F7A08100C66700 /* ContentView.swift in Sources */, 4CE6DEE927F7A08100C66700 /* ContentView.swift in Sources */,
4C75EFAD28049CFB0006080F /* PostButton.swift in Sources */, 4C75EFAD28049CFB0006080F /* PostButton.swift in Sources */,
4C75EFB92804A2740006080F /* EventView.swift in Sources */,
4C75EFA627FF87A20006080F /* Nostr.swift in Sources */, 4C75EFA627FF87A20006080F /* Nostr.swift in Sources */,
4C75EFB328049D640006080F /* NostrEvent.swift in Sources */, 4C75EFB328049D640006080F /* NostrEvent.swift in Sources */,
4C75EFB128049D510006080F /* NostrResponse.swift in Sources */, 4C75EFB128049D510006080F /* NostrResponse.swift in Sources */,

View File

@ -16,43 +16,6 @@ struct TimestampedProfile {
let timestamp: Int64 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 { enum Sheets: Identifiable {
case post case post

View File

@ -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()
}
}
}
}