Skip to content

Commit 57e6d2e

Browse files
Added changeset count and placeholder image for profile
1 parent f3b2ead commit 57e6d2e

File tree

6 files changed

+26
-151
lines changed

6 files changed

+26
-151
lines changed

GoInfoGame/GoInfoGame/UI/Profile/ProfileView.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct ProfileView: View {
2525
Image(systemName: "star.fill")
2626
.resizable()
2727
.frame(width: 25, height: 25)
28-
Text("0")
28+
Text("\(viewModel.user?.changesets.count ?? 0)")
2929
.font(.title)
3030
}
3131
}
@@ -48,15 +48,11 @@ struct ProfileView: View {
4848
}
4949

5050
private var profileImage: some View {
51-
AsyncImage(url: URL(string: "https://picsum.photos/200/300")) { phase in
52-
if let image = phase.image {
53-
image.resizable()
54-
} else if phase.error != nil {
55-
Image(systemName: "person.circle.fill")
56-
.resizable()
57-
} else {
58-
ProgressView().progressViewStyle(.circular)
59-
}
51+
AsyncImage(url: self.viewModel.imageUrl) { image in
52+
image.resizable()
53+
} placeholder: {
54+
Image(systemName: "person.circle.fill")
55+
.resizable()
6056
}
6157
.frame(width: 120, height: 120, alignment: .center)
6258
.cornerRadius(60)

GoInfoGame/GoInfoGame/UI/Profile/ProfileViewVM.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import Foundation
99
import osmapi
1010

1111
class ProfileViewVM: ObservableObject {
12-
@Published var user: OSMUserData?
12+
@Published var user: OSMUserData?
13+
1314
init() {
1415
let posmConnection = OSMConnection(config: OSMConfig.testOSM,userCreds: OSMLogin.testOSM)
1516
posmConnection.getUserDetails() { [weak self]result in
@@ -19,7 +20,7 @@ class ProfileViewVM: ObservableObject {
1920
print(userDataResponse)
2021
DispatchQueue.main.async {
2122
self?.user = user
22-
}
23+
}
2324
case .failure(let error):
2425
print("---error", error)
2526
}
@@ -32,4 +33,11 @@ class ProfileViewVM: ObservableObject {
3233
}
3334
return nil
3435
}
36+
37+
var imageUrl: URL? {
38+
if let imageString = self.user?.profileImage?.href {
39+
return URL(string: imageString)
40+
}
41+
return nil
42+
}
3543
}

GoInfoGame/GoInfoGame/UI/ProfileView.swift

Lines changed: 0 additions & 107 deletions
This file was deleted.

GoInfoGame/GoInfoGame/UI/ProfileViewVM.swift

Lines changed: 0 additions & 28 deletions
This file was deleted.

GoInfoGame/GoInfoGame/quests/CrossingType/CrossingTypeForm.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct CrossingTypeForm: View, QuestForm {
2424
var body: some View {
2525
ZStack{
2626
VStack{
27-
QuestionHeader(icon:Image("kerb_tactile_paving"), title: LocalizedStrings.questCrossingTypeTitle.localized, subtitle: "Crossing")
27+
QuestionHeader(icon:Image("pedestrian_crossing"), title: LocalizedStrings.questCrossingTypeTitle.localized, subtitle: "Crossing")
2828
VStack(alignment:.center){
2929
VStack (alignment: .leading){
3030
Text(LocalizedStrings.selectOne.localized).font(.caption).foregroundColor(.gray)

GoInfoGame/osmapi/models/OSMUserData.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public struct OSMUserData: Codable {
2121
let description: String
2222
let contributorTerms: ContributorTerms
2323
let roles: [String]
24-
let changesets, traces: Changesets
24+
public let changesets, traces: Changesets
2525
let blocks: Blocks
26+
public let profileImage: profileImage?
2627

2728
enum CodingKeys: String, CodingKey {
2829
case id
@@ -31,6 +32,7 @@ public struct OSMUserData: Codable {
3132
case description
3233
case contributorTerms = "contributor_terms"
3334
case roles, changesets, traces, blocks
35+
case profileImage = "img"
3436
}
3537
}
3638

@@ -45,11 +47,15 @@ struct Received: Codable {
4547
}
4648

4749
// MARK: - Changesets
48-
struct Changesets: Codable {
49-
let count: Int
50+
public struct Changesets: Codable {
51+
public let count: Int
5052
}
5153

5254
// MARK: - ContributorTerms
5355
struct ContributorTerms: Codable {
5456
let agreed: Bool
5557
}
58+
59+
public struct profileImage: Codable {
60+
public let href: String
61+
}

0 commit comments

Comments
 (0)