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 {
|
||||
let localAccountInfo: LocalData.UserAccountInfo
|
||||
@State
|
||||
var avatarImage: UIImage? = nil
|
||||
@State var avatarImage: UIImage? = nil
|
||||
@ObservedObject var preferences = Preferences.shared
|
||||
|
||||
var body: some View {
|
||||
let image: Image
|
||||
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 {
|
||||
image = Image(uiImage: self.avatarImage!).renderingMode(.original)
|
||||
}
|
||||
return image
|
||||
.resizable()
|
||||
.frame(width: 30, height: 30)
|
||||
.cornerRadius(preferences.avatarStyle.cornerRadiusFraction * 30)
|
||||
.onAppear(perform: self.loadImage)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue