Skip to content

Commit

Permalink
feat: add insets to windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jpudysz committed Feb 14, 2024
1 parent 46e6f1b commit 8831626
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions windows/ReactNativeUnistyles/ReactNativeUnistyles.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct Unistyles {
auto bounds = Window::Current().Bounds();

if (this->unistylesRuntime != nullptr) {
((UnistylesRuntime*)this->unistylesRuntime)->handleScreenSizeChange((int)bounds.Width, (int)bounds.Height);
((UnistylesRuntime*)this->unistylesRuntime)->handleScreenSizeChange((int)bounds.Width, (int)bounds.Height, this.getInsets(), this.getStatusBarDimensions());
}
}));

Expand Down Expand Up @@ -94,7 +94,9 @@ struct Unistyles {
uiInfo.screenWidth,
uiInfo.screenHeight,
uiInfo.colorScheme,
uiInfo.contentSizeCategory
uiInfo.contentSizeCategory,
this->getInsets(),
this->getStatusBarDimensions()
);

unistylesRuntime->onThemeChange([this](std::string theme) {
Expand Down Expand Up @@ -192,6 +194,26 @@ struct Unistyles {

return UnistylesUnspecifiedScheme;
}

std::map<std::string, int>getInsets() {
std::map<std::string, int> insets;

insets.insert({ "top", 0 });
insets.insert({ "bottom", 0 });
insets.insert({ "left", 0 });
insets.insert({ "right", 0 });

return insets;
}

std::map<std::string, int>getStatusBarDimensions() {
std::map<std::string, int> statusBar;

statusBar.insert({ "height", 0 });
statusBar.insert({ "width", 0 });

return statusBar;
}
};

} // namespace winrt::ReactNativeUnistyles

0 comments on commit 8831626

Please sign in to comment.