diff --git a/src/Home.tsx b/src/Home.tsx index c102865..109c9ca 100644 --- a/src/Home.tsx +++ b/src/Home.tsx @@ -18,6 +18,10 @@ import { GameMove } from "./models/GameMove"; import PitAnimator from "./animation/PitAnimator"; import BoardViewModel from "./viewmodel/BoardViewModel"; import { v4 } from "uuid"; +import { Menu, MenuButton, MenuItem } from "@szhsin/react-menu"; +import "@szhsin/react-menu/dist/index.css"; +import "@szhsin/react-menu/dist/transitions/slide.css"; +import { getColorByLuminance } from "./util/ColorUtil"; type ConnectionState = "connecting" | "error" | "connected" | "reconnecting"; @@ -116,6 +120,12 @@ const Home: FunctionComponent<{ initial?: number }> = ({ initial = 0 }) => { }; }, []); + React.useEffect(() => { + context.themeManager.onThemeChange = () => { + updateBoardViewModel(pitAnimator.getBoardViewModelFromGame(game)); + }; + }, [boardViewModel]); + const resetGameState = () => { setGame(undefined); setCrashMessage(undefined); @@ -185,7 +195,11 @@ const Home: FunctionComponent<{ initial?: number }> = ({ initial = 0 }) => { } return <>; }; - + const menuTextColor = getColorByLuminance( + context.themeManager.theme.appBarBgColor, + context.themeManager.theme.primary, + context.themeManager.theme.primaryLight + ); return (
= ({ initial = 0 }) => { }} >

{context.texts.Mancala}

-
+
+
+ light_mode + } + transition + align="end" + > + {context.themeManager.themes.map((theme) => { + return ( + (context.themeManager.theme = theme)} + > +
+ {theme.name} +
+ ); + })} +
+
{renderNewGameButton()} {game && !userKeyWhoLeave && diff --git a/src/animation/PitAnimator.ts b/src/animation/PitAnimator.ts index 3e912a7..d9c28fc 100644 --- a/src/animation/PitAnimator.ts +++ b/src/animation/PitAnimator.ts @@ -162,7 +162,7 @@ export default class PitAnimator { } } - private getBoardViewModelFromGame(game: MancalaGame): BoardViewModel { + public getBoardViewModelFromGame(game: MancalaGame): BoardViewModel { const pitViewModels = this.createPitViewModelsFromGame(game); return BoardViewModelFactory.create(v4(), pitViewModels); } diff --git a/src/index.html b/src/index.html index cf30955..e6ca5a9 100644 --- a/src/index.html +++ b/src/index.html @@ -11,6 +11,8 @@ +