Adds challenge rating and proficiency bonus to the monster editor.
This commit is contained in:
41
iOS/MonsterCards/Views/EditChallengeRating.swift
Normal file
41
iOS/MonsterCards/Views/EditChallengeRating.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// EditChallengeRating.swift
|
||||
// MonsterCards
|
||||
//
|
||||
// Created by Tom Hicks on 3/24/21.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct EditChallengeRating: View {
|
||||
@ObservedObject var viewModel: MonsterViewModel
|
||||
|
||||
var body: some View {
|
||||
let isUsingCustomProficiencyBonus = viewModel.challengeRating == ChallengeRating.custom
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
MCChallengeRatingPicker(
|
||||
label: "Rating",
|
||||
value: $viewModel.challengeRating)
|
||||
|
||||
MCTextField(
|
||||
label: "Custom Text",
|
||||
value: $viewModel.customChallengeRating)
|
||||
.disabled(!isUsingCustomProficiencyBonus)
|
||||
|
||||
MCStepperField(
|
||||
label: "Custom Proficiency Bonus",
|
||||
value: $viewModel.customProficiencyBonus)
|
||||
.disabled(!isUsingCustomProficiencyBonus)
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
|
||||
struct EditChallengeRating_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let viewModel = MonsterViewModel()
|
||||
EditChallengeRating(viewModel: viewModel)
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,10 @@ struct EditMonster: View {
|
||||
NavigationLink(
|
||||
"Languages",
|
||||
destination: EditLanguages(viewModel: monsterViewModel))
|
||||
|
||||
NavigationLink(
|
||||
"Challenge Rating",
|
||||
destination: EditChallengeRating(viewModel: monsterViewModel))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
35
iOS/MonsterCards/Views/MCChallengeRatingPicker.swift
Normal file
35
iOS/MonsterCards/Views/MCChallengeRatingPicker.swift
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// MCChallengeRatingPicker.swift
|
||||
// MonsterCards
|
||||
//
|
||||
// Created by Tom Hicks on 3/24/21.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct MCChallengeRatingPicker: View {
|
||||
var label: String = ""
|
||||
var value: Binding<ChallengeRating>
|
||||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
Text(label)
|
||||
.font(.caption2)
|
||||
Picker(
|
||||
selection: value,
|
||||
label: Text(value.wrappedValue.displayName)) {
|
||||
ForEach(ChallengeRating.allCases) {abilityScore in
|
||||
Text(abilityScore.displayName).tag(abilityScore)
|
||||
}
|
||||
}
|
||||
.pickerStyle(MenuPickerStyle())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MCChallengeRatingPicker_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
MCChallengeRatingPicker(
|
||||
label: "Rating",
|
||||
value: .constant(ChallengeRating.ten))
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,7 @@ struct MonsterDetail: View {
|
||||
|
||||
// Challenge Rating
|
||||
if (!monsterChallengeRatingDescription.isEmpty) {
|
||||
LabeledField("Challenge Rating") {
|
||||
LabeledField("Challenge") {
|
||||
Text(monsterChallengeRatingDescription)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user