-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#2] ADD: MonsterListItem View, MonsterListInformation View
- Loading branch information
1 parent
ec5f867
commit 1beb51c
Showing
7 changed files
with
154 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// | ||
// MonsterListItem.swift | ||
// RunningRPG | ||
// | ||
// Created by 김호세 on 6/10/23. | ||
// | ||
|
||
import Foundation | ||
|
||
internal final class MonsterListItem: Identifiable { | ||
var monster: Monster | ||
|
||
internal init(monster: Monster) { | ||
self.monster = monster | ||
} | ||
} | ||
|
||
|
||
extension MonsterListItem { | ||
static func generateMonsters() -> [MonsterListItem] { | ||
return [ | ||
MonsterListItem( | ||
monster: Monster.init( | ||
name: "총든 몬스터", | ||
hp: 10.0, | ||
currentHp: 10.0, | ||
avatar: MonsterType.gun.urls, | ||
level: 0, isOpen: true | ||
) | ||
), | ||
MonsterListItem( | ||
monster: Monster.init( | ||
name: "다람쥐 몬스터", | ||
hp: 20.0, | ||
currentHp: 20.0, | ||
avatar: MonsterType.squirrel.urls, | ||
level: 1, | ||
isOpen: true | ||
) | ||
), | ||
MonsterListItem( | ||
monster: Monster.init( | ||
name: "피자 몬스터", | ||
hp: 30.0, | ||
currentHp: 30.0, | ||
avatar: MonsterType.pizza.urls, | ||
level: 2, | ||
isOpen: true | ||
) | ||
), | ||
MonsterListItem( | ||
monster: Monster.init( | ||
name: "칼이랑 방패든 몬스터", | ||
hp: 40.0, | ||
currentHp: 40.0, | ||
avatar: MonsterType.swordShield.urls, | ||
level: 3, | ||
isOpen: true | ||
) | ||
), | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
RunningRPG/Tabbar/MonsterList/Subviews/MonsterInformationView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// MonsterInformationView.swift | ||
// RunningRPG | ||
// | ||
// Created by 김호세 on 6/10/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct MonsterInformationView: View { | ||
|
||
let item: MonsterListItem | ||
|
||
var body: some View { | ||
VStack(alignment: .leading, spacing: 10, content: { | ||
HStack(content: { | ||
Text("\(item.monster.name)") | ||
Spacer() | ||
Text("Level - \(item.monster.level)") | ||
}) | ||
HStack(alignment: .top, spacing: 5, content: { | ||
Text("\(item.monster.currentHp) / \(item.monster.hp)") | ||
}) | ||
}) | ||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
RunningRPG/Tabbar/MonsterList/Subviews/MonsterListItem.swift
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
RunningRPG/Tabbar/MonsterList/Subviews/MonsterListItemView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// MonsterListItemView.swift | ||
// RunningRPG | ||
// | ||
// Created by 김호세 on 6/10/23. | ||
// | ||
|
||
|
||
import SwiftUI | ||
|
||
struct MonsterListItemView: View { | ||
|
||
let item: MonsterListItem | ||
|
||
var body: some View { | ||
|
||
HStack(alignment: .center, spacing: 10, content: { | ||
Image(item.monster.avatar).resizable().frame(width: 50, height: 50) | ||
MonsterInformationView(item: item) | ||
}) | ||
} | ||
} |