예제 #1
0
        private async void Remove(RingItemViewModel item)
        {
            if (item == null)
            {
                return;
            }

            if (!_dialogService.ShowQuestionDialog($"Remove {item.Name}?"))
            {
                return;
            }

            await RemoveAsync(item.Token);
        }
예제 #2
0
        public async Task InitializeAsync()
        {
            _serviceStarted = await Task.Factory.StartNew(() => _tokenService.Ping());

            if (!_serviceStarted)
            {
                _synchronizationService.RunInMainThread(() => RaisePropertyChanged(nameof(AllowAdd)));

                _dialogService.ShowErrorDialog("Service not available");

                return;
            }

            var tokens = await _tokenService.GetTokensAsync(_userCredentials.GetName());

            if (Items.Any())
            {
                _synchronizationService.RunInMainThread(() => Items.Clear());
            }

            foreach (var token in tokens)
            {
                var tokenKey          = token.Key;
                var imageData         = _tokenService.GetTokenImage(tokenKey);
                var ringItemViewModel =
                    new RingItemViewModel {
                    Name = token.Value, Token = tokenKey, Image = imageData.ImageBytes
                };
                ringItemViewModel.SetDefaultName(ringItemViewModel.Name);

                _synchronizationService.RunInMainThread(() => Items.Add(ringItemViewModel));
            }

            _synchronizationService.RunInMainThread(() =>
            {
                RaisePropertyChanged(nameof(AllowAdd));
                AddCommand.RaiseCanExecuteChanged();
            });
        }