-
Notifications
You must be signed in to change notification settings - Fork 587
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kiosk: Support event-based navigation (#9700)
* Kiosk: Support event-based navigation * remove unused packages * Add spacer to add game layout to keep it centered at wide resolutions * Restore link border on scan qr page * Shortened background transition time * Better focus trapping. Fix tab nav on ScanQR page. * pr feedback * prettier
- Loading branch information
1 parent
ecc9b50
commit b312c0c
Showing
61 changed files
with
3,185 additions
and
1,358 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,71 @@ | ||
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"; | ||
import * as GamepadManager from "../Services/GamepadManager"; | ||
|
||
export default function AppModal() { | ||
const { state, dispatch } = useContext(AppStateContext); | ||
|
||
const hideAppModal = () => { | ||
GamepadManager.lockControl(GamepadManager.GamepadControl.AButton); | ||
GamepadManager.lockControl(GamepadManager.GamepadControl.EscapeButton); | ||
dispatch(hideModal()); | ||
}; | ||
|
||
const cancelClicked = () => { | ||
playSoundEffect("select"); | ||
hideAppModal(); | ||
}; | ||
|
||
const deleteConfirmClicked = () => { | ||
pxt.tickEvent("kiosk.deleteGame.confirmed"); | ||
playSoundEffect("select"); | ||
deleteGame(); | ||
hideAppModal(); | ||
}; | ||
|
||
const selectedGame = state.allGames.find( | ||
g => g.id === state.selectedGameId | ||
); | ||
|
||
const deleteGame = () => { | ||
const userAddedGames = Storage.getUserAddedGames(); | ||
const gameId = state.selectedGameId; | ||
if (gameId && userAddedGames.hasOwnProperty(gameId)) { | ||
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; | ||
} | ||
} |
Oops, something went wrong.