-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] #471 - Add ExploreShortcutViewModel
- Loading branch information
1 parent
bf10a44
commit f716f83
Showing
4 changed files
with
109 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
HappyAnding/HappyAnding/ViewModel/ExploreShortcutViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// ExploreShortcutViewModel.swift | ||
// HappyAnding | ||
// | ||
// Created by kimjimin on 2023/06/25. | ||
// | ||
|
||
import SwiftUI | ||
|
||
final class ExploreShortcutViewModel: ObservableObject { | ||
|
||
var shortcutsZipViewModel = ShortcutsZipViewModel.share | ||
|
||
@Published private(set) var isCategoryCellViewFolded = true | ||
@Published var isTappedAnnouncementCell = false | ||
@Published private(set) var numberOfDisplayedCategories = 6 | ||
@Published private(set) var randomCategories = Category.allCases.shuffled().prefix(2) | ||
|
||
func changeNumberOfCategories() { | ||
isCategoryCellViewFolded.toggle() | ||
numberOfDisplayedCategories = isCategoryCellViewFolded ? 6 : 12 | ||
} | ||
|
||
func isShowingAnnouncement() { | ||
isTappedAnnouncementCell = true | ||
} | ||
|
||
func fetchShortcutsByCategories(category: Category) -> [Shortcuts] { | ||
shortcutsZipViewModel.shortcutsInCategory[category.index] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters