mirror of
git://jb55.com/damus
synced 2024-09-30 00:40:45 +00:00
refactor profile pic into view
we'll need this in thread and event details view Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
698ddb31cc
commit
d3d8b56a08
@ -30,6 +30,7 @@
|
||||
4CEE2AEB2805AEA300AB5EEF /* secp256k1 in Frameworks */ = {isa = PBXBuildFile; productRef = 4CEE2AEA2805AEA300AB5EEF /* secp256k1 */; };
|
||||
4CEE2AED2805B22500AB5EEF /* NostrRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CEE2AEC2805B22500AB5EEF /* NostrRequest.swift */; };
|
||||
4CEE2AEF2805BE2500AB5EEF /* NostrTimeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CEE2AEE2805BE2500AB5EEF /* NostrTimeline.swift */; };
|
||||
4CEE2AF3280B25C500AB5EEF /* ProfilePicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CEE2AF2280B25C500AB5EEF /* ProfilePicView.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@ -75,6 +76,7 @@
|
||||
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>"; };
|
||||
4CEE2AEE2805BE2500AB5EEF /* NostrTimeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NostrTimeline.swift; sourceTree = "<group>"; };
|
||||
4CEE2AF2280B25C500AB5EEF /* ProfilePicView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfilePicView.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -111,6 +113,7 @@
|
||||
4C75EFA327FA577B0006080F /* PostView.swift */,
|
||||
4C75EFAC28049CFB0006080F /* PostButton.swift */,
|
||||
4C75EFB82804A2740006080F /* EventView.swift */,
|
||||
4CEE2AF2280B25C500AB5EEF /* ProfilePicView.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
@ -350,6 +353,7 @@
|
||||
4CEE2AEF2805BE2500AB5EEF /* NostrTimeline.swift in Sources */,
|
||||
4C75EFAF28049D350006080F /* NostrFilter.swift in Sources */,
|
||||
4CE6DF1627F8DEBF00C66700 /* RelayConnection.swift in Sources */,
|
||||
4CEE2AF3280B25C500AB5EEF /* ProfilePicView.swift in Sources */,
|
||||
4CE6DEE727F7A08100C66700 /* damusApp.swift in Sources */,
|
||||
4CEE2AED2805B22500AB5EEF /* NostrRequest.swift in Sources */,
|
||||
4C75EFA427FA577B0006080F /* PostView.swift in Sources */,
|
||||
|
@ -8,9 +8,6 @@
|
||||
import SwiftUI
|
||||
import Starscream
|
||||
|
||||
let PFP_SIZE: CGFloat? = 64
|
||||
let CORNER_RADIUS: CGFloat = 32
|
||||
|
||||
struct TimestampedProfile {
|
||||
let profile: Profile
|
||||
let timestamp: Int64
|
||||
|
@ -16,19 +16,7 @@ struct EventView: View {
|
||||
var body: some View {
|
||||
HStack {
|
||||
VStack {
|
||||
if let pic = profile?.picture.flatMap { URL(string: $0) } {
|
||||
CachedAsyncImage(url: pic) { img in
|
||||
img.resizable()
|
||||
} placeholder: {
|
||||
Color.purple.opacity(0.1)
|
||||
}
|
||||
.frame(width: PFP_SIZE, height: PFP_SIZE)
|
||||
.cornerRadius(CORNER_RADIUS)
|
||||
} else {
|
||||
Color.purple.opacity(0.1)
|
||||
.frame(width: PFP_SIZE, height: PFP_SIZE)
|
||||
.cornerRadius(CORNER_RADIUS)
|
||||
}
|
||||
ProfilePicView(picture: profile?.picture, size: 64)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
39
damus/Views/ProfilePicView.swift
Normal file
39
damus/Views/ProfilePicView.swift
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// ProfilePicView.swift
|
||||
// damus
|
||||
//
|
||||
// Created by William Casarin on 2022-04-16.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import CachedAsyncImage
|
||||
|
||||
let PFP_SIZE: CGFloat? = 64
|
||||
let CORNER_RADIUS: CGFloat = 32
|
||||
|
||||
struct ProfilePicView: View {
|
||||
let picture: String?
|
||||
let size: CGFloat
|
||||
|
||||
var body: some View {
|
||||
if let pic = picture.flatMap({ URL(string: $0) }) {
|
||||
CachedAsyncImage(url: pic) { img in
|
||||
img.resizable()
|
||||
} placeholder: {
|
||||
Color.purple.opacity(0.1)
|
||||
}
|
||||
.frame(width: PFP_SIZE, height: PFP_SIZE)
|
||||
.cornerRadius(CORNER_RADIUS)
|
||||
} else {
|
||||
Color.purple.opacity(0.1)
|
||||
.frame(width: PFP_SIZE, height: PFP_SIZE)
|
||||
.cornerRadius(CORNER_RADIUS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ProfilePicView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ProfilePicView(picture: "http://cdn.jb55.com/img/red-me.jpg", size: 64)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user