mirror of https://github.com/lukechilds/damus.git
Browse Source
we'll need this in thread and event details view Signed-off-by: William Casarin <jb55@jb55.com>profiles-everywhere
William Casarin
3 years ago
4 changed files with 44 additions and 16 deletions
@ -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