11import * as React from 'react' ;
2-
2+ import { Button } from 'react-native' ;
33import {
44 TimerNotification ,
55 RemoveTimer ,
66 onEvent ,
77 CustomNotification ,
8+ TYPES ,
9+ FB_TYPE ,
810} from 'react-native-custom-timer-notification' ;
9- import { Dimensions } from 'react-native' ;
10- import { image , image2 } from './image' ;
11- const windowWidth = Dimensions . get ( 'window' ) . width ;
12- const windowHeight = Dimensions . get ( 'window' ) . height ;
11+ import { image } from './image' ;
1312
1413onEvent ( ( event : any ) => {
1514 console . log ( event ) ;
1615} ) ;
1716
1817export default function App ( ) {
19- React . useEffect ( ( ) => {
18+ const CN = React . useCallback ( ( ) => {
2019 CustomNotification (
2120 {
2221 eventData : JSON . stringify ( 'notificationOpen?.data' ) ,
@@ -28,8 +27,8 @@ export default function App() {
2827 {
2928 name : 'Limited Sales' ,
3029 size : 20 ,
31- type : 2 ,
32- bold : 3 ,
30+ type : TYPES . Text ,
31+ bold : FB_TYPE . BOLD_ITALIC ,
3332 PaddingLeft : 10 ,
3433 PaddingTop : 50 ,
3534 PaddingRight : 0 ,
@@ -38,9 +37,8 @@ export default function App() {
3837 color : '#ed1a45' ,
3938 } ,
4039 {
41- size : 50 ,
4240 uri : image ,
43- type : 1 ,
41+ type : TYPES . Image ,
4442 PaddingLeft : 0 ,
4543 PaddingTop : 0 ,
4644 PaddingRight : 0 ,
@@ -49,8 +47,8 @@ export default function App() {
4947 {
5048 name : 'Buy now' ,
5149 size : 30 ,
52- type : 2 ,
53- bold : 3 ,
50+ type : TYPES . Text ,
51+ bold : FB_TYPE . BOLD_ITALIC ,
5452 PaddingLeft : 10 ,
5553 PaddingTop : 100 ,
5654 PaddingRight : 0 ,
@@ -59,11 +57,10 @@ export default function App() {
5957 color : '#fbd335' ,
6058 } ,
6159 {
62- type : 3 ,
60+ type : TYPES . Cronometer ,
61+ size : 30 ,
6362 ZeroTime : new Date ( Date . now ( ) + 20000 ) ,
6463 PaddingLeft : 800 ,
65- hide : true ,
66- size : 25 ,
6764 color : '#0000FF' ,
6865 PaddingTop : 0 ,
6966 PaddingRight : 0 ,
@@ -77,5 +74,30 @@ export default function App() {
7774 ) ;
7875 } , [ ] ) ;
7976
80- return < > </ > ;
77+ const TN = React . useCallback ( ( ) => {
78+ TimerNotification ( {
79+ payload : JSON . stringify ( 'notificationOpen?.data' ) ,
80+ title : 'My notification' ,
81+ body : 'Much longer text that cannot fit one line... ' ,
82+ id : 160211114 ,
83+ remove : false , // optional
84+ foreground : false ,
85+ date : new Date ( Date . now ( ) + 20000 ) ,
86+ isCountDown : true , // false for positive timer
87+ setCustomContentView : true , // optional
88+ } ) ;
89+ } , [ ] ) ;
90+
91+ return (
92+ < >
93+ < Button title = "Custom Notification" onPress = { CN } />
94+ < Button title = "Timer Notification" onPress = { TN } />
95+ < Button
96+ title = "remove"
97+ onPress = { ( ) => {
98+ RemoveTimer ( 1 ) ;
99+ } }
100+ />
101+ </ >
102+ ) ;
81103}
0 commit comments