Comments (6)
Humm interesting. I'll try that.
You can also try https://github.com/MAKARD/react-native-toastboard. Pretty similar to this package, and you can also fully control the layout
from react-native-toast-message.
Is one way, set undefined in height, may is good idea to add this to docs ?
xport const notificationToastConfig = { info: (props) => ( <BaseToast {...props} style={{ height: undefined, maxHeight: 200, paddingVertical: 5 }}
from react-native-toast-message.
if it helps someone
import React from "react";
import { View, Text, Pressable, StyleSheet } from "react-native";
// BaseToast styles
const HEIGHT = 60;
const WIDTH = "100%";
const BORDER_RADIUS = 5;
const styles = StyleSheet.create({
base: {
flexDirection: "row",
height: HEIGHT,
width: WIDTH,
borderRadius: BORDER_RADIUS,
shadowOffset: { width: 0, height: 0 },
shadowOpacity: 0.1,
shadowRadius: BORDER_RADIUS,
elevation: 2,
backgroundColor: "#FFF",
},
leadingBorder: {
borderLeftWidth: 5,
borderLeftColor: "#D8D8D8",
},
contentContainer: {
paddingHorizontal: 25,
flex: 1,
justifyContent: "center",
alignItems: "flex-start",
},
text1: {
fontSize: 12,
fontWeight: "bold",
marginBottom: 2,
color: "#000",
width: "100%",
},
text2: {
fontSize: 10,
color: "#979797",
flexShrink: 1,
},
});
const CustomBaseToast = ({ text1, text2, onPress }) => {
return (
<Pressable onPress={onPress} style={[styles.base, styles.leadingBorder]}>
<View style={styles.contentContainer}>
<Text style={styles.text1}>{text1}</Text>
<Text style={styles.text2}>{text2}</Text>
</View>
</Pressable>
);
};
export const toastConfig = {
error: (props) => <CustomBaseToast {...props} />,
};
in app.js
<Toast config={toastConfig} />
from react-native-toast-message.
If you look around in the src/components/BaseToast.tsx component, you can find the following property: text1NumberOfLines and text2NumberOfLines. These limit the maximum number of lines that can be rendered inside the component and is defaulted to 1.
Based on the longest text that should be displayed, set these values to higher numbers. Also note that this does not change the height of the component (so you can go as high as you want). Setting the height to undefined, minHeight to a desired number and adding some padding will create the final look desirable.
Hope this helps!
from react-native-toast-message.
if there's no way to do this feel free to use this pr:
#475
from react-native-toast-message.
Humm interesting. I'll try that.
from react-native-toast-message.
Related Issues (20)
- Export a base toast that can accept any content
- Type safety for Toast.show based on custom toast type HOT 3
- Instal with Typescript HOT 1
- Toast Not working in with React-native 0.71.8 version HOT 8
- Inconsistent Availability of text1 and text2 Style Props in toast.show Function
- display toast on more than one screen HOT 4
- migrate to reanimated ?
- how to use with expo app routes? HOT 6
- onHIide feature for toast does not work, if i pass code to execute for onHide callback as arguement HOT 1
- Toast not showing on RN v0.72.4 HOT 6
- Modal prompts on iOS overlay the toast HOT 13
- toast showing without calling it HOT 11
- You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file HOT 1
- Toast isn't swipeable inside Modal if custom toast is used
- Unable to delay between two roasts. HOT 1
- How to override the default duration for the Toast at root level for all instances? HOT 1
- Toasts should not move. How to stop moving? HOT 6
- crash on android when Toast.show() HOT 1
- Feature: Enable Swipe with Customizable Position-Right/Left HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-toast-message.