-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #744 from grahammendick/ios-bottomsheet
- Loading branch information
Showing
19 changed files
with
706 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...rc/cpp/react/renderer/components/navigationreactnative/NVBottomSheetComponentDescriptor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
#include <react/debug/react_native_assert.h> | ||
#include "NVBottomSheetShadowNode.h" | ||
#include <react/renderer/core/ConcreteComponentDescriptor.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
class NVBottomSheetComponentDescriptor final | ||
: public ConcreteComponentDescriptor<NVBottomSheetShadowNode> { | ||
public: | ||
using ConcreteComponentDescriptor::ConcreteComponentDescriptor; | ||
|
||
void adopt(ShadowNode::Unshared const &shadowNode) const override { | ||
react_native_assert( | ||
std::dynamic_pointer_cast<NVBottomSheetShadowNode>(shadowNode)); | ||
auto screenShadowNode = | ||
std::static_pointer_cast<NVBottomSheetShadowNode>(shadowNode); | ||
|
||
react_native_assert( | ||
std::dynamic_pointer_cast<YogaLayoutableShadowNode>(screenShadowNode)); | ||
auto layoutableShadowNode = | ||
std::static_pointer_cast<YogaLayoutableShadowNode>(screenShadowNode); | ||
|
||
auto state = | ||
std::static_pointer_cast<const NVBottomSheetShadowNode::ConcreteState>( | ||
shadowNode->getState()); | ||
auto stateData = state->getData(); | ||
|
||
if (stateData.frameSize.width != 0 && stateData.frameSize.height != 0) { | ||
layoutableShadowNode->setSize( | ||
Size{stateData.frameSize.width, stateData.frameSize.height}); | ||
} | ||
|
||
ConcreteComponentDescriptor::adopt(shadowNode); | ||
} | ||
}; | ||
|
||
} // namespace react | ||
} // namespace facebook |
9 changes: 9 additions & 0 deletions
9
...ative/src/cpp/react/renderer/components/navigationreactnative/NVBottomSheetShadowNode.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "NVBottomSheetShadowNode.h" | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
extern const char NVBottomSheetComponentName[] = "NVBottomSheet"; | ||
|
||
} // namespace react | ||
} // namespace facebook |
29 changes: 29 additions & 0 deletions
29
...tNative/src/cpp/react/renderer/components/navigationreactnative/NVBottomSheetShadowNode.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#include "NVBottomSheetState.h" | ||
#include <react/renderer/components/navigationreactnative/EventEmitters.h> | ||
#include <react/renderer/components/navigationreactnative/Props.h> | ||
#include <react/renderer/components/view/ConcreteViewShadowNode.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
JSI_EXPORT extern const char NVBottomSheetComponentName[]; | ||
|
||
class JSI_EXPORT NVBottomSheetShadowNode final : public ConcreteViewShadowNode< | ||
NVBottomSheetComponentName, | ||
NVBottomSheetProps, | ||
NVBottomSheetEventEmitter, | ||
NVBottomSheetState> { | ||
public: | ||
using ConcreteViewShadowNode::ConcreteViewShadowNode; | ||
|
||
static ShadowNodeTraits BaseTraits() { | ||
auto traits = ConcreteViewShadowNode::BaseTraits(); | ||
traits.set(ShadowNodeTraits::Trait::RootNodeKind); | ||
return traits; | ||
} | ||
}; | ||
|
||
} // namespace react | ||
} // namespace facebook |
14 changes: 14 additions & 0 deletions
14
...eactNative/src/cpp/react/renderer/components/navigationreactnative/NVBottomSheetState.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "NVBottomSheetState.h" | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
#ifdef ANDROID | ||
folly::dynamic NVBottomSheetState::getDynamic() const { | ||
return folly::dynamic::object("frameWidth", frameSize.width)( | ||
"frameHeight", frameSize.height); | ||
} | ||
#endif | ||
|
||
} // namespace react | ||
} // namespace facebook |
45 changes: 45 additions & 0 deletions
45
...nReactNative/src/cpp/react/renderer/components/navigationreactnative/NVBottomSheetState.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
|
||
#include <react/renderer/graphics/Float.h> | ||
#include <react/renderer/core/graphicsConversions.h> | ||
|
||
#ifdef ANDROID | ||
#include <folly/dynamic.h> | ||
#include <react/renderer/mapbuffer/MapBuffer.h> | ||
#include <react/renderer/mapbuffer/MapBufferBuilder.h> | ||
#endif | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
class JSI_EXPORT NVBottomSheetState final { | ||
public: | ||
using Shared = std::shared_ptr<const NVBottomSheetState>; | ||
|
||
NVBottomSheetState(){}; | ||
NVBottomSheetState(Size frameSize_) : frameSize(frameSize_){}; | ||
|
||
#ifdef ANDROID | ||
NVBottomSheetState( | ||
NVBottomSheetState const &previousState, | ||
folly::dynamic data) | ||
: frameSize(Size{ | ||
(Float)data["frameWidth"].getDouble(), | ||
(Float)data["frameHeight"].getDouble()}){}; | ||
#endif | ||
|
||
const Size frameSize{}; | ||
|
||
#ifdef ANDROID | ||
folly::dynamic getDynamic() const; | ||
MapBuffer getMapBuffer() const { | ||
return MapBufferBuilder::EMPTY(); | ||
}; | ||
|
||
#endif | ||
|
||
#pragma mark - Getters | ||
}; | ||
|
||
} // namespace react | ||
} // namespace facebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.