룰렛 변경
- 확률 수동 설정 - 여러개의 룰렛이 켜져있을 때 선택하여 돌리기 - 후원 히스토리에 룰렛 히스토리
This commit is contained in:
@@ -12,13 +12,61 @@ struct RoulettePreviewDialog: View {
|
||||
@Binding var isShowing: Bool
|
||||
|
||||
let title: String?
|
||||
let onClickSpin: (() -> Void)?
|
||||
let preview: RoulettePreview
|
||||
let onClickSpin: ((Int) -> Void)?
|
||||
let previewList: [RoulettePreview]
|
||||
|
||||
@State var selectedRoulette = SelectedRoulette.ROULETTE_1
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
ZStack {
|
||||
VStack(spacing: 0) {
|
||||
VStack(spacing: 16.7) {
|
||||
if previewList.count > 1 {
|
||||
HStack(spacing: 13.3) {
|
||||
SelectedButtonView(
|
||||
title: "룰렛 1",
|
||||
isActive: true,
|
||||
isSelected: selectedRoulette == .ROULETTE_1
|
||||
)
|
||||
.onTapGesture {
|
||||
if selectedRoulette != .ROULETTE_1 {
|
||||
selectedRoulette = .ROULETTE_1
|
||||
}
|
||||
}
|
||||
|
||||
SelectedButtonView(
|
||||
title: "룰렛 2",
|
||||
isActive: true,
|
||||
isSelected: selectedRoulette == .ROULETTE_2,
|
||||
checkImage: "ic_select_check_black",
|
||||
bgSelectedColor: Color(hex: "ffcb14"),
|
||||
textSelectedColor: Color.black,
|
||||
textDefaultColor: Color(hex: "ffcb14")
|
||||
)
|
||||
.onTapGesture {
|
||||
if selectedRoulette != .ROULETTE_2 {
|
||||
selectedRoulette = .ROULETTE_2
|
||||
}
|
||||
}
|
||||
|
||||
if previewList.count > 2 {
|
||||
SelectedButtonView(
|
||||
title: "룰렛 3",
|
||||
isActive: true,
|
||||
isSelected: selectedRoulette == .ROULETTE_3,
|
||||
bgSelectedColor: Color(hex: "ff14d9"),
|
||||
textDefaultColor: Color(hex: "ff14d9")
|
||||
)
|
||||
.onTapGesture {
|
||||
if selectedRoulette != .ROULETTE_3 {
|
||||
selectedRoulette = .ROULETTE_3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 16.7)
|
||||
}
|
||||
|
||||
HStack(spacing: 0) {
|
||||
Text(title ?? "룰렛")
|
||||
.font(.custom(Font.bold.rawValue, size: 18.3))
|
||||
@@ -42,54 +90,66 @@ struct RoulettePreviewDialog: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 16.7)
|
||||
.padding(.top, previewList.count > 1 ? 0 : 16.7)
|
||||
.padding(.horizontal, 13.3)
|
||||
|
||||
LazyVStack(alignment: .leading, spacing: 13.3) {
|
||||
ForEach(preview.items.indices, id: \.self) { index in
|
||||
ForEach(previewList[selectedRoulette.rawValue].items.indices, id: \.self) { index in
|
||||
HStack(spacing:13.3) {
|
||||
Text("\(index + 1)")
|
||||
.font(.custom(Font.bold.rawValue, size: 14.7))
|
||||
.foregroundColor(Color(hex: "e2e2e2"))
|
||||
|
||||
Text("\(preview.items[index].title) (\(preview.items[index].percent))")
|
||||
Text("\(previewList[selectedRoulette.rawValue].items[index].title) (\(previewList[selectedRoulette.rawValue].items[index].percent))")
|
||||
.font(.custom(Font.medium.rawValue, size: 14.7))
|
||||
.foregroundColor(Color(hex: "e2e2e2"))
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 13.3)
|
||||
.padding(.horizontal, 13.3)
|
||||
|
||||
HStack(spacing: 13.3) {
|
||||
Text("취소")
|
||||
.font(.custom(Font.bold.rawValue, size: 16))
|
||||
.foregroundColor(Color(hex: "3bb9f1"))
|
||||
.foregroundColor(
|
||||
selectedRoulette == .ROULETTE_2 ? Color(hex: "ffcb14") :
|
||||
selectedRoulette == .ROULETTE_3 ? Color(hex: "ff14d9") :
|
||||
Color.button
|
||||
)
|
||||
.padding(.horizontal, 18)
|
||||
.padding(.vertical, 16)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.stroke(Color(hex: "3bb9f1"), lineWidth: 1)
|
||||
.stroke(
|
||||
selectedRoulette == .ROULETTE_2 ? Color(hex: "ffcb14") :
|
||||
selectedRoulette == .ROULETTE_3 ? Color(hex: "ff14d9") :
|
||||
Color.button,
|
||||
lineWidth: 1
|
||||
)
|
||||
)
|
||||
.onTapGesture {
|
||||
isShowing = false
|
||||
}
|
||||
|
||||
Text("\(preview.can)캔으로 룰렛 돌리기")
|
||||
Text("\(previewList[selectedRoulette.rawValue].can)캔으로 룰렛 돌리기")
|
||||
.font(.custom(Font.bold.rawValue, size: 16))
|
||||
.foregroundColor(.white)
|
||||
.foregroundColor(selectedRoulette == .ROULETTE_2 ? .black : .white)
|
||||
.padding(.vertical, 16)
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(Color(hex: "3bb9f1"))
|
||||
.background(
|
||||
selectedRoulette == .ROULETTE_2 ? Color(hex: "ffcb14") :
|
||||
selectedRoulette == .ROULETTE_3 ? Color(hex: "ff14d9") :
|
||||
Color.button
|
||||
)
|
||||
.cornerRadius(10)
|
||||
.onTapGesture {
|
||||
if let onClickSpin = onClickSpin {
|
||||
onClickSpin()
|
||||
onClickSpin(previewList[selectedRoulette.rawValue].id)
|
||||
}
|
||||
isShowing = false
|
||||
}
|
||||
}
|
||||
.padding(.top, 26.7)
|
||||
.padding(.top, 6.7)
|
||||
}
|
||||
.padding(13.3)
|
||||
.background(Color(hex: "222222"))
|
||||
@@ -108,13 +168,32 @@ struct RoulettePreviewDialog_Previews: PreviewProvider {
|
||||
isShowing: .constant(true),
|
||||
title: nil,
|
||||
onClickSpin: nil,
|
||||
preview: RoulettePreview(
|
||||
can: 100,
|
||||
items: [
|
||||
RoulettePreviewItem(title: "옵션1", percent: "10%"),
|
||||
RoulettePreviewItem(title: "옵션2", percent: "90%"),
|
||||
]
|
||||
)
|
||||
previewList: [
|
||||
RoulettePreview(
|
||||
id: 0,
|
||||
can: 100,
|
||||
items: [
|
||||
RoulettePreviewItem(title: "옵션1", percent: "33.40%"),
|
||||
RoulettePreviewItem(title: "옵션2", percent: "66.60%"),
|
||||
]
|
||||
),
|
||||
RoulettePreview(
|
||||
id: 1,
|
||||
can: 10,
|
||||
items: [
|
||||
RoulettePreviewItem(title: "옵션3", percent: "10.8%"),
|
||||
RoulettePreviewItem(title: "옵션4", percent: "89.2%"),
|
||||
]
|
||||
),
|
||||
RoulettePreview(
|
||||
id: 2,
|
||||
can: 1000,
|
||||
items: [
|
||||
RoulettePreviewItem(title: "옵션5", percent: "10%"),
|
||||
RoulettePreviewItem(title: "옵션6", percent: "90%"),
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user