Skip to content

Commit

Permalink
Fix Similar name is provided for "Icons" Present (#26331)
Browse files Browse the repository at this point in the history
* accessibility support added for icons

* review changes added

* SelectedItem type modified

* UI issue fixed

* moved IconItem class under mode

* null value reverted

* IconItem class renamed

* file changes added
  • Loading branch information
devanathan-vaithiyanathan authored Dec 6, 2024
1 parent 096ae74 commit b387043
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
9 changes: 9 additions & 0 deletions src/Templates/src/templates/maui-mobile/Models/IconData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace MauiApp._1.Models;

public class IconData
{
public string? Icon { get; set; }
public string? Description { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ public partial class ProjectDetailPageModel : ObservableObject, IQueryAttributab
private List<Tag> _allTags = [];

[ObservableProperty]
private string _icon = FluentUI.ribbon_24_regular;
private IconData _icon;

[ObservableProperty]
bool _isBusy;

[ObservableProperty]
private List<string> _icons =
[
FluentUI.ribbon_24_regular,
FluentUI.ribbon_star_24_regular,
FluentUI.trophy_24_regular,
FluentUI.badge_24_regular,
FluentUI.book_24_regular,
FluentUI.people_24_regular,
FluentUI.bot_24_regular
];
private List<IconData> _icons = new List<IconData>
{
new IconData { Icon = FluentUI.ribbon_24_regular, Description = "Ribbon Icon" },
new IconData { Icon = FluentUI.ribbon_star_24_regular, Description = "Ribbon Star Icon" },
new IconData { Icon = FluentUI.trophy_24_regular, Description = "Trophy Icon" },
new IconData { Icon = FluentUI.badge_24_regular, Description = "Badge Icon" },
new IconData { Icon = FluentUI.book_24_regular, Description = "Book Icon" },
new IconData { Icon = FluentUI.people_24_regular, Description = "People Icon" },
new IconData { Icon = FluentUI.bot_24_regular, Description = "Bot Icon" }
};

public bool HasCompletedTasks
=> _project?.Tasks.Any(t => t.IsCompleted) ?? false;
Expand All @@ -62,7 +62,7 @@ public ProjectDetailPageModel(ProjectRepository projectRepository, TaskRepositor
_categoryRepository = categoryRepository;
_tagRepository = tagRepository;
_errorHandler = errorHandler;

_icon = _icons.First();
Tasks = [];
}

Expand Down Expand Up @@ -125,7 +125,7 @@ private async Task LoadData(int id)
Description = _project.Description;
Tasks = _project.Tasks;

Icon = _project.Icon;
Icon.Icon = _project.Icon;

Categories = await _categoryRepository.ListAsync();
Category = Categories?.FirstOrDefault(c => c.ID == _project.CategoryID);
Expand Down Expand Up @@ -171,7 +171,7 @@ private async Task Save()
_project.Name = Name;
_project.Description = Description;
_project.CategoryID = Category?.ID ?? 0;
_project.Icon = Icon ?? FluentUI.ribbon_24_regular;
_project.Icon = Icon.Icon ?? FluentUI.ribbon_24_regular;
await _projectRepository.SaveItemAsync(_project);

if (_project.IsNullOrNew())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
SelectedItem="{Binding Icon}"
ItemsSource="{Binding Icons}">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<DataTemplate x:DataType="models:IconData">
<Grid RowDefinitions="Auto,4" RowSpacing="{StaticResource size60}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
Expand All @@ -115,12 +115,14 @@
</VisualStateManager.VisualStateGroups>

<Label
Text="{Binding .}"
Text="{Binding Icon}"
x:Name="IconImage"
FontFamily="{x:Static fonts:FluentUI.FontFamily}"
FontSize="24"
VerticalOptions="Center"
HorizontalOptions="Center"
SemanticProperties.Description="{Binding Description}"
SemanticProperties.Hint="Icon representing the type of task . Tap to select"
TextColor="{AppThemeBinding Light={StaticResource DarkOnLightBackground},Dark={StaticResource LightOnDarkBackground}}"/>
<BoxView x:Name="SelectedIndicator" Color="{StaticResource Primary}" HeightRequest="4" HorizontalOptions="Fill" Grid.Row="1"/>
</Grid>
Expand Down

0 comments on commit b387043

Please sign in to comment.