Пример #1
0
        public PendingViewModel(INotificationManager notifications,
                                IUserDialogs dialogs)
        {
            this.Load = ReactiveCommand.CreateFromTask(async() =>
            {
                var pending      = await notifications.GetPending();
                this.PendingList = pending
                                   .Select(x => new CommandItem
                {
                    Text           = $"[{x.Id}] {x.Title}",
                    Detail         = $"[{x.ScheduleDate.Value}] {x.Message}",
                    PrimaryCommand = ReactiveCommand.CreateFromTask(async() =>
                    {
                        await notifications.Cancel(x.Id);
                        ((ICommand)this.Load).Execute(null);
                    })
                })
                                   .ToList();
            });
            this.BindBusyCommand(this.Load);

            this.Clear = ReactiveCommand.CreateFromTask(
                async() =>
            {
                var confirm = await dialogs.Confirm("Clear All Pending Notifications?", "Confirm", "Yes", "No");
                if (confirm)
                {
                    await notifications.Clear();
                    ((ICommand)this.Load).Execute(null);
                }
            }
                //this.WhenAny(
                //    x => x.PendingList,
                //    x => x.GetValue()?.Any() ?? false
                //)
                );
        }
Пример #2
0
 public static Task Clear() => Current.Clear();