refactor(home): use new context system
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import type { Screen, ScreenContext } from "../../screen";
|
||||
import { ContactScreen } from "../contact-screen";
|
||||
import { HomeTopScreen } from "./top";
|
||||
import { HomeBottomScreen } from "./bottom";
|
||||
|
||||
export class HomeScreen implements Screen {
|
||||
private topScreen = new HomeTopScreen();
|
||||
private bottomScreen = new HomeBottomScreen();
|
||||
private bottomScreen: HomeBottomScreen;
|
||||
|
||||
constructor(context: ScreenContext) {
|
||||
this.bottomScreen = new HomeBottomScreen(context);
|
||||
}
|
||||
|
||||
renderTop(ctx: CanvasRenderingContext2D) {
|
||||
this.topScreen.render(ctx);
|
||||
@@ -15,9 +18,11 @@ export class HomeScreen implements Screen {
|
||||
this.bottomScreen.render(ctx);
|
||||
}
|
||||
|
||||
handleTouch(x: number, y: number, context: ScreenContext): void {
|
||||
if (x >= 205 && x <= 256 && y >= 178 && y <= 192) {
|
||||
context.navigate(new ContactScreen());
|
||||
}
|
||||
handleTouch(x: number, y: number): void {
|
||||
this.bottomScreen.handleTouch(x, y);
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
this.bottomScreen.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user