/*
 * 取流方式设置页面
 * EZOpenSDK
 *
 * Created by junecheng on 2025/7/9.
 * Copyright (c) 2025年 Ezviz. All rights reserved.
 */
import { EZOpenSDK } from '@ohos/EZOpenSDK'
import GlobalKit from '../../global/GlobalKit'
import { NavigationView } from '../../global/view/NavigationView'
import PreviewList, { ListItemData } from '../../global/view/PreviewList'

@Entry
@Component
struct EZStreamTypeSettingPage {
  // 数据源
  @State private listData: ListItemData[] = []

  // ------------------------ 生命周期 ------------------------

  aboutToAppear() {
    // 初始化数据源
    this.listData = [
      {
        mainTitle: '内网直连',
        isSwitchOn: GlobalKit.getInstance().enableDirectInner,
        onSwitchClick: (on: boolean): void => {
          EZOpenSDK.enableDirectInner(on)
          GlobalKit.getInstance().enableDirectInner = on
        }
      },
      {
        mainTitle: 'P2P',
        isSwitchOn: GlobalKit.getInstance().enableP2P,
        onSwitchClick: (on: boolean): void => {
          EZOpenSDK.enableP2P(on)
          GlobalKit.getInstance().enableP2P = on
        }
      },
      {
        mainTitle: '流媒体',
        isSwitchOn: GlobalKit.getInstance().enableVTDU,
        onSwitchClick: (on: boolean): void => {
          EZOpenSDK.enableVTDU(on)
          GlobalKit.getInstance().enableVTDU = on
        }
      }
    ]

  }

  aboutToDisappear() {

  }

  // ------------------------ Actions ------------------------

  // ------------------------ 网络请求 ------------------------

  // ------------------------ 自定义方法 ------------------------

  // ------------------------ UI ------------------------

  build() {
    Column() {
      NavigationView({
        title: '取流方式设置'
      })
      PreviewList({
        items: this.listData
      })
    }.width('100%').height('100%')
  }
}