Пример #1
0
        private void ActionSheet()
        {
            var asc = new ActionSheetConfig()
                      .SetTitle("ActionSheet")
                      .SetMessage("アクションシート")
                      .SetUseBottomSheet(false);

            asc.Add("001", () => ShowActionSheetResult("イワン・ウイスキー"));
            asc.Add("002", () => ShowActionSheetResult("ジェット・リンク"));
            asc.Add("003", () => ShowActionSheetResult("フランソワーズ・アルヌール"));
            asc.Add("004", () => ShowActionSheetResult("アルベルト・ハインリヒ"));
            asc.Add("005", () => ShowActionSheetResult("ジェロニモ・ジュニア"));
            asc.Add("006", () => ShowActionSheetResult("張々湖"));
            asc.Add("007", () => ShowActionSheetResult("グレート・ブリテン"));
            asc.Add("008", () => ShowActionSheetResult("ピュンマ"));
            asc.Add("009", () => ShowActionSheetResult("島村ジョー"));

            // removeボタン
            asc.SetDestructive("削除", () => ShowActionSheetResult("削除"));

            // cancelボタン
            asc.SetCancel("キャンセル", () => ShowActionSheetResult("キャンセル"));

            // PopoverPresentationControllerの指定はできないっぽい
            // 吹き出しは画面下部中央からでてる

            _dialogs.ActionSheet(asc);
        }
Пример #2
0
        protected void OnAddPublisherClicked(object sender)
        {
            Catalogue catalogue = Catalogue.GetCatalogue();
            var       config    = new ActionSheetConfig();

            config.SetTitle(Localization.AddPublisher);
            config.SetDestructive(Localization.NewPublisher, async() =>
            {
                OnRemovePublisherClicked(null);
                await Navigation.PushModalAsync(new AddPublisherPage(Book, true));
            });
            config.SetCancel(Localization.Cancel);
            foreach (var publisher in catalogue.PublishersList)
            {
                if (Book.Publisher != publisher)
                {
                    config.Add(publisher.Name, () =>
                    {
                        OnRemovePublisherClicked(null);
                        publisher.AddBook(Book);
                        Book.Publisher = publisher;
                    });
                }
            }
            UserDialogs.Instance.ActionSheet(config);
        }
Пример #3
0
        private void ActionSheet()
        {
            var cfg = new ActionSheetConfig()
                      .SetTitle("Test Title");

            for (var i = 0; i < 5; i++)
            {
                var display = (i + 1);
                cfg.Add(
                    "Option " + display,
                    () => this.lblResult.Text = String.Format("Option {0} Selected", display)
                    );
            }
            cfg.SetDestructive("BOOM", () => this.lblResult.Text = "Destructive BOOM Selected");
            cfg.SetCancel("Cancel", () => this.lblResult.Text    = "Cancel Selected");

            UserDialogs.Instance.ActionSheet(cfg);
        }
Пример #4
0
        void ActionSheet()
        {
            var cfg = new ActionSheetConfig()
                      .SetTitle("Test Title");

            for (var i = 0; i < 5; i++)
            {
                var display = (i + 1);
                cfg.Add(
                    "Option " + display,
                    () => this.lblResult.Text = $"Option {display} Selected"
                    );
            }
            cfg.SetDestructive(action: () => this.lblResult.Text = "Destructive BOOM Selected");
            cfg.SetCancel(action: () => this.lblResult.Text      = "Cancel Selected");

            UserDialogs.Instance.ActionSheet(cfg);
        }
