Skip to content

Commit f99f227

Browse files
Implemented Title FontAttributes
1 parent 6eb4472 commit f99f227

File tree

8 files changed

+59
-18
lines changed

8 files changed

+59
-18
lines changed

src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.get -> Microsoft.Maui.SafeArea
3030
Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.set -> void
3131
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.get -> bool
3232
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.set -> void
33+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.get -> Microsoft.Maui.Controls.FontAttributes
34+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.set -> void
35+
static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty!
3336
~Microsoft.Maui.Controls.ContentPresenter.Children.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Maui.Controls.Element>
3437
~Microsoft.Maui.Controls.ContentPresenter.LowerChild(Microsoft.Maui.Controls.View view) -> void
3538
Microsoft.Maui.Controls.ContentPresenter.Padding.get -> Microsoft.Maui.Thickness

src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.set -> void
3737
~Microsoft.Maui.Controls.ContentPresenter.LowerChild(Microsoft.Maui.Controls.View view) -> void
3838
Microsoft.Maui.Controls.ContentPresenter.Padding.get -> Microsoft.Maui.Thickness
3939
Microsoft.Maui.Controls.ContentPresenter.Padding.set -> void
40+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.get -> Microsoft.Maui.Controls.FontAttributes
41+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.set -> void
42+
static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty!
4043
~Microsoft.Maui.Controls.ContentPresenter.RaiseChild(Microsoft.Maui.Controls.View view) -> void
4144
Microsoft.Maui.Controls.ContentPresenter.UpdateChildrenLayout() -> void
4245
Microsoft.Maui.Controls.ContentView.SafeAreaEdges.get -> Microsoft.Maui.SafeAreaEdges

src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.get -> Microsoft.Maui.SafeArea
3333
Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.set -> void
3434
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.get -> bool
3535
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.set -> void
36+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.get -> Microsoft.Maui.Controls.FontAttributes
37+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.set -> void
38+
static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty!
3639
~Microsoft.Maui.Controls.ContentPresenter.Children.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Maui.Controls.Element>
3740
~Microsoft.Maui.Controls.ContentPresenter.LowerChild(Microsoft.Maui.Controls.View view) -> void
3841
Microsoft.Maui.Controls.ContentPresenter.Padding.get -> Microsoft.Maui.Thickness

