From d51f2f4a838a427c3492246250dded04af05d395 Mon Sep 17 00:00:00 2001 From: jim4020key Date: Tue, 25 Jul 2023 07:35:13 +0900 Subject: [PATCH] [Feat] #471 - Set Access Modifiers --- .../HappyAnding/ViewModel/ExploreShortcutViewModel.swift | 8 ++++++-- .../ViewModel/ListCategoryShortcutViewModel.swift | 2 +- .../HappyAnding/ViewModel/ListShortcutViewModel.swift | 3 +-- .../Views/ExploreShortcutViews/ExploreShortcutView.swift | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/HappyAnding/HappyAnding/ViewModel/ExploreShortcutViewModel.swift b/HappyAnding/HappyAnding/ViewModel/ExploreShortcutViewModel.swift index 9e0b5fc3..9c6ebfb1 100644 --- a/HappyAnding/HappyAnding/ViewModel/ExploreShortcutViewModel.swift +++ b/HappyAnding/HappyAnding/ViewModel/ExploreShortcutViewModel.swift @@ -9,7 +9,7 @@ import SwiftUI final class ExploreShortcutViewModel: ObservableObject { - var shortcutsZipViewModel = ShortcutsZipViewModel.share + private let shortcutsZipViewModel = ShortcutsZipViewModel.share @Published private(set) var isCategoryCellViewFolded = true @Published var isTappedAnnouncementCell = false @@ -24,7 +24,11 @@ final class ExploreShortcutViewModel: ObservableObject { isTappedAnnouncementCell = true } - func fetchShortcutsByCategories(category: Category) -> [Shortcuts] { + func fetchShortcuts(by category: Category) -> [Shortcuts] { shortcutsZipViewModel.shortcutsInCategory[category.index] } + + func fetchShortcuts(by sectionType: SectionType) -> [Shortcuts] { + sectionType.filterShortcuts(from: shortcutsZipViewModel) + } } diff --git a/HappyAnding/HappyAnding/ViewModel/ListCategoryShortcutViewModel.swift b/HappyAnding/HappyAnding/ViewModel/ListCategoryShortcutViewModel.swift index dd6f6db3..a90df18e 100644 --- a/HappyAnding/HappyAnding/ViewModel/ListCategoryShortcutViewModel.swift +++ b/HappyAnding/HappyAnding/ViewModel/ListCategoryShortcutViewModel.swift @@ -9,7 +9,7 @@ import SwiftUI final class ListCategoryShortcutViewModel: ObservableObject { - var shortcutsZipViewModel = ShortcutsZipViewModel.share + private let shortcutsZipViewModel = ShortcutsZipViewModel.share @Published private(set) var shortcuts: [Shortcuts] = [] @Published private(set) var category: Category = .business diff --git a/HappyAnding/HappyAnding/ViewModel/ListShortcutViewModel.swift b/HappyAnding/HappyAnding/ViewModel/ListShortcutViewModel.swift index 77fcf0c3..187add77 100644 --- a/HappyAnding/HappyAnding/ViewModel/ListShortcutViewModel.swift +++ b/HappyAnding/HappyAnding/ViewModel/ListShortcutViewModel.swift @@ -9,12 +9,11 @@ import SwiftUI final class ListShortcutViewModel: ObservableObject { - var shortcutsZipViewModel = ShortcutsZipViewModel.share + private let shortcutsZipViewModel = ShortcutsZipViewModel.share @Published private(set) var shortcuts: [Shortcuts] = [] @Published private(set) var sectionType: SectionType = .download - init(data: SectionType) { sectionType = data shortcuts = fetchShortcutsBySectionType() diff --git a/HappyAnding/HappyAnding/Views/ExploreShortcutViews/ExploreShortcutView.swift b/HappyAnding/HappyAnding/Views/ExploreShortcutViews/ExploreShortcutView.swift index 7692a3b3..bb96dbf2 100644 --- a/HappyAnding/HappyAnding/Views/ExploreShortcutViews/ExploreShortcutView.swift +++ b/HappyAnding/HappyAnding/Views/ExploreShortcutViews/ExploreShortcutView.swift @@ -110,7 +110,7 @@ extension ExploreShortcutView { @ViewBuilder private func sectionView(with sectionType: SectionType) -> some View { - let shortcuts = sectionType.filterShortcuts(from: viewModel.shortcutsZipViewModel) + let shortcuts = viewModel.fetchShortcuts(by: sectionType) VStack(spacing: 0) { HStack { @@ -157,7 +157,7 @@ extension ExploreShortcutView { ScrollView(.horizontal, showsIndicators: false) { HStack { - ForEach(viewModel.fetchShortcutsByCategories(category: category).prefix(7), id: \.self) { shortcut in + ForEach(viewModel.fetchShortcuts(by: category).prefix(7), id: \.self) { shortcut in let data = NavigationReadShortcutType( shortcutID: shortcut.id, navigationParentView: .shortcuts)