diff --git a/Packages/BeMatch/Package.swift b/Packages/BeMatch/Package.swift index 6e408f57..c7e70f53 100644 --- a/Packages/BeMatch/Package.swift +++ b/Packages/BeMatch/Package.swift @@ -195,6 +195,7 @@ let package = Package( "Styleguide", "BeMatchClient", "AnalyticsKeys", + .product(name: "ActivityView", package: "SDK"), .product(name: "FeedbackGeneratorClient", package: "SDK"), .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), ]), diff --git a/Packages/BeMatch/Sources/AnalyticsKeys/ButtonClickKeys.swift b/Packages/BeMatch/Sources/AnalyticsKeys/ButtonClickKeys.swift index 1873d686..0368736b 100644 --- a/Packages/BeMatch/Sources/AnalyticsKeys/ButtonClickKeys.swift +++ b/Packages/BeMatch/Sources/AnalyticsKeys/ButtonClickKeys.swift @@ -10,4 +10,5 @@ public extension ButtonClickKeys { var close: String { "close" } var notNow: String { "not_now" } var delete: String { "delete" } + var share: String { "share" } } diff --git a/Packages/BeMatch/Sources/OnboardFeature/Onboard.swift b/Packages/BeMatch/Sources/OnboardFeature/Onboard.swift index c22ce57e..8e6e548c 100644 --- a/Packages/BeMatch/Sources/OnboardFeature/Onboard.swift +++ b/Packages/BeMatch/Sources/OnboardFeature/Onboard.swift @@ -43,7 +43,8 @@ public struct OnboardLogic { return .none case .path(.element(_, .gender(.delegate(.nextScreen)))): - state.path.append(.sample()) +// state.path.append(.sample()) + state.path.append(.capture()) return .none case .path(.element(_, .sample(.delegate(.nextScreen)))): diff --git a/Packages/BeMatch/Sources/RecommendationEmptyFeature/RecommendationEmpty.swift b/Packages/BeMatch/Sources/RecommendationEmptyFeature/RecommendationEmpty.swift index 1458f9a0..79040715 100644 --- a/Packages/BeMatch/Sources/RecommendationEmptyFeature/RecommendationEmpty.swift +++ b/Packages/BeMatch/Sources/RecommendationEmptyFeature/RecommendationEmpty.swift @@ -1,4 +1,6 @@ +import ActivityView import AnalyticsClient +import AnalyticsKeys import BeMatch import BeMatchClient import ComposableArchitecture @@ -10,15 +12,24 @@ import SwiftUI public struct RecommendationEmptyLogic { public init() {} + public struct CompletionWithItems: Equatable { + public let activityType: UIActivity.ActivityType? + public let result: Bool + } + public struct State: Equatable { var sharedURL = Constants.appStoreForEmptyURL + @BindingState var isPresented = false public init() {} } - public enum Action { + public enum Action: BindableAction { case onTask case onAppear + case shareButtonTapped case currentUserResponse(Result) + case onCompletion(CompletionWithItems) + case binding(BindingAction) } @Dependency(\.analytics) var analytics @@ -29,6 +40,7 @@ public struct RecommendationEmptyLogic { } public var body: some Reducer { + BindingReducer() Reduce { state, action in switch action { case .onTask: @@ -45,13 +57,25 @@ public struct RecommendationEmptyLogic { analytics.logScreen(screenName: "RecommendationEmpty", of: self) return .none + case .shareButtonTapped: + state.isPresented = true + return .none + case let .currentUserResponse(.success(data)): state.sharedURL = data.currentUser.gender == .female ? Constants.appStoreFemaleForEmptyURL : Constants.appStoreForEmptyURL return .none - case .currentUserResponse(.failure): + case let .onCompletion(completion): + state.isPresented = false + analytics.logEvent("activity_completion", [ + "activity_type": completion.activityType?.rawValue, + "result": completion.result, + ]) + return .none + + default: return .none } } @@ -79,7 +103,9 @@ public struct RecommendationEmptyView: View { .foregroundStyle(Color.white) .multilineTextAlignment(.center) - ShareLink(item: viewStore.sharedURL) { + Button { + store.send(.shareButtonTapped) + } label: { Text("Share", bundle: .module) .font(.system(.subheadline, weight: .semibold)) .frame(height: 50) @@ -95,6 +121,22 @@ public struct RecommendationEmptyView: View { .background(Color.black) .task { await store.send(.onTask).finish() } .onAppear { store.send(.onAppear) } + .sheet(isPresented: viewStore.$isPresented) { + ActivityView( + activityItems: [viewStore.sharedURL], + applicationActivities: nil + ) { activityType, result, _, _ in + store.send( + .onCompletion( + RecommendationEmptyLogic.CompletionWithItems( + activityType: activityType, + result: result + ) + ) + ) + } + .presentationDetents([.medium, .large]) + } } } } diff --git a/Packages/BeMatch/Sources/RecommendationFeature/Recommendation.swift b/Packages/BeMatch/Sources/RecommendationFeature/Recommendation.swift index 257eb850..95ae058d 100644 --- a/Packages/BeMatch/Sources/RecommendationFeature/Recommendation.swift +++ b/Packages/BeMatch/Sources/RecommendationFeature/Recommendation.swift @@ -61,6 +61,8 @@ public struct RecommendationLogic { ? .empty() : .swipe(RecommendationSwipeLogic.State(rows: rows)) + state.child = .empty() + return .none case let .child(.swipe(.delegate(.matched(username)))): diff --git a/Packages/SDK/Package.swift b/Packages/SDK/Package.swift index e2a7eb9b..1f43b6b5 100644 --- a/Packages/SDK/Package.swift +++ b/Packages/SDK/Package.swift @@ -9,6 +9,7 @@ var package = Package( .iOS(.v16), ], products: [ + .library(name: "ActivityView", targets: ["ActivityView"]), .library(name: "AnalyticsClient", targets: ["AnalyticsClient"]), .library(name: "ApolloClientHelpers", targets: ["ApolloClientHelpers"]), .library(name: "ApolloConcurrency", targets: ["ApolloConcurrency"]), @@ -48,6 +49,7 @@ var package = Package( .package(url: "https://github.com/pointfreeco/swift-composable-architecture", from: "1.5.6"), ], targets: [ + .target(name: "ActivityView"), .target(name: "AnalyticsClient", dependencies: [ .product(name: "Dependencies", package: "swift-dependencies"), .product(name: "FirebaseAnalytics", package: "firebase-ios-sdk"),