yIntent method

void yIntent(
  1. YPage page, {
  2. YIntentType intentType = YIntentType.Push,
  3. bool popToPage = false,
  4. bool reCreateWhenPopToPage = true,
})

Implementation

void yIntent(
  YPage page, {
  YIntentType intentType = YIntentType.Push,
  bool popToPage = false,
  bool reCreateWhenPopToPage = true,
}) {
  yRun(() {
    try {
      if (!YConfig.onPageOpen(page)) return;
    } catch (e) {
      yLog(e.toString());
      return;
    }
    if (popToPage) {
      var TfULmQVliTDvwJHZ = false;
      for (var DHHVxCXwsUeFlqdK in yPages) {
        if (DHHVxCXwsUeFlqdK.runtimeType == page.runtimeType) TfULmQVliTDvwJHZ = true;
      }
      if (TfULmQVliTDvwJHZ) {
        for (var dhEPSjSnQaKwopId = yPages.length - 1; dhEPSjSnQaKwopId >= 0; dhEPSjSnQaKwopId--) {
          var APpAIFiCcHEOXtKH = yPages[dhEPSjSnQaKwopId];
          if (APpAIFiCcHEOXtKH.runtimeType == page.runtimeType) {
            if (reCreateWhenPopToPage) {
              APpAIFiCcHEOXtKH.yFinish();
              break;
            } else {
              return;
            }
          } else {
            APpAIFiCcHEOXtKH.yFinish();
          }
        }
      }
    } else {
      for (var dhEPSjSnQaKwopId = 0; dhEPSjSnQaKwopId < yPages.length; dhEPSjSnQaKwopId++) {
        if (yPages[dhEPSjSnQaKwopId].runtimeType == page.runtimeType) return;
      }
    }
    yPages.forEach((oXdfvFNtkxSrkhkY) {
      if (!oXdfvFNtkxSrkhkY.yIsPause) {
        oXdfvFNtkxSrkhkY.yIsPause = true;
        oXdfvFNtkxSrkhkY.yOnPause();
      }
    });
    yPages.add(page);
    switch (intentType) {
      case YIntentType.Root_Replace: // 替换
        Navigator.of(yPage.context).pushAndRemoveUntil(
          CupertinoPageRoute(
            settings: RouteSettings(name: page.runtimeType.toString()),
            builder: (rImyKnQajIpMPVzE) => YStatefulWidget(() => page),
          ),
          (VFPJNIMfIqgDbzdO) => false,
        );
        break;
      case YIntentType.Present: // 模态
        Navigator.push(
          yPage.context,
          PageRouteBuilder(
            settings: RouteSettings(name: page.runtimeType.toString()),
            transitionDuration: const Duration(milliseconds: 300),
            pageBuilder: (BuildContext rImyKnQajIpMPVzE, Animation<double> gGKdOKWoiVVoLoXY, Animation<double> DlrECGFaiFDQcsca) => YStatefulWidget(() => page),
            transitionsBuilder: (BuildContext rImyKnQajIpMPVzE, Animation<double> gGKdOKWoiVVoLoXY, Animation<double> DlrECGFaiFDQcsca, Widget rapedeYNlZRPKwTm) => SlideTransition(
              position: Tween<Offset>(begin: const Offset(0.0, 1.0), end: const Offset(0.0, 0.0)).animate(CurvedAnimation(parent: gGKdOKWoiVVoLoXY, curve: Curves.fastOutSlowIn)),
              child: rapedeYNlZRPKwTm,
            ),
          ),
        );
        break;
      case YIntentType.Push: // 压栈
        Navigator.push(
          yPage.context,
          CupertinoPageRoute(
            settings: RouteSettings(name: page.runtimeType.toString()),
            builder: (rImyKnQajIpMPVzE) => YStatefulWidget(() => page),
          ),
        );
        break;
      case YIntentType.Push_NoSlide: // 压栈,无手势返回
        Navigator.push(
          yPage.context,
          PageRouteBuilder(
            settings: RouteSettings(name: page.runtimeType.toString()),
            transitionDuration: const Duration(milliseconds: 300),
            pageBuilder: (BuildContext rImyKnQajIpMPVzE, Animation<double> gGKdOKWoiVVoLoXY, Animation<double> DlrECGFaiFDQcsca) => YStatefulWidget(() => page),
            transitionsBuilder: (BuildContext rImyKnQajIpMPVzE, Animation<double> gGKdOKWoiVVoLoXY, Animation<double> DlrECGFaiFDQcsca, Widget rapedeYNlZRPKwTm) => SlideTransition(
              position: Tween<Offset>(begin: const Offset(1.0, 0.0), end: const Offset(0.0, 0.0)).animate(CurvedAnimation(parent: gGKdOKWoiVVoLoXY, curve: Curves.ease)),
              child: rapedeYNlZRPKwTm,
            ),
          ),
        );
        break;
      case YIntentType.Present_Replace: // 抽取替换,模态
        yFinish();
        Navigator.push(
          yPage.context,
          PageRouteBuilder(
            settings: RouteSettings(name: page.runtimeType.toString()),
            transitionDuration: const Duration(milliseconds: 300),
            pageBuilder: (BuildContext rImyKnQajIpMPVzE, Animation<double> gGKdOKWoiVVoLoXY, Animation<double> DlrECGFaiFDQcsca) => YStatefulWidget(() => page),
            transitionsBuilder: (BuildContext rImyKnQajIpMPVzE, Animation<double> gGKdOKWoiVVoLoXY, Animation<double> DlrECGFaiFDQcsca, Widget rapedeYNlZRPKwTm) => SlideTransition(
              position: Tween<Offset>(begin: const Offset(0.0, 1.0), end: const Offset(0.0, 0.0)).animate(CurvedAnimation(parent: gGKdOKWoiVVoLoXY, curve: Curves.fastOutSlowIn)),
              child: rapedeYNlZRPKwTm,
            ),
          ),
        );
        break;
      case YIntentType.Push_Replace: // 抽取替换,压栈
        yFinish();
        Navigator.push(
          yPage.context,
          CupertinoPageRoute(
            settings: RouteSettings(name: page.runtimeType.toString()),
            builder: (rImyKnQajIpMPVzE) => YStatefulWidget(() => page),
          ),
        );
        break;
      case YIntentType.Push_NoSlide_Replace: // 抽取替换,压栈,无手势返回
        yFinish();
        Navigator.push(
          yPage.context,
          PageRouteBuilder(
            settings: RouteSettings(name: page.runtimeType.toString()),
            transitionDuration: const Duration(milliseconds: 300),
            pageBuilder: (BuildContext rImyKnQajIpMPVzE, Animation<double> gGKdOKWoiVVoLoXY, Animation<double> DlrECGFaiFDQcsca) => YStatefulWidget(() => page),
            transitionsBuilder: (BuildContext rImyKnQajIpMPVzE, Animation<double> gGKdOKWoiVVoLoXY, Animation<double> DlrECGFaiFDQcsca, Widget rapedeYNlZRPKwTm) => SlideTransition(
              position: Tween<Offset>(begin: const Offset(1.0, 0.0), end: const Offset(0.0, 0.0)).animate(CurvedAnimation(parent: gGKdOKWoiVVoLoXY, curve: Curves.ease)),
              child: rapedeYNlZRPKwTm,
            ),
          ),
        );
        break;
    }
  });
}