Skip to content

Commit e843713

Browse files
committed
Capsule Android UI
1 parent 822896b commit e843713

File tree

5 files changed

+92
-2
lines changed

5 files changed

+92
-2
lines changed

Diff for: Kmp_iOS/Kmp_iOS.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
0A2FA1D82A969B8C00504A45 /* MissionCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A2FA1D72A969B8C00504A45 /* MissionCardView.swift */; };
2323
0A554D7E2A9A3C4100009D59 /* LinkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A554D7D2A9A3C4100009D59 /* LinkView.swift */; };
2424
0A554D812A9A4A8C00009D59 /* MyColors.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A554D802A9A4A8C00009D59 /* MyColors.swift */; };
25+
0A633DD92A9F046700DB10DB /* CapCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A633DD82A9F046700DB10DB /* CapCard.swift */; };
2526
2152FB042600AC8F00CF470E /* iOSApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2152FB032600AC8F00CF470E /* iOSApp.swift */; };
2627
7555FF83242A565900829871 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7555FF82242A565900829871 /* ContentView.swift */; };
2728
/* End PBXBuildFile section */
@@ -55,6 +56,7 @@
5556
0A2FA1D72A969B8C00504A45 /* MissionCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MissionCardView.swift; sourceTree = "<group>"; };
5657
0A554D7D2A9A3C4100009D59 /* LinkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkView.swift; sourceTree = "<group>"; };
5758
0A554D802A9A4A8C00009D59 /* MyColors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyColors.swift; sourceTree = "<group>"; };
59+
0A633DD82A9F046700DB10DB /* CapCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CapCard.swift; sourceTree = "<group>"; };
5860
2152FB032600AC8F00CF470E /* iOSApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSApp.swift; sourceTree = "<group>"; };
5961
7555FF7B242A565900829871 /* Kmp_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Kmp_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
6062
7555FF82242A565900829871 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -124,6 +126,7 @@
124126
children = (
125127
0A2FA1CB2A90443500504A45 /* CapsuleUI.swift */,
126128
0A062C282A9D4ABE002479D3 /* CapViewMode.swift */,
129+
0A633DD82A9F046700DB10DB /* CapCard.swift */,
127130
);
128131
path = Capsoule;
129132
sourceTree = "<group>";
@@ -296,6 +299,7 @@
296299
0A2FA1D82A969B8C00504A45 /* MissionCardView.swift in Sources */,
297300
0A062C292A9D4ABE002479D3 /* CapViewMode.swift in Sources */,
298301
0A2FA1C82A90309600504A45 /* RocketView.swift in Sources */,
302+
0A633DD92A9F046700DB10DB /* CapCard.swift in Sources */,
299303
7555FF83242A565900829871 /* ContentView.swift in Sources */,
300304
0A2FA1D02A904B5D00504A45 /* RocketViewMode.swift in Sources */,
301305
0A554D7E2A9A3C4100009D59 /* LinkView.swift in Sources */,

Diff for: Kmp_iOS/Kmp_iOS/Features/Capsoule/CapCard.swift

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// CapCard.swift
3+
// Kmp_iOS
4+
//
5+
// Created by Deepak Kanyan on 30/08/23.
6+
// Copyright © 2023 orgName. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
import shared
11+
12+
struct CapCardView: View {
13+
14+
var capInfo: CapModel
15+
16+
var body: some View {
17+
18+
VStack(alignment: .leading){
19+
Text(capInfo.serial).font(.body).font(.title2).frame(maxWidth: .infinity, alignment: .leading)
20+
Text(capInfo.status.uppercased()).font(.caption2).frame(maxWidth: .infinity, alignment: .leading)
21+
Text(capInfo.lastUpdate ?? "").font(.caption2).padding(.top, 5).frame(maxWidth: .infinity, alignment: .leading)
22+
}
23+
.padding()
24+
.frame(maxWidth: .infinity)
25+
.background(Color.surface)
26+
.cornerRadius(4)
27+
.shadow(radius: 2)
28+
29+
}
30+
31+
32+
}
33+

Diff for: Kmp_iOS/Kmp_iOS/Features/Capsoule/CapViewMode.swift

+29-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,32 @@ import shared
1111

1212
class CapViewModel : ObservableObject{
1313
@Published var capResponse: CapResponse = .Loading.shared
14-
}
14+
15+
16+
init() {
17+
fetchCap()
18+
}
19+
20+
21+
func fetchCap() {
22+
GetAllCap().invoke { response, error in
23+
24+
if let successResponse = response as? CapResponse.Success {
25+
self.capResponse = .Success(data: successResponse.data)
26+
}
27+
else if let error = error as? CapResponse.Error {
28+
self.capResponse = .Error(e: error.e)
29+
}
30+
else {
31+
self.capResponse = .Loading.shared
32+
}
33+
}
34+
}
35+
36+
}
37+
38+
extension CapModel: Identifiable {
39+
public var idd: String {
40+
return "\(id)"
41+
}
42+
}

Diff for: Kmp_iOS/Kmp_iOS/Features/Capsoule/CapsuleUI.swift

+26-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,33 @@
77
//
88

99
import SwiftUI
10+
import shared
1011

1112
struct CapsuleUI: View {
13+
14+
@ObservedObject var viewModel = CapViewModel()
15+
1216
var body: some View {
13-
Text("CapsuleUI")
17+
18+
Group {
19+
switch viewModel.capResponse {
20+
case is CapResponse.Loading:
21+
ProgressView()
22+
case let success as CapResponse.Success:
23+
List(success.data) { capInfo in
24+
CapCardView(capInfo: capInfo).listRowSeparator(.hidden)
25+
.foregroundColor(.none)
26+
}.background(Color.clear).listStyle(PlainListStyle())
27+
28+
case let error as CapResponse.Error:
29+
Text("Error: \(error.e)")
30+
default:
31+
EmptyView()
32+
}
33+
}
34+
.onAppear {
35+
viewModel.fetchCap()
36+
}.navigationTitle("Missions")
1437
}
1538
}
1639

@@ -19,3 +42,5 @@ struct CapsuleUI_Previews: PreviewProvider {
1942
CapsuleUI()
2043
}
2144
}
45+
46+

Diff for: images/Untitled_Project_V1.gif

30.3 MB
Loading

0 commit comments

Comments
 (0)