CustomDialogComponent.ets 4.71 KB
import router from '@ohos.router';
import { GlobalContext } from '../common/utils/GlobalContext'
import { NavigatorModel } from '../viewModel/NavigatorModel';

@CustomDialog
export default struct CustomDialogComponent {

  controller: CustomDialogController = new CustomDialogController({'builder': ''})
  cancel: Function = () => {}
  confirm: Function = () => {}


  build(){
    Column(){
      Text($r('app.string.dialog_text_title'))
        .width("90%")
        .fontColor($r('app.color.dialog_text_color'))
        .fontSize($r('app.float.dialog_text_privacy_size'))
        .textAlign(TextAlign.Center)
        .fontWeight('600')
        .margin({
          top: $r('app.float.dialog_text_privacy_top'),
          bottom: $r('app.float.dialog_text_privacy_bottom')
        })
      Text($r('app.string.dialog_text_privacy_content'))
        .fontSize($r('app.float.dialog_common_text_size'))
        .width('90%')
      Row(){

        // Button(){
        //   Text($r('app.string.privacy_text_title_policy'))
        //     .fontSize('27lpx')
        //     .fontColor(Color.Red)
        //     .margin({left:'10lpx',right:'10lpx'})
        // }
        // .width('90%')
        // .height('56lpx')
        // .margin({top:'54lpx',right:'19lpx'})
        // .backgroundColor('#80000000')
        // .onClick(() => {
        //
        // })
        // Button(){
        //   Text($r('app.string.privacy_text_title_protocol'))
        //     .fontSize('27lpx')
        //     .fontColor(Color.Red)
        //     .margin({left:'10lpx',right:'10lpx'})
        // }
        // .width('90%')
        // .height('56lpx')
        // .margin({top:'54lpx',right:'19lpx'})
        // .backgroundColor('#80000000')
        // .onClick(() => {
        //
        // })

        // Navigator({ target: 'pages/PrivacyPage', type: NavigationType.Push }) {
        //   Button($r('app.string.privacy_text_title_policy'))
            // .onClick(()=>{
            //   GlobalContext.getContext().setObject('isJumpPrivacy', true);
            // })
          // {
          //   // Text($r('app.string.privacy_text_title_policy'))
          //   //   .fontSize($r('app.float.dialog_common_text_size'))
          //   //   .width('50%')
          //   //   .fontColor(Color.Red)
          //     // .onClick(() => {
          //     //   GlobalContext.getContext().setObject('isJumpPrivacy', true);
          //     // })
          // }
           // .fancy(Const.MainConstant_BUTTON_MARGIN_TOP)
        // }
        // .params({ path: 'https://www.baidu.com', tips: '在线' } as NavigatorModel)

        Text($r('app.string.privacy_text_title_policy'))
          .fontSize($r('app.float.dialog_common_text_size'))
          .width('40%')
          .fontColor(Color.Red)
          .onClick(() => {
            //GlobalContext.getContext().setObject('isJumpPrivacy', false);
            router.pushUrl({
              url: 'pages/PrivacyPage'
            }).catch((error: Error) => {
              //Logger.error(CommonConstants.CUSTOM_DIALOG_TAG, 'CustomDialog pushUrl error ' + JSON.stringify(error));
            });
          })
        Text($r('app.string.privacy_text_title_protocol'))
          .fontSize($r('app.float.dialog_common_text_size'))
          .width('40%')
          .fontColor(Color.Red)
          .onClick(() => {
            //GlobalContext.getContext().setObject('isJumpPrivacy', true);
            router.pushUrl({
              url: 'pages/PrivacyPage'
            }).catch((error: Error) => {
              //Logger.error(CommonConstants.CUSTOM_DIALOG_TAG, 'CustomDialog pushUrl error ' + JSON.stringify(error));
            });
          })
      }
      Text($r('app.string.dialog_text_privacy_statement'))
        .width('90%')
        .fontColor($r('app.color.dialog_text_statement_color'))
        .fontSize($r('app.float.dialog_common_text_size'))
      Row() {
        Text($r('app.string.dialog_button_disagree'))
          .fancy()
          .onClick(() => {
            this.controller.close();
            this.cancel();
          })
        Blank()
          .backgroundColor($r('app.color.dialog_blank_background_color'))
          .width($r('app.float.dialog_blank_width'))
          .height($r('app.float.dialog_blank_height'))
        Text($r('app.string.dialog_button_agree'))
          .fancy()
          .onClick(() => {
            this.controller.close();
            this.confirm();
          })
      }
      .margin({ bottom: '1' })

    }
    .width('93%')
    .borderRadius('15')
    .backgroundColor(Color.White)

  }



}
// Common text styles.
@Extend(Text) function fancy () {
  .fontColor($r("app.color.dialog_fancy_text_color"))
  .fontSize($r("app.float.dialog_fancy_text_size"))
  .textAlign(TextAlign.Center)
  .fontWeight(FontWeight.Medium)
  .layoutWeight('1')
}