@@ -54,6 +54,7 @@ void OnImageButtonClicked(object? sender, EventArgs e)
5454 var glyph = glyphs . FirstOrDefault ( x => x . Value == fontImageSource . Glyph ) ;
5555 Debug . WriteLine ( $ "ImageButton clicked with Glyph: { glyph . Key } ") ;
5656 selectedIcon . Text = $ "The selected icon is { glyph . Key } .";
57+ // searchBar.Text = glyph.Key;
5758 selectedFontIcon = new PxFontIcon { FontFamily = selectedFontFamilyName , Glyph = glyph . Value } ;
5859 if ( selectedFontImageSource != null )
5960 {
@@ -68,9 +69,13 @@ void OnImageButtonClicked(object? sender, EventArgs e)
6869 }
6970 }
7071
71- async Task LoadIcons ( )
72+ async Task LoadIcons ( string keyword = "" )
7273 {
7374 glyphs = FontData . GetGlyphs ( selectedFontFamilyType ) ;
75+ if ( ! string . IsNullOrEmpty ( keyword ) )
76+ {
77+ glyphs = glyphs . Where ( x => x . Key . Contains ( keyword ) ) . OrderBy ( x => x . Key ) . ToDictionary ( x => x . Key , x => x . Value ) ;
78+ }
7479
7580 await Task . Run ( async ( ) =>
7681 {
@@ -117,4 +122,11 @@ private async void OnSaveClicked(object sender, EventArgs e)
117122 updateIcon ? . Invoke ( selectedFontIcon ) ;
118123 _ = await Shell . Current . Navigation . PopAsync ( ) ;
119124 }
125+
126+ void OnSearchButtonPressed ( object sender , EventArgs e )
127+ {
128+ SearchBar searchBar = ( SearchBar ) sender ;
129+ flexLayout . Children . Clear ( ) ;
130+ LoadIcons ( searchBar . Text ) ;
131+ }
120132}
0 commit comments