private async Task TryCloseAsync(OpenedViewModelInfo openedViewModelInfo) { if (!await openedViewModelInfo.ViewModel.CloseAsync()) { _toastPresenter.ShowAsync($"Cannot close {openedViewModelInfo.ViewModel.GetType().Name}", ToastDuration.Short); } }
private async void Refresh() { _offset = 1; var newItems = await _currentWeatherDataProvider.UpdateSensorHistoryAsync(IdSensor, PeriodType, _offset).WithBusyIndicator(this); Items.Update(newItems); _toastPresenter.ShowAsync("Загружено записей: " + newItems.Count, ToastDuration.Short); }
public IToast ShowAsync(object content, float duration, ToastPosition position = ToastPosition.Bottom, IDataContext context = null) { View holder = null; var currentActivity = PlatformExtensions.CurrentActivity; if (currentActivity != null) { var selector = currentActivity.GetBindingMemberValue(AttachedMembersDesign.Activity.SnackbarViewSelector); if (selector != null) { holder = selector(content, position, context); } if (holder == null) { holder = currentActivity.GetBindingMemberValue(AttachedMembersDesign.Activity.SnackbarView); } } if (holder == null) { return(_defaultPresenter.ShowAsync(content, duration, position, context)); } var toastImpl = new ToastImpl(); if (_threadManager.IsUiThread) { ShowInternal(currentActivity, holder, content, duration, toastImpl); } else { _threadManager.InvokeOnUiThreadAsync(() => ShowInternal(currentActivity, holder, content, duration, toastImpl), OperationPriority.High); } return(toastImpl); }
private async Task ToNextPageAsync() { using (var viewModel = GetViewModel <PageViewModel>()) { await viewModel.ShowAsync(); _toastPresenter.ShowAsync($"The '{viewModel.Text}' is closed.", ToastDuration.Short); } }
private async void Show(ViewModelCommandParameter parameter) { using (IViewModel viewModel = GetViewModel(parameter.ViewModelType)) { await viewModel.ShowAsync(parameter.Context); _toastPresenter.ShowAsync(viewModel.GetType().Name + " is closed", ToastDuration.Long); } }
private async Task AddTabPresenterAsync() { //you can use presenter to show view models using (var vm = GetViewModel <TabViewModel>()) { await vm.ShowAsync(); _toastPresenter.ShowAsync($"The '{vm.DisplayName}' is closed.", ToastDuration.Short); } }
private void ShowInternal(ToastImpl toast, IDataTemplateSelector selector, View snackbarHolderView, object content, float duration, ToastPosition position, IDataContext context) { Snackbar snackbar; if (selector == null) { snackbar = Snackbar.Make(snackbarHolderView, content.ToStringSafe("(null)"), (int)duration); } else { snackbar = (Snackbar)selector.SelectTemplate(content, snackbarHolderView); } if (snackbar == null) { toast.FromToast(_defaultPresenter.ShowAsync(content, duration, position, context)); } else { toast.Show(snackbar, duration); } }
private async Task ShowViewModelWithNotificationAsync <TViewModel>() where TViewModel : IViewModel { using (var viewModel = GetViewModel <TViewModel>()) { var operation = viewModel.ShowAsync(); //waiting until the view model is displayed, only for example operation.GetNavigationCompletedTask().ContinueWith(task => { if (!viewModel.IsDisposed) { _toastPresenter.ShowAsync($"The '{viewModel.GetType().Name}' is displayed.", ToastDuration.Short); } }); //waiting until the view model is closed await operation; _toastPresenter.ShowAsync($"The '{viewModel.GetType().Name}' is closed.", ToastDuration.Short); } }
private async Task SaveChanges(bool showToast) { await _repository .SaveAsync(_trackingCollection.GetChanges(), DisposeCancellationToken) .WithBusyIndicator(this, UiResources.SaveBusyMessage); _trackingCollection.SetStateForAll(entity => entity.State.IsDeleted(), EntityState.Detached); _trackingCollection.SetStateForAll(entity => !entity.State.IsDeleted(), EntityState.Unchanged); this.OnPropertyChanged(() => v => v.HasChanges); if (showToast) { _toastPresenter.ShowAsync(UiResources.SaveToastMessage, ToastDuration.Long); } }
private async void OpenItem(MenuItemModel item) { if (item == null) { return; } using (var vm = GetViewModel <ItemViewModel>()) { vm.DisplayName = item.Name; vm.Id = item.Id; await vm.ShowAsync(); _toastPresenter.ShowAsync(vm.DisplayName + " was closed", ToastDuration.Short); } }
private async void ShowFirstWindow(object o) { using (var vm = GetViewModel <FirstViewModel>()) using (var wrapper = vm.Wrap <IWrapper>(Constants.WindowPreferably.ToValue(true))) { await wrapper.ShowAsync(); _toastPresenter.ShowAsync("The first view model is closed (Window).", ToastDuration.Short); } }
private void Execute() { _toastPresenter.ShowAsync("Command invoked", ToastDuration.Short); }
private void Execute(MenuItemModel menuItem) { _toastPresenter.ShowAsync(menuItem.Name, ToastDuration.Short); }
private void Execute(string menuItem) { _toastPresenter.ShowAsync(menuItem, ToastDuration.Short); }
private void Execute(object cmdParameter) { _toastPresenter.ShowAsync( $"The Command is invoked with cmdParameter: {cmdParameter ?? "null"}", ToastDuration.Long); }
private void ShowSnackbar() { _toastPresenter.ShowAsync("Simple message", ToastDuration.Long); }
private void ShowOpenNotification(IViewModel viewModel, string type) { _toastPresenter.ShowAsync(string.Format("The '{0}' is opened ({1}).", viewModel.GetType().Name, type), ToastDuration.Short); }
private void Execute(object cmdParameter) { _toastPresenter.ShowAsync( string.Format("The Command is invoked with cmdParameter: {0}", cmdParameter ?? "null"), ToastDuration.Long); }