From db2f4119757634c5b25910ac285fa3109788ba21 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Thu, 15 May 2025 13:32:56 -0700 Subject: [PATCH 1/2] Scale loading bar text when island is super small --- .../Fabric/Composition/ReactNativeIsland.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp index 3dce49c0146..0d4a7200a3e 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp @@ -43,6 +43,7 @@ constexpr float loadingActivitySize = 12.0f; constexpr float loadingActivityHorizontalOffset = 16.0f; constexpr float loadingBarHeight = 36.0f; constexpr float loadingBarFontSize = 20.0f; +constexpr float loadingBarMinFontSize = 8.0f; constexpr float loadingTextHorizontalOffset = 48.0f; //! This class ensures that we access ReactRootView from UI thread. @@ -611,6 +612,14 @@ facebook::react::AttributedStringBox CreateLoadingAttributedString() noexcept { return facebook::react::AttributedStringBox{attributedString}; } +facebook::react::ParagraphAttributes CreateLoadingParagraphAttributes() noexcept { + facebook::react::ParagraphAttributes pa; + pa.adjustsFontSizeToFit = true; + pa.minimumFontSize = loadingBarMinFontSize; + pa.maximumFontSize = loadingBarFontSize; + return pa; +} + facebook::react::Size ReactNativeIsland::MeasureLoading( const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints) const noexcept { facebook::react::LayoutConstraints fbLayoutConstraints; @@ -619,7 +628,7 @@ facebook::react::Size ReactNativeIsland::MeasureLoading( auto attributedStringBox = CreateLoadingAttributedString(); winrt::com_ptr<::IDWriteTextLayout> textLayout; facebook::react::TextLayoutManager::GetTextLayout( - attributedStringBox, {} /*paragraphAttributes*/, fbLayoutConstraints, textLayout); + attributedStringBox, CreateLoadingParagraphAttributes(), fbLayoutConstraints, textLayout); DWRITE_TEXT_METRICS tm; winrt::check_hresult(textLayout->GetMetrics(&tm)); @@ -701,7 +710,7 @@ Composition::Experimental::IDrawingSurfaceBrush ReactNativeIsland::CreateLoading winrt::com_ptr<::IDWriteTextLayout> textLayout; facebook::react::TextLayoutManager::GetTextLayout( - attributedStringBox, {} /*paragraphAttributes*/, constraints, textLayout); + attributedStringBox, CreateLoadingParagraphAttributes(), constraints, textLayout); DWRITE_TEXT_METRICS tm; textLayout->GetMetrics(&tm); From f0602381ba5bf3a9651fb40cd60e2277f8fb05a0 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Thu, 15 May 2025 13:33:02 -0700 Subject: [PATCH 2/2] Change files --- ...ative-windows-ffcbc2ee-7f53-4f81-b199-38248cc85503.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/react-native-windows-ffcbc2ee-7f53-4f81-b199-38248cc85503.json diff --git a/change/react-native-windows-ffcbc2ee-7f53-4f81-b199-38248cc85503.json b/change/react-native-windows-ffcbc2ee-7f53-4f81-b199-38248cc85503.json new file mode 100644 index 00000000000..3a8be5b1fe7 --- /dev/null +++ b/change/react-native-windows-ffcbc2ee-7f53-4f81-b199-38248cc85503.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Scale loading bar text when island is super small", + "packageName": "react-native-windows", + "email": "30809111+acoates-ms@users.noreply.github.com", + "dependentChangeType": "patch" +}