react-native-true-sheet/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.h
Jovanni Lo 248b64de25
feat: move Fabric state wrapper to host view (#230)
* feat: move state wrapper from container view to host view

* fix(ios): call updateStateIfNeeded on every state update

* fix(ios): handle device rotation and only track width changes

* feat(android): align state update flow with iOS

* chore: improve clean script with colors
2025-11-26 03:32:22 +08:00

43 lines
960 B
C++

#pragma once
#include <memory>
#ifdef ANDROID
#include <folly/dynamic.h>
#include <react/renderer/mapbuffer/MapBuffer.h>
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
#endif
namespace facebook::react {
/*
* State for <TrueSheetView> component.
* Contains the container dimensions from native.
*/
class TrueSheetViewState final {
public:
using Shared = std::shared_ptr<const TrueSheetViewState>;
TrueSheetViewState() = default;
#ifdef ANDROID
TrueSheetViewState(
TrueSheetViewState const &previousState,
folly::dynamic data)
: containerWidth(static_cast<float>(data["containerWidth"].getDouble())),
containerHeight(static_cast<float>(data["containerHeight"].getDouble())) {}
#endif
float containerWidth{0};
float containerHeight{0};
#ifdef ANDROID
folly::dynamic getDynamic() const;
MapBuffer getMapBuffer() const {
return MapBufferBuilder::EMPTY();
}
#endif
};
} // namespace facebook::react