Skip to content

Commit

Permalink
Merge pull request #962 from 0x1-company/tutorial
Browse files Browse the repository at this point in the history
feat: 🎸 tutorial feature
  • Loading branch information
tomokisun authored Nov 15, 2023
2 parents 572e5f4 + eca2f78 commit 77ac892
Show file tree
Hide file tree
Showing 21 changed files with 1,000 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,22 @@ public extension UserDefaultsClient {
func dynamicLinkURL() -> String? {
stringForKey(keyDynamicLinkURL)
}

func setTutorialFinish() async {
await setBool(true, keyTutorialFinished)
}

func tutorialFinished() -> Bool {
boolForKey(keyTutorialFinished)
}
}

private let keyPhoneNumber = "PHONE_NUMBER"
private let keyVerificationId = "VERIFICATION_ID"
private let keyOnboardCompleted = "ONBOARD_COMPLETED"
private let keyReadInitialGodTeamNotification = "READ_INITIAL_GOD_TEAM_NOTIFICATION"
private let keyDynamicLinkURL = "DYNAMIC_LINK_URL"
private let keyTutorialFinished = "TUTORIAL_FINISHED"

private let decoder = JSONDecoder()
private let encoder = JSONEncoder()
11 changes: 9 additions & 2 deletions Packages/GodPackage/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ let package = Package(
.library(name: "RevealFeature", targets: ["RevealFeature"]),
.library(name: "ShareScreenshotFeature", targets: ["ShareScreenshotFeature"]),
.library(name: "ShopFeature", targets: ["ShopFeature"]),
.library(name: "TutorialFeature", targets: ["TutorialFeature"]),
],
dependencies: [
.package(path: "../CupertinoPackage"),
Expand Down Expand Up @@ -194,11 +195,12 @@ let package = Package(
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
]),
.target(name: "NavigationFeature", dependencies: [
"AboutFeature",
"ActivityFeature",
"AddFeature",
"GodFeature",
"InboxFeature",
"AboutFeature",
"ActivityFeature",
"TutorialFeature",
]),
.target(name: "OnboardFeature", dependencies: [
"HowItWorksFeature",
Expand Down Expand Up @@ -298,5 +300,10 @@ let package = Package(
.product(name: "AnalyticsClient", package: "DependencyPackage"),
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
]),
.target(name: "TutorialFeature", dependencies: [
.product(name: "Styleguide", package: "UIComponentPackage"),
.product(name: "AnalyticsClient", package: "DependencyPackage"),
.product(name: "ComposableArchitecture", package: "swift-composable-architecture"),
])
]
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import AboutFeature
import UserDefaultsClient
import ActivityFeature
import AddFeature
import ComposableArchitecture
import FriendRequestFeature
import God
import GodClient
import GodFeature
import TutorialFeature
import InboxFeature
import ProfileFeature
import SwiftUI
Expand All @@ -32,8 +34,12 @@ public struct RootNavigationLogic {
var god = GodLogic.State()
var profile = ProfileLogic.State()
var about = AboutLogic.State()
var tutorial: TutorialLogic.State?
@BindingState var selectedTab = Tab.god
public init() {}
public init() {
@Dependency(\.userDefaults) var userDefaults
self.tutorial = userDefaults.tutorialFinished() ? nil : .init()
}
}

public enum Action: BindableAction {
Expand All @@ -46,12 +52,14 @@ public struct RootNavigationLogic {
case god(GodLogic.Action)
case profile(ProfileLogic.Action)
case about(AboutLogic.Action)
case tutorial(TutorialLogic.Action)
case binding(BindingAction<State>)
case friendRequestSheet(PresentationAction<FriendRequestSheetLogic.Action>)
}

@Dependency(\.mainQueue) var mainQueue
@Dependency(\.godClient) var godClient
@Dependency(\.userDefaults) var userDefaults

enum Cancel {
case friendRequests
Expand All @@ -76,6 +84,12 @@ public struct RootNavigationLogic {
await send(.friendRequestResponse(.failure(error)))
}
.cancellable(id: Cancel.friendRequests, cancelInFlight: true)

case .tutorial(.delegate(.finish)):
state.tutorial = nil
return .run { _ in
await userDefaults.setTutorialFinish()
}

case let .friendRequestResponse(.success(data)):
let requests = data.friendRequests.edges.map(\.node.fragments.friendRequestSheetFragment)
Expand Down Expand Up @@ -111,6 +125,9 @@ public struct RootNavigationLogic {
.ifLet(\.$friendRequestSheet, action: \.friendRequestSheet) {
FriendRequestSheetLogic()
}
.ifLet(\.tutorial, action: \.tutorial) {
TutorialLogic()
}
}
}

Expand Down Expand Up @@ -186,6 +203,12 @@ public struct RootNavigationView: View {
selection: viewStore.$selectedTab
)
}
.overlay {
IfLetStore(
store.scope(state: \.tutorial, action: RootNavigationLogic.Action.tutorial),
then: TutorialView.init(store:)
)
}
.sheet(
store: store.scope(state: \.$friendRequestSheet, action: RootNavigationLogic.Action.friendRequestSheet)
) { store in
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "busts-in-silhouette.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "coin.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 77ac892

Please sign in to comment.