Пример #5
0
        ICommand CreateActionSheetCommand(bool useBottomSheet, bool cancel, int items, string message = null)
        {
            return(new Command(() =>
            {
                var cfg = new ActionSheetConfig()
                          .SetTitle("Test Title")
                          .SetMessage(message)
                          .SetUseBottomSheet(useBottomSheet);

                IBitmap testImage = null;
                try
                {
                    testImage = BitmapLoader.Current.LoadFromResource("icon.png", null, null).Result;
                }
                catch
                {
                    Debug.WriteLine("Could not load image");
                }

                for (var i = 0; i < items; i++)
                {
                    var display = i + 1;
                    cfg.Add(
                        "Option " + display,
                        () => this.Result($"Option {display} Selected"),
                        testImage
                        );
                }
                cfg.SetDestructive(null, () => this.Result("Destructive BOOM Selected"), testImage);
                if (cancel)
                {
                    cfg.SetCancel(null, () => this.Result("Cancel Selected"), testImage);
                }

                var disp = this.Dialogs.ActionSheet(cfg);
                if (this.AutoCancel)
                {
                    Task.Delay(TimeSpan.FromSeconds(3))
                    .ContinueWith(x => disp.Dispose());
                }
            }));
        }
Пример #6
0
        protected void OnAddBookClicked(object sender)
        {
            Catalogue catalogue = Catalogue.GetCatalogue();
            var       config    = new ActionSheetConfig();

            config.SetTitle(Localization.AddBook);
            config.SetDestructive(Localization.NewBook, async() => { await App.Current.MainPage.Navigation.PushModalAsync(new AddBookPage(Publisher, true)); });
            config.SetCancel(Localization.Cancel);
            foreach (var book in catalogue.BooksList)
            {
                if (book.Publisher == null && !Publisher.ContainsBook(book))
                {
                    config.Add(book.Title, () =>
                    {
                        book.Publisher = Publisher;
                        Publisher.AddBook(book);
                    });
                }
            }
            UserDialogs.Instance.ActionSheet(config);
        }
Пример #7
0
        void OpenButtonClicked(object sender, EventArgs e)
        {
            var cfg = new ActionSheetConfig().SetTitle("Test Title");

            var testImage = BitmapLoader.Current.LoadFromResource("icon.png", null, null).Result;

            for (var i = 0; i < 5; i++)
            {
                var display = (i + 1);
                cfg.Add("Option " + display, () => this.Result($"Option {display} Selected"), testImage);
            }
            cfg.SetDestructive(action: () => this.Result("Destructive BOOM Selected"));
            cfg.SetCancel(action: () => this.Result("Cancel Selected"));

            var disp = UserDialogs.Instance.ActionSheet(cfg);
            //if (this.AutoCancel)
            //{
            //    Task.Delay(TimeSpan.FromSeconds(3))
            //        .ContinueWith(x => disp.Dispose());
            //}
        }
Пример #8
0
        protected void OnAddAuthorClicked(object sender)
        {
            Catalogue catalogue = Catalogue.GetCatalogue();
            var       config    = new ActionSheetConfig();

            config.SetTitle(Localization.AddAuthor);
            config.SetDestructive(Localization.NewAuthor, async() => { await Navigation.PushModalAsync(new AddAuthorPage(Book, true)); });
            config.SetCancel(Localization.Cancel);
            foreach (var author in catalogue.AuthorsList)
            {
                if (!Book.ContainsAuthor(author))
                {
                    config.Add(author.FullName, () =>
                    {
                        author.AddBook(Book);
                        Book.AddAuthor(author);
                    });
                }
            }
            UserDialogs.Instance.ActionSheet(config);
        }
