Skip to content

Commit

Permalink
add text fields for button + update to 0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
smajumder-flpkt committed Feb 10, 2019
1 parent 6b2ebfd commit 6bb6742
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default class App extends Component {
{
header: "Hello",
info: "Wow its working",
primaryButtonText:"CANCEL",
secondaryButtonText:"CONFIRM",
primaryButtonTextStyle: styles._buttonTextStyle,
secondaryButtonTextStyle: styles.secondaryButtonText,
secondaryButtonPress:()=>{
Expand Down
10 changes: 10 additions & 0 deletions Example/components/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface DialogState {
show: boolean;
header?: string;
info: string;
primaryButtonText?:String,
secondaryButtonText?:String,
primaryButtonStyle?: ButtonStyle;
primaryButtonTextStyle?: ButtonTextStyle;
secondaryButtonStyle?: ButtonStyle;
Expand All @@ -26,6 +28,8 @@ export interface ShowDialog {
type: SHOW;
header?: string;
info: string;
primaryButtonText?:String,
secondaryButtonText?:String,
primaryButtonStyle?: ButtonStyle;
primaryButtonTextStyle?: ButtonTextStyle;
secondaryButtonStyle?: ButtonStyle;
Expand Down Expand Up @@ -58,6 +62,8 @@ const initialState: DialogState = {
show: false,
header: '',
info: '',
primaryButtonText: 'NO',
secondaryButtonText:'YES',
primaryButtonStyle: {},
primaryButtonTextStyle: {},
secondaryButtonStyle:{},
Expand All @@ -72,6 +78,8 @@ const dialogReducer = (state = initialState, action: DialogAction): DialogState
show: true,
header: action.header,
info: action.info,
primaryButtonText:action.primaryButtonText || "NO",
secondaryButtonText:action.secondaryButtonText || "YES",
primaryButtonStyle: action.primaryButtonStyle || {},
primaryButtonTextStyle: action.primaryButtonTextStyle || {},
secondaryButtonStyle: action.primaryButtonStyle || {},
Expand All @@ -90,6 +98,8 @@ const store = createStore(dialogReducer);
interface DialogParams {
header?: string;
info: string;
primaryButtonText?:String,
secondaryButtonText?:String,
primaryButtonStyle?: ButtonStyle;
primaryButtonTextStyle?: ButtonTextStyle;
secondaryButtonStyle?: ButtonStyle;
Expand Down
5 changes: 3 additions & 2 deletions Example/components/DialogComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ class DialogComponent extends Component<DialogState & IDispatch>{
</View>
<View style={styles.buttonContainer}>
<TouchableOpacity style={[styles.buttonPrimary, this.props.primaryButtonStyle]} onPress={()=>this.buttonPress('primary')}>
<Text style={[styles.buttonPrimaryText, this.props.primaryButtonTextStyle]}>No</Text>
<Text style={[styles.buttonPrimaryText, this.props.primaryButtonTextStyle]}>{this.props.primaryButtonText}</Text>
</TouchableOpacity>
{
this.props.secondaryButtonPress &&
<TouchableOpacity style={[styles.buttonSecondary, this.props.secondaryButtonStyle]} onPress={()=>this.buttonPress('secondary')}>
<Text style={[styles.buttonSecondaryText, this.props.secondaryButtonTextStyle]}>Yes</Text>
<Text style={[styles.buttonSecondaryText, this.props.secondaryButtonTextStyle]}>{this.props.secondaryButtonText}</Text>
</TouchableOpacity>
}
</View>
Expand Down Expand Up @@ -93,6 +93,7 @@ const styles = StyleSheet.create({
},
headerText:{
fontWeight:"bold",
color: "black",
fontSize: 20
},
buttonContainer:{
Expand Down
5 changes: 5 additions & 0 deletions Example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"react": "16.6.3",
"react-native": "0.58.4",
"react-redux": "^6.0.0",
"redux": "^4.0.1"
"redux": "^4.0.1",
"simple-react-native-dialog": "0.0.6"
},
"devDependencies": {
"@types/react": "^16.8.2",
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export default class App extends Component {
{
header: "Hello",
info: "Wow its working",
primaryButtonText:"CANCEL",
secondaryButtonText:"CONFIRM",
primaryButtonTextStyle: styles._buttonTextStyle,
secondaryButtonTextStyle: styles.secondaryButtonText,
secondaryButtonPress:()=>{
Expand Down Expand Up @@ -121,9 +123,15 @@ import Dialog from 'simple-react-native-dialog';
handleClick = () =>{
Dialog.showDialog(
{
header: "Hello",
info: "Wow its working",
buttonStyle: styles.buttonStyle,
buttonTextStyle: styles._buttonTextStyle,
primaryButtonText:"NO",
secondaryButtonText:"YES",
primaryButtonTextStyle: styles._buttonTextStyle,
secondaryButtonTextStyle: styles.secondaryButtonText,
secondaryButtonPress:()=>{
alert('Hello');
}
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-react-native-dialog",
"version": "0.0.6",
"version": "0.0.7",
"description": "Simple react native dialog",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 6bb6742

Please sign in to comment.