private async void OnAddDialogSubmit(object sender, EditCategoryBottomSheet.EditCategoryEventArgs args) { var dialog = (EditCategoryBottomSheet)sender; var category = new Category(args.Name); if (_categorySource.Exists(category)) { dialog.NameError = GetString(Resource.String.duplicateCategory); return; } try { await _categorySource.Add(category); } catch (Exception e) { Logger.Error(e); ShowSnackbar(Resource.String.genericError, Snackbar.LengthShort); return; } finally { RunOnUiThread(dialog.Dismiss); } RunOnUiThread(delegate { _categoryListAdapter.NotifyDataSetChanged(); CheckEmptyState(); }); }
/// <summary> /// ViewModel 資料初始化 /// </summary> /// <returns></returns> private async Task ViewModelInit() { Title = "你有一則新留言"; NaviPageSource.Clear(); NaviPageSource.Add("首頁"); NaviPageSource.Add("明細頁面"); NaviPageSelectedItem = NaviPageSource[1]; StyleSource.Clear(); StyleSource.Add(LocalNotificationStyleEnum.BigText.ToString()); StyleSource.Add(LocalNotificationStyleEnum.Image.ToString()); StyleSource.Add(LocalNotificationStyleEnum.Inbox.ToString()); StyleSource.Add(LocalNotificationStyleEnum.Normal.ToString()); StyleSelectedItem = StyleSource[0]; VisibilitySource.Clear(); VisibilitySource.Add(LocalNotificationVisibilityEnum.Private.ToString()); VisibilitySource.Add(LocalNotificationVisibilityEnum.Public.ToString()); VisibilitySource.Add(LocalNotificationVisibilityEnum.Secret.ToString()); VisibilitySelectedItem = VisibilitySource[0]; PrioritySource.Clear(); PrioritySource.Add(LocalNotificationPriorityEnum.Default.ToString()); PrioritySource.Add(LocalNotificationPriorityEnum.High.ToString()); PrioritySource.Add(LocalNotificationPriorityEnum.Low.ToString()); PrioritySource.Add(LocalNotificationPriorityEnum.Maximum.ToString()); PrioritySource.Add(LocalNotificationPriorityEnum.Minimum.ToString()); PrioritySelectedItem = PrioritySource[0]; CategorySource.Clear(); CategorySource.Add(LocalNotificationCategoryEnum.Alarm.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Call.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Email.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Error.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Event.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Message.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Progress.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Promo.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Recommendation.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Service.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Social.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Status.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.System.ToString()); CategorySource.Add(LocalNotificationCategoryEnum.Transport.ToString()); CategorySelectedItem = CategorySource[0]; ResetContentText(); await Task.Delay(100); }