Exemple #1
0
        private void ShowSearchView(ISearchableViewModel searchableViewModel)
        {
            MainActivity.TitleTextView.Visibility = ViewStates.Gone;

            var searchView = MainActivity.SearchView;

            searchView.Visibility = ViewStates.Visible;

            searchView.QueryHint = searchableViewModel.PlaceholderText;

            _searchTextChanged = searchableViewModel
                                 .Changed(() => searchableViewModel.SearchText)
                                 .Subscribe(searchText => searchView.SetQuery(searchText, false));

            _searchViewQueryChanged              = Observable.FromEventPattern <EventHandler <QueryTextChangeEventArgs>, QueryTextChangeEventArgs>(
                e => searchView.QueryTextChange += e,
                e => searchView.QueryTextChange -= e)
                                                   .Subscribe(ep => searchableViewModel.SearchText = ep.EventArgs.NewText);

            searchableViewModel.SearchText = string.Empty;

            searchView.RequestFocus();
            InputMethodManager imm = (InputMethodManager)MainActivity.GetSystemService(Context.InputMethodService);

            imm.ShowSoftInput(searchView, ShowFlags.Implicit);
        }
Exemple #2
0
        public NavigationBarSearchTextField(CGRect cgRect, ISearchableViewModel viewModel) : base(cgRect)
        {
            ViewModel = viewModel;
            _loadingActivatyIndacator = GetLocationsLoadActivityIndacator();
            var backButton = GetBackButton();

            LeftViewMode  = UITextFieldViewMode.Always;
            RightViewMode = UITextFieldViewMode.Always;
            LeftView      = backButton;

            BorderStyle = UITextBorderStyle.None;
            this.RoundCorners(UIRectCorner.AllCorners, 5);
            BackgroundColor = UIColor.White;

            ClearButtonMode = UITextFieldViewMode.WhileEditing;
            MinimumFontSize = 12;
            Font            = UIFont.SystemFontOfSize(12, UIFontWeight.Regular);
            Placeholder     = ViewModel.PlaceholderText;

            this.SetBinding(() => Text, () => ViewModel.SearchText, BindingMode.TwoWay);
            this.SetBinding(() => IsLoading, () => ViewModel.IsSearching, BindingMode.TwoWay);
            this.BindCommand(backButton, ViewModel.GoBack);
        }
Exemple #3
0
        public static NavigationBarSearchTextField CreateSearchViewOnNavigationBar(this UIViewController viewController, ISearchableViewModel vm)
        {
            var navigationBar = ((UINavigationController)UIApplication.SharedApplication.KeyWindow.RootViewController).NavigationBar;

            viewController.EdgesForExtendedLayout         = UIRectEdge.None;
            viewController.NavigationItem.HidesBackButton = true;

            var frame           = new CGRect(0, 0, navigationBar.Frame.Size.Width - 20, 40);
            var searchTextField = new NavigationBarSearchTextField(frame, vm);

            viewController.NavigationItem.TitleView = searchTextField;
            searchTextField.BecomeFirstResponder();

            return(searchTextField);
        }