Skip to content

Commit f1ae472

Browse files
initial coming on profileview
1 parent 1b26ecb commit f1ae472

File tree

6 files changed

+105
-5
lines changed

6 files changed

+105
-5
lines changed

GoInfoGame/GoInfoGame.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@
157157
A4E711AC2B58F7C000C9DE08 /* HandRailForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4E711AB2B58F7C000C9DE08 /* HandRailForm.swift */; };
158158
A4E711AE2B59004700C9DE08 /* StepsIncline.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4E711AD2B59004700C9DE08 /* StepsIncline.swift */; };
159159
A4E711B02B59011000C9DE08 /* StepsInclineForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4E711AF2B59011000C9DE08 /* StepsInclineForm.swift */; };
160+
B0CCB98C2B8626AE00AA73DE /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0CCB98B2B8626AE00AA73DE /* ProfileView.swift */; };
161+
B0CCB98E2B8626C600AA73DE /* ProfileViewVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = B0CCB98D2B8626C600AA73DE /* ProfileViewVM.swift */; };
160162
FA5853C12B21F17F00301CDA /* OnboardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA5853C02B21F17F00301CDA /* OnboardingView.swift */; };
161163
FA87A8102B68142F000A6BEA /* LoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA87A80F2B68142F000A6BEA /* LoadingView.swift */; };
162164
FA87A8132B6AC019000A6BEA /* StepsRampTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA87A8112B6AC019000A6BEA /* StepsRampTests.swift */; };
@@ -409,6 +411,8 @@
409411
A4E711AD2B59004700C9DE08 /* StepsIncline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsIncline.swift; sourceTree = "<group>"; };
410412
A4E711AF2B59011000C9DE08 /* StepsInclineForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsInclineForm.swift; sourceTree = "<group>"; };
411413
AE61EC473200AFDA81C2110A /* Pods-GoInfoGame-GoInfoGameUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GoInfoGame-GoInfoGameUITests.release.xcconfig"; path = "Target Support Files/Pods-GoInfoGame-GoInfoGameUITests/Pods-GoInfoGame-GoInfoGameUITests.release.xcconfig"; sourceTree = "<group>"; };
414+
B0CCB98B2B8626AE00AA73DE /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
415+
B0CCB98D2B8626C600AA73DE /* ProfileViewVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileViewVM.swift; sourceTree = "<group>"; };
412416
C96303080D26026265099E0E /* Pods-GoInfoGame.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GoInfoGame.release.xcconfig"; path = "Target Support Files/Pods-GoInfoGame/Pods-GoInfoGame.release.xcconfig"; sourceTree = "<group>"; };
413417
D76D8E22AC705A38AFEA78B1 /* Pods-GoInfoGame-GoInfoGameUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GoInfoGame-GoInfoGameUITests.debug.xcconfig"; path = "Target Support Files/Pods-GoInfoGame-GoInfoGameUITests/Pods-GoInfoGame-GoInfoGameUITests.debug.xcconfig"; sourceTree = "<group>"; };
414418
F008D431593E568E75C48C84 /* Pods-GoInfoGame.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GoInfoGame.debug.xcconfig"; path = "Target Support Files/Pods-GoInfoGame/Pods-GoInfoGame.debug.xcconfig"; sourceTree = "<group>"; };
@@ -569,6 +573,8 @@
569573
children = (
570574
FA87A80E2B681416000A6BEA /* Utils */,
571575
970D5BD02B62B61300C20BE7 /* MapViewController.swift */,
576+
B0CCB98B2B8626AE00AA73DE /* ProfileView.swift */,
577+
B0CCB98D2B8626C600AA73DE /* ProfileViewVM.swift */,
572578
971575152B5FFD5F0044797C /* Map */,
573579
973FC0152B4D562200878269 /* CustomComponents */,
574580
973FBFFF2B46CD4100878269 /* QuestsList */,
@@ -1663,6 +1669,7 @@
16631669
973FC04C2B5A5F5F00878269 /* RadioItem.swift in Sources */,
16641670
A495DF2D2B6A190400478E44 /* CustomMapView.swift in Sources */,
16651671
05DBBB662B17209600B6F110 /* RealmOPMeta.swift in Sources */,
1672+
B0CCB98E2B8626C600AA73DE /* ProfileViewVM.swift in Sources */,
16661673
0536DD942B0BD59900B04C4B /* OAuthError.swift in Sources */,
16671674
973FC0172B4D567900878269 /* WidthView.swift in Sources */,
16681675
97AC1C082B6A45C9004F0BF4 /* SideWalkValidationForm.swift in Sources */,
@@ -1678,6 +1685,7 @@
16781685
A4E711AC2B58F7C000C9DE08 /* HandRailForm.swift in Sources */,
16791686
A4E711A62B57BBCA00C9DE08 /* QuestProtocols.swift in Sources */,
16801687
973FBFFE2B46BB3800878269 /* Utils.swift in Sources */,
1688+
B0CCB98C2B8626AE00AA73DE /* ProfileView.swift in Sources */,
16811689
FAF44FBD2B3084EC004FE664 /* OnboardingView1.swift in Sources */,
16821690
973FC01D2B4FEE1B00878269 /* YesNoView.swift in Sources */,
16831691
);

