Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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);
Expand Down