protected void SearchButton_Clicked(Layout rootLayout) { ContentPage page = rootLayout.Parent as ContentPage; if (SearchLayout != null) { if (SearchLayout.IsVisible && SearchLayout.Opacity > 0) { return; // Also impoertant as State attribute } if (SearchButton.State == (SearchPanelState.Hidden | SearchPanelState.InSearch)) // Clean { (rootLayout.Parent as ContentPage).Title = this.DefaultTitle; searchEntry.Text = ""; var animate_in = new Animation(v => listView.Scale = v, 1, 0.9); // анимация scale для listView listView.Animate("list_in", animate_in, finished: (v, b) => { var animate_out = new Animation(_v => listView.Scale = _v, 0.9, 1); listView.Animate("list_out", animate_out, finished: (_v, _b) => { }); }); } else if (SearchButton.State == SearchPanelState.Hidden) // Show cleaned { this.PreventAnimation(); if (SearchLayout.IsVisible = !SearchLayout.IsVisible) // true { var searchFrame = SearchLayout.Children.FirstOrDefault() as Frame; if (animeted) { void FinishAction() => searchEntry?.Focus(); // Action FinishAction = () => searchFrame?.Content?.Focus(); SmoothAppearance(page.Width, FinishAction); } else { searchFrame?.Content?.Focus(); } // (rootLayout.Parent as ContentPage).Title = "Диалоги"; // searchEntry.Text = ""; } } SearchButton.StateUpdate(); } else { SearchButton.SearchLayout = SearchLayout = SearchLayoutCreation(rootLayout, page.Width); SearchButton.StateUpdate(); } }
private void SearchEntry_Focused(object sender, FocusEventArgs e) { if (e.IsFocused) { // для чего это условие?: // if (itemSource != null && listView.ItemsSource != itemSource) listView.ItemsSource = itemSource; bottomView.IsVisible = false; // I can do it by click: SearchButton.StateUpdate(); if (SearchLayout.Opacity < 0.4 && SearchLayout.Opacity > 0.2) { SmoothAppearance(PageWidth); } } else // close all { var offTime = 150; SearchButton.State = SearchPanelState.Hidden; if (string.IsNullOrEmpty(searchEntry.Text) == false) { // SearchButton.State |= SearchPanelState.InSearch; } StateByUnFocused = true; Utils.CallAfter(offTime, () => { // SearchButton.StateUpdate(hideIntent); if (animeted) { SmoothHide(animateLong, () => { SearchLayout.IsVisible = false; SearchButton.Icon = new FileImageSource { File = SearchToolbarButton.Icons[SearchButton.State] }; StateByUnFocused = false; }); } else { SearchLayout.IsVisible = false; if (listView.Parent is AbsoluteLayout) { AbsoluteLayout.SetLayoutBounds(listView, new Rectangle(0, 0, 1, 0.9)); } } }); Utils.CallAfter(offTime + 150, () => bottomView.IsVisible = true); } /* * if (SearchButton.State == (SearchPanelState.Hidden | SearchPanelState.InSearch)) * { * * (SearchButton.ContentLayout.Parent as ContentPage).Title = "Диалоги"; * searchEntry.Text = ""; * * var animate_in = new Animation(v => listView.Scale = v, 1, 0.9); // анимация scale для listView * listView.Animate("list_in", animate_in, finished: (v, b) => * { * var animate_out = new Animation(_v => listView.Scale = _v, 0.9, 1); * listView.Animate("list_out", animate_out, finished: (_v, _b) => { }); * }); * } * //*/ }