1
1
import React , { Component } from 'react' ;
2
2
import { Alert , StyleSheet } from 'react-native' ;
3
3
import { Navigation } from 'react-native-navigation' ;
4
- import { Colors , Carousel , PageControl , Modal , View , Text } from 'react-native-ui-lib' ; // eslint-disable-line
4
+ import { Colors , Carousel , PageControl , Modal , View , Text , Assets } from 'react-native-ui-lib' ; // eslint-disable-line
5
5
6
+ const BUTTONS_HIT_SLOP = { right : 5 , left : 5 , top : 10 , bottom : 10 } ;
6
7
interface ModalScreenProps {
7
8
componentId : string ;
8
9
}
@@ -12,7 +13,6 @@ interface State {
12
13
}
13
14
14
15
export default class ModalScreen extends Component < ModalScreenProps , State > {
15
-
16
16
static options ( ) {
17
17
return {
18
18
topBar : {
@@ -39,7 +39,7 @@ export default class ModalScreen extends Component<ModalScreenProps, State> {
39
39
< View flex >
40
40
< PageControl
41
41
containerStyle = { [ styles . pageControl , styles . absoluteContainer ] }
42
- numOfPages = { 4 }
42
+ numOfPages = { 5 }
43
43
currentPage = { this . state . currentPage }
44
44
color = { Colors . grey10 }
45
45
size = { 15 }
@@ -55,12 +55,8 @@ export default class ModalScreen extends Component<ModalScreenProps, State> {
55
55
} }
56
56
/>
57
57
< View padding-20 >
58
- < Text text70 >
59
- This is an example of a custom modal top bar.
60
- </ Text >
61
- < Text text70 >
62
- By default you get the 'x' cancel icon and 'save' as done label
63
- </ Text >
58
+ < Text text70 > This is an example of a custom modal top bar.</ Text >
59
+ < Text text70 > By default you get the 'x' cancel icon and 'save' as done label</ Text >
64
60
</ View >
65
61
</ View >
66
62
@@ -74,8 +70,8 @@ export default class ModalScreen extends Component<ModalScreenProps, State> {
74
70
/>
75
71
< View padding-20 >
76
72
< Text text70 >
77
- You can of course change it by changing the values of
78
- cancelIcon, cancelLabel, doneIcon, doneLabel and other props..
73
+ You can of course change it by changing the values of cancelIcon, cancelLabel, doneIcon, doneLabel and
74
+ other props..
79
75
</ Text >
80
76
</ View >
81
77
</ View >
@@ -89,9 +85,7 @@ export default class ModalScreen extends Component<ModalScreenProps, State> {
89
85
cancelLabel = "back"
90
86
/>
91
87
< View padding-20 >
92
- < Text text70 >
93
- Sending onDone/onCancel is required for rendering done/cancel actions
94
- </ Text >
88
+ < Text text70 > Sending onDone/onCancel is required for rendering done/cancel actions</ Text >
95
89
</ View >
96
90
</ View >
97
91
@@ -105,7 +99,39 @@ export default class ModalScreen extends Component<ModalScreenProps, State> {
105
99
/>
106
100
< View padding-20 >
107
101
< Text text70 >
108
- use doneButtonProps/cancelButtonProps properties to have custom behaviour or style for done/cancel actions
102
+ use doneButtonProps/cancelButtonProps properties to have custom behaviour or style for done/cancel
103
+ actions
104
+ </ Text >
105
+ </ View >
106
+ </ View >
107
+
108
+ < View bg-yellow80 flex style = { styles . page } >
109
+ < Modal . TopBar
110
+ title = "custom button"
111
+ rightButtons = { [
112
+ {
113
+ label : 'save' ,
114
+ buttonProps : { labelStyle : { color : Colors . yellow10 , marginRight : 14 } } ,
115
+ onPress : ( ) => Alert . alert ( 'save' )
116
+ } ,
117
+ {
118
+ icon : Assets . icons . demo . settings ,
119
+ onPress : ( ) => Alert . alert ( 'settings' ) ,
120
+ buttonProps : { hitSlop : BUTTONS_HIT_SLOP , iconStyle : { tintColor : Colors . yellow10 } }
121
+ }
122
+ ] }
123
+ leftButtons = { [
124
+ {
125
+ icon : Assets . icons . x ,
126
+ onPress : ( ) => Alert . alert ( 'back' ) ,
127
+ buttonProps : { hitSlop : BUTTONS_HIT_SLOP , iconStyle : { tintColor : Colors . yellow10 } }
128
+ }
129
+ ] }
130
+ />
131
+ < View padding-20 >
132
+ < Text text70 >
133
+ This is an example for using the rightButtons and leftButtons props for having more than one button each
134
+ side
109
135
</ Text >
110
136
</ View >
111
137
</ View >
0 commit comments