Esempio n. 1
0
        public async void SearchTextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
            {
                Suggestions.Clear();

                // Retrieve suggestions
                if (CanExecuteSearch)
                {
                    var suggestionsInverted = _localStorageService.Read(StorageConstants.InvertSuggestions, false);

                    var suggestions = await _apiService.RetrieveSuggestionsAsync(Word, CurrentDictionary);
                    foreach (var suggestion in suggestions)
                    {
                        if (suggestionsInverted)
                        {
                            Suggestions.Insert(0, suggestion);
                        }
                        else
                        {
                            Suggestions.Add(suggestion);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public MainViewModel(INavigationService navigationService,
                             IApiService apiService,
                             IDictionaryService dictionaryService,
                             ILocalStorageService localStorageService,
                             IRoamingStorageService roamingStorageService,
                             IAnalyticsService analyticsService,
                             INetworkService networkService,
                             IFeatureToggleService featureToggleService)
        {
            _navigationService     = navigationService;
            _apiService            = apiService;
            _dictionaryService     = dictionaryService;
            _localStorageService   = localStorageService;
            _roamingStorageService = roamingStorageService;
            _analyticsService      = analyticsService;
            _networkService        = networkService;
            _featureToggleService  = featureToggleService;

            InitializeAsync();

            Messenger.Default.Register <NewTranslationMessage>(this, async(message) =>
            {
                await AddTranslationAsync(message.Translation);
            });

            Messenger.Default.Register <HistoryRemovedMessage>(this, async(message) =>
            {
                await CreateTranslationCardsAsync();
            });

            Messenger.Default.Register <HistoryToggleMessage>(this, (message) =>
            {
                HistoryShowed = _localStorageService.Read(StorageConstants.HistoryShowed, true);
            });
        }
Esempio n. 3
0
        private async void InitializeAsync()
        {
            // Retrieve settings
            HistoryShowed      = _localStorageService.Read(StorageConstants.HistoryShowed, true);
            InstantTranslation = _localStorageService.Read(StorageConstants.InstantTranslation, true);

            // Handle network connection
            HandleNetworkConnection();

            // Create TranslationsCardItems list
            await CreateTranslationCardsAsync();

            if (InstantTranslation)
            {
                await StartNewTranslationAsync();
            }
        }
Esempio n. 4
0
        // Permission Toggles

        // User settings Toggles
        public bool ShowNewTranslationWidgetOnMainPage()
        {
            bool showNewTranslationWidgetOnMainPage = _localStorageService.Read(StorageConstants.ShowNewTranslationWidgetOnMainPage, false);

            var  translationSummaries = _roamingStorageService.Read <List <Models.TranslationSummary> >(StorageConstants.TranslationSummaries);
            bool hasNoTranslation     = translationSummaries == null;

            return(showNewTranslationWidgetOnMainPage && !hasNoTranslation);
        }
Esempio n. 5
0
        public SettingsViewModel(ILocalStorageService localStorageService, IRoamingStorageService roamingStorageService)
        {
            _localStorageService   = localStorageService;
            _roamingStorageService = roamingStorageService;

            SelectedTheme     = _localStorageService.Read(StorageConstants.SelectedTheme, Themes.First());
            InvertSuggestions = _localStorageService.Read(StorageConstants.InvertSuggestions, false);
            ShowNewTranslationWidgetOnMainPage = _localStorageService.Read(StorageConstants.ShowNewTranslationWidgetOnMainPage, false);
            EnableDropShadow   = _localStorageService.Read(StorageConstants.EnableDropShadow, false);
            HistoryShowed      = _localStorageService.Read(StorageConstants.HistoryShowed, true);
            InstantTranslation = _localStorageService.Read(StorageConstants.InstantTranslation, true);
        }