-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathShopListViewModel.swift
More file actions
62 lines (53 loc) · 1.65 KB
/
Copy pathShopListViewModel.swift
File metadata and controls
62 lines (53 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// ShopListViewModel.swift
// NativeAppTemplate
//
// Created by Claude on 2025/06/22.
//
import SwiftUI
import Observation
@Observable
@MainActor
final class ShopListViewModel {
var isShowingCreateSheet = false
var state: DataState { shopRepository.state }
var shops: [Shop] { shopRepository.shops }
var limitCount: Int { shopRepository.limitCount }
var createdShopsCount: Int { shopRepository.createdShopsCount }
var isEmpty: Bool { shopRepository.isEmpty }
var leftInShopSlots: Int { limitCount - createdShopsCount }
var shouldPopToRootView: Bool { sessionController.shouldPopToRootView }
let shopRepository: ShopRepositoryProtocol
let itemTagRepository: ItemTagRepositoryProtocol
private let sessionController: SessionControllerProtocol
private let tabViewModel: TabViewModel
private let mainTab: MainTab
private let messageBus: MessageBus
init(
sessionController: SessionControllerProtocol,
shopRepository: ShopRepositoryProtocol,
itemTagRepository: ItemTagRepositoryProtocol,
tabViewModel: TabViewModel,
mainTab: MainTab,
messageBus: MessageBus
) {
self.sessionController = sessionController
self.shopRepository = shopRepository
self.itemTagRepository = itemTagRepository
self.tabViewModel = tabViewModel
self.mainTab = mainTab
self.messageBus = messageBus
}
func reload() {
shopRepository.reload()
}
func showCreateView() {
isShowingCreateSheet.toggle()
}
func setTabViewModelShowingDetailViewToFalse() {
tabViewModel.showingDetailView[mainTab] = false
}
func scrollToTopID() -> ScrollToTopID {
ScrollToTopID(mainTab: mainTab, detail: false)
}
}