| 1 | import { MobileAd, type MobileAdOptions } from "./common"; |
| 2 | |
| 3 | export class BannerAd extends MobileAd<BannerAdOptions> { |
| 4 | static cls = "BannerAd"; |
| 5 | #loaded = false; |
| 6 | |
| 7 | constructor(opts: BannerAdOptions) { |
| 8 | super({ |
| 9 | position: "bottom", |
| 10 | ...opts, |
| 11 | }); |
| 12 | } |
| 13 | |
| 14 | isLoaded() { |
| 15 | return super.isLoaded(); |
| 16 | } |
| 17 | |
| 18 | async load() { |
| 19 | await super.load(); |
| 20 | this.#loaded = true; |
| 21 | } |
| 22 | |
| 23 | async show() { |
| 24 | if (!this.#loaded) await this.load(); |
| 25 | await super.show(); |
| 26 | } |
| 27 | |
| 28 | hide() { |
| 29 | return super.hide(); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | export type BannerPosition = "top" | "bottom"; |
| 34 | |
| 35 | export interface BannerAdOptions extends MobileAdOptions { |
| 36 | position?: BannerPosition; |
| 37 | } |