Hides elements on monster detail if they don't have values to show.

Adds TODO to hide dividers when applicable.
This commit is contained in:
2021-02-07 13:00:48 -08:00
parent 3bb52bc368
commit a5344abeb0

View File

@@ -68,24 +68,43 @@ struct MonsterDetail: View {
var body: some View { var body: some View {
ScrollView { ScrollView {
VStack (alignment: .leading) { VStack (alignment: .leading) {
// meta: "(large humanoid (elf) lawful evil" let monsterMeta = monster.meta
Text(monster.meta) let monsterArmorClassDescription = monster.armorClassDescription
.font(.subheadline) let monsterHitPoints = monster.hitPoints
.foregroundColor(.secondary) let monsterSpeed = monster.speed
if (!monsterMeta.isEmpty) {
// meta: "(large humanoid (elf) lawful evil"
Text(monsterMeta)
.font(.subheadline)
.foregroundColor(.secondary)
}
// TODO: Find a way to hide unnecessarry dividiers.
// if sections 0, 1, 2, and 3 are present there should be a divider between each of them
// if section 1 is not present there should be one and only one divider between sections 0 and 2 as well as the one between 2 and 3
// if sections 1 and 2 are not present there should be a single divider between sections 0 and 3
SectionDivider() SectionDivider()
// AC if (!monsterArmorClassDescription.isEmpty) {
LabeledField("Armor Class") { // AC
Text(monster.armorClassDescription)// armor class LabeledField("Armor Class") {
Text(monsterArmorClassDescription)// armor class
}
} }
// HP
LabeledField("Hit Points") { if (!monsterHitPoints.isEmpty) {
Text(monster.hitPoints) // hit points // HP
LabeledField("Hit Points") {
Text(monsterHitPoints) // hit points
}
} }
// Speed // Speed
LabeledField("Speed") { if (!monsterSpeed.isEmpty) {
Text(monster.speed) // speed LabeledField("Speed") {
Text(monsterSpeed) // speed
}
} }
SectionDivider() SectionDivider()