public static void Confirm(this IUserInteraction userInteraction, string message, Action <bool> answer, string title = null, string okButton = "OK", string cancelButton = "Cancel")
        {
            var task = userInteraction.ConfirmAsync(
                message,
                title,
                okButton,
                cancelButton);

            if (answer != null)
            {
                task.ContinueWith((closureTask, closureAction) => ((Action <bool>)closureAction)(closureTask.Result), answer, TaskContinuationOptions.OnlyOnRanToCompletion);
            }
        }
예제 #2
0
        public VehicleViewModel(IStoredSettingsService storedSettingsService, IServerApiService serverApiService, IUserInteraction userInteraction)
        {
            this.storedSettingsService = storedSettingsService;
            this.serverApiService      = serverApiService;
            this.userInteraction       = userInteraction;

            GoBakToVehicleListCommnad = new MvxCommand(() => ShowViewModel <VehiclesDataViewModel>());
            AddVehicleCommnad         = new MvxCommand(async() => await AddVehicleAsync());
            CancelAddingCommnad       = new MvxCommand(async() =>
            {
                var result = await userInteraction.ConfirmAsync("Are you sure you want to cancel?", "Warning", "Yes", "No");
                if (result)
                {
                    ShowViewModel <VehiclesDataViewModel>();
                }
            });
        }