룰렛 프리뷰 다이얼로그 추가
This commit is contained in:
@@ -25,6 +25,15 @@ final class RouletteSettingsViewModel: ObservableObject {
|
||||
@Published var isActive = false
|
||||
@Published var options = [RouletteOption]()
|
||||
|
||||
@Published var isShowPreview = false {
|
||||
didSet {
|
||||
if !isShowPreview {
|
||||
previewData = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@Published var previewData: RoulettePreview? = nil
|
||||
|
||||
var can = 5
|
||||
|
||||
func plusWeight(index: Int) {
|
||||
@@ -118,4 +127,24 @@ final class RouletteSettingsViewModel: ObservableObject {
|
||||
}
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func onClickPreview() {
|
||||
isLoading = true
|
||||
|
||||
var items = [RoulettePreviewItem]()
|
||||
for option in options {
|
||||
if option.title.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
|
||||
isLoading = false
|
||||
errorMessage = "옵션은 빈칸일 수 없습니다."
|
||||
isShowErrorPopup = true
|
||||
return
|
||||
}
|
||||
|
||||
items.append(RoulettePreviewItem(title: option.title, percent: "\(option.percentage)%"))
|
||||
}
|
||||
|
||||
previewData = RoulettePreview(can: self.can, items: items)
|
||||
isLoading = false
|
||||
isShowPreview = true
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user