-
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] #473 - Add ShowProfileViewModel
- Loading branch information
1 parent
dc35877
commit 7f322fa
Showing
5 changed files
with
77 additions
and
39 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
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
39 changes: 39 additions & 0 deletions
39
HappyAnding/HappyAnding/ViewModel/ShowProfileViewModel.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,39 @@ | ||
// | ||
// ShowProfileViewModel.swift | ||
// HappyAnding | ||
// | ||
// Created by kimjimin on 2023/07/08. | ||
// | ||
|
||
import SwiftUI | ||
|
||
final class ShowProfileViewModel: ObservableObject { | ||
|
||
var shortcutsZipViewModel = ShortcutsZipViewModel.share | ||
|
||
@Published var user: User | ||
@Published private(set) var shortcuts: [Shortcuts] = [] | ||
@Published private(set) var curations: [Curation] = [] | ||
@Published private(set) var userGrade = Image(systemName: "person.crop.circle.fill") | ||
@Published var currentTab: Int = 0 | ||
@Published var animationAmount = 0.0 | ||
|
||
init(data: User) { | ||
self.user = data | ||
fetchUserGrade() | ||
fetchShortcuts() | ||
fetchCurations() | ||
} | ||
|
||
private func fetchUserGrade() { | ||
self.userGrade = shortcutsZipViewModel.fetchShortcutGradeImage(isBig: true, shortcutGrade: shortcutsZipViewModel.checkShortcutGrade(userID: user.id)) | ||
} | ||
|
||
private func fetchShortcuts() { | ||
self.shortcuts = shortcutsZipViewModel.allShortcuts.filter { $0.author == user.id } | ||
} | ||
|
||
private func fetchCurations() { | ||
self.curations = shortcutsZipViewModel.fetchCurationByAuthor(author: user.id) | ||
} | ||
} |
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