Moves Basic Info section of the monster editor to a sub view.
This commit is contained in:
66
iOS/EditBasicInfo.swift
Normal file
66
iOS/EditBasicInfo.swift
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// EditBasicInfo.swift
|
||||
// MonsterCards
|
||||
//
|
||||
// Created by Tom Hicks on 3/21/21.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct EditBasicInfo: View {
|
||||
|
||||
@ObservedObject var monsterViewModel: MonsterViewModel
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
// Editable Text field bound to monster.name
|
||||
MCTextField(
|
||||
label: "Name",
|
||||
value: $monsterViewModel.name)
|
||||
|
||||
// Editable Text field bound to monster.size
|
||||
MCTextField(
|
||||
label: "Size",
|
||||
value: $monsterViewModel.size)
|
||||
|
||||
// Editable Text field bound to monster.type
|
||||
MCTextField(
|
||||
label: "Type",
|
||||
value: $monsterViewModel.type)
|
||||
|
||||
// Editable Text field bound to monster.subType
|
||||
MCTextField(
|
||||
label: "Subtype",
|
||||
value: $monsterViewModel.subType)
|
||||
|
||||
// Editable Text field bound to monster.alignment
|
||||
MCTextField(
|
||||
label: "Alignment",
|
||||
value: $monsterViewModel.alignment)
|
||||
|
||||
// Number with -/+ buttons bound to monster.hitDice
|
||||
MCStepperField(
|
||||
label: "Hit Dice",
|
||||
value: $monsterViewModel.hitDice)
|
||||
|
||||
// Toggle bound to monster.hasCustomHP?
|
||||
Toggle(
|
||||
"Has Custom HP",
|
||||
isOn:$monsterViewModel.hasCustomHP)
|
||||
|
||||
// Editable Text field bound to monster.customHpText?
|
||||
MCTextField(
|
||||
label: "Custom HP",
|
||||
value: $monsterViewModel.customHP)
|
||||
|
||||
}
|
||||
.textCase(nil)
|
||||
}
|
||||
}
|
||||
|
||||
struct EditBasicInfo_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let viewModel = MonsterViewModel.init(nil)
|
||||
EditBasicInfo(monsterViewModel: viewModel)
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
E210B83A25B42D980083EAC5 /* MCProficiencyPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = E210B83925B42D980083EAC5 /* MCProficiencyPicker.swift */; };
|
||||
E210B83F25B42DAB0083EAC5 /* MCAdvantagePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = E210B83E25B42DAB0083EAC5 /* MCAdvantagePicker.swift */; };
|
||||
E2182E6425B22F8A00DFAEF8 /* Monster+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2182E6225B22F8A00DFAEF8 /* Monster+CoreDataClass.swift */; };
|
||||
E24ACE502607326E009BF703 /* EditBasicInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = E24ACE4F2607326E009BF703 /* EditBasicInfo.swift */; };
|
||||
E2570FB925B1AC520055B23B /* MonsterCardsApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2570FB825B1AC520055B23B /* MonsterCardsApp.swift */; };
|
||||
E2570FBB25B1AC520055B23B /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2570FBA25B1AC520055B23B /* ContentView.swift */; };
|
||||
E2570FBD25B1AC550055B23B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E2570FBC25B1AC550055B23B /* Assets.xcassets */; };
|
||||
@@ -64,6 +65,7 @@
|
||||
E210B83925B42D980083EAC5 /* MCProficiencyPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCProficiencyPicker.swift; sourceTree = "<group>"; };
|
||||
E210B83E25B42DAB0083EAC5 /* MCAdvantagePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MCAdvantagePicker.swift; sourceTree = "<group>"; };
|
||||
E2182E6225B22F8A00DFAEF8 /* Monster+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Monster+CoreDataClass.swift"; sourceTree = "<group>"; };
|
||||
E24ACE4F2607326E009BF703 /* EditBasicInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditBasicInfo.swift; sourceTree = "<group>"; };
|
||||
E2570FB525B1AC520055B23B /* MonsterCards.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MonsterCards.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
E2570FB825B1AC520055B23B /* MonsterCardsApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonsterCardsApp.swift; sourceTree = "<group>"; };
|
||||
E2570FBA25B1AC520055B23B /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
@@ -129,6 +131,7 @@
|
||||
E2570FAC25B1AC520055B23B = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E24ACE4F2607326E009BF703 /* EditBasicInfo.swift */,
|
||||
E2570FB725B1AC520055B23B /* MonsterCards */,
|
||||
E2570FCE25B1AC550055B23B /* MonsterCardsTests */,
|
||||
E2570FD925B1AC550055B23B /* MonsterCardsUITests */,
|
||||
@@ -360,6 +363,7 @@
|
||||
E20209FB25D8E19100EFE733 /* SkillViewModel.swift in Sources */,
|
||||
E2570FC225B1AC550055B23B /* Persistence.swift in Sources */,
|
||||
E2570FBB25B1AC520055B23B /* ContentView.swift in Sources */,
|
||||
E24ACE502607326E009BF703 /* EditBasicInfo.swift in Sources */,
|
||||
E2570FC525B1AC550055B23B /* MonsterCards.xcdatamodeld in Sources */,
|
||||
E2182E6425B22F8A00DFAEF8 /* Monster+CoreDataClass.swift in Sources */,
|
||||
E210B83A25B42D980083EAC5 /* MCProficiencyPicker.swift in Sources */,
|
||||
|
||||
@@ -20,50 +20,7 @@ struct EditMonster: View {
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
Section(header: Text("Basic Info")) {
|
||||
// Editable Text field bound to monster.name
|
||||
MCTextField(
|
||||
label: "Name",
|
||||
value: $monsterViewModel.name)
|
||||
|
||||
// Editable Text field bound to monster.size
|
||||
MCTextField(
|
||||
label: "Size",
|
||||
value: $monsterViewModel.size)
|
||||
|
||||
// Editable Text field bound to monster.type
|
||||
MCTextField(
|
||||
label: "Type",
|
||||
value: $monsterViewModel.type)
|
||||
|
||||
// Editable Text field bound to monster.subType
|
||||
MCTextField(
|
||||
label: "Subtype",
|
||||
value: $monsterViewModel.subType)
|
||||
|
||||
// Editable Text field bound to monster.alignment
|
||||
MCTextField(
|
||||
label: "Alignment",
|
||||
value: $monsterViewModel.alignment)
|
||||
|
||||
// Number with -/+ buttons bound to monster.hitDice
|
||||
MCStepperField(
|
||||
label: "Hit Dice",
|
||||
value: $monsterViewModel.hitDice)
|
||||
|
||||
// Toggle bound to monster.hasCustomHP?
|
||||
Toggle(
|
||||
"Has Custom HP",
|
||||
isOn:$monsterViewModel.hasCustomHP)
|
||||
|
||||
// Editable Text field bound to monster.customHpText?
|
||||
MCTextField(
|
||||
label: "Custom HP",
|
||||
value: $monsterViewModel.customHP)
|
||||
|
||||
}
|
||||
.textCase(nil)
|
||||
|
||||
NavigationLink("Basic Info", destination: EditBasicInfo(monsterViewModel: monsterViewModel))
|
||||
Section(header: Text("Armor")) {
|
||||
// Armor Type select bound to monster.armorTypeEnum
|
||||
MCArmorTypePicker(
|
||||
|
||||
Reference in New Issue
Block a user