src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Microsoft.Maui.Controls.ILineHeightElement.OnLineHeightChanged(double oldValue,
3434
*REMOVED*Microsoft.Maui.Controls.IMessagingCenter
3535
Microsoft.Maui.Controls.SearchHandler.HideSoftInputAsync() -> void
3636
Microsoft.Maui.Controls.SearchHandler.ShowSoftInputAsync() -> void
37+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.get -> Microsoft.Maui.Controls.FontAttributes
38+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.set -> void
39+
static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty!
3740
*REMOVED*~Microsoft.Maui.Controls.IMessagingCenter.Send<TSender, TArgs>(TSender sender, string message, TArgs args) -> void
3841
*REMOVED*~Microsoft.Maui.Controls.IMessagingCenter.Send<TSender>(TSender sender, string message) -> void
3942
*REMOVED*~Microsoft.Maui.Controls.IMessagingCenter.Subscribe<TSender, TArgs>(object subscriber, string message, System.Action<TSender, TArgs> callback, TSender source = null) -> void

src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.get -> Microsoft.Maui.SafeArea
3030
Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.set -> void
3131
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.get -> bool
3232
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.set -> void
33+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.get -> Microsoft.Maui.Controls.FontAttributes
34+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.set -> void
35+
static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty!
3336
~Microsoft.Maui.Controls.ContentPresenter.Children.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Maui.Controls.Element>
3437
~Microsoft.Maui.Controls.ContentPresenter.LowerChild(Microsoft.Maui.Controls.View view) -> void
3538
Microsoft.Maui.Controls.ContentPresenter.Padding.get -> Microsoft.Maui.Thickness

src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.get -> Microsoft.Maui.SafeArea
3030
Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.set -> void
3131
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.get -> bool
3232
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.set -> void
33+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.get -> Microsoft.Maui.Controls.FontAttributes
34+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.set -> void
35+
static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty!
3336
~Microsoft.Maui.Controls.ContentPresenter.Children.get -> System.Collections.Generic.IReadOnlyList<Microsoft.Maui.Controls.Element>
3437
~Microsoft.Maui.Controls.ContentPresenter.LowerChild(Microsoft.Maui.Controls.View view) -> void
3538
Microsoft.Maui.Controls.ContentPresenter.Padding.get -> Microsoft.Maui.Thickness

src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.get -> Microsoft.Maui.SafeArea
3030
Microsoft.Maui.Controls.ContentPage.SafeAreaEdges.set -> void
3131
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.get -> bool
3232
Microsoft.Maui.Controls.ContentPresenter.CascadeInputTransparent.set -> void
33+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.get -> Microsoft.Maui.Controls.FontAttributes
34+
Microsoft.Maui.Controls.TitleBar.TitleFontAttributes.set -> void
35+
static readonly Microsoft.Maui.Controls.TitleBar.TitleFontAttributesProperty -> Microsoft.Maui.Controls.BindableProperty!
3336
override Microsoft.Maui.Controls.CheckBox.IsEnabledCore.get -> bool
3437
~Microsoft.Maui.Controls.CheckBox.Command.get -> System.Windows.Input.ICommand
3538
~Microsoft.Maui.Controls.CheckBox.Command.set -> void

src/Controls/src/Core/TitleBar/TitleBar.cs

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,84 +71,89 @@ public partial class TitleBar : TemplatedView, ITitleBar, ISafeAreaView
7171
public static readonly BindableProperty ForegroundColorProperty = BindableProperty.Create(nameof(ForegroundColor),
7272
typeof(Color), typeof(TitleBar));
7373

74+
/// <summary>Bindable property for <see cref="TitleFontAttributes"/>.</summary>
75+
public static readonly BindableProperty TitleFontAttributesProperty =
76+
BindableProperty.Create(nameof(TitleFontAttributes), typeof(FontAttributes),
77+
typeof(TitleBar), FontAttributes.Bold);
78+
7479
static void OnLeadingChanged(BindableObject bindable, object oldValue, object newValue)
7580
{
76-
var titlebar = (TitleBar)bindable;
81+
var titleBar = (TitleBar)bindable;
7782
if (newValue is null)
7883
{
79-
titlebar.ApplyVisibleState(LeadingHiddenState);
84+
titleBar.ApplyVisibleState(LeadingHiddenState);
8085
}
8186
else
8287
{
83-
titlebar.ApplyVisibleState(LeadingVisibleState);
88+
titleBar.ApplyVisibleState(LeadingVisibleState);
8489
(newValue as Layout)?.IgnoreLayoutSafeArea();
8590
}
8691
}
8792

8893
static void OnIconChanged(BindableObject bindable, object oldValue, object newValue)
8994
{
90-
var titlebar = (TitleBar)bindable;
95+
var titleBar = (TitleBar)bindable;
9196
var imageSource = newValue as ImageSource;
9297
if (imageSource is null || imageSource.IsEmpty)
9398
{
94-
titlebar.ApplyVisibleState(IconHiddenState);
99+
titleBar.ApplyVisibleState(IconHiddenState);
95100
}
96101
else
97102
{
98-
titlebar.ApplyVisibleState(IconVisibleState);
103+
titleBar.ApplyVisibleState(IconVisibleState);
99104
}
100105
}
101106

102107
static void OnTitleChanged(BindableObject bindable, object oldValue, object newValue)
103108
{
104-
var titlebar = (TitleBar)bindable;
109+
var titleBar = (TitleBar)bindable;
105110
if (newValue is null)
106111
{
107-
titlebar.ApplyVisibleState(TitleHiddenState);
112+
titleBar.ApplyVisibleState(TitleHiddenState);
108113
}
109114
else
110115
{
111-
titlebar.ApplyVisibleState(TitleVisibleState);
116+
titleBar.ApplyVisibleState(TitleVisibleState);
112117
}
113118
}
114119

115120
static void OnSubtitleChanged(BindableObject bindable, object oldValue, object newValue)
116121
{
117-
var titlebar = (TitleBar)bindable;
122+
var titleBar = (TitleBar)bindable;
118123
if (newValue is null)
119124
{
120-
titlebar.ApplyVisibleState(SubtitleHiddenState);
125+
titleBar.ApplyVisibleState(SubtitleHiddenState);
121126
}
122127
else
123128
{
124-
titlebar.ApplyVisibleState(SubtitleVisibleState);
129+
titleBar.ApplyVisibleState(SubtitleVisibleState);
125130
}
126131
}
127132

128133
static void OnContentChanged(BindableObject bindable, object oldValue, object newValue)
129134
{
130-
var titlebar = (TitleBar)bindable;
135+
var titleBar = (TitleBar)bindable;
131136
if (newValue is null)
132137
{
133-
titlebar.ApplyVisibleState(ContentHiddenState);
138+
titleBar.ApplyVisibleState(ContentHiddenState);
134139
}
135140
else
136141
{
137-
titlebar.ApplyVisibleState(ContentVisibleState);
142+
titleBar.ApplyVisibleState(ContentVisibleState);
138143
(newValue as Layout)?.IgnoreLayoutSafeArea();
139144
}
140145
}
141146

142147
static void OnTrailingContentChanged(BindableObject bindable, object oldValue, object newValue)
143148
{
144-
var titlebar = (TitleBar)bindable;
149+
var titleBar = (TitleBar)bindable;
145150
if (newValue is null)
146151
{
147-
titlebar.ApplyVisibleState(TrailingHiddenState);
152+
titleBar.ApplyVisibleState(TrailingHiddenState);
148153
}
149154
else
150155
{
151-
titlebar.ApplyVisibleState(TrailingVisibleState);
156+
titleBar.ApplyVisibleState(TrailingVisibleState);
152157
(newValue as Layout)?.IgnoreLayoutSafeArea();
153158
}
154159
}
@@ -236,6 +241,16 @@ public Color ForegroundColor
236241
set { SetValue(ForegroundColorProperty, value); }
237242
}
238243

244+
/// <summary>
245+
/// Gets or sets the <see cref="FontAttributes"/> applied to the title text.
246+
/// Defaults to <see cref="FontAttributes.Bold"/>.
247+
/// </summary>
248+
public FontAttributes TitleFontAttributes
249+
{
250+
get => (FontAttributes)GetValue(TitleFontAttributesProperty);
251+
set => SetValue(TitleFontAttributesProperty, value);
252+
}
253+
239254
/// <inheritdoc/>
240255
public IList<IView> PassthroughElements { get; private set; }
241256

@@ -451,6 +466,11 @@ static View BuildDefaultTemplate()
451466
static (TitleBar tb) => tb.ForegroundColor,
452467
source: RelativeBindingSource.TemplatedParent);
453468

469+
titleLabel.SetBinding(
470+
Label.FontAttributesProperty,
471+
static (TitleBar tb) => tb.TitleFontAttributes,
472+
source: RelativeBindingSource.TemplatedParent);
473+
454474
var activeVisualState = new VisualState() { Name = TitleBarActiveState };
455475
activeVisualState.Setters.Add(
456476
new Setter()

0 commit comments

Comments
 (0)