私はBottomSheetBehaviorをラップするネイティブアンドロイドモジュールを作成しています。CoordinatorLayoutとBottomSheetBehaviorのための反応ネイティブラッパー
非常に単純なBottomSheetBehaviorは私が直面した最初の事、ページ全体がそれの終わりにCoordinatorLayoutとBottomSheetBehaviorの子でなければなりません。この https://gist.github.com/cesardeazevedo/a4dc4ed12df33fe1877fc6cea42475ae
のように実装することができます。
私は2つのネイティブモジュール、<CoordinatorLayout />
と<BottomSheetBehavior />
を書かねばなりませんでした。
これはbottomSheetBehaviorラッパーです。
BottomSheetBehaviorManager.java
public class BottomSheetBehaviorManager extends ViewGroupManager<BottomSheetBehaviorView> {
@Override
public BottomSheetBehaviorView createViewInstance(ThemedReactContext context) {
return new BottomSheetBehaviorView(context);
}
}
BottomSheetBehaviorView.java
public class BottomSheetBehaviorView extends RelativeLayout {
public BottomSheetBehaviorView(Context context) {
super(context);
int width = ViewGroup.LayoutParams.WRAP_CONTENT;
int height = ViewGroup.LayoutParams.WRAP_CONTENT;
// int height = 1000; // fixed a height works, it only slide up half of the screen
CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(width, height);
params.setBehavior(new BottomSheetBehavior());
this.setLayoutParams(params);
BottomSheetBehavior<BottomSheetBehaviorView> bottomSheetBehavior = BottomSheetBehavior.from(this);
bottomSheetBehavior.setHideable(false);
bottomSheetBehavior.setPeekHeight(200);
}
}
そして、私の反応コンポーネントは次のようになります。
index.android.js
return() {
<CoordinatorLayout style={{flex: 1}}>
<View><!--app--></View>
<BottomSheetBehavior>
<View style={{height: 300}}> <!--height doesnt work-->
<Text>BottomSheetBehavior !</Text>
</View>
</BottomSheetBehavior>
</CoordinatorLayout>
)
そして、それは働きます!
しかし、私はBottomSheetがwrap_content
と彼らのチャイルズをラップ作るのに苦労してきた、それが画面全体をスライドすることになっていなかったです、それはこの場合のみに包まれたコンテンツ(Loremのイプサムてスライドさせなければなりませんテキスト)、それはアンドロイドコンポーネントで動作しますが、反応コンポーネントでは動作しません。だから、RelativeLayout
をどのようにラップするのですか?<View style={{height: 300}} />
コンポーネントですか?私もいくつかmeasure shadownodeを実装しようとしましたが、予想どおりに動作しませんでした、彼らはどのように動作するのか分かりません。
誰もが試してみたいという私のgithubにこの例を追加しました。デバッグの多くの後https://github.com/cesardeazevedo/react-native-bottom-sheet-behavior
本当にすばらしいすごいうわー、私はこれを試してみてBottomSheetFragment' 'とPRを行います共有するためのあなたの先生に感謝! :) – Noitidart