fix theme change issue
This commit is contained in:
parent
1fa0fdf973
commit
af5fd30ce6
@ -13,6 +13,7 @@ import { Context } from "../context/context";
|
|||||||
import BoardViewModelFactory from "../factory/BoardViewModelFactory";
|
import BoardViewModelFactory from "../factory/BoardViewModelFactory";
|
||||||
import { PitViewModelFactory } from "../factory/PitViewModelFactory";
|
import { PitViewModelFactory } from "../factory/PitViewModelFactory";
|
||||||
import { Game } from "../models/Game";
|
import { Game } from "../models/Game";
|
||||||
|
import { Theme } from "../theme/Theme";
|
||||||
import { getColorByBrightness } from "../util/ColorUtil";
|
import { getColorByBrightness } from "../util/ColorUtil";
|
||||||
import BoardViewModel from "../viewmodel/BoardViewModel";
|
import BoardViewModel from "../viewmodel/BoardViewModel";
|
||||||
|
|
||||||
@ -35,6 +36,7 @@ export default class PitAnimator {
|
|||||||
) {
|
) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.onBoardViewModelUpdate = onBoardViewModelUpdate;
|
this.onBoardViewModelUpdate = onBoardViewModelUpdate;
|
||||||
|
this.context.themeManager.on("themechange", this.onThemeChange.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
get mancalaGame(): MancalaGame | undefined {
|
get mancalaGame(): MancalaGame | undefined {
|
||||||
@ -190,6 +192,11 @@ export default class PitAnimator {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private onThemeChange(theme: Theme){
|
||||||
|
if(!this.game) return;
|
||||||
|
this.onBoardViewModelUpdate?.(this.getBoardViewModelFromGame(this.game));
|
||||||
|
}
|
||||||
|
|
||||||
public resetAnimationState() {
|
public resetAnimationState() {
|
||||||
this.animationIndex = -1;
|
this.animationIndex = -1;
|
||||||
this.currentHistoryItem = undefined;
|
this.currentHistoryItem = undefined;
|
||||||
@ -204,6 +211,7 @@ export default class PitAnimator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public dispose() {
|
public dispose() {
|
||||||
|
this.context.themeManager.off("themechange", this.onThemeChange.bind(this));
|
||||||
this.resetAnimationState();
|
this.resetAnimationState();
|
||||||
this.clearCurrentInterval();
|
this.clearCurrentInterval();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user