-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kiosk: Support event-based navigation #9700
Changes from 5 commits
8e18afd
4cdf80b
a0dd7be
401be2b
1da2058
a628704
143fef6
008a92e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { useContext } from "react"; | ||
import { AppStateContext } from "../State/AppStateContext"; | ||
import ConfirmModal from "./ConfirmModal"; | ||
import { hideModal, postNotification } from "../State/Actions"; | ||
import { playSoundEffect } from "../Services/SoundEffectService"; | ||
import * as Storage from "../Services/LocalStorage"; | ||
import { removeGame } from "../Transforms/removeGame"; | ||
import { makeNotification } from "../Utils"; | ||
|
||
export default function AppModal() { | ||
const { state, dispatch } = useContext(AppStateContext); | ||
|
||
const cancelClicked = () => { | ||
playSoundEffect("select"); | ||
dispatch(hideModal()); | ||
}; | ||
|
||
const deleteConfirmClicked = () => { | ||
pxt.tickEvent("kiosk.deleteGame.confirmed"); | ||
playSoundEffect("select"); | ||
deleteGame(); | ||
dispatch(hideModal()); | ||
}; | ||
|
||
const selectedGame = state.allGames.find( | ||
g => g.id === state.selectedGameId | ||
); | ||
|
||
const deleteGame = () => { | ||
const userAddedGames = Storage.getUserAddedGames(); | ||
const gameId = state.selectedGameId; | ||
if (gameId && gameId in userAddedGames) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typically prefer to avoid |
||
const name = userAddedGames[gameId].name; | ||
userAddedGames[gameId].deleted = true; | ||
Storage.setUserAddedGames(userAddedGames); | ||
removeGame(gameId); | ||
dispatch( | ||
postNotification(makeNotification(`${name} deleted`, 5000)) | ||
); | ||
} | ||
}; | ||
|
||
switch (state.modal?.id) { | ||
case "delete-game-confirmation": | ||
return ( | ||
<ConfirmModal | ||
title={"Delete Game?"} | ||
onCancel={cancelClicked} | ||
onConfirm={deleteConfirmClicked} | ||
> | ||
<div className="common-modal-body"> | ||
<p> | ||
<b>{`Delete "${selectedGame?.name}"? `}</b> | ||
{ | ||
"The only way to get the game back is by re-uploading it." | ||
} | ||
</p> | ||
</div> | ||
</ConfirmModal> | ||
); | ||
default: | ||
return null; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new div adds a spacer between the instructions and the QR code that will grow to fill the available space, pushing them apart as the viewport gets wider and wider. I'm sure there's a pure CSS way to accomplish this, but this is what came to mind first.