@@ -12,34 +12,30 @@ namespace DIPS.Mobile.UI.Components.Pages.Search;
1212/// <summary>
1313/// A Material 3 search component for ContentPage using the actual
1414/// <see cref="MaterialSearchBar"/> and <see cref="MaterialSearchView"/> components.
15- /// The SearchBar provides the collapsed pill-shaped search trigger,
16- /// while the SearchView provides the expanded search input with EditText.
15+ /// The SearchBar provides the collapsed pill-shaped search trigger at the bottom,
16+ /// while the SearchView provides the full-screen expanded search mode.
17+ /// The SearchView is attached to the root decor view so it can properly
18+ /// overlay the entire page when activated.
1719/// </summary>
1820internal class PageSearchField : Java . Lang . Object , ITextWatcher , MaterialSearchView . ITransitionListener
1921{
2022 private readonly WeakReference < SearchBehavior > m_weakBehavior ;
2123 private MaterialSearchBar ? m_searchBar ;
2224 private MaterialSearchView ? m_searchView ;
23- private FrameLayout ? m_container ;
2425 private string m_previousText = string . Empty ;
2526
2627 public PageSearchField ( Context context , SearchBehavior behavior )
2728 {
2829 m_weakBehavior = new WeakReference < SearchBehavior > ( behavior ) ;
2930
30- m_container = new FrameLayout ( context ) ;
31- m_container . LayoutParameters = new Android . Widget . LinearLayout . LayoutParams (
32- ViewGroup . LayoutParams . MatchParent ,
33- ViewGroup . LayoutParams . WrapContent ) ;
34-
35- // Material 3 SearchBar (pill-shaped search trigger)
31+ // Material 3 SearchBar (pill-shaped search trigger) — placed at bottom of page
3632 m_searchBar = new MaterialSearchBar ( context ) ;
3733 m_searchBar . LayoutParameters = new FrameLayout . LayoutParams (
3834 ViewGroup . LayoutParams . MatchParent ,
3935 ViewGroup . LayoutParams . WrapContent ) ;
40- m_container . AddView ( m_searchBar ) ;
4136
42- // Material 3 SearchView (expanded search with EditText)
37+ // Material 3 SearchView (full-screen expanded search mode)
38+ // Added to root decor view so it overlays the entire page
4339 m_searchView = new MaterialSearchView ( context ) ;
4440 m_searchView . LayoutParameters = new FrameLayout . LayoutParams (
4541 ViewGroup . LayoutParams . MatchParent ,
@@ -53,11 +49,17 @@ public PageSearchField(Context context, SearchBehavior behavior)
5349
5450 // Listen for transition events (show/hide)
5551 m_searchView . AddTransitionListener ( this ) ;
56-
57- m_container . AddView ( m_searchView ) ;
5852 }
5953
60- public AView View => m_container ! ;
54+ /// <summary>
55+ /// The pill-shaped SearchBar to be placed at the bottom of the page.
56+ /// </summary>
57+ public AView SearchBarView => m_searchBar ! ;
58+
59+ /// <summary>
60+ /// The full-screen SearchView to be attached to the root decor view.
61+ /// </summary>
62+ public AView SearchViewView => m_searchView ! ;
6163
6264 public void Focus ( )
6365 {
@@ -107,9 +109,15 @@ public void Cleanup()
107109 m_searchView . RemoveTransitionListener ( this ) ;
108110 }
109111
110- m_container ? . RemoveAllViews ( ) ;
112+ // Remove SearchView from its parent (root decor view)
113+ if ( m_searchView ? . Parent is ViewGroup searchViewParent )
114+ searchViewParent . RemoveView ( m_searchView ) ;
115+
116+ // Remove SearchBar from its parent
117+ if ( m_searchBar ? . Parent is ViewGroup searchBarParent )
118+ searchBarParent . RemoveView ( m_searchBar ) ;
119+
111120 m_searchBar = null ;
112121 m_searchView = null ;
113- m_container = null ;
114122 }
115123}
0 commit comments