Skip to content

Commit 475cd3f

Browse files
committed
Improved IconsPage
1 parent 782c42b commit 475cd3f

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

PassXYZ.Vault/Views/IconsPage.xaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
</ToolbarItem>
2626
</ContentPage.ToolbarItems>
2727

28-
<Grid RowDefinitions="Auto,*">
29-
<HorizontalStackLayout Margin="20" Grid.Row="0">
30-
<Picker ItemsSource="{Binding FontFamilyNames}" SelectedItem="{Binding SelectedFontFamilyName}" />
28+
<Grid RowDefinitions="Auto,Auto,*">
29+
<Label x:Name="selectedIcon" Text="Please select a icon"
30+
HorizontalTextAlignment="Start"
31+
Margin="20" Grid.Row="0"/>
3132

32-
<Label x:Name="selectedIcon" Text="Please select a icon"
33-
HorizontalTextAlignment="Center"
34-
Margin="10"
35-
/>
33+
<Picker Margin="20" ItemsSource="{Binding FontFamilyNames}" SelectedItem="{Binding SelectedFontFamilyName}"
34+
HorizontalOptions="StartAndExpand" Grid.Row="1" />
3635

37-
</HorizontalStackLayout>
38-
39-
<ScrollView Grid.Row="1">
36+
<SearchBar Margin="20" x:Name="searchBar" SearchButtonPressed="OnSearchButtonPressed"
37+
WidthRequest="200" HorizontalOptions="EndAndExpand" Grid.Row="1" />
38+
39+
<ScrollView Grid.Row="2">
4040
<FlexLayout x:Name="flexLayout"
4141
Wrap="Wrap" JustifyContent="SpaceAround" />
4242
</ScrollView>

PassXYZ.Vault/Views/IconsPage.xaml.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)