룰렛 최대 개수 수정
AS-IS : 최대 6개 TO-BE : 최대 10개 룰렛 확률 수정 AS-IS : 소수점 없음 TO-BE : 소수점 2자리
This commit is contained in:
		| @@ -39,7 +39,11 @@ struct FortuneWheelModel { | ||||
|             Color(hex: "#E6AAC1"), | ||||
|             Color(hex: "#8FCEEA"), | ||||
|             Color(hex: "#CD5880"), | ||||
|             Color(hex: "#C2C85E") | ||||
|             Color(hex: "#C2C85E"), | ||||
|             Color(hex: "#000000"), | ||||
|             Color(hex: "#888888"), | ||||
|             Color(hex: "#FFFFFF"), | ||||
|             Color(hex: "#000080"), | ||||
|         ] | ||||
|         self.pointerColor = pointerColor | ||||
|         self.strokeWidth = strokeWidth | ||||
|   | ||||
| @@ -1474,7 +1474,8 @@ final class LiveRoomViewModel: NSObject, ObservableObject { | ||||
|     private func calculatePercentages(options: [RouletteItem]) -> [RoulettePreviewItem] { | ||||
|         let totalWeight = options.reduce(0) { $0 + $1.weight } | ||||
|         let updatedOptions = options.map { option in | ||||
|             RoulettePreviewItem(title: option.title, percent: "\(Int(Float(option.weight) / Float(totalWeight) * Float(100)))%") | ||||
|             let percent = floor(Double(option.weight) / Double(totalWeight) * 10000) / 100 | ||||
|             return RoulettePreviewItem(title: option.title, percent: "\(String(format: "%.2f", percent))%") | ||||
|         } | ||||
|          | ||||
|         return updatedOptions | ||||
|   | ||||
| @@ -10,7 +10,7 @@ import SwiftUI | ||||
| class RouletteOption: ObservableObject { | ||||
|     var title: String | ||||
|     var weight: Int | ||||
|     var percentage: Int = 50 | ||||
|     var percentage: String = "50.00" | ||||
|      | ||||
|     init(title: String, weight: Int) { | ||||
|         self.title = title | ||||
|   | ||||
| @@ -80,7 +80,7 @@ struct RouletteSettingsView: View { | ||||
|                                     .foregroundColor(Color(hex: "eeeeee")) | ||||
|                                  | ||||
|                                 HStack(spacing: 0) { | ||||
|                                     Text("※ 룰렛 옵션은 최소 2개,\n최대 6개까지 설정할 수 있습니다.") | ||||
|                                     Text("※ 룰렛 옵션은 최소 2개,\n최대 10개까지 설정할 수 있습니다.") | ||||
|                                         .font(.custom(Font.medium.rawValue, size: 13.3)) | ||||
|                                         .foregroundColor(Color(hex: "ff5c49")) | ||||
|                                      | ||||
|   | ||||
| @@ -49,7 +49,7 @@ final class RouletteSettingsViewModel: ObservableObject { | ||||
|     } | ||||
|      | ||||
|     func addOption() { | ||||
|         if (options.count >= 6) { | ||||
|         if (options.count >= 10) { | ||||
|             return | ||||
|         } | ||||
|         options.append(RouletteOption(title: "", weight: 1)) | ||||
| @@ -72,7 +72,8 @@ final class RouletteSettingsViewModel: ObservableObject { | ||||
|         guard totalWeight > 0 else { return } | ||||
|          | ||||
|         for i in 0..<options.count { | ||||
|             options[i].percentage = Int(Double(options[i].weight) / Double(totalWeight) * 100) | ||||
|             let percent = floor(Double(options[i].weight) / Double(totalWeight) * 10000) / 100 | ||||
|             options[i].percentage = String(format: "%.2f", percent) | ||||
|         } | ||||
|          | ||||
|         removeAllAndAddOptions(options: options) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Yu Sung
					Yu Sung