Skip to content

Commit 9a999fe

Browse files
authored
Scale loading bar text when island is super small (#14680)
* Scale loading bar text when island is super small * Change files
1 parent a9cc603 commit 9a999fe

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Scale loading bar text when island is super small",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ constexpr float loadingActivitySize = 12.0f;
4343
constexpr float loadingActivityHorizontalOffset = 16.0f;
4444
constexpr float loadingBarHeight = 36.0f;
4545
constexpr float loadingBarFontSize = 20.0f;
46+
constexpr float loadingBarMinFontSize = 8.0f;
4647
constexpr float loadingTextHorizontalOffset = 48.0f;
4748

4849
//! This class ensures that we access ReactRootView from UI thread.
@@ -611,6 +612,14 @@ facebook::react::AttributedStringBox CreateLoadingAttributedString() noexcept {
611612
return facebook::react::AttributedStringBox{attributedString};
612613
}
613614

615+
facebook::react::ParagraphAttributes CreateLoadingParagraphAttributes() noexcept {
616+
facebook::react::ParagraphAttributes pa;
617+
pa.adjustsFontSizeToFit = true;
618+
pa.minimumFontSize = loadingBarMinFontSize;
619+
pa.maximumFontSize = loadingBarFontSize;
620+
return pa;
621+
}
622+
614623
facebook::react::Size ReactNativeIsland::MeasureLoading(
615624
const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints) const noexcept {
616625
facebook::react::LayoutConstraints fbLayoutConstraints;
@@ -619,7 +628,7 @@ facebook::react::Size ReactNativeIsland::MeasureLoading(
619628
auto attributedStringBox = CreateLoadingAttributedString();
620629
winrt::com_ptr<::IDWriteTextLayout> textLayout;
621630
facebook::react::TextLayoutManager::GetTextLayout(
622-
attributedStringBox, {} /*paragraphAttributes*/, fbLayoutConstraints, textLayout);
631+
attributedStringBox, CreateLoadingParagraphAttributes(), fbLayoutConstraints, textLayout);
623632

624633
DWRITE_TEXT_METRICS tm;
625634
winrt::check_hresult(textLayout->GetMetrics(&tm));
@@ -701,7 +710,7 @@ Composition::Experimental::IDrawingSurfaceBrush ReactNativeIsland::CreateLoading
701710

702711
winrt::com_ptr<::IDWriteTextLayout> textLayout;
703712
facebook::react::TextLayoutManager::GetTextLayout(
704-
attributedStringBox, {} /*paragraphAttributes*/, constraints, textLayout);
713+
attributedStringBox, CreateLoadingParagraphAttributes(), constraints, textLayout);
705714

706715
DWRITE_TEXT_METRICS tm;
707716
textLayout->GetMetrics(&tm);

0 commit comments

Comments
 (0)