Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit 59e30c6

Browse files
committed
README.md updated && IOS library updated
1 parent a0d5c07 commit 59e30c6

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Using `react-native-modal` and `@react-native-community/picker` component for IO
1818
- disabled & enabled IOS confirm button styles added.
1919
- Now we can set object array for items or array.
2020
- IOS part start using hooks
21+
- confirmButtonStyle & cancelButtonStyle & contentContainerStyle added
2122
- and a lot of upgrade...
2223

2324

@@ -57,6 +58,9 @@ react-native link react-native-picker-module
5758
|items |array / object array |- |**Yes** |Android, IOS|
5859
|title |string|- |**No** |Android, IOS|
5960
|titleStyle |object|{} |**No** |IOS |
61+
|confirmButtonStyle |object|{} |**No** |IOS |
62+
|cancelButtonStyle |object|{} |**No** |IOS |
63+
|contentContainerStyle |object|{} |**No** |IOS |
6064
|itemStyle |object|{} |**No** |IOS |
6165
|cancelButtonTextStyle |object| {} |**No** |IOS |
6266
|confirmButtonEnabledTextStyle|object| {} |**No** |IOS |
@@ -119,13 +123,22 @@ const App = () => {
119123
pickerRef={pickerRef}
120124
value={value}
121125
title={"Select a language"}
122-
items={dataset_2}
123-
titleStyle={{ color: "red" }}
124-
itemStyle={{ color: "red" }}
126+
items={dataset_1}
127+
titleStyle={{ color: "white" }}
128+
itemStyle={{ color: "white" }}
125129
selectedColor="#FC0"
126-
confirmButtonEnabledTextStyle={{ color: "red" }}
130+
confirmButtonEnabledTextStyle={{ color: "white" }}
127131
confirmButtonDisabledTextStyle={{ color: "grey" }}
128-
cancelButtonTextStyle={{ color: "red" }}
132+
cancelButtonTextStyle={{ color: "white" }}
133+
confirmButtonStyle={{
134+
backgroundColor: "rgba(0,0,0,1)",
135+
}}
136+
cancelButtonStyle={{
137+
backgroundColor: "rgba(0,0,0,1)",
138+
}}
139+
contentContainerStyle={{
140+
backgroundColor: "rgba(0,0,0,1)",
141+
}}
129142
onCancel={() => {
130143
console.log("Cancelled")
131144
}}

lib/index.ios.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const ReactNativePickerModule = ({
1212
cancelButton,
1313
confirmButton,
1414
onCancel,
15+
contentContainerStyle,
1516
titleStyle,
1617
itemStyle,
1718
useNativeDriver,
@@ -21,6 +22,8 @@ const ReactNativePickerModule = ({
2122
backdropColor,
2223
backdropOpacity,
2324
selectedColor,
25+
confirmButtonStyle,
26+
cancelButtonStyle,
2427
}) => {
2528
const dismissPress = () => {
2629
setIsVisible(false)
@@ -46,7 +49,7 @@ const ReactNativePickerModule = ({
4649
isVisible={isVisible}
4750
style={{ justifyContent: "flex-end" }}
4851
hideModalContentWhileAnimating={true}>
49-
<View style={styles.content}>
52+
<View style={[styles.content, contentContainerStyle]}>
5053
<View style={styles.titleView}>
5154
<Text style={[styles.titleText, titleStyle]}>{title}</Text>
5255
</View>
@@ -61,17 +64,17 @@ const ReactNativePickerModule = ({
6164
<Picker.Item
6265
color={value === item.value ? selectedColor : undefined}
6366
key={"item-" + index}
64-
label={item.label}
65-
value={item.value}
67+
label={item.label.toString()}
68+
value={item.value.toString()}
6669
/>
6770
)
6871
} else {
6972
return (
7073
<Picker.Item
7174
color={value === item ? selectedColor : undefined}
7275
key={"item-" + index}
73-
label={item}
74-
value={item}
76+
label={item.toString()}
77+
value={item.toString()}
7578
/>
7679
)
7780
}
@@ -84,7 +87,7 @@ const ReactNativePickerModule = ({
8487
onValueChange(selectedValue)
8588
setIsVisible(false)
8689
}}
87-
style={styles.confirmButtonView}>
90+
style={[styles.confirmButtonView, confirmButtonStyle]}>
8891
<Text
8992
style={[
9093
styles.confirmButtonText,
@@ -95,7 +98,10 @@ const ReactNativePickerModule = ({
9598
</TouchableOpacity>
9699
</View>
97100
<View style={styles.cancelButton}>
98-
<TouchableOpacity activeOpacity={0.9} style={styles.cancelButtonView} onPress={dismissPress}>
101+
<TouchableOpacity
102+
activeOpacity={0.9}
103+
style={[styles.cancelButtonView, cancelButtonStyle]}
104+
onPress={dismissPress}>
99105
<Text style={[styles.cancelButtonText, cancelButtonTextStyle]}>{cancelButton}</Text>
100106
</TouchableOpacity>
101107
</View>

react-native-picker-module.d.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,26 @@
66
import React from "react"
77

88
export interface ReactNativePickerModuleProps {
9-
value?: string,
9+
value?: string
1010
items: string[]
1111
title?: string
1212
pickerRef: any[]
1313
onValueChange: (value: string) => void
1414
onCancel?: () => void
1515
cancelButton?: string
1616
confirmButton?: string
17+
contentContainerStyle?: object
18+
confirmButtonStyle?: object
19+
cancelButtonStyle?: object
1720
titleStyle?: object
1821
itemStyle?: object
1922
useNativeDriver?: boolean
2023
confirmButtonDisabledTextStyle?: object
2124
confirmButtonEnabledTextStyle?: object
22-
cancelButtonTextStyle?: object,
23-
backdropColor?: string,
24-
backdropOpacity?: number,
25-
selectedColor?: string,
25+
cancelButtonTextStyle?: object
26+
backdropColor?: string
27+
backdropOpacity?: number
28+
selectedColor?: string
2629
}
2730

2831
export default class ReactNativePickerModule extends React.Component<ReactNativePickerModuleProps> {

0 commit comments

Comments
 (0)