From 5a6062f3c3543acda3c36ca4683cd8fc7fe86ba7 Mon Sep 17 00:00:00 2001
From: Federico Nembrini <25205086+FedericoNembrini@users.noreply.github.com>
Date: Mon, 14 Aug 2023 22:34:38 +0200
Subject: [PATCH] Fix tab view item font family (ios and uwp) (#1979)
---
.../XCT.Sample/Pages/TestCases/Issue1978.xaml | 30 +++++++++++++++++++
.../Pages/TestCases/Issue1978.xaml.cs | 13 ++++++++
.../TestCases/Issue1978ViewModel.cs | 9 ++++++
.../TestCases/TestCasesGalleryViewModel.cs | 7 ++++-
.../Xamarin.CommunityToolkit.Sample.csproj | 3 ++
.../CupertinoTabViewItemTemplate.shared.cs | 1 +
.../WindowsTabViewItemTemplate.shared.cs | 1 +
7 files changed, 63 insertions(+), 1 deletion(-)
create mode 100644 samples/XCT.Sample/Pages/TestCases/Issue1978.xaml
create mode 100644 samples/XCT.Sample/Pages/TestCases/Issue1978.xaml.cs
create mode 100644 samples/XCT.Sample/ViewModels/TestCases/Issue1978ViewModel.cs
diff --git a/samples/XCT.Sample/Pages/TestCases/Issue1978.xaml b/samples/XCT.Sample/Pages/TestCases/Issue1978.xaml
new file mode 100644
index 000000000..d6720565d
--- /dev/null
+++ b/samples/XCT.Sample/Pages/TestCases/Issue1978.xaml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/XCT.Sample/Pages/TestCases/Issue1978.xaml.cs b/samples/XCT.Sample/Pages/TestCases/Issue1978.xaml.cs
new file mode 100644
index 000000000..574a11d1d
--- /dev/null
+++ b/samples/XCT.Sample/Pages/TestCases/Issue1978.xaml.cs
@@ -0,0 +1,13 @@
+using Xamarin.Forms.Xaml;
+
+namespace Xamarin.CommunityToolkit.Sample.Pages.TestCases
+{
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ public partial class Issue1978Page : BasePage
+ {
+ public Issue1978Page()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/samples/XCT.Sample/ViewModels/TestCases/Issue1978ViewModel.cs b/samples/XCT.Sample/ViewModels/TestCases/Issue1978ViewModel.cs
new file mode 100644
index 000000000..68a363d74
--- /dev/null
+++ b/samples/XCT.Sample/ViewModels/TestCases/Issue1978ViewModel.cs
@@ -0,0 +1,9 @@
+namespace Xamarin.CommunityToolkit.Sample.ViewModels.TestCases
+{
+ public class Issue1978ViewModel : BaseViewModel
+ {
+ public Issue1978ViewModel()
+ {
+ }
+ }
+}
diff --git a/samples/XCT.Sample/ViewModels/TestCases/TestCasesGalleryViewModel.cs b/samples/XCT.Sample/ViewModels/TestCases/TestCasesGalleryViewModel.cs
index 06d08e146..c750b71e7 100644
--- a/samples/XCT.Sample/ViewModels/TestCases/TestCasesGalleryViewModel.cs
+++ b/samples/XCT.Sample/ViewModels/TestCases/TestCasesGalleryViewModel.cs
@@ -63,7 +63,12 @@ protected override IEnumerable CreateItems() => new[]
new SectionModel(
typeof(Issue1900Page),
"BadgeView Issue GitHub #1900",
- "BadgeView default text")
+ "BadgeView default text"),
+
+ new SectionModel(
+ typeof(Issue1978Page),
+ "TabView Issue GitHub #1978",
+ "TabView font family")
};
}
}
\ No newline at end of file
diff --git a/samples/XCT.Sample/Xamarin.CommunityToolkit.Sample.csproj b/samples/XCT.Sample/Xamarin.CommunityToolkit.Sample.csproj
index 0170537df..ce299f1bc 100644
--- a/samples/XCT.Sample/Xamarin.CommunityToolkit.Sample.csproj
+++ b/samples/XCT.Sample/Xamarin.CommunityToolkit.Sample.csproj
@@ -32,6 +32,9 @@
MSBuild:UpdateDesignTimeXaml
+
+ MSBuild:UpdateDesignTimeXaml
+
MSBuild:UpdateDesignTimeXaml
diff --git a/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/TabView/CupertinoTabViewItemTemplate.shared.cs b/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/TabView/CupertinoTabViewItemTemplate.shared.cs
index 6482e2e87..8a356b7ef 100644
--- a/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/TabView/CupertinoTabViewItemTemplate.shared.cs
+++ b/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/TabView/CupertinoTabViewItemTemplate.shared.cs
@@ -69,6 +69,7 @@ protected override void OnParentSet()
text.SetBinding(Label.TextColorProperty, "CurrentTextColor");
text.SetBinding(Label.FontSizeProperty, "CurrentFontSize");
text.SetBinding(Label.FontAttributesProperty, "CurrentFontAttributes");
+ text.SetBinding(Label.FontFamilyProperty, "CurrentFontFamily");
badge.SetBinding(TabBadgeView.BackgroundColorProperty, "CurrentBadgeBackgroundColor");
badge.SetBinding(TabBadgeView.BorderColorProperty, "CurrentBadgeBorderColor");
diff --git a/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/TabView/WindowsTabViewItemTemplate.shared.cs b/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/TabView/WindowsTabViewItemTemplate.shared.cs
index a8f8e1845..507cc6f5b 100644
--- a/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/TabView/WindowsTabViewItemTemplate.shared.cs
+++ b/src/CommunityToolkit/Xamarin.CommunityToolkit/Views/TabView/WindowsTabViewItemTemplate.shared.cs
@@ -65,6 +65,7 @@ protected override void OnParentSet()
text.SetBinding(Label.TextColorProperty, "CurrentTextColor");
text.SetBinding(Label.FontSizeProperty, "CurrentFontSize");
text.SetBinding(Label.FontAttributesProperty, "CurrentFontAttributes");
+ text.SetBinding(Label.FontFamilyProperty, "CurrentFontFamily");
badge.SetBinding(TabBadgeView.BackgroundColorProperty, "CurrentBadgeBackgroundColor");
badge.SetBinding(TabBadgeView.TextProperty, "BadgeText");