Makes armor type a picker instead of a string.
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
E2570FFF25B1AE180055B23B /* Library.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2570FFE25B1AE180055B23B /* Library.swift */; };
|
E2570FFF25B1AE180055B23B /* Library.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2570FFE25B1AE180055B23B /* Library.swift */; };
|
||||||
E257100425B1AF4A0055B23B /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E257100325B1AF4A0055B23B /* SearchBar.swift */; };
|
E257100425B1AF4A0055B23B /* SearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = E257100325B1AF4A0055B23B /* SearchBar.swift */; };
|
||||||
E257100925B1B2480055B23B /* MonsterDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = E257100825B1B2470055B23B /* MonsterDetail.swift */; };
|
E257100925B1B2480055B23B /* MonsterDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = E257100825B1B2470055B23B /* MonsterDetail.swift */; };
|
||||||
|
E26CDA2B25CFB38E00E3F50D /* MCArmorTypePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = E26CDA2A25CFB38E00E3F50D /* MCArmorTypePicker.swift */; };
|
||||||
E2B5285925B3028700AAA69E /* EditMonster.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2B5285825B3028700AAA69E /* EditMonster.swift */; };
|
E2B5285925B3028700AAA69E /* EditMonster.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2B5285825B3028700AAA69E /* EditMonster.swift */; };
|
||||||
E2BD702C25B3A8D70058ED69 /* MCTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2BD702B25B3A8D70058ED69 /* MCTextField.swift */; };
|
E2BD702C25B3A8D70058ED69 /* MCTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2BD702B25B3A8D70058ED69 /* MCTextField.swift */; };
|
||||||
E2BD703125B3BBB90058ED69 /* MCStepperField.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2BD703025B3BBB90058ED69 /* MCStepperField.swift */; };
|
E2BD703125B3BBB90058ED69 /* MCStepperField.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2BD703025B3BBB90058ED69 /* MCStepperField.swift */; };
|
||||||
@@ -75,6 +76,7 @@
|
|||||||
E2570FFE25B1AE180055B23B /* Library.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Library.swift; sourceTree = "<group>"; };
|
E2570FFE25B1AE180055B23B /* Library.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Library.swift; sourceTree = "<group>"; };
|
||||||
E257100325B1AF4A0055B23B /* SearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = "<group>"; };
|
E257100325B1AF4A0055B23B /* SearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchBar.swift; sourceTree = "<group>"; };
|
||||||
E257100825B1B2470055B23B /* MonsterDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonsterDetail.swift; sourceTree = "<group>"; };
|
E257100825B1B2470055B23B /* MonsterDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonsterDetail.swift; sourceTree = "<group>"; };
|
||||||
|
E26CDA2A25CFB38E00E3F50D /* MCArmorTypePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCArmorTypePicker.swift; sourceTree = "<group>"; };
|
||||||
E2B5285825B3028700AAA69E /* EditMonster.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditMonster.swift; sourceTree = "<group>"; };
|
E2B5285825B3028700AAA69E /* EditMonster.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditMonster.swift; sourceTree = "<group>"; };
|
||||||
E2BD702B25B3A8D70058ED69 /* MCTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCTextField.swift; sourceTree = "<group>"; };
|
E2BD702B25B3A8D70058ED69 /* MCTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCTextField.swift; sourceTree = "<group>"; };
|
||||||
E2BD703025B3BBB90058ED69 /* MCStepperField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCStepperField.swift; sourceTree = "<group>"; };
|
E2BD703025B3BBB90058ED69 /* MCStepperField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCStepperField.swift; sourceTree = "<group>"; };
|
||||||
@@ -183,6 +185,7 @@
|
|||||||
E2BD702B25B3A8D70058ED69 /* MCTextField.swift */,
|
E2BD702B25B3A8D70058ED69 /* MCTextField.swift */,
|
||||||
E2BD703025B3BBB90058ED69 /* MCStepperField.swift */,
|
E2BD703025B3BBB90058ED69 /* MCStepperField.swift */,
|
||||||
E210B83925B42D980083EAC5 /* MCProficiencyPicker.swift */,
|
E210B83925B42D980083EAC5 /* MCProficiencyPicker.swift */,
|
||||||
|
E26CDA2A25CFB38E00E3F50D /* MCArmorTypePicker.swift */,
|
||||||
);
|
);
|
||||||
path = Views;
|
path = Views;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -353,6 +356,7 @@
|
|||||||
E210B83025B426570083EAC5 /* ProficiencyType.swift in Sources */,
|
E210B83025B426570083EAC5 /* ProficiencyType.swift in Sources */,
|
||||||
E2BD702C25B3A8D70058ED69 /* MCTextField.swift in Sources */,
|
E2BD702C25B3A8D70058ED69 /* MCTextField.swift in Sources */,
|
||||||
E210B83F25B42DAB0083EAC5 /* MCAdvantagePicker.swift in Sources */,
|
E210B83F25B42DAB0083EAC5 /* MCAdvantagePicker.swift in Sources */,
|
||||||
|
E26CDA2B25CFB38E00E3F50D /* MCArmorTypePicker.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ struct EditMonster: View {
|
|||||||
@State private var monsterHitDice: Int64 = 0
|
@State private var monsterHitDice: Int64 = 0
|
||||||
@State private var monsterHasCustomHP: Bool = false
|
@State private var monsterHasCustomHP: Bool = false
|
||||||
@State private var monsterCustomHP: String = ""
|
@State private var monsterCustomHP: String = ""
|
||||||
@State private var monsterArmorType: String = ""
|
@State private var monsterArmorType: ArmorType = ArmorType.none
|
||||||
@State private var monsterHasShield: Bool = false
|
@State private var monsterHasShield: Bool = false
|
||||||
@State private var monsterNaturalArmorBonus: Int64 = 0
|
@State private var monsterNaturalArmorBonus: Int64 = 0
|
||||||
@State private var monsterCustomArmor: String = ""
|
@State private var monsterCustomArmor: String = ""
|
||||||
@@ -103,9 +103,8 @@ struct EditMonster: View {
|
|||||||
.textCase(nil)
|
.textCase(nil)
|
||||||
|
|
||||||
Section(header: Text("Armor")) {
|
Section(header: Text("Armor")) {
|
||||||
// Armor Type select bound to monster.armorType?
|
// Armor Type select bound to monster.armorTypeEnum
|
||||||
// TODO: this should be a select/dropdown
|
MCArmorTypePicker(
|
||||||
MCTextField(
|
|
||||||
label: "Armor Type",
|
label: "Armor Type",
|
||||||
value: $monsterArmorType)
|
value: $monsterArmorType)
|
||||||
|
|
||||||
@@ -306,7 +305,7 @@ struct EditMonster: View {
|
|||||||
monsterHitDice = monster.hitDice
|
monsterHitDice = monster.hitDice
|
||||||
monsterHasCustomHP = monster.hasCustomHP
|
monsterHasCustomHP = monster.hasCustomHP
|
||||||
monsterCustomHP = monster.customHP ?? ""
|
monsterCustomHP = monster.customHP ?? ""
|
||||||
monsterArmorType = monster.armorType ?? ""
|
monsterArmorType = monster.armorTypeEnum
|
||||||
monsterHasShield = monster.hasShield
|
monsterHasShield = monster.hasShield
|
||||||
monsterNaturalArmorBonus = monster.naturalArmorBonus
|
monsterNaturalArmorBonus = monster.naturalArmorBonus
|
||||||
monsterCustomArmor = monster.customArmor ?? ""
|
monsterCustomArmor = monster.customArmor ?? ""
|
||||||
@@ -347,7 +346,7 @@ struct EditMonster: View {
|
|||||||
monster.hitDice = monsterHitDice
|
monster.hitDice = monsterHitDice
|
||||||
monster.hasCustomHP = monsterHasCustomHP
|
monster.hasCustomHP = monsterHasCustomHP
|
||||||
monster.customHP = monsterCustomHP
|
monster.customHP = monsterCustomHP
|
||||||
monster.armorType = monsterArmorType
|
monster.armorType = monsterArmorType.rawValue
|
||||||
monster.hasShield = monsterHasShield
|
monster.hasShield = monsterHasShield
|
||||||
monster.naturalArmorBonus = monsterNaturalArmorBonus
|
monster.naturalArmorBonus = monsterNaturalArmorBonus
|
||||||
monster.customArmor = monsterCustomArmor
|
monster.customArmor = monsterCustomArmor
|
||||||
|
|||||||
36
iOS/MonsterCards/Views/MCArmorTypePicker.swift
Normal file
36
iOS/MonsterCards/Views/MCArmorTypePicker.swift
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// MCArmorTypePicker.swift
|
||||||
|
// MonsterCards
|
||||||
|
//
|
||||||
|
// Created by Tom Hicks on 2/6/21.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct MCArmorTypePicker: View {
|
||||||
|
var label: String = ""
|
||||||
|
var value: Binding<ArmorType>
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack(alignment: .leading) {
|
||||||
|
Text(label)
|
||||||
|
.font(.caption2)
|
||||||
|
Picker(
|
||||||
|
selection: value,
|
||||||
|
label: Text(value.wrappedValue.displayName)) {
|
||||||
|
ForEach(ArmorType.allCases) {armorType in
|
||||||
|
Text(armorType.displayName).tag(armorType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.pickerStyle(MenuPickerStyle())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MCArmorTypePicker_Previews: PreviewProvider {
|
||||||
|
static var previews: some View {
|
||||||
|
MCArmorTypePicker(
|
||||||
|
value: .constant(ArmorType.none)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user