|
|
@@ -1,179 +1,364 @@
|
|
|
-import * as WebBrowser from 'expo-web-browser';
|
|
|
-import * as React from 'react';
|
|
|
-import { Image, Platform, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
|
|
|
-import { ScrollView } from 'react-native-gesture-handler';
|
|
|
-
|
|
|
-import { MonoText } from '../components/StyledText';
|
|
|
-
|
|
|
-export default function HomeScreen() {
|
|
|
- return (
|
|
|
- <View style={styles.container}>
|
|
|
- <ScrollView style={styles.container} contentContainerStyle={styles.contentContainer}>
|
|
|
- <View style={styles.welcomeContainer}>
|
|
|
- <Image
|
|
|
- source={
|
|
|
- __DEV__
|
|
|
- ? require('../assets/images/robot-dev.png')
|
|
|
- : require('../assets/images/robot-prod.png')
|
|
|
- }
|
|
|
- style={styles.welcomeImage}
|
|
|
- />
|
|
|
- </View>
|
|
|
-
|
|
|
- <View style={styles.getStartedContainer}>
|
|
|
- <DevelopmentModeNotice />
|
|
|
-
|
|
|
- <Text style={styles.getStartedText}>Open up the code for this screen:</Text>
|
|
|
-
|
|
|
- <View style={[styles.codeHighlightContainer, styles.homeScreenFilename]}>
|
|
|
- <MonoText>screens/HomeScreen.js</MonoText>
|
|
|
- </View>
|
|
|
-
|
|
|
- <Text style={styles.getStartedText}>
|
|
|
- Change any of the text, save the file, and your app will automatically reload.
|
|
|
- </Text>
|
|
|
- </View>
|
|
|
-
|
|
|
- <View style={styles.helpContainer}>
|
|
|
- <TouchableOpacity onPress={handleHelpPress} style={styles.helpLink}>
|
|
|
- <Text style={styles.helpLinkText}>Help, it didn’t automatically reload!</Text>
|
|
|
- </TouchableOpacity>
|
|
|
- </View>
|
|
|
- </ScrollView>
|
|
|
-
|
|
|
- <View style={styles.tabBarInfoContainer}>
|
|
|
- <Text style={styles.tabBarInfoText}>This is a tab bar. You can edit it in:</Text>
|
|
|
-
|
|
|
- <View style={[styles.codeHighlightContainer, styles.navigationFilename]}>
|
|
|
- <MonoText style={styles.codeHighlightText}>navigation/BottomTabNavigator.js</MonoText>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- );
|
|
|
-}
|
|
|
+import * as WebBrowser from "expo-web-browser";
|
|
|
+import * as React from "react";
|
|
|
+import {
|
|
|
+ Image,
|
|
|
+ Platform,
|
|
|
+ StyleSheet,
|
|
|
+ TouchableOpacity,
|
|
|
+ View,
|
|
|
+ ImageBackground,
|
|
|
+} from "react-native";
|
|
|
+import * as ImagePicker from "expo-image-picker";
|
|
|
+import scrollPage from "../decorator/scrollPage";
|
|
|
+import { useModel } from "flooks";
|
|
|
+import Badge from "../components/Badge";
|
|
|
+import {
|
|
|
+ Layout,
|
|
|
+ Tab,
|
|
|
+ TabView,
|
|
|
+ Text,
|
|
|
+ useTheme,
|
|
|
+ Button,
|
|
|
+ Card,
|
|
|
+ Icon,
|
|
|
+ MenuItem,
|
|
|
+ OverflowMenu,
|
|
|
+ TopNavigation,
|
|
|
+ TopNavigationAction,
|
|
|
+ Modal,
|
|
|
+} from "@ui-kitten/components";
|
|
|
+import FormInput from "../components/FormInput";
|
|
|
+import { useFocusEffect } from "@react-navigation/native";
|
|
|
+import ScrollPage from "../components/ScrollPage";
|
|
|
+import NavHeaderBar from "../components/NavHeaderBar";
|
|
|
+import GoodsCard from "../components/GoodsCard";
|
|
|
+import Textarea from "react-native-textarea";
|
|
|
+import HomePage1 from "./HomeScreenPage1";
|
|
|
|
|
|
-HomeScreen.navigationOptions = {
|
|
|
- header: null,
|
|
|
-};
|
|
|
+const NextIcon = (props) => <Icon {...props} name='arrow-ios-downward' />;
|
|
|
+
|
|
|
+const SearchIcon = (props) => <Icon {...props} name='search-outline' />;
|
|
|
+const MailIcon = (props) => <Icon {...props} name='email-outline' />;
|
|
|
+const ShareIcon = (props) => <Icon {...props} name='share-outline' />;
|
|
|
+
|
|
|
+const MenuIcon = (props) => <Icon {...props} name='more-vertical' />;
|
|
|
+
|
|
|
+const InfoIcon = (props) => <Icon {...props} name='info' />;
|
|
|
+
|
|
|
+const LogoutIcon = (props) => <Icon {...props} name='log-out' />;
|
|
|
|
|
|
-function DevelopmentModeNotice() {
|
|
|
- if (__DEV__) {
|
|
|
- const learnMoreButton = (
|
|
|
- <Text onPress={handleLearnMorePress} style={styles.helpLinkText}>
|
|
|
- Learn more
|
|
|
- </Text>
|
|
|
+export default function HomeScreen({ navigation, route }) {
|
|
|
+ const theme = useTheme();
|
|
|
+ const { changeBackground } = useModel("barModel");
|
|
|
+ const { setNavigation, pushRouter } = useModel("routersModel", true);
|
|
|
+ const {
|
|
|
+ showName,
|
|
|
+ logo,
|
|
|
+ introduction,
|
|
|
+ proclamation,
|
|
|
+ updateMerchant,
|
|
|
+ banner,
|
|
|
+ } = useModel("userModel");
|
|
|
+
|
|
|
+ const {
|
|
|
+ homeBar,
|
|
|
+ homeTip1,
|
|
|
+ homeTitle1,
|
|
|
+ homeTitle2,
|
|
|
+ homeTitle3,
|
|
|
+ homeTip2,
|
|
|
+ homeTip3,
|
|
|
+ homeTab1,
|
|
|
+ homeTab2,
|
|
|
+ homeTab3,
|
|
|
+ } = useModel("wordsModel");
|
|
|
+ const [bannerImg, changeBannerImg] = React.useState([]);
|
|
|
+ const [merchantNatureList, changeMerchantNatureList] = React.useState([]);
|
|
|
+
|
|
|
+ const { showDialog } = useModel("dialogModel", true);
|
|
|
+ const { httpPost } = useModel("httpModel", true);
|
|
|
+ const [selectedIndex, setSelectedIndex] = React.useState(0);
|
|
|
+
|
|
|
+ useFocusEffect(
|
|
|
+ React.useCallback(() => {
|
|
|
+ changeBackground(theme["color-primary-500"]);
|
|
|
+ setNavigation(navigation);
|
|
|
+ }, [])
|
|
|
);
|
|
|
|
|
|
- return (
|
|
|
- <Text style={styles.developmentModeText}>
|
|
|
- Development mode is enabled: your app will be slower but you can use useful development
|
|
|
- tools. {learnMoreButton}
|
|
|
- </Text>
|
|
|
+ const canNext = React.useMemo(() => {
|
|
|
+ return true;
|
|
|
+ }, [name]);
|
|
|
+
|
|
|
+ const [menuVisible, setMenuVisible] = React.useState(false);
|
|
|
+
|
|
|
+ const toggleMenu = () => {
|
|
|
+ setMenuVisible(!menuVisible);
|
|
|
+ };
|
|
|
+
|
|
|
+ const renderMenuAction = () => (
|
|
|
+ <TopNavigationAction icon={MenuIcon} onPress={toggleMenu} />
|
|
|
);
|
|
|
- } else {
|
|
|
- return (
|
|
|
- <Text style={styles.developmentModeText}>
|
|
|
- You are not in development mode: your app will run at full speed.
|
|
|
- </Text>
|
|
|
+
|
|
|
+ const renderRightActions = () => (
|
|
|
+ <React.Fragment>
|
|
|
+ <TopNavigationAction icon={SearchIcon} />
|
|
|
+ <TopNavigationAction icon={MailIcon} />
|
|
|
+ <TopNavigationAction icon={ShareIcon} />
|
|
|
+ <OverflowMenu
|
|
|
+ anchor={renderMenuAction}
|
|
|
+ visible={menuVisible}
|
|
|
+ onBackdropPress={toggleMenu}
|
|
|
+ >
|
|
|
+ <MenuItem accessoryLeft={InfoIcon} title='About' />
|
|
|
+ <MenuItem accessoryLeft={LogoutIcon} title='Logout' />
|
|
|
+ </OverflowMenu>
|
|
|
+ </React.Fragment>
|
|
|
);
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
-function handleLearnMorePress() {
|
|
|
- WebBrowser.openBrowserAsync('https://docs.expo.io/versions/latest/workflow/development-mode/');
|
|
|
-}
|
|
|
+ const renderBackAction = () => <Text category='h6'>{homeBar}</Text>;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <>
|
|
|
+ <ScrollPage>
|
|
|
+ <TopNavigation
|
|
|
+ appearance='homeBar'
|
|
|
+ alignment='center'
|
|
|
+ accessoryLeft={renderBackAction}
|
|
|
+ accessoryRight={renderRightActions}
|
|
|
+ />
|
|
|
+ <Layout style={styles.container}>
|
|
|
+ <ImageBackground source={banner} style={styles.banner}>
|
|
|
+ <Button
|
|
|
+ appearance='bannerButton'
|
|
|
+ onPress={() => {
|
|
|
+ _pickImage().then((img) => {
|
|
|
+ httpPost("/upload/base64", {
|
|
|
+ base64: img,
|
|
|
+ }).then((res) => {
|
|
|
+ updateMerchant({ banner: res });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {homeTip1}
|
|
|
+ </Button>
|
|
|
+ </ImageBackground>
|
|
|
+
|
|
|
+ <Card appearance='homeCard' style={styles.homeCard}>
|
|
|
+ <Image source={logo} style={styles.icon} />
|
|
|
|
|
|
-function handleHelpPress() {
|
|
|
- WebBrowser.openBrowserAsync(
|
|
|
- 'https://docs.expo.io/versions/latest/get-started/create-a-new-app/#making-your-first-change'
|
|
|
- );
|
|
|
+ <Layout style={styles.cardMain}>
|
|
|
+ <Layout style={styles.cardTop}>
|
|
|
+ <Text>{showName}</Text>
|
|
|
+ <Layout style={[styles.FlexRow]}>
|
|
|
+ <Layout
|
|
|
+ style={[styles.FlexRow, styles.layItem]}
|
|
|
+ >
|
|
|
+ <Image
|
|
|
+ source={require("../assets/images/zan.png")}
|
|
|
+ style={styles.zanImg}
|
|
|
+ />
|
|
|
+ <Text category='c1' status='primary'>
|
|
|
+ 0
|
|
|
+ </Text>
|
|
|
+ </Layout>
|
|
|
+ <Layout
|
|
|
+ style={[styles.FlexRow, styles.layItem]}
|
|
|
+ >
|
|
|
+ <Image
|
|
|
+ source={require("../assets/images/cai.png")}
|
|
|
+ style={styles.zanImg}
|
|
|
+ />
|
|
|
+ <Text category='c1' status='info'>
|
|
|
+ 0
|
|
|
+ </Text>
|
|
|
+ </Layout>
|
|
|
+ <Layout>
|
|
|
+ <Text category='c1' status='info'>
|
|
|
+ {homeTip2}
|
|
|
+ </Text>
|
|
|
+ </Layout>
|
|
|
+ </Layout>
|
|
|
+ </Layout>
|
|
|
+
|
|
|
+ <Layout style={styles.badges}>
|
|
|
+ <Badge style={styles.badge}>40减20</Badge>
|
|
|
+ <Badge style={styles.badge}>69减38</Badge>
|
|
|
+ <Badge>100减50</Badge>
|
|
|
+ </Layout>
|
|
|
+ </Layout>
|
|
|
+
|
|
|
+ <Button
|
|
|
+ appearance='labelButton'
|
|
|
+ accessoryRight={NextIcon}
|
|
|
+ children={(TextProps) => (
|
|
|
+ <Text
|
|
|
+ style={[TextProps.style, styles.labelText]}
|
|
|
+ numberOfLines={1}
|
|
|
+ ellipsizeMode='tail'
|
|
|
+ >
|
|
|
+ {homeTip3}:{proclamation}
|
|
|
+ </Text>
|
|
|
+ )}
|
|
|
+ onPress={() => {
|
|
|
+ showDialog({
|
|
|
+ pla: "",
|
|
|
+ maxLength: 50,
|
|
|
+ defaultValue: proclamation,
|
|
|
+ isEdit: true,
|
|
|
+ title: homeTitle3,
|
|
|
+ cancelable: true,
|
|
|
+ confirmCallback: (info) => {
|
|
|
+ updateMerchant({ proclamation: info });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Card>
|
|
|
+
|
|
|
+ <Layout style={styles.mainContent}>
|
|
|
+ <TabView
|
|
|
+ tabBarStyle={styles.tab}
|
|
|
+ appearance='homeTab'
|
|
|
+ selectedIndex={selectedIndex}
|
|
|
+ onSelect={(index) => setSelectedIndex(index)}
|
|
|
+ indicatorStyle={styles.tabIndicator}
|
|
|
+ >
|
|
|
+ <Tab
|
|
|
+ title={homeTab1}
|
|
|
+ appearance='homeTab'
|
|
|
+ style={styles.tab}
|
|
|
+ >
|
|
|
+ <HomePage1 />
|
|
|
+ </Tab>
|
|
|
+ <Tab
|
|
|
+ title={homeTab2}
|
|
|
+ appearance='homeTab'
|
|
|
+ style={styles.tab}
|
|
|
+ >
|
|
|
+ <Layout style={styles.tabContainer}>
|
|
|
+ <Text category='h5'>ORDERS</Text>
|
|
|
+ </Layout>
|
|
|
+ </Tab>
|
|
|
+ <Tab
|
|
|
+ title={homeTab3}
|
|
|
+ appearance='homeTab'
|
|
|
+ style={styles.tab}
|
|
|
+ >
|
|
|
+ <Layout style={styles.tabContainer}>
|
|
|
+ <Text category='h5'>TRANSACTIONS</Text>
|
|
|
+ </Layout>
|
|
|
+ </Tab>
|
|
|
+ </TabView>
|
|
|
+ </Layout>
|
|
|
+ </Layout>
|
|
|
+ </ScrollPage>
|
|
|
+ </>
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
- container: {
|
|
|
- flex: 1,
|
|
|
- backgroundColor: '#fff',
|
|
|
- },
|
|
|
- developmentModeText: {
|
|
|
- marginBottom: 20,
|
|
|
- color: 'rgba(0,0,0,0.4)',
|
|
|
- fontSize: 14,
|
|
|
- lineHeight: 19,
|
|
|
- textAlign: 'center',
|
|
|
- },
|
|
|
- contentContainer: {
|
|
|
- paddingTop: 30,
|
|
|
- },
|
|
|
- welcomeContainer: {
|
|
|
- alignItems: 'center',
|
|
|
- marginTop: 10,
|
|
|
- marginBottom: 20,
|
|
|
- },
|
|
|
- welcomeImage: {
|
|
|
- width: 100,
|
|
|
- height: 80,
|
|
|
- resizeMode: 'contain',
|
|
|
- marginTop: 3,
|
|
|
- marginLeft: -10,
|
|
|
- },
|
|
|
- getStartedContainer: {
|
|
|
- alignItems: 'center',
|
|
|
- marginHorizontal: 50,
|
|
|
- },
|
|
|
- homeScreenFilename: {
|
|
|
- marginVertical: 7,
|
|
|
- },
|
|
|
- codeHighlightText: {
|
|
|
- color: 'rgba(96,100,109, 0.8)',
|
|
|
- },
|
|
|
- codeHighlightContainer: {
|
|
|
- backgroundColor: 'rgba(0,0,0,0.05)',
|
|
|
- borderRadius: 3,
|
|
|
- paddingHorizontal: 4,
|
|
|
- },
|
|
|
- getStartedText: {
|
|
|
- fontSize: 17,
|
|
|
- color: 'rgba(96,100,109, 1)',
|
|
|
- lineHeight: 24,
|
|
|
- textAlign: 'center',
|
|
|
- },
|
|
|
- tabBarInfoContainer: {
|
|
|
- position: 'absolute',
|
|
|
- bottom: 0,
|
|
|
- left: 0,
|
|
|
- right: 0,
|
|
|
- ...Platform.select({
|
|
|
- ios: {
|
|
|
- shadowColor: 'black',
|
|
|
- shadowOffset: { width: 0, height: -3 },
|
|
|
- shadowOpacity: 0.1,
|
|
|
- shadowRadius: 3,
|
|
|
- },
|
|
|
- android: {
|
|
|
- elevation: 20,
|
|
|
- },
|
|
|
- }),
|
|
|
- alignItems: 'center',
|
|
|
- backgroundColor: '#fbfbfb',
|
|
|
- paddingVertical: 20,
|
|
|
- },
|
|
|
- tabBarInfoText: {
|
|
|
- fontSize: 17,
|
|
|
- color: 'rgba(96,100,109, 1)',
|
|
|
- textAlign: 'center',
|
|
|
- },
|
|
|
- navigationFilename: {
|
|
|
- marginTop: 5,
|
|
|
- },
|
|
|
- helpContainer: {
|
|
|
- marginTop: 15,
|
|
|
- alignItems: 'center',
|
|
|
- },
|
|
|
- helpLink: {
|
|
|
- paddingVertical: 15,
|
|
|
- },
|
|
|
- helpLinkText: {
|
|
|
- fontSize: 14,
|
|
|
- color: '#2e78b7',
|
|
|
- },
|
|
|
+ container: {
|
|
|
+ flex: 1,
|
|
|
+ backgroundColor: "#F0F0F0",
|
|
|
+ },
|
|
|
+ icon: {
|
|
|
+ width: 53,
|
|
|
+ height: 53,
|
|
|
+ backgroundColor: "#E5E5E5",
|
|
|
+ borderRadius: 3,
|
|
|
+ position: "absolute",
|
|
|
+ left: 10,
|
|
|
+ top: 10,
|
|
|
+ zIndex: 2,
|
|
|
+ },
|
|
|
+ text: {
|
|
|
+ fontWeight: "500",
|
|
|
+ marginBottom: 7,
|
|
|
+ },
|
|
|
+ button: {
|
|
|
+ marginTop: 19,
|
|
|
+ },
|
|
|
+ banner: {
|
|
|
+ height: 100,
|
|
|
+ backgroundColor: "#E5E5E5",
|
|
|
+ },
|
|
|
+ FlexRow: {
|
|
|
+ flexDirection: "row",
|
|
|
+ alignItems: "center",
|
|
|
+ },
|
|
|
+ zanImg: {
|
|
|
+ width: 12,
|
|
|
+ height: 12,
|
|
|
+ marginRight: 3,
|
|
|
+ },
|
|
|
+ layItem: {
|
|
|
+ width: 40,
|
|
|
+ marginRight: 10,
|
|
|
+ },
|
|
|
+ cardMain: {
|
|
|
+ alignItems: "center",
|
|
|
+ zIndex: 1,
|
|
|
+ },
|
|
|
+ cardTop: {
|
|
|
+ height: 53,
|
|
|
+ alignItems: "center",
|
|
|
+ justifyContent: "center",
|
|
|
+ },
|
|
|
+ badges: {
|
|
|
+ flexDirection: "row",
|
|
|
+ justifyContent: "center",
|
|
|
+ },
|
|
|
+ badge: {
|
|
|
+ marginRight: 15,
|
|
|
+ },
|
|
|
+ labelText: {
|
|
|
+ width: 223,
|
|
|
+ textAlign: "left",
|
|
|
+ },
|
|
|
+ homeCard: {
|
|
|
+ position: "absolute",
|
|
|
+ left: 13,
|
|
|
+ top: 66,
|
|
|
+ right: 13,
|
|
|
+ zIndex: 2,
|
|
|
+ },
|
|
|
+ mainContent: {
|
|
|
+ paddingTop: 100,
|
|
|
+ backgroundColor: "transparent",
|
|
|
+ },
|
|
|
+ tab: {
|
|
|
+ backgroundColor: "transparent",
|
|
|
+ zIndex: 2,
|
|
|
+ },
|
|
|
+ tabContainer: {
|
|
|
+ backgroundColor: "transparent",
|
|
|
+ },
|
|
|
+ tabIndicator: {
|
|
|
+ height: 13,
|
|
|
+ borderRadius: "50%",
|
|
|
+ bottom: 18,
|
|
|
+ maxWidth: 27,
|
|
|
+ marginHorizontal: 49,
|
|
|
+ zIndex: 1,
|
|
|
+ },
|
|
|
});
|
|
|
+
|
|
|
+const _pickImage = () => {
|
|
|
+ return new Promise(async (resolve, reject) => {
|
|
|
+ try {
|
|
|
+ let result = await ImagePicker.launchImageLibraryAsync({
|
|
|
+ mediaTypes: ImagePicker.MediaTypeOptions.All,
|
|
|
+ allowsEditing: true,
|
|
|
+ aspect: [4, 3],
|
|
|
+ quality: 1,
|
|
|
+ });
|
|
|
+ if (!result.cancelled) {
|
|
|
+ resolve(result.uri);
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ reject(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|