Commit fe40ad0f authored by shiyunjie's avatar shiyunjie

largList

parent d4829cc3
...@@ -138,6 +138,8 @@ android { ...@@ -138,6 +138,8 @@ android {
} }
dependencies { dependencies {
implementation project(':react-native-linear-gradient')
implementation project(':react-native-device-info')
implementation project(':react-native-spring-scrollview') implementation project(':react-native-spring-scrollview')
implementation project(':react-native-gesture-handler') implementation project(':react-native-gesture-handler')
implementation project(':react-native-vector-icons') implementation project(':react-native-vector-icons')
......
...@@ -3,6 +3,8 @@ package com.basicapp; ...@@ -3,6 +3,8 @@ package com.basicapp;
import android.app.Application; import android.app.Application;
import com.facebook.react.ReactApplication; import com.facebook.react.ReactApplication;
import com.BV.LinearGradient.LinearGradientPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.bolan9999.SpringScrollViewPackage; import com.bolan9999.SpringScrollViewPackage;
import com.oblador.vectoricons.VectorIconsPackage; import com.oblador.vectoricons.VectorIconsPackage;
import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactNativeHost;
...@@ -25,6 +27,8 @@ public class MainApplication extends Application implements ReactApplication { ...@@ -25,6 +27,8 @@ public class MainApplication extends Application implements ReactApplication {
protected List<ReactPackage> getPackages() { protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList( return Arrays.<ReactPackage>asList(
new MainReactPackage(), new MainReactPackage(),
new LinearGradientPackage(),
new RNDeviceInfo(),
new SpringScrollViewPackage(), new SpringScrollViewPackage(),
new VectorIconsPackage() new VectorIconsPackage()
); );
......
rootProject.name = 'BasicApp' rootProject.name = 'BasicApp'
include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-spring-scrollview' include ':react-native-spring-scrollview'
project(':react-native-spring-scrollview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-spring-scrollview/android') project(':react-native-spring-scrollview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-spring-scrollview/android')
include ':react-native-vector-icons' include ':react-native-vector-icons'
......
This diff is collapsed.
...@@ -15,9 +15,11 @@ ...@@ -15,9 +15,11 @@
"moment": "^2.24.0", "moment": "^2.24.0",
"react": "16.8.3", "react": "16.8.3",
"react-native": "0.59.5", "react-native": "0.59.5",
"react-native-device-info": "^2.1.1",
"react-native-elements": "^1.1.0", "react-native-elements": "^1.1.0",
"react-native-gesture-handler": "^1.1.0", "react-native-gesture-handler": "^1.1.0",
"react-native-largelist-v3": "^3.0.14", "react-native-largelist-v3": "^3.0.14",
"react-native-linear-gradient": "^2.5.4",
"react-native-spring-scrollview": "^2.0.22", "react-native-spring-scrollview": "^2.0.22",
"react-native-update-mutlirn-hg": "^3.1.1", "react-native-update-mutlirn-hg": "^3.1.1",
"react-native-vector-icons": "^6.4.2", "react-native-vector-icons": "^6.4.2",
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
} from 'react-navigation'; } from 'react-navigation';
import JSPage from '../jsComponent/JSPage'; import JSPage from '../jsComponent/JSPage';
import FramePage from '../home/FramePage'; import FramePage from '../home/FramePage';
import ThemePage from '../themePage'; import ThemePage from '../changeThemePage';
import NativeComponentList from '../home/NativeComponentList'; import NativeComponentList from '../home/NativeComponentList';
import JSComponentList from '../home/JSComponentList'; import JSComponentList from '../home/JSComponentList';
import NativePage from '../nativeComponent/NativePage'; import NativePage from '../nativeComponent/NativePage';
......
...@@ -18,14 +18,14 @@ import { compose } from 'redux'; ...@@ -18,14 +18,14 @@ import { compose } from 'redux';
import { push, tab } from '../BasicNavigator/actions'; import { push, tab } from '../BasicNavigator/actions';
import themeType from '../theme'; import themeType from '../theme';
import themeAction from '../theme/action'; import themeAction from '../theme/action';
import NavigationBar from '../components/NavigationBar';
import BackButton from '../components/BackButton';
import Button from '../components/ThemeButton';
type Props = {}; type Props = {};
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF', backgroundColor: '#F5FCFF',
}, },
instructions: { instructions: {
...@@ -37,37 +37,42 @@ const styles = StyleSheet.create({ ...@@ -37,37 +37,42 @@ const styles = StyleSheet.create({
class ThemePage extends Component<Props> { class ThemePage extends Component<Props> {
render() { render() {
const { theme, setCurrentTheme } = this.props const { theme, setCurrentTheme } = this.props;
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Text style={styles.instructions}>ThemeDemo</Text> <NavigationBar
<TouchableOpacity onPress={() => { left={<BackButton />}
title="ThemeDemo"
/>
<Button
containerStyle={{ height: 40, margin: 10 }}
onPress={() => {
setCurrentTheme(themeType.blackTheme);//Object.assign setCurrentTheme(themeType.blackTheme);//Object.assign
}} }}
> title="切换黑色主题"
<Text style={styles.instructions, { color: theme.themeColor }}>启动黑色主题</Text> />
</TouchableOpacity> <Button
<TouchableOpacity onPress={() => { containerStyle={{ height: 40, margin: 10 }}
onPress={() => {
setCurrentTheme(themeType.defaultTheme);//Object.assign setCurrentTheme(themeType.defaultTheme);//Object.assign
}} }}
> title="切换蓝色主题"
<Text style={styles.instructions, { color: theme.themeColor }}>启动蓝色主题</Text> />
</TouchableOpacity> <Button
<TouchableOpacity onPress={() => { containerStyle={{ height: 40, margin: 10 }}
onPress={() => {
setCurrentTheme(themeType.redTheme);//Object.assign setCurrentTheme(themeType.redTheme);//Object.assign
}} }}
> title="切换红色主题"
<Text style={styles.instructions, { color: theme.themeColor }}>启动红色主题</Text> />
</TouchableOpacity>
</View> </View>
); );
} }
} }
function propsMapping(props) { function propsMapping(props) {
const { nav, theme } = props const { nav, theme } = props;
return { return {
nav, nav,
theme, theme,
......
/**
* @flow
*/
import React from 'react';
import { TouchableOpacity, View } from 'react-native';
import { connect } from 'react-redux';
import Index from '../BasicIcon';
import { pop } from '../../BasicNavigator/actions';
import StyleSheet from '../../utils/StyleSheet';
const styles = StyleSheet.create({
backButton: {
flexDirection: 'row',
alignItems: 'center',
paddingLeft: 10,
},
buttonIOSAndroid: {
width: 90,
ios: {
paddingTop: 0,
height: 44,
},
android: {
paddingTop: 0,
height: 44,
},
justifyContent: 'center',
},
})
type BackButtonType = {
onBackPressed: ()=>void,
routes: Array,
imageUrl?: any,
}
function BackButton({ onBackPressed, imageUrl }: BackButtonType) {
return (
<TouchableOpacity
onPress={() => {
onBackPressed()
}}
style={styles.backButton}
>
<View
style={styles.buttonIOSAndroid}
>
<Index suite="Ionicons" name="ios-arrow-back" size={26} color="white" />
</View>
</TouchableOpacity>
);
}
const actionMapping = (dispatch, props) => ({
onBackPressed: props.onBackPressed || (() => {
console.log('BackButton:', props)
if (props.routes && props.routes.length === 1) {
} else {
dispatch(pop());
}
}),
})
export default connect(null, actionMapping)(BackButton);
...@@ -40,7 +40,7 @@ export type IconType = { ...@@ -40,7 +40,7 @@ export type IconType = {
size?: number, size?: number,
} }
export default function BasicIcon(props: IconType) { export default function Index(props: IconType) {
const { suite, ...extraProps } = { const { suite, ...extraProps } = {
color: 'white', color: 'white',
size: 30, size: 30,
......
/**
* @flow
*/
import React, { Element } from 'react';
import { connect } from 'react-redux';
import {
View,
Text,
Platform,
TouchableOpacity,
} from 'react-native';
import DeviceInfo from 'react-native-device-info';
import LinearGradient from 'react-native-linear-gradient';
import StyleSheet from '../../utils/StyleSheet';
export const isLessKitKat = Platform.OS === 'android' && Platform.Version > 19;
export const androidTop = isLessKitKat ? 0 : 24;
const systemVersion = DeviceInfo.getSystemVersion();
const styles = StyleSheet.create({
navBarContainer: {
ios: {
marginTop: parseInt(systemVersion, 10) < 11 ? 20 : 0,
height: 64,
},
android: {
paddingTop: androidTop,
height: 44 + androidTop,
},
iPad: {
height: 98,
},
androidPad: {
height: 88,
},
backgroundColor: '#0074E1',
// backgroundColor: 'rgb(42,85,161)',
flexDirection: 'row',
},
left: {
flex: 1,
flexDirection: 'row',
},
right: {
flex: 1,
flexDirection: 'row-reverse',
},
navStyle: {
alignItems: 'center',
justifyContent: 'center',
},
title: {
textAlign: 'center',
phone: {
fontSize: 18,
},
pad: {
fontSize: 24,
},
color: 'white',
alignSelf: 'center',
},
});
export type NavBarPropsType = {
left?: Element<*>,
title?: string,
titleStyle?: Object,
right?: Element<*>,
style?: Object,
fontStyle?: Object,
onPress?: ()=>void,
textStyle?:Object,
theme:Object,
}
function NavigationBar(props: NavBarPropsType) {
const {
style, titleStyle, left, onPress, textStyle, fontStyle, title, right, theme,
} = props;
if (theme.navEndColor) {
return (
<LinearGradient
start={{ x: 0.0, y: 0.25 }}
end={{ x: 0.5, y: 1.0 }}
locations={[0, 1]}
colors={[theme.themeColor, theme.navEndColor]}
style={[styles.navBarContainer, { backgroundColor: theme.themeColor }, style]}
>
<View style={[styles.left, titleStyle]}>{left}</View>
<TouchableOpacity style={styles.navStyle} activeOpacity={1} onLongPress={onPress}>
<Text style={[styles.title, textStyle, fontStyle]}>{title}</Text>
</TouchableOpacity>
<View style={styles.right}>{right}</View>
</LinearGradient>
);
}
return (
<View style={[styles.navBarContainer, { backgroundColor: theme.themeColor }, style]}>
<View style={[styles.left, titleStyle]}>{left}</View>
<TouchableOpacity style={styles.navStyle} activeOpacity={1} onLongPress={onPress}>
<Text style={[styles.title, textStyle, fontStyle]}>{title}</Text>
</TouchableOpacity>
<View style={styles.right}>{right}</View>
</View>
);
}
function propsMapping({ theme }) {
return {
theme,
};
}
export default connect(propsMapping, null)(NavigationBar);
...@@ -6,7 +6,7 @@ import React, { Component } from 'react'; ...@@ -6,7 +6,7 @@ import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { View, Text } from 'react-native'; import { View, Text } from 'react-native';
import BasicIcon from '../BasicIcon'; import Index from '../BasicIcon';
type Props = {} type Props = {}
...@@ -16,7 +16,7 @@ class TabButton extends Component<Props> { ...@@ -16,7 +16,7 @@ class TabButton extends Component<Props> {
const color = focused ? theme.themeColor : theme.Colors.charcoal; const color = focused ? theme.themeColor : theme.Colors.charcoal;
return ( return (
<View style={{ alignItems: 'center' }}> <View style={{ alignItems: 'center' }}>
<BasicIcon <Index
style={{ margin: 0, padding: 0 }} style={{ margin: 0, padding: 0 }}
suite={iconSuite} suite={iconSuite}
name={tabBarIconName} name={tabBarIconName}
......
/**
* @flow
* Created by Rabbit on 2019-04-30.
*/
import React from 'react';
import { connect } from 'react-redux';
import { Button } from 'react-native-elements';
import LinearGradient from 'react-native-linear-gradient';
function ThemeButton(props) {
const { theme, buttonStyle } = props;
if (theme.navEndColor) {
return (
<Button
{...props}
ViewComponent={LinearGradient} // Don't forget this!
buttonStyle={[buttonStyle, { backgroundColor: theme.themeColor }]}
linearGradientProps={{
colors: [theme.themeColor, theme.navEndColor],
start: { x: 0, y: 0.5 },
end: { x: 1, y: 0.5 },
}}
/>
);
}
return (
<Button
{...props}
buttonStyle={[buttonStyle, { backgroundColor: theme.themeColor }]}
/>
);
}
function propsMapping({ theme }) {
return {
theme,
};
}
export default connect(propsMapping, null)(ThemeButton);
...@@ -13,10 +13,11 @@ import { LargeList } from 'react-native-largelist-v3'; ...@@ -13,10 +13,11 @@ import { LargeList } from 'react-native-largelist-v3';
import { import {
StyleSheet, StyleSheet,
Text, Text,
TouchableOpacity,
View, View,
} from 'react-native'; } from 'react-native';
import Button from '../components/ThemeButton';
import { push } from '../BasicNavigator/actions'; import { push } from '../BasicNavigator/actions';
import NavigationBar from '../components/NavigationBar';
type type
...@@ -87,14 +88,17 @@ Row ...@@ -87,14 +88,17 @@ Row
sContent.items.push(row); sContent.items.push(row);
} }
data.push(sContent); data.push(sContent);
} }
return ( return (
<View style={styles.container}> <View style={styles.container}>
<NavigationBar
<TouchableOpacity onPress={() => { this.props.push('ThemePage'); }}> title="Frame"
<Text style={styles.instructions}>Frame</Text> />
</TouchableOpacity> <Button
containerStyle={{ height: 40, margin: 10 }}
onPress={() => { this.props.push('ThemePage'); }}
title="Frame"
/>
<LargeList <LargeList
style={styles.container} style={styles.container}
data={data} data={data}
...@@ -114,6 +118,10 @@ function actionMapping(dispatch) { ...@@ -114,6 +118,10 @@ function actionMapping(dispatch) {
push: compose(dispatch, push), push: compose(dispatch, push),
}; };
} }
//const mapDispatchToProps = dispatch => (bindActionCreators({goNext}, dispatch)) function propsMapping({ theme }) {
return {
theme,
};
}
export default connect(null, actionMapping)(FramePage); export default connect(propsMapping, actionMapping)(FramePage);
...@@ -9,21 +9,21 @@ ...@@ -9,21 +9,21 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { import {
StyleSheet, StyleSheet,
Text, Image,
View, View,
} from 'react-native'; } from 'react-native';
import { WaterfallList } from 'react-native-largelist-v3';
import { compose } from 'redux'; import { compose } from 'redux';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { push } from '../BasicNavigator/actions'; import { push } from '../BasicNavigator/actions';
import NavigationBar from '../components/NavigationBar';
const cookData = require('./data.json').data.list;
type Props = {}; type Props = {};
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF', backgroundColor: '#F5FCFF',
}, },
instructions: { instructions: {
...@@ -34,11 +34,24 @@ const styles = StyleSheet.create({ ...@@ -34,11 +34,24 @@ const styles = StyleSheet.create({
}); });
class NativeComponentList extends Component<Props> { class NativeComponentList extends Component<Props> {
state = { data: [...cookData, ...cookData, ...cookData, ...cookData, ...cookData] };
_renderItem = item => <Image source={{ uri: item.showimg }} style={{ flex: 1, margin: 5 }} />;
render() { render() {
console.log('ServicePage', this.props);
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Text style={styles.instructions}>NativeComponentList</Text> <NavigationBar
title="NativeComponentList"
/>
<WaterfallList
data={this.state.data}
heightForItem={item => SCREEN_WIDTH / Math.floor(SCREEN_HEIGHT / 150)
* +item.showimg_height / +item.showimg_width}
numColumns={2}
// preferColumnWidth={150}
renderItem={this._renderItem}
/>
</View> </View>
); );
} }
......
This diff is collapsed.
...@@ -7,8 +7,9 @@ import Metrics from '../Metrics'; ...@@ -7,8 +7,9 @@ import Metrics from '../Metrics';
import Images from '../Images'; import Images from '../Images';
import ApplicationStyles from '../ApplicationStyles'; import ApplicationStyles from '../ApplicationStyles';
const themeColor = Colors.facebook const themeColor = '#0091FF';
const navEndColor = '#00C7FD';
export default { export default {
Colors, Fonts, Images, Metrics, ApplicationStyles, themeColor, Colors, Fonts, Images, Metrics, ApplicationStyles, themeColor, navEndColor,
}; };
...@@ -7,8 +7,9 @@ import Metrics from '../Metrics'; ...@@ -7,8 +7,9 @@ import Metrics from '../Metrics';
import Images from '../Images'; import Images from '../Images';
import ApplicationStyles from '../ApplicationStyles'; import ApplicationStyles from '../ApplicationStyles';
const themeColor = Colors.fire const themeColor = '#F52F52';
const navEndColor = '#F65542';
export default { export default {
Colors, Fonts, Images, Metrics, ApplicationStyles, themeColor Colors, Fonts, Images, Metrics, ApplicationStyles, themeColor, navEndColor,
}; };
...@@ -6280,6 +6280,11 @@ react-native-debugger-open@^0.3.19: ...@@ -6280,6 +6280,11 @@ react-native-debugger-open@^0.3.19:
minimist "^1.2.0" minimist "^1.2.0"
semver "^5.4.1" semver "^5.4.1"
react-native-device-info@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-2.1.1.tgz#c6ddc022033756a5e4c5899eb83e390b5a18cc17"
integrity sha512-H0qq9UdP3zGESYH4HMPuv2A/FwOMszVbktj0JWuT/eVhW97PyRkYcobhFd1ggW0U+ksVSewSyX+JenQejGp7+w==
react-native-elements@^1.1.0: react-native-elements@^1.1.0:
version "1.1.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/react-native-elements/-/react-native-elements-1.1.0.tgz#f99bcda4459a886f3ab4591c684c099d37aedf2b" resolved "https://registry.yarnpkg.com/react-native-elements/-/react-native-elements-1.1.0.tgz#f99bcda4459a886f3ab4591c684c099d37aedf2b"
...@@ -6307,6 +6312,11 @@ react-native-largelist-v3@^3.0.14: ...@@ -6307,6 +6312,11 @@ react-native-largelist-v3@^3.0.14:
resolved "https://registry.yarnpkg.com/react-native-largelist-v3/-/react-native-largelist-v3-3.0.14.tgz#0b03dc588ed90f90432361f91ffa26d8e529e7c0" resolved "https://registry.yarnpkg.com/react-native-largelist-v3/-/react-native-largelist-v3-3.0.14.tgz#0b03dc588ed90f90432361f91ffa26d8e529e7c0"
integrity sha512-eom9InjkKCGjFESft3/BmkNttV3EFOhSisd4DKDe/dAaj0+ySt+ukUTSv9AVnLim6HW3MiUkfNgMBxckoVyDqg== integrity sha512-eom9InjkKCGjFESft3/BmkNttV3EFOhSisd4DKDe/dAaj0+ySt+ukUTSv9AVnLim6HW3MiUkfNgMBxckoVyDqg==
react-native-linear-gradient@^2.5.4:
version "2.5.4"
resolved "https://registry.yarnpkg.com/react-native-linear-gradient/-/react-native-linear-gradient-2.5.4.tgz#dce133526f5a5510a639af94544f1ed0c984bd1e"
integrity sha512-FF1NhlerA4uBiS0gFIHa4FBp8/aftv4vPj14Y47lGNkYjSI94tnI6oYO3EfUxXjEyCUPiOVNKZOB9kScyjc5Ew==
react-native-ratings@^6.3.0: react-native-ratings@^6.3.0:
version "6.3.1" version "6.3.1"
resolved "https://registry.yarnpkg.com/react-native-ratings/-/react-native-ratings-6.3.1.tgz#4e4bd87f376423dc62c933f570fc1932c78adaa4" resolved "https://registry.yarnpkg.com/react-native-ratings/-/react-native-ratings-6.3.1.tgz#4e4bd87f376423dc62c933f570fc1932c78adaa4"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment