Skip to content

Commit

Permalink
feat: TodoStore TodoStatus로 필터 변수 추가, 피자 잠금해제 메소드 추가 #77
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonghwan committed Oct 22, 2023
1 parent 24dbf5b commit a3a6cd7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Pickle/Pickle/Screen/ViewModel/TodoStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ final class TodoStore: ObservableObject {

@Published var todos: [Todo] = []

var readyTodos: [Todo] {
todos.filter { $0.status == .ready }
}

var complteTodos: [Todo] {
todos.filter { $0.status == .complete }
}

var giveUpTodos: [Todo] {
todos.filter { $0.status == .giveUp }
}

var ongoingTodos: [Todo] {
todos.filter { $0.status == .ongoing }
}

var doneTodos: [Todo] {
todos.filter { $0.status == .done }
}
/// 완료한 todos
@Published var complteTask: Int = 0

Expand Down
12 changes: 12 additions & 0 deletions Pickle/Pickle/Screen/ViewModel/UserStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ final class UserStore: ObservableObject {
}
}

/// 피자를 언락 하기 위한 메서드
/// - Parameter pizza: 언락할 피자를 인자로 받는다
func unLockPizza(pizza: Pizza) {
self.user.unlockPizza(pizza: pizza)
do {
// try userRepository.updatePizza(model: model, specific: Date())
try userRepository.updateUser(model: user)
} catch {
Log.error("\(error)")
}
}

func deleteuserAll() {
do {
try userRepository.deleteAll()
Expand Down

0 comments on commit a3a6cd7

Please sign in to comment.