Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# Watchman
.watchmanconfig
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class FormView extends React.Component{

}
render(){
return (<ScrollView keyboardShouldPersistTaps={true} style={{paddingLeft:10,paddingRight:10, height:200}}>
return (<ScrollView keyboardShouldPersistTaps='always' style={{paddingLeft:10,paddingRight:10, height:200}}>
<Form
ref='registrationForm'
onFocus={this.handleFormFocus.bind(this)}
Expand Down
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import {SwitchField} from './src/fields/SwitchField';
import {PickerField} from './src/fields/PickerField';
import {DatePickerField} from './src/fields/DatePickerField';
import {TimePickerField} from './src/fields/TimePickerField';
import {CountDownField} from './src/fields/CountDownField';


//import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
export {
Form,
Separator, InputField, LinkField,
SwitchField, PickerField, DatePickerField,
CountDownField, TimePickerField
TimePickerField
}
35 changes: 35 additions & 0 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "0.9.10"
"version": "0.9.11"
}
83 changes: 37 additions & 46 deletions src/Form.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,55 @@
import React from 'react';
let { View, TextInput,
StyleSheet,
ScrollView,
Text,
SliderIOS,
TouchableWithoutFeedback
} = require('react-native');

// import {Separator} from './fields/Separator';

export class Form extends React.Component{
constructor(props){
super();

this.values = {};
import React from 'react'
import { Text, View } from 'react-native'

export class Form extends React.Component {
constructor () {
super()
this.values = {}
}

handleFieldFocused(event, inputHandle){
this.props.onFocus && this.props.onFocus(event, inputHandle);
handleFieldFocused (event, inputHandle) {
this.props.onFocus && this.props.onFocus(event, inputHandle)
}
handleFieldChange(field_ref, value){
this.values[field_ref] = value;
this.props.onChange && this.props.onChange(this.values);

handleFieldChange (fieldRef, value) {
this.values[fieldRef] = value
this.props.onChange && this.props.onChange(this.values)
}
getValues(){
return this.values;

getValues () {
return this.values
}

underscoreToSpaced(str){
var words = str.split('_');
var res=[];
words.map(function(word, i){
res.push(word.charAt(0).toUpperCase() + word.slice(1));
underscoreToSpaced (str) {
var words = str.split('_')
var res = []
words.map(function (word) {
res.push(word.charAt(0).toUpperCase() + word.slice(1))
})

return res.join(' ');
return res.join(' ')
}

render(){
let wrappedChildren = [];

React.Children.map(this.props.children, (child, i)=> {
render () {
let wrappedChildren = []
React.Children.map(this.props.children, (child, i) => {
if (!child) {
return;
return
}
wrappedChildren.push(React.cloneElement(child, {
key: child.ref || child.type + i,
fieldRef: child.ref,
ref: child.ref,
onFocus: this.handleFieldFocused.bind(this),
onChange: this.handleFieldChange.bind(this, child.ref)
}
wrappedChildren.push(React.cloneElement(child, {
key: child.ref || child.type+i,
fieldRef : child.ref,
ref: child.ref,
onFocus:this.handleFieldFocused.bind(this),
onChange:this.handleFieldChange.bind(this, child.ref)
}
));
}, this);
))
}, this)

return (
<View style={this.props.style}>
{wrappedChildren}
<Text>{this.props.label}</Text>
{wrappedChildren}
</View>
);
)
}
}
4 changes: 2 additions & 2 deletions src/fields/Separator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import React from 'react';
let { View, StyleSheet, Text} = require('react-native');
let { View, ViewPropTypes, StyleSheet, Text} = require('react-native');

export class Separator extends React.Component{
render(){
Expand All @@ -18,7 +18,7 @@ export class Separator extends React.Component{

Separator.propTypes = {
labelStyle: Text.propTypes.style,
containerStyle: View.propTypes.style
containerStyle: ViewPropTypes.style
}


Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

// comment here if you have apln

import {InputField} from './src/fields/InputField';
import {SwitchField} from './src/fields/SwitchField';
Expand Down
4 changes: 2 additions & 2 deletions src/lib/InputComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import ReactNative, { Platform } from 'react-native';
import {Field} from './Field.js';

const {View, StyleSheet, TextInput, Text} = ReactNative;
const {View, ViewPropTypes, StyleSheet, TextInput, Text} = ReactNative;

function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
Expand Down Expand Up @@ -208,5 +208,5 @@ export class InputComponent extends React.Component{
InputComponent.propTypes = {
labelStyle: Text.propTypes.style,
inputStyle: TextInput.propTypes.style,
containerStyle: View.propTypes.style
containerStyle: ViewPropTypes.style
}
4 changes: 2 additions & 2 deletions src/lib/LinkComponent.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import React from 'react';
let { View, StyleSheet, Text} = require('react-native');
let { View, ViewPropTypes, StyleSheet, Text} = require('react-native');
import {Field} from './Field';


Expand Down Expand Up @@ -48,5 +48,5 @@ export class LinkComponent extends React.Component{

LinkComponent.propTypes = {
labelStyle: Text.propTypes.style,
containerStyle: View.propTypes.style
containerStyle: ViewPropTypes.style
}
4 changes: 2 additions & 2 deletions src/lib/SwitchComponent.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import React from 'react';
let { View, StyleSheet, Text, Switch} = require('react-native');
let { View, ViewPropTypes, StyleSheet, Text, Switch} = require('react-native');

import {Field} from './Field';

Expand Down Expand Up @@ -53,7 +53,7 @@ export class SwitchComponent extends React.Component{

SwitchComponent.propTypes = {
labelStyle: Text.propTypes.style,
containerStyle: View.propTypes.style,
containerStyle: ViewPropTypes.style,
switchStyle: Switch.propTypes.style
}

Expand Down