John O'Reilly
06/15/2023, 8:48 PMJohn O'Reilly
06/15/2023, 9:09 PMArkadii Ivanov
06/15/2023, 9:17 PMJohn O'Reilly
06/15/2023, 9:20 PMJohn O'Reilly
06/15/2023, 9:20 PMJohn O'Reilly
06/15/2023, 9:23 PMJohn O'Reilly
06/15/2023, 9:26 PMJohn O'Reilly
06/15/2023, 9:27 PMJohn O'Reilly
06/15/2023, 9:31 PMArkadii Ivanov
06/15/2023, 10:03 PMJohn O'Reilly
06/16/2023, 6:35 AMArkadii Ivanov
06/16/2023, 7:50 AMin main repo, we've pulled in these
I understand this as we added those things on the screenshot as swift packages. But it looks like I'm wrong.
John O'Reilly
06/16/2023, 7:51 AMJohn O'Reilly
06/16/2023, 1:30 PMSessionsComponent
directly?John O'Reilly
06/16/2023, 1:40 PMDefaultSessionsComponent
from swift codeArkadii Ivanov
06/16/2023, 1:42 PMArkadii Ivanov
06/16/2023, 1:43 PMJohn O'Reilly
06/16/2023, 2:43 PMDefaultSessionsComponent
is a KoinComponent
and I've called KoinKt.doInitKoin()
...are there other changes you think are needed?John O'Reilly
06/16/2023, 2:44 PMJohn O'Reilly
06/16/2023, 2:46 PMstruct SessionsView: View {
private let component: SessionsComponent
private let lifecycle: LifecycleRegistry
@StateValue
private var uiState: SessionsUiState
init() {
lifecycle = LifecycleRegistryKt.LifecycleRegistry()
self.component = DefaultSessionsComponent(
componentContext: DefaultComponentContext(lifecycle: lifecycle),
conference: "droidconsf2023", user: nil, onSessionSelected: {_ in }, onSignIn: {})
_uiState = StateValue(component.uiState)
}
var body: some View {
switch uiState {
case is SessionsUiStateLoading: ProgressView()
case is SessionsUiStateError: ErrorView()
case let state as SessionsUiStateSuccess: SessionsContentView(component: component, sessionUiState: state)
default: EmptyView()
}
}
}
John O'Reilly
06/16/2023, 2:46 PMArkadii Ivanov
06/16/2023, 2:48 PMare there other changes you think are needed?That should be enough.
Arkadii Ivanov
06/16/2023, 2:50 PMArkadii Ivanov
06/16/2023, 2:51 PMJohn O'Reilly
06/16/2023, 2:51 PMUIApplicationDelegate
?John O'Reilly
06/16/2023, 2:51 PMApp
class?Arkadii Ivanov
06/16/2023, 2:53 PMAppDelegate.swift
and iOSApp.swift
John O'Reilly
06/16/2023, 2:53 PMJohn O'Reilly
06/16/2023, 2:54 PMArkadii Ivanov
06/16/2023, 2:57 PMwould it be sufficient I wonder to use @State for itI never tried it, sorry.
Part of what I'm looking at here is what the absolute minimum code needed would beIn this case, I would try extracting the whole plumbing into a separate Holder class, call
LifecycleRegistryExtKt.resume(lifecycle)
in init
, and destroy
in deinit
. Then embed the Holder as StateObject
.John O'Reilly
06/16/2023, 3:00 PMJohn O'Reilly
06/16/2023, 3:20 PM@main
struct Test2App: App {
@State private var component: SessionsComponent
private let lifecycle: LifecycleRegistry
init() {
KoinKt.doInitKoin()
lifecycle = LifecycleRegistryKt.LifecycleRegistry()
LifecycleRegistryExtKt.resume(lifecycle)
self.component = DefaultSessionsComponent(
componentContext: DefaultComponentContext(lifecycle: lifecycle),
conference: "droidconsf2023", user: nil, onSessionSelected: {_ in }, onSignIn: {})
}
var body: some Scene {
WindowGroup {
SessionsView(component)
}
}
}
struct SessionsView: View {
let component: SessionsComponent
@StateValue
private var uiState: SessionsUiState
init(_ component: SessionsComponent) {
self.component = component
_uiState = StateValue(component.uiState)
}
var body: some View {
switch uiState {
case is SessionsUiStateLoading: ProgressView()
case is SessionsUiStateError: ErrorView()
case let state as SessionsUiStateSuccess: SessionsContentView(component: component, sessionUiState: state)
default: EmptyView()
}
}
}
John O'Reilly
06/16/2023, 3:21 PMArkadii Ivanov
06/16/2023, 3:25 PMdeinit
is available.John O'Reilly
06/16/2023, 3:27 PMWell, that would be more than "minimum".Sorry, didn't fully understand....what could be simplified above? You mean by creating that wrapper classs?
John O'Reilly
06/16/2023, 3:27 PMJohn O'Reilly
06/16/2023, 3:28 PMArkadii Ivanov
06/16/2023, 3:31 PMArkadii Ivanov
06/16/2023, 3:32 PMJohn O'Reilly
06/16/2023, 3:32 PMJohn O'Reilly
06/16/2023, 3:33 PMJohn O'Reilly
06/16/2023, 3:35 PMJohn O'Reilly
06/16/2023, 3:35 PMArkadii Ivanov
06/16/2023, 3:38 PMJohn O'Reilly
06/16/2023, 4:14 PMJohn O'Reilly
06/16/2023, 4:15 PMArkadii Ivanov
06/16/2023, 4:22 PMConfettiSPM
?John O'Reilly
06/16/2023, 4:22 PMJohn O'Reilly
06/16/2023, 4:23 PMArkadii Ivanov
06/16/2023, 4:23 PMJohn O'Reilly
06/16/2023, 4:38 PMmbonnin
06/16/2023, 4:38 PMJohn O'Reilly
06/16/2023, 4:39 PMPackage.swift
etc is hosted)mbonnin
06/16/2023, 4:40 PMConfetti
?John O'Reilly
06/16/2023, 4:40 PMmbonnin
06/16/2023, 4:41 PMJohn O'Reilly
06/16/2023, 4:41 PMmbonnin
06/16/2023, 4:42 PMJohn O'Reilly
06/16/2023, 4:43 PMbod
06/16/2023, 4:43 PMConfettiSPM
probably makes sense)John O'Reilly
06/16/2023, 4:43 PMbod
06/16/2023, 4:44 PMJohn O'Reilly
06/16/2023, 4:44 PMConfgettiUsingSwfitPackage
πbod
06/16/2023, 4:44 PMJohn O'Reilly
06/16/2023, 4:45 PMSwiftUI
πJohn O'Reilly
06/16/2023, 4:45 PMJohn O'Reilly
06/16/2023, 4:50 PMJohn O'Reilly
06/16/2023, 4:52 PMJohn O'Reilly
06/16/2023, 4:53 PMJohn O'Reilly
06/16/2023, 6:46 PMbod
06/16/2023, 6:49 PM