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 fe431475a2
commit da74b68a9c

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) {
let monsterMeta = monster.meta
let monsterArmorClassDescription = monster.armorClassDescription
let monsterHitPoints = monster.hitPoints
let monsterSpeed = monster.speed
if (!monsterMeta.isEmpty) {
// meta: "(large humanoid (elf) lawful evil" // meta: "(large humanoid (elf) lawful evil"
Text(monster.meta) Text(monsterMeta)
.font(.subheadline) .font(.subheadline)
.foregroundColor(.secondary) .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()
if (!monsterArmorClassDescription.isEmpty) {
// AC // AC
LabeledField("Armor Class") { LabeledField("Armor Class") {
Text(monster.armorClassDescription)// armor class Text(monsterArmorClassDescription)// armor class
} }
}
if (!monsterHitPoints.isEmpty) {
// HP // HP
LabeledField("Hit Points") { LabeledField("Hit Points") {
Text(monster.hitPoints) // hit points Text(monsterHitPoints) // hit points
} }
}
// Speed // Speed
if (!monsterSpeed.isEmpty) {
LabeledField("Speed") { LabeledField("Speed") {
Text(monster.speed) // speed Text(monsterSpeed) // speed
}
} }
SectionDivider() SectionDivider()