Skip to content

Commit c94a0e1

Browse files
Merge branch 'develop'
2 parents 27ab5ae + 115efed commit c94a0e1

4 files changed

Lines changed: 57 additions & 9 deletions

File tree

nuget.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup Condition=" $(MSBuildProjectName.Equals('HorusStudio.Maui.MaterialDesignControls')) ">
33
<PackageId>HorusStudio.Maui.MaterialDesignControls</PackageId>
4-
<Version>10.0.0</Version>
4+
<Version>10.0.1</Version>
55
<Authors>Horus Studio and contributors</Authors>
66
<Company>Horus Studio</Company>
77
<Title>Material Design Controls for .NET MAUI</Title>
@@ -15,7 +15,7 @@
1515
<PackageTags>dotnet-maui;dotnet;maui;cross-platform;android;ios;macos;maccatalyst;materialdesign;ui</PackageTags>
1616
<PackageReadmeFile>README.md</PackageReadmeFile>
1717
<PackageReleaseNotes>
18-
- Add net10.0 support
18+
- Add independent LabelColor support for NavigationDrawer items
1919
</PackageReleaseNotes>
2020
<PackageOutputPath>$(MSBuildThisFileDirectory)Artifacts</PackageOutputPath>
2121
<EscapedCurrentDirectory>$([System.Text.RegularExpressions.Regex]::Escape('$(MSBuildThisFileDirectory)'))</EscapedCurrentDirectory>

samples/HorusStudio.Maui.MaterialDesignControls.Sample/ViewModels/NavigationDrawerViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ private void LoadItems(bool includeAllItems)
9999
SelectedLeadingIcon = "trash.png",
100100
LeadingIcon = "trash.png",
101101
Text = "Trash",
102+
LabelColor = Colors.Red,
103+
ActiveIndicatorLabelColor = Colors.Red
102104
},
103105
new()
104106
{

src/HorusStudio.Maui.MaterialDesignControls/Controls/NavigationDrawer/MaterialNavigationDrawer.cs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,15 +1155,25 @@ private void SetLabelTextColorPropertyBindings(MaterialLabel label, MaterialNavi
11551155
new Binding(nameof(item.IsSelected), source: item),
11561156
new Binding(nameof(ActiveIndicatorLabelColor), source: this),
11571157
new Binding(nameof(LabelColor), source: this),
1158-
new Binding(nameof(DisabledLabelColor), source: this)
1158+
new Binding(nameof(DisabledLabelColor), source: this),
1159+
new Binding(nameof(item.LabelColor), source: item),
1160+
new Binding(nameof(item.ActiveIndicatorLabelColor), source: item)
11591161
},
11601162
Converter = new MultiValueConverter((values, targetType, parameter, culture) =>
11611163
{
11621164
var isEnabled = (bool)values[0];
11631165
var isSelected = (bool)values[1];
1164-
var activeIndicatorLabelColor = (Color)values[2];
1165-
var labelColor = (Color)values[3];
1166+
var drawerActiveIndicatorLabelColor = (Color)values[2];
1167+
var drawerLabelColor = (Color)values[3];
11661168
var disabledLabelColor = (Color)values[4];
1169+
var itemLabelColor = (Color?)values[5];
1170+
var itemActiveIndicatorLabelColor = (Color?)values[6];
1171+
1172+
// If item has its own LabelColor, use it instead of drawer's LabelColor
1173+
var labelColor = itemLabelColor ?? drawerLabelColor;
1174+
1175+
// If item has its own ActiveIndicatorLabelColor, use it instead of drawer's ActiveIndicatorLabelColor
1176+
var activeIndicatorLabelColor = itemActiveIndicatorLabelColor ?? drawerActiveIndicatorLabelColor;
11671177

11681178
return isEnabled ? (isSelected ? activeIndicatorLabelColor : labelColor) : disabledLabelColor;
11691179
})
@@ -1177,16 +1187,30 @@ private void SetIconTintColorPropertyBindings(IconTintColorBehavior iconTintColo
11771187
Bindings = new Collection<BindingBase>
11781188
{
11791189
new Binding(nameof(item.IsEnabled), source: item),
1190+
new Binding(nameof(item.IsSelected), source: item),
1191+
new Binding(nameof(ActiveIndicatorLabelColor), source: this),
11801192
new Binding(nameof(LabelColor), source: this),
1181-
new Binding(nameof(DisabledLabelColor), source: this)
1193+
new Binding(nameof(DisabledLabelColor), source: this),
1194+
new Binding(nameof(item.LabelColor), source: item),
1195+
new Binding(nameof(item.ActiveIndicatorLabelColor), source: item)
11821196
},
11831197
Converter = new MultiValueConverter((values, targetType, parameter, culture) =>
11841198
{
11851199
var isEnabled = (bool)values[0];
1186-
var labelColor = (Color)values[1];
1187-
var disabledLabelColor = (Color)values[2];
1200+
var isSelected = (bool)values[1];
1201+
var drawerActiveIndicatorLabelColor = (Color)values[2];
1202+
var drawerLabelColor = (Color)values[3];
1203+
var disabledLabelColor = (Color)values[4];
1204+
var itemLabelColor = (Color?)values[5];
1205+
var itemActiveIndicatorLabelColor = (Color?)values[6];
1206+
1207+
// If item has its own LabelColor, use it instead of drawer's LabelColor
1208+
var labelColor = itemLabelColor ?? drawerLabelColor;
1209+
1210+
// If item has its own ActiveIndicatorLabelColor, use it instead of drawer's ActiveIndicatorLabelColor
1211+
var activeIndicatorLabelColor = itemActiveIndicatorLabelColor ?? drawerActiveIndicatorLabelColor;
11881212

1189-
return isEnabled ? labelColor : disabledLabelColor;
1213+
return isEnabled ? (isSelected ? activeIndicatorLabelColor : labelColor) : disabledLabelColor;
11901214
})
11911215
});
11921216
}

src/HorusStudio.Maui.MaterialDesignControls/Controls/NavigationDrawer/MaterialNavigationDrawerItem.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class MaterialNavigationDrawerItem : INotifyPropertyChanged
2222
private bool _isSelected;
2323
private bool _isEnabled = true;
2424
private string _automationId = null!;
25+
private Color? _labelColor;
26+
private Color? _activeIndicatorLabelColor;
2527

2628
#endregion Attributes
2729

@@ -149,6 +151,26 @@ public string AutomationId
149151
set => SetProperty(ref _automationId, value);
150152
}
151153

154+
/// <summary>
155+
/// Gets or sets the label color for this item. If null, falls back to the MaterialNavigationDrawer's LabelColor.
156+
/// This color is also applied to the leading and trailing icons when ApplyLeadingIconTintColor or ApplyTrailingIconTintColor is true.
157+
/// </summary>
158+
public Color? LabelColor
159+
{
160+
get => _labelColor;
161+
set => SetProperty(ref _labelColor, value);
162+
}
163+
164+
/// <summary>
165+
/// Gets or sets the active indicator label color for this item when selected. If null, falls back to the MaterialNavigationDrawer's ActiveIndicatorLabelColor.
166+
/// This color is also applied to the leading and trailing icons when the item is selected and ApplyLeadingIconTintColor or ApplyTrailingIconTintColor is true.
167+
/// </summary>
168+
public Color? ActiveIndicatorLabelColor
169+
{
170+
get => _activeIndicatorLabelColor;
171+
set => SetProperty(ref _activeIndicatorLabelColor, value);
172+
}
173+
152174
/// <inheritdoc />
153175
public event PropertyChangedEventHandler? PropertyChanged;
154176

0 commit comments

Comments
 (0)