callstack / callstack/react-native-paper

Snackbar as a function.

オープン
#2,825 コメント 9 件 リアクション 22 件 担当者 0 名 GitHub で見る
enhancement
主要言語
TypeScript
スター
14.5k
フォーク
2.2k
平均マージ
5日 23時間
マージ済み PR(30日)
12

説明

It would be great if we could use Snackbar and toggle it as a function.

Like in [Toast](https://docs.nativebase.io/toast) provided by [Native Base](https://nativebase.io/), we can customize it like this

```javascript
import { Toast } from "native-base";

function show({
text,
type = "danger",
buttonText,
duration = 3000,
position,
bottom = 60,
}) {
Toast.show({
text: text,
position: position,
type: type,
duration: duration,
buttonText: buttonText,
});
}

export default {
show,
};
```

Then I use it on any screen or component like this

```javascript
Toast.show({ text: "This API call was successful" }); // This pops a Toast message and disappears after 3 seconds
```

I love the Snackbar that React Native Paper has, but I couldn't figure out how to use it as described above.

Right now, I have to add a component on every page and maintain a state to toggle it. It would have been so good if we could use it like `Snackbar.show("Some Text")`

If anyone has any advice on using Snackbar as a function to toggle Toasts, I would love to discuss it.

Versions :
- "react-native": "~0.63.4"
- "react-native-paper": "^4.9.2"

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。