import { TitleBar } from '../../view/TitleBar'

@Entry
@ComponentV2
struct PhotoViewPage {
  @Local title: string = ''
  @Local uri?: string = ''

  aboutToAppear(): void {
    this.initParams()
  }

  initParams() {
    const params = this.getUIContext().getRouter().getParams() as Record<string, Object>;
    if (params) {
      this.title = params.title as string
      this.uri = params.uri as string;
    }
  }

  build() {
    Column() {
      TitleBar({title: this.title}).width('100%')
      Image(this.uri).width('100%').layoutWeight(1)
        .margin({bottom: 50})
        .objectFit(ImageFit.Contain)
    }
    .width('100%')
    .height('100%')
    .backgroundColor($r('app.color.window_background'))
  }
}