添加很多页面

This commit is contained in:
wushenghua
2016-02-23 15:35:42 +08:00
parent 1c9594f753
commit 3070f11460
29 changed files with 1504 additions and 428 deletions
+233
View File
File diff suppressed because one or more lines are too long
+96 -59
View File
File diff suppressed because one or more lines are too long
+214
View File
@@ -0,0 +1,214 @@
//3个主界面的listview
'use strict';
import React, {
AppRegistry,
Component,
StyleSheet,
ListView,
Text,
View,
Image,
TouchableOpacity,
AlertIOS,
RefreshControl,
ActivityIndicatorIOS
} from 'react-native';
import InfoPage from './Info.js'
export default class MyListView extends Component{
//初始化。
constructor(props) {
super(props);
this.state = {
isLoading: true, //是否正在加载.
isLoadingFail: true, //是否加载失败.
isHaveData: false, //是否有加载出数据了。
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}),
queryNumber: 0,
};
// this.setState({dataSource:this.props.dataSource});
}
componentDidMount(){
// this.props.navComponent.setNavItems({
// title: {
// component: (
// <Text style={styles.title}>
// {this.props.title}
// </Text>
// ),
// event: function() {
// this.fetchData();
// }.bind(this)
// }
// }),
this.myfetchData();
}
onRefresh(){
this.myfetchData();
}
//数据查询.
myfetchData(){
this.setState({isLoading:true,isLoadingFail:false});
this.props.fetchData().then((responseData)=>{
console.log('接受到数据');
console.log(responseData);
this.setState({
isLoading: false,
isLoadingFail: false,
isHaveData: true,
// dataSource:this.state.dataSource.cloneWithRows(responseData),
});
},(error)=>{
AlertIOS.alert('没有数据');
this.setState({
isLoading: false,
isLoadingFail:true,
isHaveData:false,
});
});
}
render(){
// return this.renderLoadingView();
if (!this.state.isHaveData) {
return this.renderLoadingView();
}
return (
<ListView
dataSource={this.props.dataSource}
renderRow={this.renderMovie.bind(this)}
renderSeparator={this.renderMovieRow}
refreshControl={
<RefreshControl
refreshing={this.state.isLoading}
onRefresh={this.myfetchData.bind(this)}
tintColor="#61BFA9"
title={this.props.refreshTitle}
colors={['#ff0000', '#00ff00', '#0000ff']}
progressBackgroundColor="#61BFA9"/>}
style={styles.listView}/>
);
}
pushInfo(index){
this.props.navigator.push({
title: 'New Page',
component: <InfoPage movie={this.state.dataSource.getRowData(0,index)}> </InfoPage>
}).bind(this);
}
renderLoadingView(){
if (this.state.isLoadingFail) {
return (
<TouchableOpacity onPress={() =>this.myfetchData.bind(this)} style={styles.container} >
<View style={styles.container}>
<Text>
{'点击刷新'}
</Text>
</View>
</TouchableOpacity>
);
}else{
return(
<View style={styles.container}>
<Text>
{'正在刷新'}
</Text>
<ActivityIndicatorIOS />
</View>
)
}
}
renderMovieRow(sectionID, rowID, adjacentRowHighlighted){
return (
<View style={styles.topContainer} key={rowID}>
</View>
);
}
renderMovie(movie,sectionID, rowID, highlightRow){
return (
<View style={styles.container} key={rowID}>
<TouchableOpacity onPress={(rowID) =>this.pushInfo.bind(this)} style={styles.container} >
<Image
source={{uri: movie.imageurl}}
style={styles.thumbnail}/>
<View style={styles.rightContainer}>
<Text style={styles.title}>{movie.title}</Text>
</View>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex:2,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'White',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
title: {
fontSize: 15,
marginBottom: 8,
marginTop: 10,
marginLeft: 4,
marginRight: 4,
textAlign: 'left',
},
year: {
textAlign: 'center',
},
rightContainer: {
flex: 1,
},
topContainer:{
flex:1,
height : 30,
backgroundColor: 'LightGray',
},
thumbnail: {
width: 400,
height: 200,
},
listView: {
paddingTop: 0,
marginBottom: 44,
backgroundColor: 'LightGray',
},
navItem: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
// top{
// height:60,
// flex: 1,
// },
});
module.exports = MyListView;
+149
View File
@@ -0,0 +1,149 @@
//3个主界面的listview
'use strict';
import React, {
AppRegistry,
Component,
StyleSheet,
ListView,
Text,
View,
Image,
TouchableOpacity,
AlertIOS,
RefreshControl,
ActivityIndicatorIOS
} from 'react-native';
import MyListView from './MyListView'
var isPromise = require('is-promise')
var REQUEST_URL = 'http://127.0.0.1:3000/users/list';
export default class MyListViewDemo extends Component{
//初始化。
constructor(props) {
super(props);
this.state = {
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
}),
};
}
componentDidMount(){
this.props.navComponent.setNavItems({
title: {
component: (
<Text style={styles.title}>
随机
</Text>
),
event: function() {
this.fetchData();
}.bind(this)
}
})
}
onRefresh(){
this.myfetchData();
}
//数据查询.
fetchData(){
var page = Math.random() * 1000;
page = Math.floor(page);
var url = REQUEST_URL + '?page=' + page;
return new Promise((resolve, reject)=>{
fetch(url)
.then((response) => response.json())
.catch((error) => {
reject(err);
})
.then((responseData) => {
if(responseData){
this.setState({
dataSource: this.state.dataSource.cloneWithRows(responseData.datas),
});
resolve(responseData.datas);
}else{
reject('none');
}
})
.done();
})
}
render(){
return (
<MyListView
dataSource={this.state.dataSource}
refreshTitle={'测试一下刷新'}
navigator={this.props.navigator}
fetchData={this.fetchData.bind(this)}/>
);
}
}
const styles = StyleSheet.create({
container: {
flex:2,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'White',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
title: {
fontSize: 15,
marginBottom: 8,
marginTop: 10,
marginLeft: 4,
marginRight: 4,
textAlign: 'left',
},
year: {
textAlign: 'center',
},
rightContainer: {
flex: 1,
},
topContainer:{
flex:1,
height : 30,
backgroundColor: 'LightGray',
},
thumbnail: {
width: 400,
height: 200,
},
listView: {
paddingTop: 0,
marginBottom: 44,
backgroundColor: 'LightGray',
},
navItem: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
// top{
// height:60,
// flex: 1,
// },
});
module.exports = MyListViewDemo;
+1 -1
View File
@@ -119,7 +119,7 @@ getInitialState: function() {
<Text> <Text>
点击刷新 点击刷新
</Text> </Text>
<Image source={require('./../../../Desktop/ReactDemo/testdemo/bottom_ic_first_up.png')}> <Image source={require('./bottom_ic_first_up.png')}>
</Image> </Image>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
+12 -10
View File
@@ -14,10 +14,10 @@ import React, {
TouchableOpacity, TouchableOpacity,
AlertIOS, AlertIOS,
ActivityIndicatorIOS, ActivityIndicatorIOS,
RefreshControl,
} from 'react-native'; } from 'react-native';
import InfoPage from './Info.js' import InfoPage from './Info.js'
var ControlledRefreshableListView = require('./lib/ControlledRefreshableListView');
var REQUEST_URL = 'http://127.0.0.1:3000/users/list'; var REQUEST_URL = 'http://127.0.0.1:3000/users/list';
var MOCKED_MOVIES_DATA = [ var MOCKED_MOVIES_DATA = [
{title: 'Title', year: '2015', posters: {thumbnail: 'http://i.imgur.com/UePbdph.jpg'}}, {title: 'Title', year: '2015', posters: {thumbnail: 'http://i.imgur.com/UePbdph.jpg'}},
@@ -136,21 +136,23 @@ getInitialState: function() {
return this.renderLoadingView(); return this.renderLoadingView();
} }
return ( return (
<ControlledRefreshableListView <ListView
dataSource={this.state.dataSource} dataSource={this.state.dataSource}
renderRow={this.renderMovie} renderRow={this.renderMovie}
renderSeparator={this.renderMovieRow} renderSeparator={this.renderMovieRow}
onEndReached={this.onEndReached} onEndReached={this.onEndReached}
renderFooter={this.renderFoot} refreshControl={
isRefreshing={this.state.isRefreshingArticles} <RefreshControl
onRefresh={()=>this.onRefreshData()} refreshing={this.state.isLoading}
onResponderRelease={()=>this} onRefresh={this.fetchData}
refreshDescription="加载中" tintColor="#61BFA9"
waitingDescription="松开可以刷新" title="刷新"
colors={['#ff0000', '#00ff00', '#0000ff']}
progressBackgroundColor="#61BFA9"/>}
style={styles.listView}/> style={styles.listView}/>
); );
}, },
renderFoot:function(){ renderFoot:function(){
return ( return (
<View style={styles.foot}> <View style={styles.foot}>
+9 -1
View File
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
platform :ios, 7.0
pod 'LKDBHelper'
+15
View File
@@ -0,0 +1,15 @@
PODS:
- FMDB (2.6):
- FMDB/standard (= 2.6)
- FMDB/standard (2.6)
- LKDBHelper (2.1.8):
- FMDB
DEPENDENCIES:
- LKDBHelper
SPEC CHECKSUMS:
FMDB: c1968bab3ab0aed38f66cb778ae1e7fa9a652b6e
LKDBHelper: 1b55f67e44f34af8828b31aa36b36141fdde03a8
COCOAPODS: 0.39.0
+155 -2
View File
@@ -22,6 +22,13 @@
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
9F11DD32883B03E4B264948B /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D67D0A238A6039E65D1E8453 /* libPods.a */; };
A96B82451C7C3CE600FFB1FE /* ASHUIMenuControllerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A96B823C1C7C3CE600FFB1FE /* ASHUIMenuControllerManager.m */; };
A96B82461C7C3CE600FFB1FE /* ASHUtilManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A96B823E1C7C3CE600FFB1FE /* ASHUtilManager.m */; };
A96B82471C7C3CE600FFB1FE /* MessageInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = A96B82401C7C3CE600FFB1FE /* MessageInfo.m */; };
A96B82481C7C3CE600FFB1FE /* MessageInfoManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A96B82421C7C3CE600FFB1FE /* MessageInfoManager.m */; };
A96B82491C7C3CE600FFB1FE /* UIViewController+Category.m in Sources */ = {isa = PBXBuildFile; fileRef = A96B82441C7C3CE600FFB1FE /* UIViewController+Category.m */; };
A96B825A1C7C407500FFB1FE /* libRCTCameraRoll.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A96B82591C7C3FCB00FFB1FE /* libRCTCameraRoll.a */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
@@ -102,6 +109,13 @@
remoteGlobalIDString = 58B5119B1A9E6C1200147676; remoteGlobalIDString = 58B5119B1A9E6C1200147676;
remoteInfo = RCTText; remoteInfo = RCTText;
}; };
A96B82581C7C3FCB00FFB1FE /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A96B82541C7C3FCB00FFB1FE /* RCTCameraRoll.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B5115D1A9E6B3D00147676;
remoteInfo = RCTCameraRoll;
};
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
@@ -124,8 +138,22 @@
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = testdemo/Info.plist; sourceTree = "<group>"; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = testdemo/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = testdemo/main.m; sourceTree = "<group>"; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = testdemo/main.m; sourceTree = "<group>"; };
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; }; 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
4E8B8F317A98774CD5A46837 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
589BBF17415E6F48D1D7AD15 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; }; 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; }; 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
A96B823B1C7C3CE600FFB1FE /* ASHUIMenuControllerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASHUIMenuControllerManager.h; sourceTree = "<group>"; };
A96B823C1C7C3CE600FFB1FE /* ASHUIMenuControllerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASHUIMenuControllerManager.m; sourceTree = "<group>"; };
A96B823D1C7C3CE600FFB1FE /* ASHUtilManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASHUtilManager.h; sourceTree = "<group>"; };
A96B823E1C7C3CE600FFB1FE /* ASHUtilManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASHUtilManager.m; sourceTree = "<group>"; };
A96B823F1C7C3CE600FFB1FE /* MessageInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageInfo.h; sourceTree = "<group>"; };
A96B82401C7C3CE600FFB1FE /* MessageInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageInfo.m; sourceTree = "<group>"; };
A96B82411C7C3CE600FFB1FE /* MessageInfoManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageInfoManager.h; sourceTree = "<group>"; };
A96B82421C7C3CE600FFB1FE /* MessageInfoManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageInfoManager.m; sourceTree = "<group>"; };
A96B82431C7C3CE600FFB1FE /* UIViewController+Category.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+Category.h"; sourceTree = "<group>"; };
A96B82441C7C3CE600FFB1FE /* UIViewController+Category.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+Category.m"; sourceTree = "<group>"; };
A96B82541C7C3FCB00FFB1FE /* RCTCameraRoll.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTCameraRoll.xcodeproj; path = "../node_modules/react-native/Libraries/CameraRoll/RCTCameraRoll.xcodeproj"; sourceTree = "<group>"; };
D67D0A238A6039E65D1E8453 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@@ -140,6 +168,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
A96B825A1C7C407500FFB1FE /* libRCTCameraRoll.a in Frameworks */,
146834051AC3E58100842450 /* libReact.a in Frameworks */, 146834051AC3E58100842450 /* libReact.a in Frameworks */,
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */, 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */,
@@ -150,6 +179,7 @@
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
9F11DD32883B03E4B264948B /* libPods.a in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@@ -232,6 +262,7 @@
13B07FAE1A68108700A75B9A /* testdemo */ = { 13B07FAE1A68108700A75B9A /* testdemo */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A96B823A1C7C3CE600FFB1FE /* Class */,
008F07F21AC5B25A0029DE68 /* main.jsbundle */, 008F07F21AC5B25A0029DE68 /* main.jsbundle */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */, 13B07FAF1A68108700A75B9A /* AppDelegate.h */,
13B07FB01A68108700A75B9A /* AppDelegate.m */, 13B07FB01A68108700A75B9A /* AppDelegate.m */,
@@ -262,6 +293,7 @@
832341AE1AAA6A7D00B99B32 /* Libraries */ = { 832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
A96B82541C7C3FCB00FFB1FE /* RCTCameraRoll.xcodeproj */,
146833FF1AC3E56700842450 /* React.xcodeproj */, 146833FF1AC3E56700842450 /* React.xcodeproj */,
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */, 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */,
@@ -291,6 +323,8 @@
832341AE1AAA6A7D00B99B32 /* Libraries */, 832341AE1AAA6A7D00B99B32 /* Libraries */,
00E356EF1AD99517003FC87E /* testdemoTests */, 00E356EF1AD99517003FC87E /* testdemoTests */,
83CBBA001A601CBA00E9B192 /* Products */, 83CBBA001A601CBA00E9B192 /* Products */,
D9444A8B1A40711F773FD395 /* Pods */,
C6406205DAB825BD0DC603B2 /* Frameworks */,
); );
indentWidth = 2; indentWidth = 2;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -305,6 +339,49 @@
name = Products; name = Products;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
A96B823A1C7C3CE600FFB1FE /* Class */ = {
isa = PBXGroup;
children = (
A96B823B1C7C3CE600FFB1FE /* ASHUIMenuControllerManager.h */,
A96B823C1C7C3CE600FFB1FE /* ASHUIMenuControllerManager.m */,
A96B823D1C7C3CE600FFB1FE /* ASHUtilManager.h */,
A96B823E1C7C3CE600FFB1FE /* ASHUtilManager.m */,
A96B823F1C7C3CE600FFB1FE /* MessageInfo.h */,
A96B82401C7C3CE600FFB1FE /* MessageInfo.m */,
A96B82411C7C3CE600FFB1FE /* MessageInfoManager.h */,
A96B82421C7C3CE600FFB1FE /* MessageInfoManager.m */,
A96B82431C7C3CE600FFB1FE /* UIViewController+Category.h */,
A96B82441C7C3CE600FFB1FE /* UIViewController+Category.m */,
);
name = Class;
path = testdemo/Class;
sourceTree = "<group>";
};
A96B82551C7C3FCB00FFB1FE /* Products */ = {
isa = PBXGroup;
children = (
A96B82591C7C3FCB00FFB1FE /* libRCTCameraRoll.a */,
);
name = Products;
sourceTree = "<group>";
};
C6406205DAB825BD0DC603B2 /* Frameworks */ = {
isa = PBXGroup;
children = (
D67D0A238A6039E65D1E8453 /* libPods.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
D9444A8B1A40711F773FD395 /* Pods */ = {
isa = PBXGroup;
children = (
589BBF17415E6F48D1D7AD15 /* Pods.debug.xcconfig */,
4E8B8F317A98774CD5A46837 /* Pods.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */ /* End PBXGroup section */
/* Begin PBXNativeTarget section */ /* Begin PBXNativeTarget section */
@@ -330,10 +407,13 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "testdemo" */; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "testdemo" */;
buildPhases = ( buildPhases = (
F35D02B5C27F53894766E3BE /* Check Pods Manifest.lock */,
13B07F871A680F5B00A75B9A /* Sources */, 13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */, 13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
1B17331BD8AA282C42483D64 /* Embed Pods Frameworks */,
3E0A10D478F798AF58FA27F0 /* Copy Pods Resources */,
); );
buildRules = ( buildRules = (
); );
@@ -375,6 +455,10 @@
ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */; ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */;
ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
}, },
{
ProductGroup = A96B82551C7C3FCB00FFB1FE /* Products */;
ProjectRef = A96B82541C7C3FCB00FFB1FE /* RCTCameraRoll.xcodeproj */;
},
{ {
ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */; ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */;
ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */;
@@ -491,6 +575,13 @@
remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR; sourceTree = BUILT_PRODUCTS_DIR;
}; };
A96B82591C7C3FCB00FFB1FE /* libRCTCameraRoll.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTCameraRoll.a;
remoteRef = A96B82581C7C3FCB00FFB1FE /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */ /* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */ /* Begin PBXResourcesBuildPhase section */
@@ -527,6 +618,51 @@
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "../node_modules/react-native/packager/react-native-xcode.sh"; shellScript = "../node_modules/react-native/packager/react-native-xcode.sh";
}; };
1B17331BD8AA282C42483D64 /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
3E0A10D478F798AF58FA27F0 /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
showEnvVarsInLog = 0;
};
F35D02B5C27F53894766E3BE /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */ /* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */
@@ -542,8 +678,13 @@
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
A96B82491C7C3CE600FFB1FE /* UIViewController+Category.m in Sources */,
A96B82461C7C3CE600FFB1FE /* ASHUtilManager.m in Sources */,
A96B82481C7C3CE600FFB1FE /* MessageInfoManager.m in Sources */,
A96B82451C7C3CE600FFB1FE /* ASHUIMenuControllerManager.m in Sources */,
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
13B07FC11A68108700A75B9A /* main.m in Sources */, 13B07FC11A68108700A75B9A /* main.m in Sources */,
A96B82471C7C3CE600FFB1FE /* MessageInfo.m in Sources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@@ -609,6 +750,7 @@
}; };
13B07F941A680F5B00A75B9A /* Debug */ = { 13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 589BBF17415E6F48D1D7AD15 /* Pods.debug.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEAD_CODE_STRIPPING = NO; DEAD_CODE_STRIPPING = NO;
@@ -620,13 +762,19 @@
INFOPLIST_FILE = testdemo/Info.plist; INFOPLIST_FILE = testdemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 7.0; IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = (
"-ObjC",
"-l\"FMDB\"",
"-l\"LKDBHelper\"",
"-l\"sqlite3\"",
);
PRODUCT_NAME = testdemo; PRODUCT_NAME = testdemo;
}; };
name = Debug; name = Debug;
}; };
13B07F951A680F5B00A75B9A /* Release */ = { 13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 4E8B8F317A98774CD5A46837 /* Pods.release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
@@ -637,7 +785,12 @@
INFOPLIST_FILE = testdemo/Info.plist; INFOPLIST_FILE = testdemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 7.0; IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = "-ObjC"; OTHER_LDFLAGS = (
"-ObjC",
"-l\"FMDB\"",
"-l\"LKDBHelper\"",
"-l\"sqlite3\"",
);
PRODUCT_NAME = testdemo; PRODUCT_NAME = testdemo;
}; };
name = Release; name = Release;
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:testdemo.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
@@ -0,0 +1,14 @@
//
// ASHUIMenuControllerManager.h
// testdemo
//
// Created by xmfish on 16/2/19.
// Copyright © 2016年 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#import "RCTLog.h"
@interface ASHUIMenuControllerManager : NSObject<RCTBridgeModule>
@end
@@ -0,0 +1,78 @@
//
// ASHUIMenuControllerManager.m
// testdemo
//
// Created by xmfish on 16/2/19.
// Copyright © 2016年 Facebook. All rights reserved.
//
#import "ASHUIMenuControllerManager.h"
#import <UIKit/UIKit.h>
#import "RCTConvert.h"
#import "RCTLog.h"
#import "RCTUtils.h"
#import "RCTBridge.h"
#import "RCTUIManager.h"
#import "UIViewController+Category.h"
@implementation ASHUIMenuControllerManager
{
NSMapTable *_callbacks;
UIMenuController *_menu;
}
RCT_EXPORT_MODULE();
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}
RCT_EXPORT_METHOD(hideMenu)
{
if (_menu) {
[_menu setMenuVisible:NO];
}
}
RCT_EXPORT_METHOD(showMenuWithTitleArr:(NSArray*)titleArray withXPoint:(nonnull NSNumber*)xpoint withYPoint:(nonnull NSNumber*)ypoint withCallback:(RCTResponseSenderBlock)callback)
{
if (!_callbacks) {
_callbacks = [NSMapTable strongToStrongObjectsMapTable];
}
if(titleArray.count>0){
NSMutableArray* itemArr = [NSMutableArray array];
[titleArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
UIMenuItem *menuItem = [[UIMenuItem alloc] initWithTitle:obj action:@selector(meunClick:)];
[itemArr addObject:menuItem];
}];
UIViewController *controller = RCTKeyWindow().rootViewController;
while (controller.presentedViewController) {
controller = controller.presentedViewController;
}
if (controller == nil) {
RCTLogError(@"Tried to display MenuController but there is no application window. options: %@", titleArray);
return;
}
controller.rnDelegate = self;
UIView *sourceView = controller.view;
[sourceView becomeFirstResponder];
UIMenuController *menu = [UIMenuController sharedMenuController];
[menu setMenuItems:itemArr];
[menu setTargetRect:CGRectMake(xpoint.floatValue, ypoint.floatValue, 1.0, 1.0) inView:sourceView];
[menu setMenuVisible:YES animated:YES];
_menu = menu;
[_callbacks setObject:callback forKey:menu];
}else{
callback(@[@"no title"]);
}
}
-(void)meunClick:(UIMenuController*)menuController
{
if ([_callbacks objectForKey:menuController]) {
((RCTResponseSenderBlock)[_callbacks objectForKey:menuController])(@[@"no title", @1]);
}
}
@end
+14
View File
@@ -0,0 +1,14 @@
//
// ASHUtilManager.h
// testdemo
//
// Created by xmfish on 16/2/22.
// Copyright © 2016年 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#import "RCTLog.h"
@interface ASHUtilManager : NSObject <RCTBridgeModule>
@end
+21
View File
@@ -0,0 +1,21 @@
//
// ASHUtilManager.m
// testdemo
//
// Created by xmfish on 16/2/22.
// Copyright © 2016年 Facebook. All rights reserved.
//
#import "ASHUtilManager.h"
#import <UIKit/UIKit.h>
@implementation ASHUtilManager
RCT_EXPORT_MODULE();
//复制文本
RCT_EXPORT_METHOD(pasteWithText:(NSString*)text)
{
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = text;
}
@end
+21
View File
@@ -0,0 +1,21 @@
//
// MessageInfo.h
// testdemo
//
// Created by xmfish on 16/2/18.
// Copyright © 2016年 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <LKDBHelper.h>
#import "NSObject+LKDBHelper.h"
@interface MessageInfo : NSObject
@property(nonatomic, strong) NSString* title;
@property(nonatomic, strong) NSString* image;
@property(nonatomic, strong) NSString* infoKey;
-(NSDictionary*)dictionary;
-(NSString*)JSON;
@end
+28
View File
@@ -0,0 +1,28 @@
//
// MessageInfo.m
// testdemo
//
// Created by xmfish on 16/2/18.
// Copyright © 2016年 Facebook. All rights reserved.
//
#import "MessageInfo.h"
@implementation MessageInfo
+(NSString *)getTableName
{
return @"MessageInfo";
}
+ (NSString*)getPrimaryKey
{
return @"infoKey";
}
-(NSDictionary*)dictionary
{
return [NSDictionary dictionaryWithObjectsAndKeys:self.infoKey, @"id", self.title,@"title", self.image,@"imageurl", nil];
}
-(NSString*)JSON
{
return [NSString stringWithFormat:@"{'id':%@,'title':%@,'imageurl':%@}",self.infoKey,self.title,self.image];
}
@end
+14
View File
@@ -0,0 +1,14 @@
//
// MessageInfoManager.h
// testdemo
//
// Created by xmfish on 16/2/18.
// Copyright © 2016年 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#import "RCTLog.h"
@interface MessageInfoManager : NSObject <RCTBridgeModule>
@end
+65
View File
@@ -0,0 +1,65 @@
//
// MessageInfoManager.m
// testdemo
//
// Created by xmfish on 16/2/18.
// Copyright © 2016年 Facebook. All rights reserved.
//
#import "MessageInfoManager.h"
#import "MessageInfo.h"
#import <LKDBHelper.h>
#import "NSObject+LKDBHelper.h"
#import "UIView+React.h"
@implementation MessageInfoManager
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(getMessageArrWithCallBack:(RCTResponseSenderBlock)callback)
{
RCTLogInfo(@"getMessageArrWithCallBack");
NSMutableArray* array = [MessageInfo searchWithWhere:nil orderBy:nil offset:0 count:MAXFLOAT];
if (array) {
NSMutableArray* resultArr = [NSMutableArray array];
[array enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[resultArr addObject:[obj dictionary]];
}];
callback(@[[NSNull null], resultArr]);
}else{
callback(@[@"no data", [NSNull null]]);
}
}
RCT_EXPORT_METHOD(saveMessageWithKey:(NSString*)key withImage:(NSString*)image withTitle:(NSString*)title withCallBack:(RCTResponseSenderBlock)callback)
{
RCTLogInfo(@"saveMessageWithKey");
MessageInfo* info = [[MessageInfo alloc] init];
info.infoKey = key;
info.image = image;
info.title = title;
BOOL ret = [MessageInfo insertWhenNotExists:info];
if (ret) {
callback(@[[NSNull null], @1]);
}else{
callback(@[@"unkonwerror", [NSNull null]]);
}
}
RCT_EXPORT_METHOD(isExistWithKey:(NSString*)key withCallBack:(RCTResponseSenderBlock)callback)
{
NSMutableArray* array = [MessageInfo searchWithWhere:@{@"infokey":key}];
callback(@[[NSNull null], @(array.count>0?1:0)]);
}
RCT_EXPORT_METHOD(delWithKey:(NSString*)key withCallBack:(RCTResponseSenderBlock)callback)
{
BOOL ret = [MessageInfo deleteWithWhere:@{@"infokey":key}];
callback(@[[NSNull null], @(ret)]);
}
@end
@@ -0,0 +1,14 @@
//
// UIViewController+Category.h
// testdemo
//
// Created by xmfish on 16/2/19.
// Copyright © 2016年 Facebook. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIViewController (Category)
@property (nonatomic, weak)id rnDelegate;
@end
@@ -0,0 +1,38 @@
//
// UIViewController+Category.m
// testdemo
//
// Created by xmfish on 16/2/19.
// Copyright © 2016年 Facebook. All rights reserved.
//
#import "UIViewController+Category.h"
#import "objc/runtime.h"
static char rnDelegateURLKey;
@implementation UIViewController (Category)
- (void)setRnDelegate:(id)rnDelegate
{
objc_setAssociatedObject(self,&rnDelegateURLKey, rnDelegate, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (id)rnDelegate
{
return objc_getAssociatedObject(self, &rnDelegateURLKey);
}
-(BOOL)canBecomeFirstResponder
{
return YES;
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (action == @selector(meunClick:) ){
return YES;
}
return NO;
}
-(void)meunClick:(id)sender
{
if (self.rnDelegate && [self.rnDelegate respondsToSelector:@selector(meunClick:)]) {
[self.rnDelegate meunClick:sender];
}
}
@end
-186
View File
@@ -1,186 +0,0 @@
var React = require('react-native')
var {
PropTypes,
StyleSheet,
ActivityIndicatorIOS,
View,
Text,
} = React
var ListView = require('./ListView')
var createElementFrom = require('./createElementFrom')
var RefreshingIndicator = require('./RefreshingIndicator')
var isPromise = require('is-promise')
var delay = require('./delay')
const SCROLL_EVENT_THROTTLE = 32
const MIN_PULLDOWN_DISTANCE = 40
const LISTVIEW_REF = 'listview'
var ControlledRefreshableListView = React.createClass({
propTypes: {
onRefresh: PropTypes.func.isRequired,
minDisplayTime: PropTypes.number,
minBetweenTime: PropTypes.number,
isRefreshing: PropTypes.bool.isRequired,
refreshDescription: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
waitingDescription: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
refreshingIndictatorComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.element]),
minPulldownDistance: PropTypes.number,
ignoreInertialScroll: PropTypes.bool,
scrollEventThrottle: PropTypes.number,
onScroll: PropTypes.func,
renderHeader: PropTypes.func,
renderHeaderWrapper: PropTypes.func,
onResponderGrant: PropTypes.func,
onResponderRelease: PropTypes.func,
},
getInitialState() {
return {
refreshstate: 1,//1普通,2下拉中,3下拉可以松手,4刷新中
}
},
getDefaultProps() {
return {
minDisplayTime: 300,
minBetweenTime: 300,
minPulldownDistance: MIN_PULLDOWN_DISTANCE,
scrollEventThrottle: SCROLL_EVENT_THROTTLE,
ignoreInertialScroll: true,
refreshingIndictatorComponent: RefreshingIndicator,
}
},
handleScroll(e) {
var scrollY = e.nativeEvent.contentInset.top + e.nativeEvent.contentOffset.y
if (this.beginTouch && (this.state.refreshstate==2 || this.state.refreshstate==1) && scrollY< -this.props.minPulldownDistance) {
this.setState({
refreshstate: 3,
})
}else if(this.beginTouch && this.state.refreshstate==1 && (scrollY < -20)){
this.setState({
refreshstate: 2,
})
}
if (this.endTouch || (!this.endTouch && !this.props.ignoreInertialScroll)) {
if (scrollY < -this.props.minPulldownDistance) {
if (!this.props.isRefreshing) {
this.setState({
refreshstate: 4,
})
if (this.props.onRefresh ) {
this.props.onRefresh()
}
}
}
}
this.props.onScroll && this.props.onScroll(e)
},
handleResponderGrant() {
this.endTouch = false
this.beginTouch = true
this.isTouching = true
if (this.props.onResponderGrant) {
this.props.onResponderGrant.apply(null, arguments)
}
},
handleResponderRelease() {
this.endTouch = true
this.beginTouch = false
this.isTouching = false
if(this.state.refreshstate == 2){
this.setState({refreshstate:1})
}
if(this.state.refreshstate == 3){
this.setState({refreshstate:4})
}
if (this.props.onResponderRelease) {
this.props.onResponderRelease.apply(null, arguments)
}
},
getScrollResponder() {
return this.refs[LISTVIEW_REF].getScrollResponder()
},
setNativeProps(props) {
this.refs[LISTVIEW_REF].setNativeProps(props)
},
renderHeader() {
var description = this.props.refreshDescription
var waiting = '松手即可刷新'
var isscroll = '下拉可以刷新'
var refreshingIndictator
if (this.state.refreshstate == 4) {
// console.log('正在刷新')
Promise.all([
delay(this.props.minDisplayTime),
])
.then(() => {
if (!this.props.isRefreshing) {this.setState({refreshstate:1})};
})
// })
refreshingIndictator = createElementFrom(this.props.refreshingIndictatorComponent, {description:description})
} else {
if (this.state.refreshstate == 2) {
console.log(waiting)
refreshingIndictator = createElementFrom(this.props.refreshingIndictatorComponent, {description:isscroll,stylesheet:{activityIndicator:styles.refreshhide}})
// return this.renderFoot
}else if(this.state.refreshstate == 3){
refreshingIndictator = createElementFrom(this.props.refreshingIndictatorComponent, {description:waiting,stylesheet:{activityIndicator:styles.refreshhide}})
}else{
refreshingIndictator = null
}
}
if (this.props.renderHeaderWrapper) {
return this.props.renderHeaderWrapper(refreshingIndictator)
} else if (this.props.renderHeader) {
console.warn('renderHeader is deprecated. Use renderHeaderWrapper instead.')
return this.props.renderHeader(refreshingIndictator)
} else {
return refreshingIndictator
}
},
renderFoot(){
return (
<View style={styles.tophead}>
<ActivityIndicatorIOS />
<Text>下拉刷新</Text>
</View>
)
},
render() {
return (
<ListView
{...this.props}
ref={LISTVIEW_REF}
onScroll={this.handleScroll}
renderHeader={this.renderHeader}
scrollEventThrottle={this.props.scrollEventThrottle}
onResponderGrant={this.handleResponderGrant}
onResponderRelease={this.handleResponderRelease}
/>
)
},
})
const styles = StyleSheet.create({
tophead:{
height : 30,
textAlign:'center',
},
refreshhide:{
opacity:0,
},
refreshshow:{
opacity:100
}
});
ControlledRefreshableListView.DataSource = ListView.DataSource
ControlledRefreshableListView.RefreshingIndicator = RefreshingIndicator
module.exports = ControlledRefreshableListView
-3
View File
@@ -1,3 +0,0 @@
var {ListView} = require('react-native')
module.exports = ListView
+202
View File
@@ -0,0 +1,202 @@
'use strict';
var React = require('react-native');
var {
Component,
StyleSheet,
Text,
View,
Navigator,
TouchableOpacity,
SegmentedControlIOS,
Image
} = React;
var MainTabBar = require('./MainTabBar');
var style = StyleSheet.create({
flexEnabled: {
flex: 1
},
leftBackButton: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
paddingLeft: 7
},
sceneStyle: {
shadowColor: '#000000',
shadowOpacity: .5,
shadowOffset: {
height: 1,
width: 0
},
overflow: 'visible',
flex: 1,
marginTop: 64,
backgroundColor: '#ffffff'
}
});
var lightBackArrow = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAMAAABrrFhUAAAA2FBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8lb+eLAAAAR3RSTlMAAQIDBAYICQsMDQ4QERQXGBofJykqODlAQUlMUldeYWhrbW98f4KMlJWYnZ6goqutr7K0tbrAwcPMzs/T5ujp6+/z9ff7/dlYrXMAAAJCSURBVHja7dBXUlQBFEXR+wwtmHNWzBgxZzHDnf+M/LHUgg52lT++s/YM1q7639p/6enmxxeXJxXaxW/d3d1bVzL9d/pX94ZA/3r/0caQ7Q88sMMfd2CXP+zAFH/Ugan+oAMz/DEHZvpDDszxRxyY6w84sMA/+gML/SM/8Bf+7gfh/u4b4f7uo+H+Xg/39/ch2989Cff3ari/94X734T7+0K4//2Q7f+ymu3/eizcf5yfn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn5+fn39a18P9J8P99SrcvxLur9Ph/jq31IDzo/PXmaUGfD4yugEHO/3A2/QDpzr9wK30A8NDBxxwwAEHHHDAAQcccMABBxxwwAEHHHBg2QOHHXDAAQcccMABBxxwYGwHHjnggAMOOOCAAw444IADDjjggAMOOOCAAw444IADDjjggAMOOOCAAw444IADDjjggANLHvjkgAMOOOCAAw444IADDjjggAMOOOCAAw6M7sCGAw444IADDix5YHOSfuB1pR84m37gZaUf2Jt+YKXCDxyo7ANbQ2UfuFuVfeBEZR+4XRV94MlQ0Qee7alKPjBu/+IDY/cvOjB+//wDCf55BzL8sw88D/HPOpDjn34gyT/tQJZ/94E0/84Def6q4f5v/+NAf1Vd3f7pvzlUZitr77a3P1w7VPon/QDqIm8Mnw8FiAAAAABJRU5ErkJggg==';
class TabBarNavigator extends Component {
constructor(props) {
super(props);
this.state = {
rootNavigatorTitle: '',
currentTabIndex: 0,
refresh:0,
};
this.navItems = {};
this.navRouter = {};
this.currentRoute = null;
this.rootNavigatorItems = {};
this.currentTabIndex = 0;
var self = this;
this.navRouter = {
LeftButton(route, navigator, index, navState) {
if (!route.isRoot) {
if (route.navItems && route.navItems.leftItem) {
return React.cloneElement(route.navItems.leftItem.component, {
onPress: () => {route.navItems.leftItem.event(self.popThisNavigator.bind(self, navigator))}
});
}
else {
return (
<TouchableOpacity style={style.leftBackButton} onPress={() => {
self.popThisNavigator(navigator);
}}>
<Image style={{width: 20, height: 20}} source={{uri: lightBackArrow}}/>
</TouchableOpacity>
);
}
}
else {
var navItems = self.rootNavigatorItems;
var currentIndex = self.currentTabIndex;
if (navItems[currentIndex] && navItems[currentIndex].leftItem) {
return React.cloneElement(navItems[currentIndex].leftItem.component, {
onPress: () => {navItems[currentIndex].leftItem.event()}
});
}
}
},
RightButton(route, navigator, index, navState) {
if (!route.isRoot) {
if (route.navItems && route.navItems.rightItem) {
return React.cloneElement(route.navItems.rightItem.component, {
onPress: () => {route.navItems.rightItem.event(self.popThisNavigator.bind(self, navigator))}
});
}
}
else {
var navItems = self.rootNavigatorItems;
var currentIndex = self.currentTabIndex;
if (navItems[currentIndex] && navItems[currentIndex].rightItem) {
return React.cloneElement(navItems[currentIndex].rightItem.component, {
onPress: () => {navItems[currentIndex].rightItem.event()}
});
}
}
},
Title(route, navigator, index, navState) {
if (!route.isRoot) {
if (route.navItems && route.navItems.title) {
return React.cloneElement(route.navItems.title.component, {
onPress: () => {route.navItems.title.event()}
});
}
}
else {
var navItems = self.rootNavigatorItems;
var currentIndex = self.state.currentTabIndex;
if (navItems[currentIndex] && navItems[currentIndex].title) {
return React.cloneElement(navItems[currentIndex].title.component, {
onPress: () => {navItems[currentIndex].title.event()}
});
}
}
return (
<Text style={{flex: 1, justifyContent: 'center', color: self.props.navTintColor ? self.props.navTintColor : 'ffffff', fontSize: 17, marginTop: 12}}>
{route.isRoot ? self.state.rootNavigatorTitle : route.title}
</Text>
);
}
};
}
setNavItems(config) {
console.log('setting nav items. currentTabIndex: ' + this.currentTabIndex);
if (this.currentRoute.isRoot) {
this.rootNavigatorItems[this.state.currentTabIndex] = config;
this.forceUpdate();
}
else {
this.currentRoute.navItems = config;
}
}
popThisNavigator(navigator) {
this.resetNavItems();
this.forceReRender();
navigator.pop();
}
resetNavItems() {
this.navItems.rightItem = false;
this.navItems.titleItem = false;
this.navItems.leftItem = false;
}
forceReRender() {
this.setState({
forceReRender: !this.state.forceReRender
});
}
reloadView(){
this.forceUpdate();
}
renderScene(route, navigator) {
this.currentRoute = route;
this.resetNavItems();
var newComponent = React.cloneElement(route.component, {
navigator: navigator,
navComponent: this
});
return newComponent;
}
render() {
var initialRoute = {
title: '',
isRoot: true,
component: (
<MainTabBar {...this.props} initialConfig={this.props.children} onChange={this.props.onChange}/>
)
};
var navBar = (
<Navigator.NavigationBar
style={{backgroundColor: this.props.navBarTintColor ? this.props.navBarTintColor : 'rgba(0,0,0,.8)', alignItems: 'center', borderBottomWidth: 1, borderBottomColor: '#ddd' }}
routeMapper={this.navRouter}
/>
);
return (
<Navigator
ref='navigator'
style={[style.flexEnabled, {backgroundColor: 'transparent'}]}
initialRoute={initialRoute}
renderScene={this.renderScene.bind(this)}
navigationBar={navBar}
sceneStyle={style.sceneStyle}
/>
);
}
}
class TabBarNavigatorItem extends Component {
render() {
return <View/>;
}
}
TabBarNavigator.Item = TabBarNavigatorItem;
module.exports = TabBarNavigator;
+98
View File
@@ -0,0 +1,98 @@
'use strict';
var React = require('react-native');
var {
Component,
StyleSheet,
Text,
View,
TabBarIOS
} = React;
var style = StyleSheet.create({
rootView: {
flex: 1
}
});
class MainTabBar extends Component {
constructor(props) {
super(props);
this.tabBarData = [];
this.state = {
selectedTab: 0
};
}
componentWillMount() {
this.configureTabBar();
}
configureTabBar() {
var defaultTabIndex = 1;
React.Children.map(this.props.initialConfig, function(eachChild, index) {
var eachTabBarData = {
id: index,
title: eachChild.props.title,
icon: eachChild.props.icon,
component: eachChild.props.children
};
this.tabBarData.push(eachTabBarData);
if (eachChild.props.defaultTab) {
defaultTabIndex = index;
}
}.bind(this));
this.setState({
selectedTab: defaultTabIndex
});
this.props.navComponent.currentTabIndex = defaultTabIndex;
this.props.navComponent.setState({
rootNavigatorTitle: this.tabBarData[defaultTabIndex].title
});
}
switchTab(tabId, tabTitle, currentTabIndex) {
this.props.navComponent.currentTabIndex = currentTabIndex;
this.props.navComponent.setState({
currentTabIndex: currentTabIndex,
rootNavigatorTitle: tabTitle
});
this.props.navComponent.forceUpdate();
this.setState({
selectedTab: tabId
});
}
renderTabBarItems() {
var items = [];
var self = this;
for (var i = 0; i < this.tabBarData.length; i++) {
var eachData = this.tabBarData[i];
var eachComponent = React.cloneElement(eachData.component, {
navigator: this.props.navigator,
navComponent: this.props.navComponent
});
items.push(
<TabBarIOS.Item
key={i}
title={eachData.title}
icon={eachData.icon}
selected={self.state.selectedTab === eachData.id}
onPress={self.switchTab.bind(self, eachData.id, eachData.title, i)}>
{eachComponent}
</TabBarIOS.Item>
);
}
return items;
}
render() {
return (
<TabBarIOS
style={style.flexEnabled}
tintColor={this.props.tabTintColor}
barTintColor={this.props.tabBarTintColor}>
{this.renderTabBarItems()}
</TabBarIOS>
);
}
}
module.exports = MainTabBar;
-82
View File
@@ -1,82 +0,0 @@
var React = require('react-native')
var {
PropTypes,
} = React
var isPromise = require('is-promise')
var delay = require('./delay')
var ListView = require('./ListView')
var RefreshingIndicator = require('./RefreshingIndicator')
var ControlledRefreshableListView = require('./ControlledRefreshableListView')
const LISTVIEW_REF = 'listview'
var RefreshableListView = React.createClass({
propTypes: {
loadData: PropTypes.func.isRequired,
minDisplayTime: PropTypes.number,
minBetweenTime: PropTypes.number,
// props passed to child
refreshDescription: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
refreshingIndictatorComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.element]),
minPulldownDistance: PropTypes.number,
renderHeaderWrapper: PropTypes.func,
},
getDefaultProps() {
return {
minDisplayTime: 300,
minBetweenTime: 300,
minPulldownDistance: 40,
refreshingIndictatorComponent: RefreshingIndicator,
}
},
getInitialState() {
return {
isRefreshing: false,
}
},
handleRefresh() {
if (this.willRefresh) return
this.willRefresh = true
var loadingDataPromise = new Promise((resolve) => {
var loadDataReturnValue = this.props.loadData(resolve)
if (isPromise(loadDataReturnValue)) {
loadingDataPromise = loadDataReturnValue
}
Promise.all([
loadingDataPromise,
new Promise((resolve) => this.setState({isRefreshing: true}, resolve)),
delay(this.props.minDisplayTime),
])
.then(() => delay(this.props.minBetweenTime))
.then(() => {
this.willRefresh = false
this.setState({isRefreshing: false})
})
})
},
getScrollResponder() {
return this.refs[LISTVIEW_REF].getScrollResponder()
},
setNativeProps(props) {
this.refs[LISTVIEW_REF].setNativeProps(props)
},
render() {
return (
<ControlledRefreshableListView
{...this.props}
ref={LISTVIEW_REF}
onRefresh={this.handleRefresh}
isRefreshing={this.state.isRefreshing}
/>
)
},
})
RefreshableListView.DataSource = ListView.DataSource
RefreshableListView.RefreshingIndicator = RefreshingIndicator
module.exports = RefreshableListView
-63
View File
@@ -1,63 +0,0 @@
var React = require('react-native')
var {
View,
Text,
ActivityIndicatorIOS,
PropTypes,
StyleSheet,
isValidElement,
createElement,
} = React
var RefreshingIndicator = React.createClass({
propTypes: {
activityIndicatorComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.element]),
stylesheet: PropTypes.object,
description: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
},
getDefaultProps() {
return {
activityIndicatorComponent: ActivityIndicatorIOS,
}
},
renderActivityIndicator(style) {
var activityIndicator = this.props.activityIndicatorComponent
if (isValidElement(activityIndicator)) {
return activityIndicator
} else { // is a component class, not an element
return createElement(activityIndicator, {style})
}
},
render() {
var styles = Object.assign({}, stylesheet, this.props.stylesheet)
return (
<View style={[styles.container, styles.wrapper]}>
<View style={[styles.container, styles.loading, styles.content]}>
<Text style={styles.description}>
{this.props.description}
</Text>
{this.renderActivityIndicator(styles.activityIndicator)}
</View>
</View>
)
},
})
var stylesheet = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'space-around',
alignItems: 'center',
},
wrapper: {
height: 60,
marginTop: 10,
},
content: {
marginTop: 10,
height: 60,
},
})
module.exports = RefreshingIndicator
-16
View File
@@ -1,16 +0,0 @@
var React = require('react-native')
var {
cloneElement,
createElement,
isValidElement,
} = React
function createElementFrom(elementOrClass, props) {
if (isValidElement(elementOrClass)) {
return cloneElement(elementOrClass, props)
} else { // is a component class, not an element
return createElement(elementOrClass, props)
}
}
module.exports = createElementFrom
-5
View File
@@ -1,5 +0,0 @@
function delay(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
module.exports = delay