More cleaning, added min width of cards and scrollable if too many cards are on the screen
This commit is contained in:
@@ -12,11 +12,7 @@ struct SetGameView: View {
|
||||
@ObservedObject var game: SetGameModelView
|
||||
var body: some View {
|
||||
VStack {
|
||||
AspectVGrid(items: game.cardsOnTable, aspectRatio: 2/3) { card in
|
||||
CardView(card: card).foregroundColor(.red).onTapGesture {
|
||||
game.choose(card)
|
||||
}
|
||||
}
|
||||
ScrollOrAspectVGrid()
|
||||
Spacer()
|
||||
Spacer()
|
||||
VStack {
|
||||
@@ -30,6 +26,31 @@ struct SetGameView: View {
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func ScrollOrAspectVGrid() -> some View {
|
||||
if (game.cardsOnTable.count <= 21) {
|
||||
AspectVGrid(items: game.cardsOnTable, aspectRatio: 2/3) { card in
|
||||
CardView(card: card).foregroundColor(.red).onTapGesture {
|
||||
game.choose(card)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ScrollView {
|
||||
LazyVGrid(columns: [GridItem(.adaptive(minimum: 70), spacing: 0)], spacing: 0) {
|
||||
ForEach(game.cardsOnTable) { card in
|
||||
CardView(card: card)
|
||||
.aspectRatio(2/3, contentMode: .fit)
|
||||
.foregroundColor(.red)
|
||||
.onTapGesture {
|
||||
game.choose(card)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user