コード例 #1
0
        public void OnTaskListAutoSuggestBoxTextChange(string currentText)
        {
            var filteredItems = string.IsNullOrEmpty(currentText)
                ? _mapper.Map <IEnumerable <ItemModel> >(TaskLists
                                                         .OrderBy(t => t.Title)
                                                         .Take(10))
                : _mapper.Map <IEnumerable <ItemModel> >(TaskLists
                                                         .Where(t => t.Title.ToLowerInvariant().Contains(currentText.ToLowerInvariant()))
                                                         .OrderBy(t => t.Title)
                                                         .Take(10));

            TaskListsAutoSuggestBoxItems.Clear();
            TaskListsAutoSuggestBoxItems.AddRange(filteredItems);
        }
コード例 #2
0
        private async Task InitViewAsync(bool onFullSync = false)
        {
            int selectedTaskListID;

            if (!onFullSync && _appSettings.RunSyncBackgroundTaskAfterStart)
            {
                _backgroundTaskManager.StartBackgroundTask(BackgroundTaskType.SYNC);
                return;
            }

            //If we have something in the init details, lets select that task list
            selectedTaskListID       = !onFullSync && InitDetails != null
                ? selectedTaskListID = InitDetails.Item1
                : selectedTaskListID = _appSettings.SelectedDbTaskListId;

            _messenger.Send(true, $"{MessageType.SHOW_CONTENT_FRAME_PROGRESS_RING}");

            SelectedItem        =
                CurrentTaskList = null;
            TaskLists.Clear();
            TaskListsAutoSuggestBoxItems.Clear();

            var dbResponse = await _dataService
                             .TaskListService
                             .GetAsNoTrackingAsync(
                tl => tl.User.IsActive && tl.LocalStatus != LocalStatus.DELETED,
                tl => tl.OrderBy(t => t.Title));

            if (!dbResponse.Succeed)
            {
                await _dialogService.ShowMessageDialogAsync(
                    "Error",
                    $"An unknown error occurred while trying to retrieve all the task lists from the db. Error = {dbResponse.Message}");

                return;
            }

            TaskLists.AddRange(_mapper.Map <IEnumerable <TaskListItemViewModel> >(dbResponse.Result));

            TaskListsAutoSuggestBoxItems.AddRange(_mapper.Map <IEnumerable <ItemModel> >(dbResponse.Result));

            SortTaskLists(_appSettings.DefaultTaskListSortOrder);

            _messenger.Send(false, $"{MessageType.SHOW_CONTENT_FRAME_PROGRESS_RING}");
            //The msg send by nav vm could take longer.. so lets way a litte bit
            //with that, the progress ring animation doesnt gets swallowed
            await Task.Delay(500);

            var taskList = TaskLists.Any(tl => tl.Id == selectedTaskListID)
                ? TaskLists.FirstOrDefault(tl => tl.Id == selectedTaskListID)
                : TaskLists.FirstOrDefault();

            SelectedItem = taskList;
            //For some reason OnNavigationViewSelectionChangeAsync is not getting called
            //if SelectedItem is null
            if (SelectedItem is null)
            {
                OnNavigationViewSelectionChangeAsync(SelectedItem);
            }
            else
            {
                _appSettings.SelectedDbTaskListId = taskList.Id;
            }
        }