From 76630b6d7a76b5d79fc7c3a68cb5d100dfd2e6b8 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 1 Apr 2023 19:57:51 +0900 Subject: [PATCH 01/15] Modify package name --- AppPackage/Package.swift | 4 ++-- .../{Share => ShareFeature}/KakaoShareButtonStyle.swift | 0 .../Sources/{Share => ShareFeature}/ShareLinkCopyView.swift | 0 AppPackage/Sources/{Share => ShareFeature}/ShareView.swift | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename AppPackage/Sources/{Share => ShareFeature}/KakaoShareButtonStyle.swift (100%) rename AppPackage/Sources/{Share => ShareFeature}/ShareLinkCopyView.swift (100%) rename AppPackage/Sources/{Share => ShareFeature}/ShareView.swift (100%) diff --git a/AppPackage/Package.swift b/AppPackage/Package.swift index a2fdb0f..34723a5 100644 --- a/AppPackage/Package.swift +++ b/AppPackage/Package.swift @@ -9,7 +9,7 @@ let package = Package( name: "AppPackage", targets: [ "TimeTableFeature", - "Share", + "ShareFeature", "MakePromise", "PromiseManagement", "LoginFeature", @@ -90,7 +90,7 @@ let package = Package( ] ), .target( - name: "Share", + name: "ShareFeature", dependencies: [ "DesignSystem", .product(name: "ComposableArchitecture", package: "swift-composable-architecture") diff --git a/AppPackage/Sources/Share/KakaoShareButtonStyle.swift b/AppPackage/Sources/ShareFeature/KakaoShareButtonStyle.swift similarity index 100% rename from AppPackage/Sources/Share/KakaoShareButtonStyle.swift rename to AppPackage/Sources/ShareFeature/KakaoShareButtonStyle.swift diff --git a/AppPackage/Sources/Share/ShareLinkCopyView.swift b/AppPackage/Sources/ShareFeature/ShareLinkCopyView.swift similarity index 100% rename from AppPackage/Sources/Share/ShareLinkCopyView.swift rename to AppPackage/Sources/ShareFeature/ShareLinkCopyView.swift diff --git a/AppPackage/Sources/Share/ShareView.swift b/AppPackage/Sources/ShareFeature/ShareView.swift similarity index 100% rename from AppPackage/Sources/Share/ShareView.swift rename to AppPackage/Sources/ShareFeature/ShareView.swift From 4f47348c6fe82d9155955cfa221541aa504ba0ec Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 1 Apr 2023 22:15:45 +0900 Subject: [PATCH 02/15] [PI-36] update --- AppPackage/Package.swift | 6 ++- .../ShareFeature/SharePromiseStore.swift | 37 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 AppPackage/Sources/ShareFeature/SharePromiseStore.swift diff --git a/AppPackage/Package.swift b/AppPackage/Package.swift index 34723a5..7d3f6a4 100644 --- a/AppPackage/Package.swift +++ b/AppPackage/Package.swift @@ -47,7 +47,8 @@ let package = Package( .package(url: "https://github.com/siteline/SwiftUI-Introspect.git", from: "0.1.4"), .package(url: "https://github.com/devxoul/Then.git", from: "3.0.0"), .package(url: "https://github.com/Team-Planz/Planz-iOS-APIClient.git", branch: "main"), - .package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "0.6.1") + .package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "0.6.1"), + .package(url: "https://github.com/firebase/firebase-ios-sdk", from: "8.10.0") ], targets: [ .target( @@ -93,7 +94,8 @@ let package = Package( name: "ShareFeature", dependencies: [ "DesignSystem", - .product(name: "ComposableArchitecture", package: "swift-composable-architecture") + .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), + .product(name: "APIClient", package: "Planz-iOS-APIClient") ] ), .target( diff --git a/AppPackage/Sources/ShareFeature/SharePromiseStore.swift b/AppPackage/Sources/ShareFeature/SharePromiseStore.swift new file mode 100644 index 0000000..f9ff261 --- /dev/null +++ b/AppPackage/Sources/ShareFeature/SharePromiseStore.swift @@ -0,0 +1,37 @@ +// +// File.swift +// +// +// Created by 한상준 on 2023/04/01. +// + +import APIClient +import ComposableArchitecture +import Foundation + +public struct SharePromiseState {} + +public enum SharePromiseAction { + case viewDidAppear + case copyLinkTapped + case shareAsKakaoTapped +} + +public struct SharePromiseEnvironment { + public init() {} +} + +public let sharePromiseReducer = AnyReducer< + SharePromiseState, + SharePromiseAction, + SharePromiseEnvironment +> { _, action, _ in + switch action { + case .viewDidAppear: + return .none + case .copyLinkTapped: + return .none + case .shareAsKakaoTapped: + return .none + } +} From 4814210a8839f1d2db6a32d9db40aa0f9bc41c1c Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 4 Apr 2023 18:34:16 +0900 Subject: [PATCH 03/15] [PI-36] update --- .../ShareFeature/SharePromiseView.swift | 85 +++++++++++++++++++ .../Sources/ShareFeature/ShareView.swift | 74 ---------------- Planz.xcodeproj/project.pbxproj | 4 + 3 files changed, 89 insertions(+), 74 deletions(-) create mode 100644 AppPackage/Sources/ShareFeature/SharePromiseView.swift delete mode 100644 AppPackage/Sources/ShareFeature/ShareView.swift diff --git a/AppPackage/Sources/ShareFeature/SharePromiseView.swift b/AppPackage/Sources/ShareFeature/SharePromiseView.swift new file mode 100644 index 0000000..d9464ba --- /dev/null +++ b/AppPackage/Sources/ShareFeature/SharePromiseView.swift @@ -0,0 +1,85 @@ +// +// ShareView.swift +// +// +// Created by 한상준 on 2023/02/07. +// + +import ComposableArchitecture +import DesignSystem +import SwiftUI + +public struct SharePromiseView: View { + let mailImage: String = "mailIllustration" + + public let store: StoreOf + + public init(store: StoreOf) { + self.store = store + } + + public var body: some View { + WithViewStore(self.store) { viewStore in + VStack(spacing: .zero) { + VStack(spacing: 50) { + VStack(spacing: 6) { + HStack(spacing: .zero) { + EmptyView().frame(width: 20) + Text("이제 약속을 ") + .font(.system(size: 20)) + .fontWeight(.bold) + Text("공유") + .font(.system(size: 20)) + .foregroundColor(PDS.COLOR.purple9.scale) + .fontWeight(.bold) + Text("하세요!") + .font(.system(size: 20)) + .fontWeight(.bold) + Spacer() + } + .padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) + HStack(spacing: .zero) { + Text("최대 10명까지 응답 가능") + .font(.system(size: 16)) + Spacer() + } + .padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) + HStack(spacing: .zero) { + Text("*본인포함") + .font(.system(size: 12)) + Spacer() + } + .padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) + } + PDS.Icon.mailIllustration.image + .resizable() + .aspectRatio(contentMode: .fit) + } + Spacer() + VStack(spacing: 12) { + ShareLinkCopyView() + Button {} label: { + HStack(spacing: 0) { + PDS.Icon.kakao.image + Text("카카오톡으로 약속 공유하기") + .lineLimit(1) + }.frame(maxWidth: .infinity) + } + .buttonStyle(KakaoShareButtonStyle()) + } + } + .background(PDS.COLOR.white1.scale) + .onAppear(perform: { + viewStore.send(.viewDidAppear) + }) + } + } +} + +#if DEBUG + struct ShareView_Previews: PreviewProvider { + static var previews: some View { + SharePromiseView(store: .init(initialState: SharePromiseFeature.State(), reducer: SharePromiseFeature()._printChanges())) + } + } +#endif diff --git a/AppPackage/Sources/ShareFeature/ShareView.swift b/AppPackage/Sources/ShareFeature/ShareView.swift deleted file mode 100644 index 9afc6c2..0000000 --- a/AppPackage/Sources/ShareFeature/ShareView.swift +++ /dev/null @@ -1,74 +0,0 @@ -// -// ShareView.swift -// -// -// Created by 한상준 on 2023/02/07. -// - -import DesignSystem -import SwiftUI - -public struct ShareView: View { - let mailImage: String = "mailIllustration" - public init() {} - - public var body: some View { - VStack(spacing: .zero) { - VStack(spacing: 50) { - VStack(spacing: 6) { - HStack(spacing: .zero) { - EmptyView().frame(width: 20) - Text("이제 약속을 ") - .font(.system(size: 20)) - .fontWeight(.bold) - Text("공유") - .font(.system(size: 20)) - .foregroundColor(PDS.COLOR.purple9.scale) - .fontWeight(.bold) - Text("하세요!") - .font(.system(size: 20)) - .fontWeight(.bold) - Spacer() - } - .padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) - HStack(spacing: .zero) { - Text("최대 10명까지 응답 가능") - .font(.system(size: 16)) - Spacer() - } - .padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) - HStack(spacing: .zero) { - Text("*본인포함") - .font(.system(size: 12)) - Spacer() - } - .padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) - } - PDS.Icon.mailIllustration.image - .resizable() - .aspectRatio(contentMode: .fit) - } - Spacer() - VStack(spacing: 12) { - ShareLinkCopyView() - Button {} label: { - HStack(spacing: 0) { - PDS.Icon.kakao.image - Text("카카오톡으로 약속 공유하기") - .lineLimit(1) - }.frame(maxWidth: .infinity) - } - .buttonStyle(KakaoShareButtonStyle()) - } - } - .background(PDS.COLOR.white1.scale) - } -} - -#if DEBUG - struct ShareView_Previews: PreviewProvider { - static var previews: some View { - ShareView() - } - } -#endif diff --git a/Planz.xcodeproj/project.pbxproj b/Planz.xcodeproj/project.pbxproj index 60b8aa2..ceb0f76 100644 --- a/Planz.xcodeproj/project.pbxproj +++ b/Planz.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 4972CFB029D8690400765115 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4972CFAF29D8690400765115 /* GoogleService-Info.plist */; }; 49D91E12297999AC00A5C2BA /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = 49D91E11297999AC00A5C2BA /* .swiftlint.yml */; }; 49D91E1529799F9D00A5C2BA /* runLint.sh in Resources */ = {isa = PBXBuildFile; fileRef = 49D91E1429799F9D00A5C2BA /* runLint.sh */; }; 49F41A7D2984C519008A3AFA /* runSwiftformat.sh in Resources */ = {isa = PBXBuildFile; fileRef = 49F41A7C2984C519008A3AFA /* runSwiftformat.sh */; }; @@ -42,6 +43,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 4972CFAF29D8690400765115 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 49D91E11297999AC00A5C2BA /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = ""; }; 49D91E1429799F9D00A5C2BA /* runLint.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = runLint.sh; sourceTree = ""; }; 49F41A7C2984C519008A3AFA /* runSwiftformat.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = runSwiftformat.sh; sourceTree = ""; }; @@ -117,6 +119,7 @@ 6F47599828D9D0CE005CC91B /* Planz */ = { isa = PBXGroup; children = ( + 4972CFAF29D8690400765115 /* GoogleService-Info.plist */, AE79C84329863F400098BA28 /* Info.plist */, 6F47599928D9D0CE005CC91B /* PlanzApp.swift */, 6F47599D28D9D0CF005CC91B /* Assets.xcassets */, @@ -277,6 +280,7 @@ 6F4759A128D9D0CF005CC91B /* Preview Assets.xcassets in Resources */, 6F47599E28D9D0CF005CC91B /* Assets.xcassets in Resources */, 49D91E1529799F9D00A5C2BA /* runLint.sh in Resources */, + 4972CFB029D8690400765115 /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; From 5d007e61378fadcc7d200fe6fa72b6d03c117117 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 4 Apr 2023 18:56:03 +0900 Subject: [PATCH 04/15] [PI-36] update package --- AppPackage/Package.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AppPackage/Package.swift b/AppPackage/Package.swift index 7d3f6a4..b6a506d 100644 --- a/AppPackage/Package.swift +++ b/AppPackage/Package.swift @@ -95,7 +95,10 @@ let package = Package( dependencies: [ "DesignSystem", .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), - .product(name: "APIClient", package: "Planz-iOS-APIClient") + .product(name: "APIClient", package: "Planz-iOS-APIClient"), + .product(name: "FirebaseAuth", package: "firebase-ios-sdk"), + .product(name: "FirebaseFirestore", package: "firebase-ios-sdk"), + .product(name: "FirebaseDynamicLinks", package: "firebase-ios-sdk") ] ), .target( From 43812a8f7fbdb7fabcf9e0ab3960d8517f02168a Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 4 Apr 2023 19:18:49 +0900 Subject: [PATCH 05/15] [PI-36] add app delegate --- Planz/PlanzApp.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Planz/PlanzApp.swift b/Planz/PlanzApp.swift index 3dfdb50..05af0af 100644 --- a/Planz/PlanzApp.swift +++ b/Planz/PlanzApp.swift @@ -1,9 +1,23 @@ import AppFeature import ComposableArchitecture +import Firebase +import ShareFeature import SwiftUI +class AppDelegate: NSObject, UIApplicationDelegate { + func application(_: UIApplication, + didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool + { + print("Colors application is starting up. ApplicationDelegate didFinishLaunchingWithOptions.") + FirebaseApp.configure() + return true + } +} + @main struct PlanzApp: App { + @UIApplicationDelegateAdaptor(AppDelegate.self) var delegate + let store: StoreOf = .init( initialState: .launchScreen, reducer: AppCore() From f487ca5a63e61d9d7a69e157524c37a157f934ea Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 7 Apr 2023 23:37:58 +0900 Subject: [PATCH 06/15] [PI-36] update logic and apply Secrets --- AppPackage/Package.swift | 8 +- .../ShareFeature/ShareLinkCopyView.swift | 29 ++++-- .../ShareFeature/SharePromiseStore.swift | 89 ++++++++++++++----- .../ShareFeature/SharePromiseView.swift | 6 +- Planz/PlanzApp.swift | 4 +- 5 files changed, 101 insertions(+), 35 deletions(-) diff --git a/AppPackage/Package.swift b/AppPackage/Package.swift index b6a506d..3ae4470 100644 --- a/AppPackage/Package.swift +++ b/AppPackage/Package.swift @@ -48,7 +48,9 @@ let package = Package( .package(url: "https://github.com/devxoul/Then.git", from: "3.0.0"), .package(url: "https://github.com/Team-Planz/Planz-iOS-APIClient.git", branch: "main"), .package(url: "https://github.com/pointfreeco/swiftui-navigation", from: "0.6.1"), - .package(url: "https://github.com/firebase/firebase-ios-sdk", from: "8.10.0") + .package(url: "https://github.com/firebase/firebase-ios-sdk", from: "8.10.0"), + .package(url: "https://github.com/kakao/kakao-ios-sdk.git", from: "2.14.0"), + .package(url: "https://github.com/Team-Planz/Planz-iOS-Secrets", branch: "main") ], targets: [ .target( @@ -98,7 +100,9 @@ let package = Package( .product(name: "APIClient", package: "Planz-iOS-APIClient"), .product(name: "FirebaseAuth", package: "firebase-ios-sdk"), .product(name: "FirebaseFirestore", package: "firebase-ios-sdk"), - .product(name: "FirebaseDynamicLinks", package: "firebase-ios-sdk") + .product(name: "FirebaseDynamicLinks", package: "firebase-ios-sdk"), + .product(name: "KakaoSDK", package: "kakao-ios-sdk"), + .product(name: "Planz-iOS-Secrets", package: "Planz-iOS-Secrets") ] ), .target( diff --git a/AppPackage/Sources/ShareFeature/ShareLinkCopyView.swift b/AppPackage/Sources/ShareFeature/ShareLinkCopyView.swift index 846d31f..ef1fbf2 100644 --- a/AppPackage/Sources/ShareFeature/ShareLinkCopyView.swift +++ b/AppPackage/Sources/ShareFeature/ShareLinkCopyView.swift @@ -5,24 +5,35 @@ // Created by 한상준 on 2023/02/12. // +import ComposableArchitecture import DesignSystem import SwiftUI struct ShareLinkCopyView: View { + public let store: StoreOf + public init(store: StoreOf) { + self.store = store + } + public var body: some View { - HStack { + WithViewStore(self.store) { viewStore in HStack { - Text("url/link/1234/1234") - Spacer() - Button("복사") {} + HStack { + Text(viewStore.linkForShare) + .lineLimit(1) + Spacer() + Button("복사") { + viewStore.send(.copyLinkTapped) + } .font(.system(size: 14)) .foregroundColor(PDS.COLOR.purple9.scale) + } + .padding(EdgeInsets(top: 16, leading: 20, bottom: 16, trailing: 20)) + .background(PDS.COLOR.white3.scale) + .border(PDS.COLOR.gray2.scale, width: 1) + .cornerRadius(10) } - .padding(EdgeInsets(top: 16, leading: 20, bottom: 16, trailing: 20)) - .background(PDS.COLOR.white3.scale) - .border(PDS.COLOR.gray2.scale, width: 1) - .cornerRadius(10) + .padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) } - .padding(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20)) } } diff --git a/AppPackage/Sources/ShareFeature/SharePromiseStore.swift b/AppPackage/Sources/ShareFeature/SharePromiseStore.swift index f9ff261..347ba3e 100644 --- a/AppPackage/Sources/ShareFeature/SharePromiseStore.swift +++ b/AppPackage/Sources/ShareFeature/SharePromiseStore.swift @@ -7,31 +7,78 @@ import APIClient import ComposableArchitecture +import FirebaseAuth +import FirebaseCore +import FirebaseDynamicLinks +import FirebaseFirestore import Foundation +import KakaoSDKShare +import KakaoSDKTemplate +import UIKit +import Planz_iOS_Secrets -public struct SharePromiseState {} +public struct SharePromiseFeature: ReducerProtocol { + public init() {} + public struct State: Equatable { + var linkForShare = "" + var id: Int? + public init() {} + } -public enum SharePromiseAction { - case viewDidAppear - case copyLinkTapped - case shareAsKakaoTapped -} + public enum Action: Equatable { + case viewDidAppear + case copyLinkTapped + case shareAsKakaoTapped + } -public struct SharePromiseEnvironment { - public init() {} -} + func getDeepLink(id: String?) -> URL? { + if let id { + return URL(string: "\(Secrets.Firebase.domain.value)/?plandId=\(id)") + } else { + return URL(string: Secrets.Firebase.domain.value) + } + } + + func getDynamicLink(id _: String?) -> URL? { + guard let link = getDeepLink(id: nil) else { return nil } + let dynamicLinksDomainURIPrefix = Secrets.Firebase.prefix.value + let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix) + linkBuilder?.iOSParameters = DynamicLinkIOSParameters(bundleID: Secrets.App.iosBundleId.value) + linkBuilder?.androidParameters = DynamicLinkAndroidParameters(packageName: Secrets.App.androidBundleId.value) + return linkBuilder?.url + } + + func shareViaKakao(url _: String) { + if ShareApi.isKakaoTalkSharingAvailable() { + //TODO: 이전 화면에서 전달해주는 id 값에 맞춰서 공유 링크의 파라미터로 추가하도록 수정 필요 + ShareApi.shared.shareCustom(templateId: Int(Secrets.Kakao.templateId.value)!, templateArgs: ["": ""]) { linkResult, error in + if let error = error { + print("error : \(error)") + } else { + print("defaultLink(templateObject:templateJsonObject) success.") + guard let linkResult = linkResult else { return } + UIApplication.shared.open(linkResult.url, options: [:], completionHandler: nil) + } + } + + } else {} + } -public let sharePromiseReducer = AnyReducer< - SharePromiseState, - SharePromiseAction, - SharePromiseEnvironment -> { _, action, _ in - switch action { - case .viewDidAppear: - return .none - case .copyLinkTapped: - return .none - case .shareAsKakaoTapped: - return .none + public var body: some ReducerProtocol { + Reduce { state, action in + switch action { + case .viewDidAppear: + if let link = getDynamicLink(id: nil) { + state.linkForShare = link.absoluteString + } + return .none + case .copyLinkTapped: + UIPasteboard.general.string = state.linkForShare + return .none + case .shareAsKakaoTapped: + shareViaKakao(url: state.linkForShare) + return .none + } + } } } diff --git a/AppPackage/Sources/ShareFeature/SharePromiseView.swift b/AppPackage/Sources/ShareFeature/SharePromiseView.swift index d9464ba..61218dd 100644 --- a/AppPackage/Sources/ShareFeature/SharePromiseView.swift +++ b/AppPackage/Sources/ShareFeature/SharePromiseView.swift @@ -57,8 +57,10 @@ public struct SharePromiseView: View { } Spacer() VStack(spacing: 12) { - ShareLinkCopyView() - Button {} label: { + ShareLinkCopyView(store: store) + Button { + viewStore.send(.shareAsKakaoTapped) + } label: { HStack(spacing: 0) { PDS.Icon.kakao.image Text("카카오톡으로 약속 공유하기") diff --git a/Planz/PlanzApp.swift b/Planz/PlanzApp.swift index 05af0af..6d55e72 100644 --- a/Planz/PlanzApp.swift +++ b/Planz/PlanzApp.swift @@ -1,15 +1,17 @@ import AppFeature import ComposableArchitecture import Firebase +import KakaoSDKCommon import ShareFeature import SwiftUI +import Planz_iOS_Secrets class AppDelegate: NSObject, UIApplicationDelegate { func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { - print("Colors application is starting up. ApplicationDelegate didFinishLaunchingWithOptions.") FirebaseApp.configure() + KakaoSDK.initSDK(appKey: Secrets.Kakao.appKey.value) return true } } From bcf3086cf4cacba93dbc444cba8192166b8b53be Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 7 Apr 2023 23:50:06 +0900 Subject: [PATCH 07/15] [PI-36] add and hide xcconfig for secret --- .gitignore | 3 +++ .../Sources/ShareFeature/SharePromiseStore.swift | 6 +++--- Planz.xcodeproj/project.pbxproj | 6 ++++++ Planz/Info.plist | 16 ++++++++++++++++ Planz/PlanzApp.swift | 2 +- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index cd75295..919c183 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +## xcconfig hide +*.xcconfig + ## User settings xcuserdata/ diff --git a/AppPackage/Sources/ShareFeature/SharePromiseStore.swift b/AppPackage/Sources/ShareFeature/SharePromiseStore.swift index 347ba3e..b09793e 100644 --- a/AppPackage/Sources/ShareFeature/SharePromiseStore.swift +++ b/AppPackage/Sources/ShareFeature/SharePromiseStore.swift @@ -14,8 +14,8 @@ import FirebaseFirestore import Foundation import KakaoSDKShare import KakaoSDKTemplate -import UIKit import Planz_iOS_Secrets +import UIKit public struct SharePromiseFeature: ReducerProtocol { public init() {} @@ -50,8 +50,8 @@ public struct SharePromiseFeature: ReducerProtocol { func shareViaKakao(url _: String) { if ShareApi.isKakaoTalkSharingAvailable() { - //TODO: 이전 화면에서 전달해주는 id 값에 맞춰서 공유 링크의 파라미터로 추가하도록 수정 필요 - ShareApi.shared.shareCustom(templateId: Int(Secrets.Kakao.templateId.value)!, templateArgs: ["": ""]) { linkResult, error in + // TODO: 이전 화면에서 전달해주는 id 값에 맞춰서 공유 링크의 파라미터로 추가하도록 수정 필요 + ShareApi.shared.shareCustom(templateId: Int64(Secrets.Kakao.templateId.value)!, templateArgs: ["": ""]) { linkResult, error in if let error = error { print("error : \(error)") } else { diff --git a/Planz.xcodeproj/project.pbxproj b/Planz.xcodeproj/project.pbxproj index ceb0f76..c9c4810 100644 --- a/Planz.xcodeproj/project.pbxproj +++ b/Planz.xcodeproj/project.pbxproj @@ -43,6 +43,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 496EFF7829E0633C00351034 /* Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; + 496EFF7929E0635100351034 /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 4972CFAF29D8690400765115 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 49D91E11297999AC00A5C2BA /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = ""; }; 49D91E1429799F9D00A5C2BA /* runLint.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = runLint.sh; sourceTree = ""; }; @@ -124,6 +126,8 @@ 6F47599928D9D0CE005CC91B /* PlanzApp.swift */, 6F47599D28D9D0CF005CC91B /* Assets.xcassets */, 6F47599F28D9D0CF005CC91B /* Preview Content */, + 496EFF7829E0633C00351034 /* Debug.xcconfig */, + 496EFF7929E0635100351034 /* Release.xcconfig */, ); path = Planz; sourceTree = ""; @@ -497,6 +501,7 @@ }; 6F4759BB28D9D0CF005CC91B /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 496EFF7829E0633C00351034 /* Debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -526,6 +531,7 @@ }; 6F4759BC28D9D0CF005CC91B /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 496EFF7929E0635100351034 /* Release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; diff --git a/Planz/Info.plist b/Planz/Info.plist index a719cf5..a624320 100644 --- a/Planz/Info.plist +++ b/Planz/Info.plist @@ -2,6 +2,22 @@ + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + $(KakaoURLScheme) + + + + LSApplicationQueriesSchemes + + kakaokompassauth + kakaolink + UIApplicationSceneManifest UIApplicationSupportsMultipleScenes diff --git a/Planz/PlanzApp.swift b/Planz/PlanzApp.swift index 6d55e72..1402483 100644 --- a/Planz/PlanzApp.swift +++ b/Planz/PlanzApp.swift @@ -2,9 +2,9 @@ import AppFeature import ComposableArchitecture import Firebase import KakaoSDKCommon +import Planz_iOS_Secrets import ShareFeature import SwiftUI -import Planz_iOS_Secrets class AppDelegate: NSObject, UIApplicationDelegate { func application(_: UIApplication, From 8c701030232c46acdf692d0af1ac3d96cc3c3525 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 7 Apr 2023 23:58:49 +0900 Subject: [PATCH 08/15] [PI-36] update gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 919c183..f0ee037 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ ## xcconfig hide *.xcconfig +## Firebase +GoogleService-Info.plist + ## User settings xcuserdata/ From af2a944744456b3de558e4a255da922513b5294c Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 8 Apr 2023 00:12:52 +0900 Subject: [PATCH 09/15] [PI-36] add secret folder --- Planz.xcodeproj/project.pbxproj | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Planz.xcodeproj/project.pbxproj b/Planz.xcodeproj/project.pbxproj index c9c4810..badef23 100644 --- a/Planz.xcodeproj/project.pbxproj +++ b/Planz.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 4972CFB029D8690400765115 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 4972CFAF29D8690400765115 /* GoogleService-Info.plist */; }; 49D91E12297999AC00A5C2BA /* .swiftlint.yml in Resources */ = {isa = PBXBuildFile; fileRef = 49D91E11297999AC00A5C2BA /* .swiftlint.yml */; }; 49D91E1529799F9D00A5C2BA /* runLint.sh in Resources */ = {isa = PBXBuildFile; fileRef = 49D91E1429799F9D00A5C2BA /* runLint.sh */; }; 49F41A7D2984C519008A3AFA /* runSwiftformat.sh in Resources */ = {isa = PBXBuildFile; fileRef = 49F41A7C2984C519008A3AFA /* runSwiftformat.sh */; }; @@ -43,9 +42,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 496EFF7829E0633C00351034 /* Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; - 496EFF7929E0635100351034 /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; - 4972CFAF29D8690400765115 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 49D91E11297999AC00A5C2BA /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = .swiftlint.yml; sourceTree = ""; }; 49D91E1429799F9D00A5C2BA /* runLint.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = runLint.sh; sourceTree = ""; }; 49F41A7C2984C519008A3AFA /* runSwiftformat.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = runSwiftformat.sh; sourceTree = ""; }; @@ -93,6 +89,13 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 496EFF7A29E06A5000351034 /* Secrets */ = { + isa = PBXGroup; + children = ( + ); + path = Secrets; + sourceTree = ""; + }; 6F47598D28D9D0CE005CC91B = { isa = PBXGroup; children = ( @@ -121,13 +124,11 @@ 6F47599828D9D0CE005CC91B /* Planz */ = { isa = PBXGroup; children = ( - 4972CFAF29D8690400765115 /* GoogleService-Info.plist */, + 496EFF7A29E06A5000351034 /* Secrets */, AE79C84329863F400098BA28 /* Info.plist */, 6F47599928D9D0CE005CC91B /* PlanzApp.swift */, 6F47599D28D9D0CF005CC91B /* Assets.xcassets */, 6F47599F28D9D0CF005CC91B /* Preview Content */, - 496EFF7829E0633C00351034 /* Debug.xcconfig */, - 496EFF7929E0635100351034 /* Release.xcconfig */, ); path = Planz; sourceTree = ""; @@ -284,7 +285,6 @@ 6F4759A128D9D0CF005CC91B /* Preview Assets.xcassets in Resources */, 6F47599E28D9D0CF005CC91B /* Assets.xcassets in Resources */, 49D91E1529799F9D00A5C2BA /* runLint.sh in Resources */, - 4972CFB029D8690400765115 /* GoogleService-Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -501,7 +501,6 @@ }; 6F4759BB28D9D0CF005CC91B /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 496EFF7829E0633C00351034 /* Debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -531,7 +530,6 @@ }; 6F4759BC28D9D0CF005CC91B /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 496EFF7929E0635100351034 /* Release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; From 1d645b6b6a74dae353cbbd4a1185419b00338aca Mon Sep 17 00:00:00 2001 From: PlanzEngineering Date: Fri, 7 Apr 2023 15:19:15 +0000 Subject: [PATCH 10/15] Automatically reformatted for Swift-lint --- Planz/PlanzApp.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Planz/PlanzApp.swift b/Planz/PlanzApp.swift index 1402483..a752572 100644 --- a/Planz/PlanzApp.swift +++ b/Planz/PlanzApp.swift @@ -8,8 +8,7 @@ import SwiftUI class AppDelegate: NSObject, UIApplicationDelegate { func application(_: UIApplication, - didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool - { + didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { FirebaseApp.configure() KakaoSDK.initSDK(appKey: Secrets.Kakao.appKey.value) return true From 8882e859091d05c503a49836d06f2c41f103c2c1 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 10 Apr 2023 19:32:33 +0900 Subject: [PATCH 11/15] [PI-36-1] add repository --- AppPackage/Package.swift | 17 +++-- .../Repository/FirebaseRepository.swift | 37 +++++++++++ .../Sources/Repository/KakaoRepository.swift | 38 ++++++++++++ .../ShareFeature/SharePromiseStore.swift | 62 +++++++------------ 4 files changed, 110 insertions(+), 44 deletions(-) create mode 100644 AppPackage/Sources/Repository/FirebaseRepository.swift create mode 100644 AppPackage/Sources/Repository/KakaoRepository.swift diff --git a/AppPackage/Package.swift b/AppPackage/Package.swift index 3ae4470..70298ba 100644 --- a/AppPackage/Package.swift +++ b/AppPackage/Package.swift @@ -96,12 +96,9 @@ let package = Package( name: "ShareFeature", dependencies: [ "DesignSystem", + "Repository", .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), .product(name: "APIClient", package: "Planz-iOS-APIClient"), - .product(name: "FirebaseAuth", package: "firebase-ios-sdk"), - .product(name: "FirebaseFirestore", package: "firebase-ios-sdk"), - .product(name: "FirebaseDynamicLinks", package: "firebase-ios-sdk"), - .product(name: "KakaoSDK", package: "kakao-ios-sdk"), .product(name: "Planz-iOS-Secrets", package: "Planz-iOS-Secrets") ] ), @@ -153,6 +150,16 @@ let package = Package( ] ), .target(name: "SwiftUIHelper"), - .target(name: "Entity") + .target(name: "Entity"), + .target( + name: "Repository", + dependencies: [ + .product(name: "FirebaseAuth", package: "firebase-ios-sdk"), + .product(name: "FirebaseFirestore", package: "firebase-ios-sdk"), + .product(name: "FirebaseDynamicLinks", package: "firebase-ios-sdk"), + .product(name: "KakaoSDK", package: "kakao-ios-sdk"), + .product(name: "Planz-iOS-Secrets", package: "Planz-iOS-Secrets") + ] + ) ] ) diff --git a/AppPackage/Sources/Repository/FirebaseRepository.swift b/AppPackage/Sources/Repository/FirebaseRepository.swift new file mode 100644 index 0000000..2cf169a --- /dev/null +++ b/AppPackage/Sources/Repository/FirebaseRepository.swift @@ -0,0 +1,37 @@ +// +// File.swift +// +// +// Created by 한상준 on 2023/04/10. +// + +import FirebaseAuth +import FirebaseCore +import FirebaseDynamicLinks +import FirebaseFirestore +import Foundation +import Planz_iOS_Secrets +public protocol FirebaseRepository { + func getDynamicLink(id: String?) -> URL? +} + +public class FirebaseRepositoryImpl: FirebaseRepository { + public init() {} + + private func getDeepLink(id: String?) -> URL? { + if let id { + return URL(string: "\(Secrets.Firebase.domain.value)/?plandId=\(id)") + } else { + return URL(string: Secrets.Firebase.domain.value) + } + } + + public func getDynamicLink(id: String? = nil) -> URL? { + guard let link = getDeepLink(id: id) else { return nil } + let dynamicLinksDomainURIPrefix = Secrets.Firebase.prefix.value + let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix) + linkBuilder?.iOSParameters = DynamicLinkIOSParameters(bundleID: Secrets.App.iosBundleId.value) + linkBuilder?.androidParameters = DynamicLinkAndroidParameters(packageName: Secrets.App.androidBundleId.value) + return linkBuilder?.url + } +} diff --git a/AppPackage/Sources/Repository/KakaoRepository.swift b/AppPackage/Sources/Repository/KakaoRepository.swift new file mode 100644 index 0000000..4d7684f --- /dev/null +++ b/AppPackage/Sources/Repository/KakaoRepository.swift @@ -0,0 +1,38 @@ +// +// File.swift +// +// +// Created by 한상준 on 2023/04/10. +// + +import KakaoSDKShare +import KakaoSDKTemplate +import Planz_iOS_Secrets + +public protocol KakaoRepository { + func getKakaoTalkSharingResult(url: String) async -> Result +} + +public enum KakaoError: Error { + case kakaoTalkSharingInAvailable +} +public class KakaoRepositoryImpl: KakaoRepository { + public init() {} + public func getKakaoTalkSharingResult(url _: String) async -> Result { + if ShareApi.isKakaoTalkSharingAvailable() { + // TODO: 이전 화면에서 전달해주는 id 값에 맞춰서 공유 링크의 파라미터로 추가하도록 수정 필요 + return await withCheckedContinuation({ continuation in + ShareApi.shared.shareCustom(templateId: Int64(Secrets.Kakao.templateId.value)!, templateArgs: ["": ""]) { linkResult, error in + if let error = error { + continuation.resume(returning: .failure(error)) + } else { + guard let linkResult = linkResult else { return } + continuation.resume(returning: .success(linkResult)) + } + } + }) + } else { + return .failure(KakaoError.kakaoTalkSharingInAvailable) + } + } +} diff --git a/AppPackage/Sources/ShareFeature/SharePromiseStore.swift b/AppPackage/Sources/ShareFeature/SharePromiseStore.swift index b09793e..14c4a7f 100644 --- a/AppPackage/Sources/ShareFeature/SharePromiseStore.swift +++ b/AppPackage/Sources/ShareFeature/SharePromiseStore.swift @@ -7,18 +7,22 @@ import APIClient import ComposableArchitecture -import FirebaseAuth -import FirebaseCore -import FirebaseDynamicLinks -import FirebaseFirestore import Foundation -import KakaoSDKShare -import KakaoSDKTemplate import Planz_iOS_Secrets +import Repository import UIKit public struct SharePromiseFeature: ReducerProtocol { - public init() {} + let firebaseRepository: FirebaseRepository + let kakaoRepository: KakaoRepository + + public init( + firebaseRepository: FirebaseRepository = FirebaseRepositoryImpl(), kakaoRepository: KakaoRepository = KakaoRepositoryImpl() + ) { + self.firebaseRepository = firebaseRepository + self.kakaoRepository = kakaoRepository + } + public struct State: Equatable { var linkForShare = "" var id: Int? @@ -31,44 +35,24 @@ public struct SharePromiseFeature: ReducerProtocol { case shareAsKakaoTapped } - func getDeepLink(id: String?) -> URL? { - if let id { - return URL(string: "\(Secrets.Firebase.domain.value)/?plandId=\(id)") - } else { - return URL(string: Secrets.Firebase.domain.value) - } - } - - func getDynamicLink(id _: String?) -> URL? { - guard let link = getDeepLink(id: nil) else { return nil } - let dynamicLinksDomainURIPrefix = Secrets.Firebase.prefix.value - let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix) - linkBuilder?.iOSParameters = DynamicLinkIOSParameters(bundleID: Secrets.App.iosBundleId.value) - linkBuilder?.androidParameters = DynamicLinkAndroidParameters(packageName: Secrets.App.androidBundleId.value) - return linkBuilder?.url - } - - func shareViaKakao(url _: String) { - if ShareApi.isKakaoTalkSharingAvailable() { - // TODO: 이전 화면에서 전달해주는 id 값에 맞춰서 공유 링크의 파라미터로 추가하도록 수정 필요 - ShareApi.shared.shareCustom(templateId: Int64(Secrets.Kakao.templateId.value)!, templateArgs: ["": ""]) { linkResult, error in - if let error = error { - print("error : \(error)") - } else { - print("defaultLink(templateObject:templateJsonObject) success.") - guard let linkResult = linkResult else { return } - UIApplication.shared.open(linkResult.url, options: [:], completionHandler: nil) - } + func shareViaKakao(link: String) { + Task { + let sharingResult = await self.kakaoRepository.getKakaoTalkSharingResult(url: link) + do { + let url = try sharingResult.get().url + await UIApplication.shared.open(url) + } catch { + // TODO: 공유 에러 팝업 노출 + print(error) } - - } else {} + } } public var body: some ReducerProtocol { Reduce { state, action in switch action { case .viewDidAppear: - if let link = getDynamicLink(id: nil) { + if let link = self.firebaseRepository.getDynamicLink(id: nil) { state.linkForShare = link.absoluteString } return .none @@ -76,7 +60,7 @@ public struct SharePromiseFeature: ReducerProtocol { UIPasteboard.general.string = state.linkForShare return .none case .shareAsKakaoTapped: - shareViaKakao(url: state.linkForShare) + shareViaKakao(link: state.linkForShare) return .none } } From c09f98946347876cd135226cfb09fc0957e35320 Mon Sep 17 00:00:00 2001 From: PlanzEngineering Date: Mon, 17 Apr 2023 13:52:20 +0000 Subject: [PATCH 12/15] Automatically reformatted for Swift-lint --- AppPackage/Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppPackage/Package.swift b/AppPackage/Package.swift index 987bdfb..c013811 100644 --- a/AppPackage/Package.swift +++ b/AppPackage/Package.swift @@ -49,7 +49,7 @@ let package = Package( .package(url: "https://github.com/devxoul/Then.git", from: "3.0.0"), .package(url: "https://github.com/kakao/kakao-ios-sdk.git", from: "2.14.0"), .package(url: "https://github.com/Team-Planz/Planz-iOS-Secrets.git", branch: "main") - .package(url: "https://github.com/firebase/firebase-ios-sdk", from: "8.10.0"), + .package(url: "https://github.com/firebase/firebase-ios-sdk", from: "8.10.0") ], targets: [ .target( From 7e4567b9a8c27900f8de1a4e09b721d5901c1a28 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Apr 2023 22:29:10 +0900 Subject: [PATCH 13/15] [PI-36-1] update package --- AppPackage/Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppPackage/Package.swift b/AppPackage/Package.swift index c013811..f872bfe 100644 --- a/AppPackage/Package.swift +++ b/AppPackage/Package.swift @@ -48,7 +48,7 @@ let package = Package( .package(url: "https://github.com/siteline/SwiftUI-Introspect.git", from: "0.1.4"), .package(url: "https://github.com/devxoul/Then.git", from: "3.0.0"), .package(url: "https://github.com/kakao/kakao-ios-sdk.git", from: "2.14.0"), - .package(url: "https://github.com/Team-Planz/Planz-iOS-Secrets.git", branch: "main") + .package(url: "https://github.com/Team-Planz/Planz-iOS-Secrets.git", branch: "main"), .package(url: "https://github.com/firebase/firebase-ios-sdk", from: "8.10.0") ], targets: [ From a56b4cfcac05aaa03d6fc50d7e18d71a4230022a Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 20 Apr 2023 16:10:10 +0900 Subject: [PATCH 14/15] [PI-36-1] update --- AppPackage/Package.swift | 5 ++--- .../Sources/MakePromise/MakePromiseStore.swift | 3 ++- .../Sources/Repository/FirebaseRepository.swift | 6 +++--- AppPackage/Sources/Repository/KakaoRepository.swift | 7 ++++--- .../Sources/ShareFeature/SharePromiseStore.swift | 12 +++++++----- Planz/PlanzApp.swift | 3 ++- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/AppPackage/Package.swift b/AppPackage/Package.swift index f872bfe..4fecae2 100644 --- a/AppPackage/Package.swift +++ b/AppPackage/Package.swift @@ -113,7 +113,7 @@ let package = Package( "DesignSystem", "Repository", .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), - .product(name: "APIClient", package: "Planz-iOS-APIClient"), + "APIClient", .product(name: "Planz-iOS-Secrets", package: "Planz-iOS-Secrets") ] ), @@ -187,8 +187,7 @@ let package = Package( dependencies: [ "Entity" ] - ) - .target(name: "Entity"), + ), .target( name: "Repository", dependencies: [ diff --git a/AppPackage/Sources/MakePromise/MakePromiseStore.swift b/AppPackage/Sources/MakePromise/MakePromiseStore.swift index 0af0469..985d884 100644 --- a/AppPackage/Sources/MakePromise/MakePromiseStore.swift +++ b/AppPackage/Sources/MakePromise/MakePromiseStore.swift @@ -63,7 +63,8 @@ public let makePromiseReducer = AnyReducer URL? + func getDynamicLink(id: Int?) -> URL? } public class FirebaseRepositoryImpl: FirebaseRepository { public init() {} - private func getDeepLink(id: String?) -> URL? { + private func getDeepLink(id: Int?) -> URL? { if let id { return URL(string: "\(Secrets.Firebase.domain.value)/?plandId=\(id)") } else { @@ -26,7 +26,7 @@ public class FirebaseRepositoryImpl: FirebaseRepository { } } - public func getDynamicLink(id: String? = nil) -> URL? { + public func getDynamicLink(id: Int? = nil) -> URL? { guard let link = getDeepLink(id: id) else { return nil } let dynamicLinksDomainURIPrefix = Secrets.Firebase.prefix.value let linkBuilder = DynamicLinkComponents(link: link, domainURIPrefix: dynamicLinksDomainURIPrefix) diff --git a/AppPackage/Sources/Repository/KakaoRepository.swift b/AppPackage/Sources/Repository/KakaoRepository.swift index 4d7684f..5ce4a29 100644 --- a/AppPackage/Sources/Repository/KakaoRepository.swift +++ b/AppPackage/Sources/Repository/KakaoRepository.swift @@ -1,6 +1,6 @@ // // File.swift -// +// // // Created by 한상준 on 2023/04/10. // @@ -16,12 +16,13 @@ public protocol KakaoRepository { public enum KakaoError: Error { case kakaoTalkSharingInAvailable } + public class KakaoRepositoryImpl: KakaoRepository { public init() {} public func getKakaoTalkSharingResult(url _: String) async -> Result { if ShareApi.isKakaoTalkSharingAvailable() { // TODO: 이전 화면에서 전달해주는 id 값에 맞춰서 공유 링크의 파라미터로 추가하도록 수정 필요 - return await withCheckedContinuation({ continuation in + return await withCheckedContinuation { continuation in ShareApi.shared.shareCustom(templateId: Int64(Secrets.Kakao.templateId.value)!, templateArgs: ["": ""]) { linkResult, error in if let error = error { continuation.resume(returning: .failure(error)) @@ -30,7 +31,7 @@ public class KakaoRepositoryImpl: KakaoRepository { continuation.resume(returning: .success(linkResult)) } } - }) + } } else { return .failure(KakaoError.kakaoTalkSharingInAvailable) } diff --git a/AppPackage/Sources/ShareFeature/SharePromiseStore.swift b/AppPackage/Sources/ShareFeature/SharePromiseStore.swift index 14c4a7f..8811a4c 100644 --- a/AppPackage/Sources/ShareFeature/SharePromiseStore.swift +++ b/AppPackage/Sources/ShareFeature/SharePromiseStore.swift @@ -15,9 +15,9 @@ import UIKit public struct SharePromiseFeature: ReducerProtocol { let firebaseRepository: FirebaseRepository let kakaoRepository: KakaoRepository - public init( - firebaseRepository: FirebaseRepository = FirebaseRepositoryImpl(), kakaoRepository: KakaoRepository = KakaoRepositoryImpl() + firebaseRepository: FirebaseRepository = FirebaseRepositoryImpl(), + kakaoRepository: KakaoRepository = KakaoRepositoryImpl() ) { self.firebaseRepository = firebaseRepository self.kakaoRepository = kakaoRepository @@ -25,8 +25,10 @@ public struct SharePromiseFeature: ReducerProtocol { public struct State: Equatable { var linkForShare = "" - var id: Int? - public init() {} + var id: Int + public init(id: Int) { + self.id = id + } } public enum Action: Equatable { @@ -52,7 +54,7 @@ public struct SharePromiseFeature: ReducerProtocol { Reduce { state, action in switch action { case .viewDidAppear: - if let link = self.firebaseRepository.getDynamicLink(id: nil) { + if let link = self.firebaseRepository.getDynamicLink(id: state.id) { state.linkForShare = link.absoluteString } return .none diff --git a/Planz/PlanzApp.swift b/Planz/PlanzApp.swift index a752572..1402483 100644 --- a/Planz/PlanzApp.swift +++ b/Planz/PlanzApp.swift @@ -8,7 +8,8 @@ import SwiftUI class AppDelegate: NSObject, UIApplicationDelegate { func application(_: UIApplication, - didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { + didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool + { FirebaseApp.configure() KakaoSDK.initSDK(appKey: Secrets.Kakao.appKey.value) return true From dd57432ada852d006bbf15cad167ab5529479c48 Mon Sep 17 00:00:00 2001 From: PlanzEngineering Date: Mon, 24 Apr 2023 14:02:32 +0000 Subject: [PATCH 15/15] Automatically reformatted for Swift-lint --- AppPackage/Sources/MakePromise/MakePromiseStore.swift | 3 +-- Planz/PlanzApp.swift | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/AppPackage/Sources/MakePromise/MakePromiseStore.swift b/AppPackage/Sources/MakePromise/MakePromiseStore.swift index 985d884..0af0469 100644 --- a/AppPackage/Sources/MakePromise/MakePromiseStore.swift +++ b/AppPackage/Sources/MakePromise/MakePromiseStore.swift @@ -63,8 +63,7 @@ public let makePromiseReducer = AnyReducer Bool - { + didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { FirebaseApp.configure() KakaoSDK.initSDK(appKey: Secrets.Kakao.appKey.value) return true