Skip to content

Commit 3280fd5

Browse files
Added loader for AsyncImage
1 parent 57e6d2e commit 3280fd5

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

GoInfoGame/GoInfoGame/UI/Profile/ProfileView.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,27 @@ struct ProfileView: View {
4747

4848
}
4949

50+
@ViewBuilder
5051
private var profileImage: some View {
51-
AsyncImage(url: self.viewModel.imageUrl) { image in
52-
image.resizable()
53-
} placeholder: {
52+
if self.viewModel.imageUrl == nil {
5453
Image(systemName: "person.circle.fill")
5554
.resizable()
55+
.frame(width: 120, height: 120, alignment: .center)
56+
.cornerRadius(60)
57+
}else {
58+
AsyncImage(url: self.viewModel.imageUrl) { phase in
59+
if let image = phase.image {
60+
image.resizable()
61+
} else if phase.error != nil {
62+
Image(systemName: "person.circle.fill")
63+
.resizable()
64+
} else {
65+
ProgressView().progressViewStyle(.circular)
66+
}
67+
}
68+
.frame(width: 120, height: 120, alignment: .center)
69+
.cornerRadius(60)
5670
}
57-
.frame(width: 120, height: 120, alignment: .center)
58-
.cornerRadius(60)
5971
}
6072

6173
private var profileButton: some View {

0 commit comments

Comments
 (0)