GoInfoGame/GoInfoGame/Base.lproj/Main.storyboard

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
<view key="view" contentMode="scaleToFill" id="WIL-R2-Zwd">
1717
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
1818
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
19+
<subviews>
20+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="sta" translatesAutoresizingMaskIntoConstraints="NO" id="eFu-Od-x7K">
21+
<rect key="frame" x="114" y="400" width="240" height="128"/>
22+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
23+
</imageView>
24+
</subviews>
1925
<viewLayoutGuide key="safeArea" id="YrN-Z6-zFT"/>
2026
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
2127
</view>
@@ -48,6 +54,7 @@
4854
</scene>
4955
</scenes>
5056
<resources>
57+
<image name="sta" width="128" height="128"/>
5158
<systemColor name="systemBackgroundColor">
5259
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
5360
</systemColor>

GoInfoGame/GoInfoGame/UI/MapViewController.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class MapViewController: UIHostingController<MapView> {
1717

1818
let questListButton = UIBarButtonItem(barButtonSystemItem: .search, target: self, action: #selector(questListButtonTapped))
1919
navigationItem.rightBarButtonItem = questListButton
20+
21+
let profileButton = UIBarButtonItem(image: UIImage(systemName: "person.crop.circle.fill"), style: .plain, target: self, action: #selector(profileButtonTapped))
22+
navigationItem.leftBarButtonItem = profileButton
2023
}
2124

2225
required init?(coder aDecoder: NSCoder) {
@@ -28,4 +31,10 @@ class MapViewController: UIHostingController<MapView> {
2831
let hostingController = UIHostingController(rootView: questListView)
2932
present(hostingController, animated: true, completion: nil)
3033
}
34+
35+
@objc func profileButtonTapped() {
36+
let profileView = ProfileView()
37+
let hostingController = UIHostingController(rootView: profileView)
38+
present(hostingController, animated: true, completion: nil)
39+
}
3140
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// ProfileView.swift
3+
// GoInfoGame
4+
//
5+
// Created by Sudula Murali Krishna on 2/21/24.
6+
//
7+
8+
import Foundation
9+
import SwiftUI
10+
11+
struct ProfileView: View {
12+
@ObservedObject private var viewModel = ProfileViewVM()
13+
14+
var body: some View {
15+
return VStack {
16+
HStack {
17+
AsyncImage(url: URL(string: "https://picsum.photos/200/300")) { image in
18+
image.resizable()
19+
.aspectRatio(contentMode: .fill)
20+
} placeholder: {
21+
ProgressView()
22+
}
23+
.frame(width: 150, height: 150, alignment: .center)
24+
.cornerRadius(75)
25+
VStack {
26+
Text(viewModel.user?.displayName ?? "testste")
27+
.multilineTextAlignment(.leading)
28+
HStack {
29+
Image(systemName: "star.fill")
30+
.resizable()
31+
.frame(width: 25, height: 25)
32+
Text("0")
33+
.font(.title)
34+
Spacer()
35+
}
36+
37+
}
38+
Spacer()
39+
}
40+
Spacer()
41+
}
42+
.padding(20)
43+
}
44+
}
45+
46+
#Preview {
47+
ProfileView()
48+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// ProfileViewVM.swift
3+
// GoInfoGame
4+
//
5+
// Created by Sudula Murali Krishna on 2/21/24.
6+
//
7+
8+
import Foundation
9+
import osmapi
10+
11+
class ProfileViewVM: ObservableObject {
12+
@Published var user: OSMUserData?
13+
init() {
14+
let posmConnection = OSMConnection(config: OSMConfig.test,userCreds: OSMLogin.test)
15+
posmConnection.getUserDetails() { [weak self]result in
16+
switch result {
17+
case .success(let userDataResponse):
18+
let user = userDataResponse.user
19+
print(userDataResponse)
20+
DispatchQueue.main.async {
21+
self?.user = user
22+
}
23+
case .failure(let error):
24+
print("---error", error)
25+
}
26+
}
27+
}
28+
}

GoInfoGame/osmapi/models/OSMUserData.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
import Foundation
88

99
// MARK: - OSMUserData
10-
struct OSMUserDataResponse: Codable {
10+
public struct OSMUserDataResponse: Codable {
1111
let version, generator, copyright: String
1212
let attribution, license: String
13-
let user: OSMUserData
13+
public let user: OSMUserData
1414
}
1515

1616
// MARK: - User
17-
struct OSMUserData: Codable {
18-
let id: Int
19-
let displayName: String
17+
public struct OSMUserData: Codable {
18+
public let id: Int
19+
public let displayName: String
2020
let accountCreated: Date
2121
let description: String
2222
let contributorTerms: ContributorTerms

0 commit comments

Comments
 (0)