Пример #9
0
        public StandardViewModel(IUserDialogs dialogs) : base(dialogs)
        {
            this.Alert         = this.Create(async token => await this.Dialogs.AlertAsync("Test alert", "Alert Title", null, token));
            this.AlertLongText = this.Create(async token =>
                                             await this.Dialogs.AlertAsync(
                                                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc consequat diam nec eros ornare, vitae cursus nunc molestie. Praesent eget lacus non neque cursus posuere. Nunc venenatis quam sed justo bibendum, ut convallis arcu lobortis. Vestibulum in diam nisl. Nulla pulvinar lacus vel laoreet auctor. Morbi mi urna, viverra et accumsan in, pretium vel lorem. Proin elementum viverra commodo. Sed nunc justo, sollicitudin eu fermentum vitae, faucibus a est. Nulla ante turpis, iaculis et magna sed, facilisis blandit dolor. Morbi est felis, semper non turpis non, tincidunt consectetur enim.",
                                                 cancelToken: token
                                                 )
                                             );

            this.ActionSheet = new Command(() =>
            {
                var cfg = new ActionSheetConfig()
                          .SetTitle("Test Title");

                //var testImage = BitmapLoader.Current.LoadFromResource("icon.png", null, null).Result;

                for (var i = 0; i < 5; i++)
                {
                    var display = (i + 1);
                    cfg.Add(
                        "Option " + display,
                        () => this.Result($"Option {display} Selected")
                        //testImage
                        );
                }
                cfg.SetDestructive(action: () => this.Result("Destructive BOOM Selected"));
                cfg.SetCancel(action: () => this.Result("Cancel Selected"));

                var disp = this.Dialogs.ActionSheet(cfg);
                if (this.AutoCancel)
                {
                    Task.Delay(TimeSpan.FromSeconds(3))
                    .ContinueWith(x => disp.Dispose());
                }
            });

            this.ActionSheetAsync = this.Create(async token =>
            {
                var result = await this.Dialogs.ActionSheetAsync("Test Title", "Cancel", "Destroy", token, "Button1", "Button2", "Button3");
                this.Result(result);
            });

            this.Confirm = this.Create(async token =>
            {
                var r    = await this.Dialogs.ConfirmAsync("Pick a choice", "Pick Title", cancelToken: token);
                var text = r ? "Yes" : "No";
                this.Result($"Confirmation Choice: {text}");
            });

            this.Login = this.Create(async token =>
            {
                var r = await this.Dialogs.LoginAsync(new LoginConfig
                {
                    Message = "DANGER"
                }, token);
                var status = r.Ok ? "Success" : "Cancelled";
                this.Result($"Login {status} - User Name: {r.LoginText} - Password: {r.Password}");
            });

            this.Prompt = new Command(() => this.Dialogs.ActionSheet(new ActionSheetConfig()
                                                                     .SetTitle("Choose Type")
                                                                     .Add("Default", () => this.PromptCommand(InputType.Default))
                                                                     .Add("E-Mail", () => this.PromptCommand(InputType.Email))
                                                                     .Add("Name", () => this.PromptCommand(InputType.Name))
                                                                     .Add("Number", () => this.PromptCommand(InputType.Number))
                                                                     .Add("Number with Decimal", () => this.PromptCommand(InputType.DecimalNumber))
                                                                     .Add("Password", () => this.PromptCommand(InputType.Password))
                                                                     .Add("Numeric Password (PIN)", () => this.PromptCommand(InputType.NumericPassword))
                                                                     .Add("Phone", () => this.PromptCommand(InputType.Phone))
                                                                     .Add("Url", () => this.PromptCommand(InputType.Url))
                                                                     .SetCancel()
                                                                     ));
            this.PromptNoTextOrCancel = this.Create(async token =>
            {
                var result = await this.Dialogs.PromptAsync(new PromptConfig
                {
                    Title         = "PromptWithTextAndNoCancel",
                    Text          = "Existing Text",
                    IsCancellable = false
                }, token);
                this.Result($"Result - {result.Text}");
            });

            this.Date = this.Create(async token =>
            {
                var result = await this.Dialogs.DatePromptAsync(new DatePromptConfig
                {
                    IsCancellable = true,
                    MinimumDate   = DateTime.Now.AddDays(-3),
                    MaximumDate   = DateTime.Now.AddDays(1)
                }, token);
                this.Result($"Date Prompt: {result.Ok} - Value: {result.SelectedDate}");
            });
            this.Time = this.Create(async token =>
            {
                var result = await this.Dialogs.TimePromptAsync(new TimePromptConfig
                {
                    IsCancellable = true
                }, token);
                this.Result($"Time Prompt: {result.Ok} - Value: {result.SelectedTime}");
            });
        }
        private MeetingListItemViewModel CreateListItem(Meeting m)
        {
            var isOwner = m.CreatedBy == Settings.LoginUser?.Id;

            var item = new MeetingListItemViewModel
            {
                Text       = m.Name,
                DetailText = $"発話権: {m.Tickets}枚 ({m.Seconds}秒/枚), 振興券: {m.Coupons}枚",
                Selectable = true,
                Image      =
                    m.Status == MeetingStatus.Waiting ? "meeting_blue" :
                    m.Status == MeetingStatus.InMeeting ? "meeting_red" :
                    m.Status == MeetingStatus.Evaluating ? "meeting_yellow" :
                    m.Status == MeetingStatus.Closed ? "meeting_grey" : "",
                SmallIcon =
                    m.Status == MeetingStatus.Evaluating ? "ic_lead_pencil_black_24dp" :
                    m.Status == MeetingStatus.Closed ? "ic_trophy_variant_black_24dp" : null,
                Value = m,
            };

            switch (m.Status)
            {
            case MeetingStatus.Waiting:
                item.OnAction = () =>
                {
                    var config = new ActionSheetConfig();
                    config.Add("参加する", async() =>
                    {
                        if (await EnterAsync(m.Id, Settings.LoginUser.Id, true))
                        {
                            await NavigationService.Navigate(typeof(EventViewModel), m);
                        }
                    });
                    config.Add("立ち見する", async() =>
                    {
                        await EnterAsync(m.Id, Settings.LoginUser.Id, false);
                        await NavigationService.Navigate(typeof(EventViewModel), m);
                    });

                    if (isOwner)
                    {
                        config.SetDestructive("削除", async() => await DeleteAsync(item));
                    }

                    config.SetCancel();
                    UserDialogs.Instance.ActionSheet(config);
                };
                break;

            case MeetingStatus.InMeeting:
                item.OnAction = async() =>
                {
                    await NavigationService.Navigate(typeof(EventViewModel), m);
                };
                break;

            case MeetingStatus.Evaluating:
                item.OnAction = async() =>
                {
                    var config = new ActionSheetConfig();

                    var source    = new CancellationTokenSource();
                    var evaluated = await UserDialogs.Instance.LoadingDelayedAsync(_meetingHub.IsEvaluated(m.Id, Settings.LoginUser.Id), source);

                    if (!evaluated)
                    {
                        config.Add("評価する", async() =>
                        {
                            var result = await NavigationService.Navigate <RatingsViewModel, RatingParameter, RatingResult>(new RatingParameter()
                            {
                                MeetingId = m.Id, CurrentEvaluationItem = EvaluationItem.Clear
                            });
                            if (result != null)
                            {
                                await this.ClosePicker(() => { }, false);
                            }
                        });
                    }
                    else
                    {
                        config.Add("評価済み");
                    }

                    if (isOwner)
                    {
                        config.Add("評価終了", async() =>
                        {
                            if (await FinishEvaluationAsync(item))
                            {
                                item.Image     = "meeting_grey";
                                item.SmallIcon = "ic_trophy_variant_black_24dp";
                                item.OnAction  = async() => await NavigationService.Navigate(typeof(MeetingResultTabRootViewModel), m);;

                                await NavigationService.Navigate(typeof(MeetingResultTabRootViewModel), m);;
                            }
                        });
                    }
                    config.SetCancel();
                    UserDialogs.Instance.ActionSheet(config);
                };
                break;

            case MeetingStatus.Closed:
                item.OnAction = async() =>
                {
                    await NavigationService.Navigate(typeof(MeetingResultTabRootViewModel), m);
                };
                break;

            default:
                break;
            }

            return(item);
        }