public SetupAssistedViewModel(FlutterDiagOutArg checkResult, IScreen screen = null) : base("setup_assisted", screen)
        {
            Title = "Step-by-step Configuration";

            Button2Visible = true;

            Button3Command = ReactiveCommand.CreateFromTask(async() =>
            {
                await HostScreen.Router.Navigate.Execute(new SetupAssistedProgressViewModel(new FlutnetSetupInArg
                {
                    FlutterSdkLocation = FlutterLocation,
                    AndroidSdkLocation = !SkipAndroidConfiguration ? AndroidLocation : string.Empty,
                    JavaSdkLocation    = !SkipAndroidConfiguration ? JavaLocation : string.Empty
                }, HostScreen));
            });

            CurrentShell = checkResult.CurrentShell;
            CurrentShellConfigurationFile = checkResult.CurrentShellConfigurationFile;

            FlutterLocation       = checkResult.FlutterSdkLocation;
            BrowseFlutterLocation = ReactiveCommand.CreateFromTask(BrowseFlutterLocationAsync);

            AndroidLocation       = checkResult.AndroidSdkLocation;
            BrowseAndroidLocation = ReactiveCommand.CreateFromTask(BrowseAndroidLocationAsync);

            JavaLocation       = checkResult.JavaSdkLocation;
            BrowseJavaLocation = ReactiveCommand.CreateFromTask(BrowseJavaLocationAsync);

            this.WhenAnyValue(
                t => t.FlutterLocation, t => t.AndroidLocation, t => t.JavaLocation, t => t.SkipAndroidConfiguration,
                (p1, p2, p3, p4) => !string.IsNullOrEmpty(p1) && (!string.IsNullOrEmpty(p2) && !string.IsNullOrEmpty(p3) || p4))
            .BindTo(this, t => t.Button3Enabled);
        }
Example #2
0
        public SetupFinishViewModel(SetupResult result, AdvancedWizardPageViewModel previousPage, IScreen screen = null) : base("setup_finish", screen)
        {
            Button1Visible = false;
            Button2Visible = false;
            Button3Text    = "Finish";
            IsFinishPage   = true;

            Button3Command = ReactiveCommand.CreateFromObservable(() =>
            {
                var closeWizard = (HostScreen as SetupWindowViewModel)?.CloseWizard;
                return(closeWizard?.Handle(Unit.Default));
            });

            if (result.OperationCanceled)
            {
                Title = "Setup Aborted";
                Text  = "Setup Aborted";
                return;
            }

            if (result.OperationFailed)
            {
                Title = "Setup Failed";
                Text  = Properties.Resources.Setup_Finish_UnexpectedError_Message;
                return;
            }

            Title = "Setup Completed";

            if (previousPage is SetupCheckFlutterViewModel || previousPage is SetupCheckFlutterErrorViewModel)
            {
                FlutterDiagOutArg operationResult = (FlutterDiagOutArg)result.OperationResult;

                string txt = string.Empty;
                switch (operationResult.Compatibility)
                {
                case FlutterCompatibility.Supported:
                    txt = Properties.Resources.Setup_Finish_Congratulations_v1_Message;
                    break;

                case FlutterCompatibility.SupportNotGuaranteed:
                    txt = !string.IsNullOrEmpty(operationResult.NextSupportedVersion)
                            ? Properties.Resources.Setup_Finish_LimitedSupport_v1_Message
                            : Properties.Resources.Setup_Finish_LimitedSupport_v2_Message;
                    break;

                case FlutterCompatibility.NotSupported:
                    txt = Properties.Resources.Setup_Finish_NoCompatibility_Message;
                    break;
                }

                Text = SetupWindowViewModel.ReplaceText(txt, operationResult.InstalledVersion, operationResult.LatestSupportedVersion);
            }
            else
            {
                Text = Properties.Resources.Setup_Finish_Congratulations_v2_Message;
            }
        }
