diff --git a/KuringApp/KuringApp/KuringApp.swift b/KuringApp/KuringApp/KuringApp.swift index 5cc69ba1..143d6562 100644 --- a/KuringApp/KuringApp/KuringApp.swift +++ b/KuringApp/KuringApp/KuringApp.swift @@ -29,9 +29,6 @@ struct KuringApp: App { if completesLink { // MARK: ContentView ContentView() - .fullScreenCover(isPresented: $showsOnboarding) { - OnboardingView() - } // MARK: 앱 업데이트 알림 .versionUpdateAlert() // MARK: 새 공지 보여주기 (알림 탭했을 때) @@ -102,14 +99,19 @@ struct KuringApp: App { // MARK: LaunchScreen SplashScreen() .kuringLink( - onRequest: { - print("onRequest") - }, onCompletion: { result in - print("onCompletion: \(result)") - completesLink = true + onRequest: { }, + onCompletion: { result in showsOnboarding = !commons.isCompleteOnboarding() + if !showsOnboarding { + completesLink = true + } } ) + .fullScreenCover(isPresented: $showsOnboarding) { + completesLink = true + } content: { + OnboardingView() + } } } } diff --git a/package-kuring/Package.swift b/package-kuring/Package.swift index 7837d60e..f8b4f65e 100644 --- a/package-kuring/Package.swift +++ b/package-kuring/Package.swift @@ -128,7 +128,9 @@ let package = Package( "DepartmentUI", "Networks", "ColorSet", + "Caches", .product(name: "Lottie", package: "lottie-spm"), + .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), ], path: "Sources/UIKit/OnboardingUI", resources: [.process("Resources")] diff --git a/package-kuring/Sources/Caches/Dependency/Departments.swift b/package-kuring/Sources/Caches/Dependency/Departments.swift index 4f1e5224..76cc3676 100644 --- a/package-kuring/Sources/Caches/Dependency/Departments.swift +++ b/package-kuring/Sources/Caches/Dependency/Departments.swift @@ -66,7 +66,7 @@ extension Departments { Self.selections }, getCurrent: { - Self.current + Self.current ?? Self.selections.first }, changeCurrent: { noticeProvider in Self.current = noticeProvider diff --git a/package-kuring/Sources/Models/NoticeProvider.swift b/package-kuring/Sources/Models/NoticeProvider.swift index 0450e147..df20adfa 100644 --- a/package-kuring/Sources/Models/NoticeProvider.swift +++ b/package-kuring/Sources/Models/NoticeProvider.swift @@ -5,7 +5,6 @@ import Foundation import OrderedCollections -import Dependencies /// 공지 제공자 카테고리 public enum NoticeType: String, Codable, Hashable, CaseIterable, Identifiable, Equatable { diff --git a/package-kuring/Sources/UIKit/CommonUI/View.onFetchAllData.swift b/package-kuring/Sources/UIKit/CommonUI/View.onFetchAllData.swift index e14bdc67..2a0d6e64 100644 --- a/package-kuring/Sources/UIKit/CommonUI/View.onFetchAllData.swift +++ b/package-kuring/Sources/UIKit/CommonUI/View.onFetchAllData.swift @@ -16,23 +16,7 @@ struct KuringLinkFetcher: ViewModifier { func body(content: Content) -> some View { content - .task { - onRequest() - do { - @Dependency(\.kuringLink) var kuringLink - async let allUnivNoticeTypes = try kuringLink.getAllUnivNoticeType() - async let allDepartments = try kuringLink.getAllDepartments() - let _ = try await [allUnivNoticeTypes, allDepartments] - - async let subscribedDepartments = try kuringLink.getSubscribedDepartments() - async let subscribedUnivNotices = try kuringLink.getSubscribedUnivNotices() - let _ = try await [subscribedDepartments, subscribedUnivNotices] - onCompletion(.success(())) - } catch { - showsNetworkError = true - onCompletion(.failure(error)) - } - } + .task { await request() } .alert("앗! 인터넷 연결이 좋지 않아요!", isPresented: $showsNetworkError) { // 무시 Button(role: .cancel) { @@ -43,7 +27,24 @@ struct KuringLinkFetcher: ViewModifier { } message: { Text("네트워크 연결이 좋지 않아서 서버 정보를 불러오는데에 실패했어요.") } - + } + + func request() async { + onRequest() + do { + @Dependency(\.kuringLink) var kuringLink + async let allUnivNoticeTypes = try kuringLink.getAllUnivNoticeType() + async let allDepartments = try kuringLink.getAllDepartments() + let _ = try await [allUnivNoticeTypes, allDepartments] + + async let subscribedDepartments = try kuringLink.getSubscribedDepartments() + async let subscribedUnivNotices = try kuringLink.getSubscribedUnivNotices() + let _ = try await [subscribedDepartments, subscribedUnivNotices] + onCompletion(.success(())) + } catch { + showsNetworkError = true + onCompletion(.failure(error)) + } } } diff --git a/package-kuring/Sources/UIKit/OnboardingUI/MyDepartmentSelector/MyDepartmentSelector.swift b/package-kuring/Sources/UIKit/OnboardingUI/MyDepartmentSelector/MyDepartmentSelector.swift index 5be8e97e..4ca96f19 100644 --- a/package-kuring/Sources/UIKit/OnboardingUI/MyDepartmentSelector/MyDepartmentSelector.swift +++ b/package-kuring/Sources/UIKit/OnboardingUI/MyDepartmentSelector/MyDepartmentSelector.swift @@ -3,9 +3,11 @@ // See the 'License.txt' file for licensing information. // +import Caches import Models import SwiftUI import ColorSet +import Dependencies struct MyDepartmentSelector: View { @Environment(\.dismiss) private var dismiss @@ -33,7 +35,9 @@ struct MyDepartmentSelector: View { if currentStep == .selectDepartment { Button(StringSet.button_complete.rawValue) { if let selectedDepartment { + @Dependency(\.departments) var departments NoticeProvider.addedDepartments.append(selectedDepartment) + departments.add(selectedDepartment) } currentStep = .addedDepartment.id }