Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.0.3 Release -> Develop #209

Merged
merged 6 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Projects/App/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
Log.debug("fcm token: \(fcmToken ?? "NO TOKEN")")
if let fcmToken {
// TODO: user defaults 설정 방법 변경
UserDefaults.standard.set(fcmToken, forKey: "fcmToken")
store.send(.appDelegate(.didReceivedFcmToken(fcmToken: fcmToken)))
}
}

Expand Down
14 changes: 9 additions & 5 deletions Projects/Domain/Auth/Sources/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import Foundation

import DomainAuthInterface
import DomainUser

import CoreNetwork
import CoreLoggerInterface

Expand All @@ -19,12 +21,13 @@ extension AuthClient: DependencyKey {
private static func live() -> AuthClient {
@Dependency(\.network) var networkManager
@Dependency(\.loginManager) var loginManager

@Dependency(\.userClient) var userClient
return .init(
signInWithKakao: {
let signInResult = try await loginManager.signIn(loginType: .kakao)
let accessToken = signInResult.accessToken
guard let fcmToken = UserDefaults.standard.string(forKey: "fcmToken")
let fcmToken = userClient.fetchFcmToken()
guard let fcmToken = fcmToken
else {
Log.fault("no fcm token")
fatalError()
Expand All @@ -40,8 +43,8 @@ extension AuthClient: DependencyKey {
let signInResult = try await loginManager.signIn(loginType: .apple)
let accessToken = signInResult.accessToken
let userName = signInResult.userName

guard let fcmToken = UserDefaults.standard.string(forKey: "fcmToken")
let fcmToken = userClient.fetchFcmToken()
guard let fcmToken = fcmToken
else {
Log.fault("no fcm token")
fatalError()
Expand All @@ -62,7 +65,8 @@ extension AuthClient: DependencyKey {
try await networkManager.reqeust(api: .apiType(AuthAPI.withdraw))
},
logout: {
guard let fcmToken = UserDefaults.standard.string(forKey: "fcmToken")
let fcmToken = userClient.fetchFcmToken()
guard let fcmToken = fcmToken
else {
Log.fault("no fcm token")
return
Expand Down
16 changes: 15 additions & 1 deletion Projects/Domain/User/Interface/Sources/UserClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@ import Foundation
public struct UserClient {
private let _isLoggedIn: () -> Bool
private let _isAppDeleted: () -> Bool
private let _fetchFcmToken: () -> String?
private let updateLoginState: (Bool) -> Void
private let updateDeleteState: (Bool) -> Void
private let updateFcmToken: (String) -> Void

public init(
isLoggedIn: @escaping () -> Bool,
isAppDeleted: @escaping () -> Bool,
fetchFcmToken: @escaping () -> String?,
updateLoginState: @escaping (Bool) -> Void,
updateDeleteState: @escaping (Bool) -> Void
updateDeleteState: @escaping (Bool) -> Void,
updateFcmToken: @escaping (String) -> Void
) {
self._isLoggedIn = isLoggedIn
self._isAppDeleted = isAppDeleted
self._fetchFcmToken = fetchFcmToken
self.updateLoginState = updateLoginState
self.updateDeleteState = updateDeleteState
self.updateFcmToken = updateFcmToken
}

public func isLoggedIn() -> Bool {
Expand All @@ -33,11 +39,19 @@ public struct UserClient {
_isAppDeleted()
}

public func fetchFcmToken() -> String? {
_fetchFcmToken()
}

public func updateLoginState(isLoggedIn: Bool) {
updateLoginState(isLoggedIn)
}

public func updateDeleteState(isDelete: Bool) {
updateDeleteState(isDelete)
}

public func updateFcmToken(fcmToken: String) {
updateFcmToken(fcmToken)
}
}
8 changes: 8 additions & 0 deletions Projects/Domain/User/Sources/UserClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ extension UserClient: DependencyKey {
return !UserDefaults.standard.bool(forKey: "deleteState")
},

fetchFcmToken: {
return UserDefaults.standard.string(forKey: "fcmToken")
},

updateLoginState: { isLoggedIn in
UserDefaults.standard.set(isLoggedIn, forKey: "loginState")
},

updateDeleteState: { isDelete in
UserDefaults.standard.set(!isDelete, forKey: "deleteState")
},

updateFcmToken: { fcmToken in
UserDefaults.standard.set(fcmToken, forKey: "fcmToken")
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ extension LoginFeature {
case let .path(.element(id: _, action: .startGuide(.delegate(delegate)))):
switch delegate {
case .doneButtonDidTapped:
return goToOboarding(state: &state)

return goToOboarding(state: &state)
}
// appleLogin Delegate

case let .path(.element(id: _, action: .appleLogin(.delegate(delegate)))):
Expand Down
72 changes: 36 additions & 36 deletions Projects/Feature/Login/Interface/Sources/Login/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,54 +28,53 @@ public struct LoginView: View {
public var body: some View {
WithPerceptionTracking {
NavigationStack(path: $store.scope(state: \.path, action: \.path)) {
VStack(spacing: 0) {
Spacer()
.frame(height: 52)
whiteLogo
.padding(.top, 52)
.padding(.bottom, .xl)

mainText

Spacer()

VStack(spacing: 30.0) {
signInWithKakaoButton
snsLoginButton
}
.padding(.bottom, 30.0)
VStack(spacing: 0) {
Spacer()
.frame(height: 52)
whiteLogo
.padding(.top, 52)
.padding(.bottom, .xl)

mainText

Spacer()

VStack(spacing: 30.0) {
signInWithKakaoButton
snsLoginButton
}
.background {
BottleImageView(
type: .local(bottleImageSystem: .illustraition(.loginBackground))
)
}
.edgesIgnoringSafeArea([.top, .bottom])
.sheet(
isPresented: $store.isPresentTermView,
content: {
TermsWebView(url: store.termURL)
}
.padding(.bottom, 30.0)
}
.background {
BottleImageView(
type: .local(bottleImageSystem: .illustraition(.loginBackground))
)
.overlay {
if store.isLoading {
LoadingIndicator()
}
}
.edgesIgnoringSafeArea([.top, .bottom])
.sheet(
isPresented: $store.isPresentTermView,
content: {
TermsWebView(url: store.termURL)
}

)
.overlay {
if store.isLoading {
LoadingIndicator()
}
}
} destination: { store in
WithPerceptionTracking {
switch store.state {
case .generalLogin:
if let store = store.scope(state: \.generalLogin, action: \.generalLogin) {
GeneralLogInView(store: store)
}

case .onBoarding:
if let store = store.scope(state: \.onBoarding, action: \.onBoarding) {
OnboardingView(store: store)
}

case .generalSignUp:
if let store = store.scope(state: \.generalSignUp, action: \.generalSignUp) {
GeneralSignUpView(store: store)
Expand All @@ -99,11 +98,12 @@ public struct LoginView: View {
case .startGuide:
if let store = store.scope(state: \.startGuide, action: \.startGuide) {
StartGuideView(store: store)
}

}
case .appleLogin:
if let store = store.scope(state: \.appleLogin, action: \.appleLogin) {
AppleLoginView(store: store)
}
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions Projects/Feature/Sources/App/AppDelegateFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ public struct AppDelegateFeature {

public enum Action {
case didFinishLunching
case didReceivedFcmToken(fcmToken: String)

// Delegate
case delegate(Delegate)

public enum Delegate {
case fcmTokenDidRecevied(fcmToken: String)
}
}

public var body: some ReducerOf<Self> {
Expand All @@ -37,6 +45,14 @@ public struct AppDelegateFeature {

KakaoSDK.initSDK(appKey: kakaoAppKey)
return .none

case let .didReceivedFcmToken(fcmToken):
return .run { send in
await send(.delegate(.fcmTokenDidRecevied(fcmToken: fcmToken)))
}

default:
return .none
}
}
}
11 changes: 10 additions & 1 deletion Projects/Feature/Sources/App/AppFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public struct AppFeature {
case login(LoginFeature.Action)
case onboarding(OnboardingFeature.Action)

case checkUserLoginState
case sceneDidActive
case appleUserIdDidRevoked
case loginCheckCompleted(isLoggedIn: Bool)
Expand Down Expand Up @@ -85,7 +86,7 @@ public struct AppFeature {
action: Action
) -> EffectOf<Self> {
switch action {
case .onAppear:
case .checkUserLoginState:
let isAppDeleted = userClient.isAppDeleted()
let isLoggedIn = authClient.checkTokenIsExist()

Expand Down Expand Up @@ -120,6 +121,14 @@ public struct AppFeature {
return changeRoot(.Onboarding, state: &state)
}

// AppDelegate Delegate
case let .appDelegate(.delegate(delegate)):
switch delegate {
case let .fcmTokenDidRecevied(fcmToken):
userClient.updateFcmToken(fcmToken: fcmToken)
return .send(.checkUserLoginState)
}

// Login Delegate
case let .login(.delegate(delegate)):
switch delegate {
Expand Down
8 changes: 4 additions & 4 deletions Tuist/ProjectDescriptionHelpers/InfoPlist+Templates.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import ProjectDescription
public extension InfoPlist {
static var app: InfoPlist {
return .extendingDefault(with: [
"CFBundleShortVersionString": "1.0.2",
"CFBundleVersion": "21",
"CFBundleShortVersionString": "1.0.3",
"CFBundleVersion": "23",
"UIUserInterfaceStyle": "Light",
"CFBundleName": "보틀",
"UILaunchScreen": [
Expand Down Expand Up @@ -39,8 +39,8 @@ public extension InfoPlist {

static var example: InfoPlist {
return .extendingDefault(with: [
"CFBundleShortVersionString": "1.0.2",
"CFBundleVersion": "21",
"CFBundleShortVersionString": "1.0.3",
"CFBundleVersion": "23",
"UIUserInterfaceStyle": "Light",
"UILaunchScreen": [:],
"UISupportedInterfaceOrientations": [
Expand Down