From fa17d2e47340ae79d9bf4c51852556b72baf67b8 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:00:12 +0900 Subject: [PATCH 01/19] remove unnecessary dependency --- app-ios/Package.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/app-ios/Package.swift b/app-ios/Package.swift index 3c6d71b5a..5fa8d2642 100644 --- a/app-ios/Package.swift +++ b/app-ios/Package.swift @@ -89,7 +89,6 @@ let package = Package( .firebaseRemoteConfig, .tca, .model, - .licenseList, ] ), From 874a4d401b28c2ab890b55a64b1531a23fb55654 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:03:23 +0900 Subject: [PATCH 02/19] Add KMPClientLive Target --- app-ios/Package.swift | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app-ios/Package.swift b/app-ios/Package.swift index 5fa8d2642..b23f10f3a 100644 --- a/app-ios/Package.swift +++ b/app-ios/Package.swift @@ -73,6 +73,7 @@ let package = Package( .eventMapFeature, .tca, .kmpClient, + .KMPClientLive, .licenseList, ] ), @@ -85,13 +86,20 @@ let package = Package( name: "KMPClient", dependencies: [ .kmpModule, - .firebaseAuth, - .firebaseRemoteConfig, .tca, .model, ] ), - + + .target( + name: "KMPClientLive", + dependencies: [ + .kmpClient, + .firebaseAuth, + .firebaseRemoteConfig, + ] + ), + .target( name: "EventKitClient", dependencies: [ @@ -292,6 +300,7 @@ extension Target.Dependency { static let profileCardFeature: Target.Dependency = "ProfileCardFeature" static let kmpModule: Target.Dependency = "KmpModule" static let kmpClient: Target.Dependency = "KMPClient" + static let KMPClientLive: Target.Dependency = "KMPClientLive" static let eventKitClient: Target.Dependency = "EventKitClient" static let theme: Target.Dependency = "Theme" static let commonComponents: Target.Dependency = "CommonComponents" From a0537ba23630a41b26fbdaf18bf2a6613b1c77ab Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:03:56 +0900 Subject: [PATCH 03/19] Use KMPClientLive Target on App --- app-ios/App/App.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/app-ios/App/App.swift b/app-ios/App/App.swift index e78707b84..e6ff6f41a 100644 --- a/app-ios/App/App.swift +++ b/app-ios/App/App.swift @@ -2,6 +2,7 @@ import App import ComposableArchitecture import SwiftUI import Theme +import KMPClientLive final class AppDelegate: NSObject, UIApplicationDelegate { let store = Store( From 6c58f47e0b5ff258bd1f58aead76b8cba14df4f2 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:20:17 +0900 Subject: [PATCH 04/19] Move LiveKey to KMPClientLive --- app-ios/Sources/{KMPClient => KMPClientLive}/LiveKey.swift | 2 ++ 1 file changed, 2 insertions(+) rename app-ios/Sources/{KMPClient => KMPClientLive}/LiveKey.swift (99%) diff --git a/app-ios/Sources/KMPClient/LiveKey.swift b/app-ios/Sources/KMPClientLive/LiveKey.swift similarity index 99% rename from app-ios/Sources/KMPClient/LiveKey.swift rename to app-ios/Sources/KMPClientLive/LiveKey.swift index 77f721d16..d0344a4a7 100644 --- a/app-ios/Sources/KMPClient/LiveKey.swift +++ b/app-ios/Sources/KMPClientLive/LiveKey.swift @@ -2,6 +2,8 @@ import Dependencies import shared import Model import Foundation +import Firebase +import KMPClient private var sessionsRepository: any SessionsRepository { Container.shared.get(type: (any SessionsRepository).self) From 0ed6703f6c6daba14d28a984db8fffb10ea91f5e Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:23:12 +0900 Subject: [PATCH 05/19] Move Container to KMPClientLive --- .../{KMPClient => KMPClientLive}/Helpers/Container.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename app-ios/Sources/{KMPClient => KMPClientLive}/Helpers/Container.swift (75%) diff --git a/app-ios/Sources/KMPClient/Helpers/Container.swift b/app-ios/Sources/KMPClientLive/Helpers/Container.swift similarity index 75% rename from app-ios/Sources/KMPClient/Helpers/Container.swift rename to app-ios/Sources/KMPClientLive/Helpers/Container.swift index e22939ec1..57b0be706 100644 --- a/app-ios/Sources/KMPClient/Helpers/Container.swift +++ b/app-ios/Sources/KMPClientLive/Helpers/Container.swift @@ -19,9 +19,9 @@ public struct Container: Sendable { } public func get(type: TypeProtocol) -> ReturnType where TypeProtocol: Protocol { - guard let object = entryPoint.get(objCProtocol: type) as? ReturnType else { - fatalError("Not found instance for \(type)") - } - return object + guard let object = entryPoint.get(objCProtocol: type) as? ReturnType else { + fatalError("Not found instance for \(type)") } + return object + } } From aa9607408c00e5e65b25c5ac69e445cd47663478 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:24:03 +0900 Subject: [PATCH 06/19] Move AuthenticatorImpl to KMPClientLive --- .../{KMPClient => KMPClientLive}/Helpers/Authenticator.swift | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app-ios/Sources/{KMPClient => KMPClientLive}/Helpers/Authenticator.swift (100%) diff --git a/app-ios/Sources/KMPClient/Helpers/Authenticator.swift b/app-ios/Sources/KMPClientLive/Helpers/Authenticator.swift similarity index 100% rename from app-ios/Sources/KMPClient/Helpers/Authenticator.swift rename to app-ios/Sources/KMPClientLive/Helpers/Authenticator.swift From 12119d4a975b26591844d07f081adca52d6d9024 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:27:20 +0900 Subject: [PATCH 07/19] Move RemoteConfig to KMPClientLive --- .../{KMPClient => KMPClientLive}/Helpers/RemoteConfig.swift | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app-ios/Sources/{KMPClient => KMPClientLive}/Helpers/RemoteConfig.swift (100%) diff --git a/app-ios/Sources/KMPClient/Helpers/RemoteConfig.swift b/app-ios/Sources/KMPClientLive/Helpers/RemoteConfig.swift similarity index 100% rename from app-ios/Sources/KMPClient/Helpers/RemoteConfig.swift rename to app-ios/Sources/KMPClientLive/Helpers/RemoteConfig.swift From 112662560640507b6e6fcabab52616175068e5e6 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:31:02 +0900 Subject: [PATCH 08/19] Add FirebaseAppClient --- app-ios/Sources/KMPClient/Client.swift | 10 ++++++++++ app-ios/Sources/KMPClientLive/Helpers/Container.swift | 4 ---- app-ios/Sources/KMPClientLive/LiveKey.swift | 10 ++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app-ios/Sources/KMPClient/Client.swift b/app-ios/Sources/KMPClient/Client.swift index 58aa594f3..493490f83 100644 --- a/app-ios/Sources/KMPClient/Client.swift +++ b/app-ios/Sources/KMPClient/Client.swift @@ -4,6 +4,11 @@ import shared import Model extension DependencyValues { + public var firebaseAppClient: FirebaseAppClient { + get { self[FirebaseAppClient.self] } + set { self[FirebaseAppClient.self] = newValue } + } + public var timetableClient: TimetableClient { get { self[TimetableClient.self] } set { self[TimetableClient.self] = newValue } @@ -35,6 +40,11 @@ extension DependencyValues { } } +@DependencyClient +public struct FirebaseAppClient: Sendable { + public var prepareFirebase: @Sendable () -> () +} + @DependencyClient public struct TimetableClient: Sendable { public var streamTimetable: @Sendable () throws -> AsyncThrowingStream diff --git a/app-ios/Sources/KMPClientLive/Helpers/Container.swift b/app-ios/Sources/KMPClientLive/Helpers/Container.swift index 57b0be706..f9da2f4df 100644 --- a/app-ios/Sources/KMPClientLive/Helpers/Container.swift +++ b/app-ios/Sources/KMPClientLive/Helpers/Container.swift @@ -2,10 +2,6 @@ import Firebase import ObjectiveC @preconcurrency import shared -public func prepareFirebase() { - FirebaseApp.configure() -} - public struct Container: Sendable { public static let shared: Container = .init() diff --git a/app-ios/Sources/KMPClientLive/LiveKey.swift b/app-ios/Sources/KMPClientLive/LiveKey.swift index d0344a4a7..88a357dcd 100644 --- a/app-ios/Sources/KMPClientLive/LiveKey.swift +++ b/app-ios/Sources/KMPClientLive/LiveKey.swift @@ -29,6 +29,16 @@ private var profileCardRepository: any ProfileCardRepository { Container.shared.get(type: (any ProfileCardRepository).self) } +extension FirebaseAppClient: DependencyKey { + public static var liveValue: Self { + Self( + prepareFirebase: { + FirebaseApp.configure() + } + ) + } +} + extension TimetableClient: DependencyKey { public static let liveValue: TimetableClient = .init( streamTimetable: { From ade5fdbe1e4ca7386bb7909bd950a1fab5bde8a7 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:32:22 +0900 Subject: [PATCH 09/19] Use FirebaseAppClient --- app-ios/Sources/App/AppDelegate.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app-ios/Sources/App/AppDelegate.swift b/app-ios/Sources/App/AppDelegate.swift index 7e53860d0..d203f330d 100644 --- a/app-ios/Sources/App/AppDelegate.swift +++ b/app-ios/Sources/App/AppDelegate.swift @@ -3,6 +3,7 @@ import KMPClient @Reducer public struct AppDelegateReducer { + @Dependency(\.firebaseAppClient) var firebaseAppClient public struct State: Equatable { public init() {} } @@ -15,7 +16,7 @@ public struct AppDelegateReducer { Reduce { state, action in switch action { case .didFinishLaunching: - prepareFirebase() + firebaseAppClient.prepareFirebase() return .none } From ae462b8a7312b82f34631662841979257301a96f Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:35:11 +0900 Subject: [PATCH 10/19] Add FirebaseAppClient TestDependencyKey --- app-ios/Sources/KMPClient/TestKey.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app-ios/Sources/KMPClient/TestKey.swift b/app-ios/Sources/KMPClient/TestKey.swift index 3526fe91f..eb92740fd 100644 --- a/app-ios/Sources/KMPClient/TestKey.swift +++ b/app-ios/Sources/KMPClient/TestKey.swift @@ -1,5 +1,10 @@ import Dependencies +extension FirebaseAppClient: TestDependencyKey { + public static let previewValue: Self = Self() + public static let testValue: Self = Self() +} + extension TimetableClient: TestDependencyKey { public static let previewValue: Self = Self() From 24808044a17e41edbea1e5a674cda92237deaabf Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:36:04 +0900 Subject: [PATCH 11/19] Add ContainerClient --- app-ios/Sources/KMPClient/Client.swift | 16 ++++++++++++++++ app-ios/Sources/KMPClient/TestKey.swift | 5 +++++ app-ios/Sources/KMPClientLive/LiveKey.swift | 10 ++++++++++ 3 files changed, 31 insertions(+) diff --git a/app-ios/Sources/KMPClient/Client.swift b/app-ios/Sources/KMPClient/Client.swift index 493490f83..03313a8d6 100644 --- a/app-ios/Sources/KMPClient/Client.swift +++ b/app-ios/Sources/KMPClient/Client.swift @@ -9,6 +9,11 @@ extension DependencyValues { set { self[FirebaseAppClient.self] = newValue } } + public var containerClient: ContainerClient { + get { self[ContainerClient.self] } + set { self[ContainerClient.self] = newValue } + } + public var timetableClient: TimetableClient { get { self[TimetableClient.self] } set { self[TimetableClient.self] = newValue } @@ -45,6 +50,17 @@ public struct FirebaseAppClient: Sendable { public var prepareFirebase: @Sendable () -> () } +@DependencyClient +public struct ContainerClient: Sendable { + private class DefaultRepositories: Repositories { + var map = [AnyHashable: Any]() + } + + public var repositories: @Sendable () -> any Repositories = { + DefaultRepositories() + } +} + @DependencyClient public struct TimetableClient: Sendable { public var streamTimetable: @Sendable () throws -> AsyncThrowingStream diff --git a/app-ios/Sources/KMPClient/TestKey.swift b/app-ios/Sources/KMPClient/TestKey.swift index eb92740fd..f1801bbca 100644 --- a/app-ios/Sources/KMPClient/TestKey.swift +++ b/app-ios/Sources/KMPClient/TestKey.swift @@ -5,6 +5,11 @@ extension FirebaseAppClient: TestDependencyKey { public static let testValue: Self = Self() } +extension ContainerClient: TestDependencyKey { + public static let previewValue: Self = Self() + public static let testValue: Self = Self() +} + extension TimetableClient: TestDependencyKey { public static let previewValue: Self = Self() diff --git a/app-ios/Sources/KMPClientLive/LiveKey.swift b/app-ios/Sources/KMPClientLive/LiveKey.swift index 88a357dcd..6d7949d63 100644 --- a/app-ios/Sources/KMPClientLive/LiveKey.swift +++ b/app-ios/Sources/KMPClientLive/LiveKey.swift @@ -39,6 +39,16 @@ extension FirebaseAppClient: DependencyKey { } } +extension ContainerClient: DependencyKey { + public static var liveValue: Self { + Self( + repositories: { + Container.shared.get(type: (any Repositories).self) + } + ) + } +} + extension TimetableClient: DependencyKey { public static let liveValue: TimetableClient = .init( streamTimetable: { From b62c960375917a5bd436b97f7203e1076452e7b0 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:36:54 +0900 Subject: [PATCH 12/19] Use ContainerClient --- .../ContributorFeature/KmpPresenterContributorView.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app-ios/Sources/ContributorFeature/KmpPresenterContributorView.swift b/app-ios/Sources/ContributorFeature/KmpPresenterContributorView.swift index 7e354a2c4..30ce8cdea 100644 --- a/app-ios/Sources/ContributorFeature/KmpPresenterContributorView.swift +++ b/app-ios/Sources/ContributorFeature/KmpPresenterContributorView.swift @@ -4,6 +4,7 @@ import Model import SwiftUI @preconcurrency import shared import Theme +import ComposableArchitecture struct KmpPresenterContributorView: View { private let repositories: any Repositories @@ -12,8 +13,9 @@ struct KmpPresenterContributorView: View { @State private var currentState: ContributorsUiState? = nil init(onContributorButtonTapped: @escaping (URL) -> Void) { - self.repositories = Container.shared.get(type: (any Repositories).self) + @Dependency(\.containerClient) var containerClient + self.repositories = containerClient.repositories() self.events = SkieKotlinSharedFlowFactory() .createSkieKotlinSharedFlow(replay: 0, extraBufferCapacity: 0) self.onContributorButtonTapped = onContributorButtonTapped From 9060d5875d8a95d72eb4d95f04eef21e3f816cfe Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:38:49 +0900 Subject: [PATCH 13/19] Move KmpAppComposeViewControllerWrapper to App/Views --- .../Views/KmpAppComposeViewControllerWrapper.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) rename app-ios/Sources/{KMPClient => App}/Views/KmpAppComposeViewControllerWrapper.swift (78%) diff --git a/app-ios/Sources/KMPClient/Views/KmpAppComposeViewControllerWrapper.swift b/app-ios/Sources/App/Views/KmpAppComposeViewControllerWrapper.swift similarity index 78% rename from app-ios/Sources/KMPClient/Views/KmpAppComposeViewControllerWrapper.swift rename to app-ios/Sources/App/Views/KmpAppComposeViewControllerWrapper.swift index b5c64b8d7..5e592cc78 100644 --- a/app-ios/Sources/KMPClient/Views/KmpAppComposeViewControllerWrapper.swift +++ b/app-ios/Sources/App/Views/KmpAppComposeViewControllerWrapper.swift @@ -1,15 +1,17 @@ import SwiftUI import LicenseList -@preconcurrency import shared +import shared +import ComposableArchitecture +@MainActor public struct KmpAppComposeViewControllerWrapper: UIViewControllerRepresentable { + @Dependency(\.containerClient) var containerClient + public init() {} public func makeUIViewController(context: Context) -> UIViewController { - let container = Container.shared - let repositories: any Repositories = container.get(type: (any Repositories).self) - return IosComposeKaigiAppKt.kaigiAppController( - repositories: repositories, + IosComposeKaigiAppKt.kaigiAppController( + repositories: containerClient.repositories(), onLicenseScreenRequest: { openLicenseScreen() } @@ -18,7 +20,7 @@ public struct KmpAppComposeViewControllerWrapper: UIViewControllerRepresentable public func updateUIViewController(_ uiViewController: UIViewController, context: Context) { } - + private func openLicenseScreen() { if let windowScene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene { if let rootViewController = windowScene.windows.first?.rootViewController { From 4d44d92d18c504dd926ea0c2b203727e98cdeead Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:40:33 +0900 Subject: [PATCH 14/19] Change access level --- .../App/Views/KmpAppComposeViewControllerWrapper.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app-ios/Sources/App/Views/KmpAppComposeViewControllerWrapper.swift b/app-ios/Sources/App/Views/KmpAppComposeViewControllerWrapper.swift index 5e592cc78..963ed1085 100644 --- a/app-ios/Sources/App/Views/KmpAppComposeViewControllerWrapper.swift +++ b/app-ios/Sources/App/Views/KmpAppComposeViewControllerWrapper.swift @@ -4,12 +4,12 @@ import shared import ComposableArchitecture @MainActor -public struct KmpAppComposeViewControllerWrapper: UIViewControllerRepresentable { +struct KmpAppComposeViewControllerWrapper: UIViewControllerRepresentable { @Dependency(\.containerClient) var containerClient - public init() {} + init() {} - public func makeUIViewController(context: Context) -> UIViewController { + func makeUIViewController(context: Context) -> UIViewController { IosComposeKaigiAppKt.kaigiAppController( repositories: containerClient.repositories(), onLicenseScreenRequest: { @@ -18,7 +18,7 @@ public struct KmpAppComposeViewControllerWrapper: UIViewControllerRepresentable ) } - public func updateUIViewController(_ uiViewController: UIViewController, context: Context) { + func updateUIViewController(_ uiViewController: UIViewController, context: Context) { } private func openLicenseScreen() { From 671b7080c761747ac54bd7d5fcce9d36ba043de1 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:45:32 +0900 Subject: [PATCH 15/19] Move KmpProfileCardComposeViewControllerWrapper to App/Views --- .../KmpProfileCardComposeViewControllerWrapper.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename app-ios/Sources/{KMPClient => App}/Views/KmpProfileCardComposeViewControllerWrapper.swift (85%) diff --git a/app-ios/Sources/KMPClient/Views/KmpProfileCardComposeViewControllerWrapper.swift b/app-ios/Sources/App/Views/KmpProfileCardComposeViewControllerWrapper.swift similarity index 85% rename from app-ios/Sources/KMPClient/Views/KmpProfileCardComposeViewControllerWrapper.swift rename to app-ios/Sources/App/Views/KmpProfileCardComposeViewControllerWrapper.swift index f77b2860f..1d840b359 100644 --- a/app-ios/Sources/KMPClient/Views/KmpProfileCardComposeViewControllerWrapper.swift +++ b/app-ios/Sources/App/Views/KmpProfileCardComposeViewControllerWrapper.swift @@ -3,15 +3,15 @@ import shared public struct KmpProfileCardComposeViewControllerWrapper: UIViewControllerRepresentable { public init() {} - + public func makeUIViewController(context: Context) -> UIViewController { profileCardViewController( repositories: Container.shared.get(type: (any Repositories).self), onClickShareProfileCard: { image, text in let activityViewController = UIActivityViewController(activityItems: [text, image], applicationActivities: nil) if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, - let keyWindow = windowScene.windows.first(where: { $0.isKeyWindow }), - let rootViewController = keyWindow.rootViewController { + let keyWindow = windowScene.windows.first(where: { $0.isKeyWindow }), + let rootViewController = keyWindow.rootViewController { rootViewController.present(activityViewController, animated: true, completion: nil) } else { print("Unable to find the root view controller.") @@ -19,7 +19,7 @@ public struct KmpProfileCardComposeViewControllerWrapper: UIViewControllerRepres } ) } - + public func updateUIViewController(_ uiViewController: UIViewController, context: Context) { } } From 66b47aa4c6e6dec9b99eeb2dfb58f464619cc215 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:46:33 +0900 Subject: [PATCH 16/19] Use ContainerClient --- .../Views/KmpProfileCardComposeViewControllerWrapper.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app-ios/Sources/App/Views/KmpProfileCardComposeViewControllerWrapper.swift b/app-ios/Sources/App/Views/KmpProfileCardComposeViewControllerWrapper.swift index 1d840b359..583fd751c 100644 --- a/app-ios/Sources/App/Views/KmpProfileCardComposeViewControllerWrapper.swift +++ b/app-ios/Sources/App/Views/KmpProfileCardComposeViewControllerWrapper.swift @@ -1,12 +1,15 @@ import SwiftUI import shared +import ComposableArchitecture public struct KmpProfileCardComposeViewControllerWrapper: UIViewControllerRepresentable { + @Dependency(\.containerClient) var containerClient + public init() {} public func makeUIViewController(context: Context) -> UIViewController { profileCardViewController( - repositories: Container.shared.get(type: (any Repositories).self), + repositories: containerClient.repositories(), onClickShareProfileCard: { image, text in let activityViewController = UIActivityViewController(activityItems: [text, image], applicationActivities: nil) if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, From 8401fc821a30489a044839a8c3c46a747da69e16 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:47:14 +0900 Subject: [PATCH 17/19] Change access level --- .../KmpProfileCardComposeViewControllerWrapper.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app-ios/Sources/App/Views/KmpProfileCardComposeViewControllerWrapper.swift b/app-ios/Sources/App/Views/KmpProfileCardComposeViewControllerWrapper.swift index 583fd751c..3e5676aaa 100644 --- a/app-ios/Sources/App/Views/KmpProfileCardComposeViewControllerWrapper.swift +++ b/app-ios/Sources/App/Views/KmpProfileCardComposeViewControllerWrapper.swift @@ -2,12 +2,12 @@ import SwiftUI import shared import ComposableArchitecture -public struct KmpProfileCardComposeViewControllerWrapper: UIViewControllerRepresentable { +struct KmpProfileCardComposeViewControllerWrapper: UIViewControllerRepresentable { @Dependency(\.containerClient) var containerClient - public init() {} + init() {} - public func makeUIViewController(context: Context) -> UIViewController { + func makeUIViewController(context: Context) -> UIViewController { profileCardViewController( repositories: containerClient.repositories(), onClickShareProfileCard: { image, text in @@ -23,6 +23,6 @@ public struct KmpProfileCardComposeViewControllerWrapper: UIViewControllerRepres ) } - public func updateUIViewController(_ uiViewController: UIViewController, context: Context) { + func updateUIViewController(_ uiViewController: UIViewController, context: Context) { } } From 1568cd70899dc5ff21a9bf7ba21d5cd9f7cb8863 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:47:58 +0900 Subject: [PATCH 18/19] Move KmpContributorComposeViewControllerWrapper to ContributorFeature --- .../KmpContributorComposeViewControllerWrapper.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename app-ios/Sources/{KMPClient/Views => ContributorFeature}/KmpContributorComposeViewControllerWrapper.swift (83%) diff --git a/app-ios/Sources/KMPClient/Views/KmpContributorComposeViewControllerWrapper.swift b/app-ios/Sources/ContributorFeature/KmpContributorComposeViewControllerWrapper.swift similarity index 83% rename from app-ios/Sources/KMPClient/Views/KmpContributorComposeViewControllerWrapper.swift rename to app-ios/Sources/ContributorFeature/KmpContributorComposeViewControllerWrapper.swift index 871d23637..41bdf9a4a 100644 --- a/app-ios/Sources/KMPClient/Views/KmpContributorComposeViewControllerWrapper.swift +++ b/app-ios/Sources/ContributorFeature/KmpContributorComposeViewControllerWrapper.swift @@ -1,5 +1,6 @@ import SwiftUI import shared +import ComposableArchitecture public struct KmpContributorComposeViewControllerWrapper: UIViewControllerRepresentable { public typealias URLString = String @@ -8,7 +9,9 @@ public struct KmpContributorComposeViewControllerWrapper: UIViewControllerRepres private let onContributorsItemClick: (URLString) -> Void public init(onContributorsItemClick: @escaping (URLString) -> Void) { - self.repositories = Container.shared.get(type: (any Repositories).self) + @Dependency(\.containerClient) var containerClient + + self.repositories = containerClient.repositories() self.onContributorsItemClick = onContributorsItemClick } From c03af9b4138260f3dacd1129a4ca24a7814ebc99 Mon Sep 17 00:00:00 2001 From: yimajo Date: Tue, 3 Sep 2024 22:49:41 +0900 Subject: [PATCH 19/19] Change access level --- .../KmpContributorComposeViewControllerWrapper.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app-ios/Sources/ContributorFeature/KmpContributorComposeViewControllerWrapper.swift b/app-ios/Sources/ContributorFeature/KmpContributorComposeViewControllerWrapper.swift index 41bdf9a4a..3a55e417a 100644 --- a/app-ios/Sources/ContributorFeature/KmpContributorComposeViewControllerWrapper.swift +++ b/app-ios/Sources/ContributorFeature/KmpContributorComposeViewControllerWrapper.swift @@ -2,26 +2,26 @@ import SwiftUI import shared import ComposableArchitecture -public struct KmpContributorComposeViewControllerWrapper: UIViewControllerRepresentable { +struct KmpContributorComposeViewControllerWrapper: UIViewControllerRepresentable { public typealias URLString = String - public let repositories: any Repositories + let repositories: any Repositories private let onContributorsItemClick: (URLString) -> Void - public init(onContributorsItemClick: @escaping (URLString) -> Void) { + init(onContributorsItemClick: @escaping (URLString) -> Void) { @Dependency(\.containerClient) var containerClient self.repositories = containerClient.repositories() self.onContributorsItemClick = onContributorsItemClick } - public func makeUIViewController(context: Context) -> UIViewController { + func makeUIViewController(context: Context) -> UIViewController { return contributorsViewController( repositories: repositories, onContributorsItemClick: onContributorsItemClick ) } - public func updateUIViewController(_ uiViewController: UIViewController, context: Context) { + func updateUIViewController(_ uiViewController: UIViewController, context: Context) { } }