Example #3
0
        public SetupCheckFlutterErrorViewModel(FlutterDiagOutArg checkResult, IScreen screen = null) : base("setup_check_flutter_err", screen)
        {
            _checkResult = checkResult;

            Button1Visible = true;
            Button1Text    = "Check again";
            Button1Command = screen?.Router.NavigateBack;

            Button3Visible = true;
            Button3Text    = "Assisted setup";
            Button3Command = ReactiveCommand.CreateFromTask(async() =>
            {
                await HostScreen.Router.Navigate.Execute(new SetupAssistedViewModel(_checkResult, HostScreen));
            });

            if (checkResult.Issues == FlutterIssues.SdkNotFound)
            {
                Title = "Flutter Not Detected";

                Text = SetupWindowViewModel.ReplaceText(Properties.Resources.Setup_Check_FlutterNotFound_Message, checkResult.InstalledVersion, checkResult.LatestSupportedVersion);

                Button2Visible = false;

                FlutterNotFound = true;
            }
            else
            {
                Title = "Flutter Installed with Errors";

                Text = Properties.Resources.Setup_Check_FlutterErrors_Message;

                Button2Visible = true;
                Button2Text    = "Ignore and continue";
                Button2Command = ReactiveCommand.CreateFromTask(async() =>
                {
                    await HostScreen.Router.Navigate.Execute(new SetupFinishViewModel(new Models.SetupResult
                    {
                        OperationResult = _checkResult
                    }, this, HostScreen));
                });

                FlutterNotFound = false;

                StringBuilder sb = new StringBuilder();
                foreach (var kvp in _checkResult.DoctorErrors)
                {
                    sb.AppendLine(kvp.Key);
                    foreach (string line in kvp.Value.Split(Environment.NewLine))
                    {
                        sb.AppendFormat("    {0}", line);
                        sb.AppendLine();
                    }
                    sb.AppendLine();
                }
                Errors = sb.ToString();
            }
        }
Example #4
0
        public SetupCheckFlutterViewModel(IScreen screen = null) : base("setup_check_flutter", screen)
        {
            Title = "Check Flutter";

            Button1Visible = false;
            Button2Visible = false;
            Button3Visible = false;

            // Create the command that calls Flutnet CLI
            RunDiagnostic = ReactiveCommand.CreateFromTask(async ct =>
            {
                CommandLineCallResult callResult = await CommandLineTools.Call <FlutterDiagInArg, FlutterDiagOutArg>(ct);

                // This is not the proper way to change property values and raise property change notifications:
                // we should return a public object and subscribe to the command observable
                // so that we can use ReactiveUI framework methods such as ToProperty, BindTo etc.

                SetupResult overallResult     = null;
                FlutterDiagOutArg checkResult = null;

                if (callResult.Canceled)
                {
                    // Jump to finish page and notify the user that the operation has been canceled.
                    overallResult = new SetupResult {
                        OperationCanceled = true
                    };
                }
                else if (callResult.Failed)
                {
                    // Jump to finish page and notify the user that an unexpected error occured.
                    overallResult = new SetupResult {
                        OperationFailed = true
                    };
                }
                else
                {
                    FlutterDiagOutArg result = (FlutterDiagOutArg)callResult.CommandResult;
                    if (!result.Success)
                    {
                        // Jump to finish page and notify the user that an unexpected error occured.
                        overallResult = new SetupResult {
                            OperationFailed = true
                        };
                    }
                    else if (result.Issues == FlutterIssues.None || result.Issues == FlutterIssues.CompatibilityIssues)
                    {
                        // Jump to finish page and notify the user if we detected a compatibility issue.
                        overallResult = new SetupResult {
                            OperationResult = result
                        };
                    }
                    else
                    {
                        checkResult = result;
                    }
                }

                if (overallResult != null)
                {
                    await HostScreen.Router.Navigate.Execute(new SetupFinishViewModel(overallResult, this, HostScreen));
                }
                else
                {
                    await HostScreen.Router.Navigate.Execute(new SetupCheckFlutterErrorViewModel(checkResult, HostScreen));
                }
            });

            RunDiagnostic.IsExecuting.ToProperty(this, x => x.IsInProgress, out _isInProgress);
            RunDiagnostic.IsExecuting.BindTo(this, x => x.IsBusy);

            // Execute the command when the View is activated
            this.WhenActivated(disposables =>
            {
                RunDiagnostic.Execute(Unit.Default).Subscribe().DisposeWith(disposables);
            });
        }