示例#1
0
        public static void checkForUpdates(CheckVersionType type)
        {
            if (type == CheckVersionType.setting)
            {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog(message: "正在检查更新")
                    );
            }

            SettingApi.CheckNewVersion(platform: Config.platform, store: Config.store, $"{Config.versionCode}")
            .Then(versionResponse => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }

                var status = versionResponse.status;
                if (status == "NEED_UPDATE" && versionResponse.url.isNotEmpty())
                {
                    if (type == CheckVersionType.initialize && !needNoticeNewVersion() || needForceUpdate())
                    {
                        return;
                    }
                    markUpdateNoticeTime();
                    CustomDialogUtils.showCustomDialog(
                        barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                        child: new CustomAlertDialog(
                            null,
                            message: versionResponse.changeLog,
                            new List <Widget> {
                        new CustomButton(
                            child: new Center(
                                child: new Text(
                                    "稍后再说",
                                    style: CTextStyle.PLargeBody5.defaultHeight(),
                                    textAlign: TextAlign.center
                                    )
                                ),
                            onPressed: CustomDialogUtils.hiddenCustomDialog
                            ),
                        new CustomButton(
                            child: new Center(
                                child: new Text(
                                    "立即更新",
                                    style: CTextStyle.PLargeBlue.defaultHeight(),
                                    textAlign: TextAlign.center
                                    )
                                ),
                            onPressed: () => {
                            CustomDialogUtils.hiddenCustomDialog();
                            Application.OpenURL(url: versionResponse.url);
                        }
                            )
                    },
                            new Stack(
                                children: new List <Widget> {
                        Image.asset("image/updaterBg"),
                        new Align(
                            alignment: Alignment.bottomCenter,
                            child: new Container(height: 1, color: CColors.White)
                            )
                    }
                                )
                            )
                        );
                }
                else
                {
                    if (type == CheckVersionType.setting)
                    {
                        var customSnackBar = new CustomSnackBar(
                            "当前是最新版本",
                            color: CColors.TextBody
                            );
                        customSnackBar.show();
                    }
                }
            })
            .Catch(error => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }
            });
        }
示例#2
0
        public static void checkForUpdates(CheckVersionType type)
        {
            if (type == CheckVersionType.setting)
            {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog(message: "正在检查更新")
                    );
            }

            SettingApi.FetchVersion(Config.platform, Config.store, $"{Config.versionCode}")
            .Then(versionResponse => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }

                var status = versionResponse["status"];
                if (status.ToLower() == "need_update" && versionResponse.ContainsKey("url"))
                {
                    var changeLog = "发现新版本,立即更新体验吧!";
                    if (versionResponse.ContainsKey("changeLog"))
                    {
                        if (versionResponse["changeLog"].isNotEmpty())
                        {
                            changeLog = versionResponse["changeLog"];
                        }
                    }

                    CustomDialogUtils.showCustomDialog(
                        barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                        child: new CustomAlertDialog(
                            "版本更新",
                            changeLog,
                            new List <Widget> {
                        new CustomButton(
                            child: new Text(
                                "稍后再说",
                                style: new TextStyle(
                                    height: 1.33f,
                                    fontSize: 16,
                                    fontFamily: "Roboto-Regular",
                                    color: new Color(0xFF959595)
                                    ),
                                textAlign: TextAlign.center
                                ),
                            onPressed: _ignoreUpdater
                            ),
                        new CustomButton(
                            child: new Text(
                                "立即更新",
                                style: CTextStyle.PLargeBlue,
                                textAlign: TextAlign.center
                                ),
                            onPressed: () => {
                            _ignoreUpdater();
                            var url = versionResponse["url"];
                            Application.OpenURL(url);
                        }
                            )
                    }
                            )
                        );
                }
                else
                {
                    if (type == CheckVersionType.setting)
                    {
                        var customSnackBar = new CustomSnackBar(
                            "当前是最新版本",
                            color: CColors.TextBody
                            );
                        customSnackBar.show();
                    }
                }
            })
            .Catch(error => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }
            });
        }
示例#3
0
        public static void checkForUpdates(CheckVersionType type)
        {
            if (type == CheckVersionType.setting)
            {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog(message: "正在检查更新")
                    );
            }

            SettingApi.CheckNewVersion(platform: Config.platform, store: Config.store, $"{Config.versionCode}")
            .Then(versionResponse => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }

                var status = versionResponse.status;
                if (status == "NEED_UPDATE" && versionResponse.url.isNotEmpty())
                {
                    if (type == CheckVersionType.initialize && !needNoticeNewVersion())
                    {
                        return;
                    }

                    markUpdateNoticeTime();
                    CustomDialogUtils.showCustomDialog(
                        barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                        child: new CustomAlertDialog(
                            "版本更新",
                            message: versionResponse.changeLog,
                            new List <Widget> {
                        new CustomButton(
                            child: new Text(
                                "稍后再说",
                                style: new TextStyle(
                                    height: 1.33f,
                                    fontSize: 16,
                                    fontFamily: "Roboto-Regular",
                                    color: new Color(0xFF959595)
                                    ),
                                textAlign: TextAlign.center
                                ),
                            onPressed: CustomDialogUtils.hiddenCustomDialog
                            ),
                        new CustomButton(
                            child: new Text(
                                "立即更新",
                                style: CTextStyle.PLargeBlue,
                                textAlign: TextAlign.center
                                ),
                            onPressed: () => {
                            CustomDialogUtils.hiddenCustomDialog();
                            Application.OpenURL(url: versionResponse.url);
                        }
                            )
                    }
                            )
                        );
                }
                else
                {
                    if (type == CheckVersionType.setting)
                    {
                        var customSnackBar = new CustomSnackBar(
                            "当前是最新版本",
                            color: CColors.TextBody
                            );
                        customSnackBar.show();
                    }
                }
            })
            .Catch(error => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }
            });
        }