Skip to content

Commit

Permalink
use buttons instead of tap gestures for game view
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-cup committed Dec 31, 2020
1 parent 45b10ea commit d304e6e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 29 deletions.
33 changes: 17 additions & 16 deletions bowtie2/views/GameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,25 @@ struct GameView: View {
var body: some View {
ScrollView {
ForEach(game.scoresArray, id: \.self) { score in
PlayerScoreCard(name: score.player!.wrappedName,
colour: score.player!.wrappedColor,
score: score.currentScore,
numTurns: score.history!.count,
maxScoresGame: game.maxNumberOfEntries)
.contextMenu {
Button(action: {
sheetState = GameViewSheetState.viewHistory(for: score)
}) {
HStack {
Text("View History")
Image(systemName: "archivebox")
Button(action: {
sheetState = GameViewSheetState.addingScore(for: score)
}) {
PlayerScoreCard(name: score.player!.wrappedName,
colour: score.player!.wrappedColor,
score: score.currentScore,
numTurns: score.history!.count,
maxScoresGame: game.maxNumberOfEntries)
.contextMenu {
Button(action: {
sheetState = GameViewSheetState.viewHistory(for: score)
}) {
HStack {
Text("View History")
Image(systemName: "archivebox")
}
}
}
}
.onTapGesture(count: 1, perform: {
sheetState = GameViewSheetState.addingScore(for: score)
})
}
}
.padding(.horizontal)

Expand Down
27 changes: 14 additions & 13 deletions bowtie2/views/PlayersListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct PlayersListView: View {
.frame(width: 180.0)
}
.offset(y: -20)

Spacer()

Button(action: {
Expand Down Expand Up @@ -78,20 +78,21 @@ struct PlayersListView: View {
ScrollView {
LazyVGrid(columns: columns) {
ForEach(players, id: \.self) { player in
PlayerCard(name: player.wrappedName, colour: player.wrappedColor)
.contextMenu {
Button(action: {
self.deletePlayer(player: player)
}) {
HStack {
Text("Delete Player")
Image(systemName: "trash")
Button(action: {
self.sheetState = PlayersListSheetState(editing: player)
}) {
PlayerCard(name: player.wrappedName, colour: player.wrappedColor)
.contextMenu {
Button(action: {
self.deletePlayer(player: player)
}) {
HStack {
Text("Delete Player")
Image(systemName: "trash")
}
}
}
}
.onTapGesture(count: 1, perform: {
self.sheetState = PlayersListSheetState(editing: player)
})
}
}
}
}
Expand Down

0 comments on commit d304e6e

Please sign in to comment.