Apply avatar style to local account avatar images
This commit is contained in:
parent
5a098df931
commit
04496aca1d
|
@ -10,19 +10,27 @@ import SwiftUI
|
||||||
|
|
||||||
struct LocalAccountAvatarView: View {
|
struct LocalAccountAvatarView: View {
|
||||||
let localAccountInfo: LocalData.UserAccountInfo
|
let localAccountInfo: LocalData.UserAccountInfo
|
||||||
@State
|
@State var avatarImage: UIImage? = nil
|
||||||
var avatarImage: UIImage? = nil
|
@ObservedObject var preferences = Preferences.shared
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
let image: Image
|
let image: Image
|
||||||
if avatarImage == nil {
|
if avatarImage == nil {
|
||||||
image = Image(systemName: "person.crop.square")
|
let imageName: String
|
||||||
|
switch preferences.avatarStyle {
|
||||||
|
case .circle:
|
||||||
|
imageName = "person.crop.circle"
|
||||||
|
case .roundRect:
|
||||||
|
imageName = "person.crop.square"
|
||||||
|
}
|
||||||
|
image = Image(systemName: imageName).resizable()
|
||||||
} else {
|
} else {
|
||||||
image = Image(uiImage: self.avatarImage!).renderingMode(.original)
|
image = Image(uiImage: self.avatarImage!).renderingMode(.original)
|
||||||
}
|
}
|
||||||
return image
|
return image
|
||||||
.resizable()
|
.resizable()
|
||||||
.frame(width: 30, height: 30)
|
.frame(width: 30, height: 30)
|
||||||
|
.cornerRadius(preferences.avatarStyle.cornerRadiusFraction * 30)
|
||||||
.onAppear(perform: self.loadImage)
|
.onAppear(perform: self.loadImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue