11import React , { useCallback } from 'react' ;
22import {
3- SafeAreaView ,
3+ Pressable ,
4+ ScrollView ,
5+ StatusBar ,
46 StyleSheet ,
57 Text ,
6- TouchableOpacity ,
78 View ,
9+ useWindowDimensions ,
810} from 'react-native' ;
911import { ToastProvider , useToast } from 'react-native-rooster' ;
1012import type { ToastType } from 'react-native-rooster' ;
13+ import { SafeAreaView } from 'react-native-safe-area-context' ;
1114
1215type ButtonConfig = {
1316 label : string ;
@@ -25,6 +28,8 @@ const BUTTONS: ButtonConfig[] = [
2528
2629const ToastDemo : React . FC = ( ) => {
2730 const { addToast } = useToast ( ) ;
31+ const { width } = useWindowDimensions ( ) ;
32+ const isWide = width >= 768 ;
2833
2934 const handlePress = useCallback (
3035 ( config : ButtonConfig ) => {
@@ -48,21 +53,57 @@ const ToastDemo: React.FC = () => {
4853 ) ;
4954
5055 return (
51- < SafeAreaView style = { styles . container } >
52- < Text style = { styles . header } > React Native Rooster</ Text >
53- < View style = { styles . buttons } >
54- { BUTTONS . map ( ( button ) => (
55- < TouchableOpacity
56- key = { button . label }
57- accessibilityRole = "button"
58- style = { styles . button }
59- onPress = { ( ) => handlePress ( button ) }
60- >
61- < Text style = { styles . buttonText } > { button . label } </ Text >
62- </ TouchableOpacity >
63- ) ) }
64- </ View >
65- < Text style = { styles . helper } > Tap a button to trigger a toast.</ Text >
56+ < SafeAreaView style = { styles . screen } >
57+ < StatusBar barStyle = "light-content" />
58+ < ScrollView
59+ contentContainerStyle = { [
60+ styles . scrollContent ,
61+ isWide && styles . scrollContentWide ,
62+ ] }
63+ >
64+ < View style = { [ styles . hero , isWide && styles . heroWide ] } >
65+ < Text style = { styles . eyebrow } > Instant feedback</ Text >
66+ < Text style = { styles . header } > React Native Rooster</ Text >
67+ < Text style = { styles . subtitle } >
68+ Delight your users with polished toast notifications. One provider,
69+ one hook, endless customisation.
70+ </ Text >
71+ </ View >
72+
73+ < View style = { [ styles . panel , isWide && styles . panelWide ] } >
74+ < Text style = { styles . panelTitle } > Try it now</ Text >
75+ < Text style = { styles . panelSubtitle } >
76+ Trigger different variants to see Rooster in action.
77+ </ Text >
78+
79+ < View style = { [ styles . buttonGroup , isWide && styles . buttonGroupWide ] } >
80+ { BUTTONS . map ( ( button ) => (
81+ < Pressable
82+ key = { button . label }
83+ accessibilityRole = "button"
84+ style = { ( { pressed } ) => [
85+ styles . button ,
86+ pressed && styles . buttonPressed ,
87+ ] }
88+ android_ripple = { { color : 'rgba(255,255,255,0.05)' } }
89+ onPress = { ( ) => handlePress ( button ) }
90+ >
91+ < Text style = { styles . buttonText } > { button . label } </ Text >
92+ </ Pressable >
93+ ) ) }
94+ </ View >
95+
96+ < View style = { styles . tipBanner } >
97+ < Text style = { styles . tipEmoji } > 💡</ Text >
98+ < Text style = { styles . tipText } >
99+ Toasts stack automatically, respect safe areas, and avoid the
100+ keyboard when needed.
101+ </ Text >
102+ </ View >
103+ </ View >
104+
105+ < Text style = { styles . helper } > Tap any button to trigger a toast.</ Text >
106+ </ ScrollView >
66107 </ SafeAreaView >
67108 ) ;
68109} ;
@@ -76,35 +117,126 @@ export default function App() {
76117}
77118
78119const styles = StyleSheet . create ( {
79- container : {
120+ screen : {
80121 flex : 1 ,
81- padding : 24 ,
82- justifyContent : 'center' ,
83- alignItems : 'center' ,
84122 backgroundColor : '#121212' ,
85123 } ,
124+ scrollContent : {
125+ flexGrow : 1 ,
126+ paddingHorizontal : 24 ,
127+ paddingVertical : 32 ,
128+ alignItems : 'center' ,
129+ gap : 24 ,
130+ } ,
131+ scrollContentWide : {
132+ paddingVertical : 48 ,
133+ } ,
134+ hero : {
135+ width : '100%' ,
136+ maxWidth : 520 ,
137+ alignItems : 'center' ,
138+ gap : 12 ,
139+ } ,
140+ heroWide : {
141+ maxWidth : 640 ,
142+ } ,
143+ eyebrow : {
144+ color : '#a5b4fc' ,
145+ fontSize : 14 ,
146+ letterSpacing : 1 ,
147+ textTransform : 'uppercase' ,
148+ } ,
86149 header : {
87150 color : '#fff' ,
88- fontSize : 24 ,
151+ fontSize : 30 ,
89152 fontWeight : '700' ,
153+ textAlign : 'center' ,
90154 } ,
91- buttons : {
155+ subtitle : {
156+ color : '#d1d5db' ,
157+ fontSize : 16 ,
158+ lineHeight : 22 ,
159+ textAlign : 'center' ,
160+ } ,
161+ panel : {
92162 width : '100%' ,
163+ maxWidth : 520 ,
164+ backgroundColor : '#1f1f1f' ,
165+ borderRadius : 16 ,
166+ paddingVertical : 24 ,
167+ paddingHorizontal : 20 ,
168+ gap : 16 ,
169+ shadowColor : '#000' ,
170+ shadowOpacity : 0.25 ,
171+ shadowRadius : 20 ,
172+ shadowOffset : { width : 0 , height : 16 } ,
173+ elevation : 12 ,
174+ } ,
175+ panelWide : {
176+ maxWidth : 640 ,
177+ } ,
178+ panelTitle : {
179+ color : '#f9fafb' ,
180+ fontSize : 18 ,
181+ fontWeight : '600' ,
182+ textAlign : 'center' ,
183+ } ,
184+ panelSubtitle : {
185+ color : '#9ca3af' ,
186+ fontSize : 15 ,
187+ textAlign : 'center' ,
188+ } ,
189+ buttonGroup : {
190+ gap : 12 ,
191+ } ,
192+ buttonGroupWide : {
193+ flexDirection : 'row' ,
194+ flexWrap : 'wrap' ,
195+ justifyContent : 'space-between' ,
93196 } ,
94197 button : {
95- paddingVertical : 12 ,
96- borderRadius : 8 ,
97- backgroundColor : '#1f1f1f' ,
98- marginBottom : 12 ,
198+ borderRadius : 10 ,
199+ backgroundColor : '#272727' ,
200+ paddingVertical : 14 ,
201+ paddingHorizontal : 16 ,
202+ justifyContent : 'center' ,
203+ alignItems : 'center' ,
204+ overflow : 'hidden' ,
205+ borderWidth : StyleSheet . hairlineWidth ,
206+ borderColor : 'rgba(255,255,255,0.06)' ,
207+ } ,
208+ buttonPressed : {
209+ backgroundColor : '#2f2f2f' ,
99210 } ,
100211 buttonText : {
101212 textAlign : 'center' ,
102213 color : '#fff' ,
103214 fontSize : 16 ,
104215 fontWeight : '600' ,
105216 } ,
217+ tipBanner : {
218+ flexDirection : 'row' ,
219+ alignItems : 'center' ,
220+ paddingVertical : 14 ,
221+ paddingHorizontal : 16 ,
222+ borderRadius : 12 ,
223+ backgroundColor : '#111827' ,
224+ borderWidth : StyleSheet . hairlineWidth ,
225+ borderColor : 'rgba(147, 197, 253, 0.25)' ,
226+ gap : 12 ,
227+ } ,
228+ tipEmoji : {
229+ fontSize : 20 ,
230+ } ,
231+ tipText : {
232+ flex : 1 ,
233+ color : '#e5e7eb' ,
234+ fontSize : 14 ,
235+ lineHeight : 20 ,
236+ } ,
106237 helper : {
107238 color : '#bbb' ,
108239 fontSize : 14 ,
240+ textAlign : 'center' ,
109241 } ,
110242} ) ;
0 commit comments