Skip to content

Commit d4ffe0c

Browse files
committed
0.1.0 (sep 29, 15:24)
1 parent 646ce53 commit d4ffe0c

File tree

6 files changed

+51
-8
lines changed

6 files changed

+51
-8
lines changed

iosApp/Podfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
ENV['SWIFT_VERSION'] = '5'
2+
13
target 'iosApp' do
24
use_frameworks!
35
platform :ios, '14.1'

iosApp/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ SPEC CHECKSUMS:
2424
shared: 87955ce175f3e0125b3dc8555b1b78fd7eb688aa
2525
sharedSwift: 069e6019f6963d18ae01d1d772429c854db2fe1e
2626

27-
PODFILE CHECKSUM: 42e9abcd0de83560b82796c5d325b3626db87b31
27+
PODFILE CHECKSUM: 071241557371c02424821106ec0998c691309d94
2828

2929
COCOAPODS: 1.12.1

iosApp/iosApp/ContentView.swift

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Combine
44
import sharedSwift
55

66
struct ContentView: View {
7-
@ObservedObject var vm = IOSGithubSearchViewModel(vm: DIContainer.shared.get())
7+
@StateObject var vm: IOSGithubSearchViewModel
88

99
@State private var showingAlert = false
1010
@State private var event: GithubSearchSingleEventKs?
@@ -81,9 +81,9 @@ struct ContentView: View {
8181
}
8282
.navigationViewStyle(.stack)
8383
.onReceive(self.vm.eventPublisher) { event in
84-
self.event = event
85-
self.showingAlert = true
86-
}
84+
self.event = event
85+
self.showingAlert = true
86+
}
8787
.alert(isPresented: $showingAlert, content: eventAlert)
8888
}
8989

@@ -115,8 +115,35 @@ struct ContentView: View {
115115

116116
extension RepoItem: Identifiable { }
117117

118+
class FakeRepoItemRepository: RepoItemRepository {
119+
func searchRepoItems(term: String, page: Int32) async throws -> Arrow_coreEither<AppError, NSArray> {
120+
let items: [RepoItem] = [
121+
.init(
122+
id: 0,
123+
fullName: "Fullname 0",
124+
language: "Kotlin",
125+
starCount: 0,
126+
name: "Name 0",
127+
repoDescription: "Description 0",
128+
languageColor: ArgbColor.Companion.shared.parse(hex: "#000000").getOrNull(),
129+
htmlUrl: "html.com",
130+
owner: .init(id: 1, username: "username", avatar: "avatar"),
131+
updatedAt: Kotlinx_datetimeInstant.Companion.shared.fromEpochMilliseconds(epochMilliseconds: 0)
132+
)
133+
]
134+
135+
return EitherExt.shared.right(value: items) as! Arrow_coreEither<AppError, NSArray>
136+
}
137+
}
138+
118139
struct ContentView_Previews: PreviewProvider {
119140
static var previews: some View {
120-
ContentView()
141+
let vm = IOSGithubSearchViewModel.init(
142+
vm: .init(
143+
searchRepoItemsUseCase: .init(repoItemRepository: FakeRepoItemRepository()),
144+
savedStateHandle: .init()
145+
)
146+
)
147+
ContentView(vm: vm)
121148
}
122149
}

iosApp/iosApp/Github Search Page/IOSGithubSearchViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class IOSGithubSearchViewModel: ObservableObject {
4747
}
4848

4949
deinit {
50-
Napier.d("\(self)::deinit")
5150
vm.clear()
51+
Napier.d("\(self)::deinit isCleared=\(vm.isCleared())")
5252
}
5353
}

iosApp/iosApp/iOSApp.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ struct iOSApp: App {
99

1010
var body: some Scene {
1111
WindowGroup {
12-
ContentView()
12+
ContentView(
13+
vm: IOSGithubSearchViewModel(
14+
vm: DIContainer.shared.get()
15+
)
16+
)
1317
}
1418
}
1519
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@file:Suppress("unused")
2+
3+
package com.hoc081098.github_search_kmm.utils
4+
5+
import arrow.core.Either
6+
7+
object EitherExt {
8+
fun <L, R> left(value: L): Either<L, R> = Either.Left(value)
9+
fun <L, R> right(value: R): Either<L, R> = Either.Right(value)
10+
}

0 commit comments

Comments
 (0)