1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084 |
- /**
- * Sample React Native App
- * https://github.com/facebook/react-native
- *
- * @format
- * @flow
- */
- import React, { Component } from "react";
- import {
- Platform,
- StyleSheet,
- Text,
- View,
- Image,
- FlatList,
- TouchableOpacity,
- ImageBackground,
- Button,
- ViewPagerAndroid,
- DeviceEventEmitter
- } from "react-native";
- import Swiper from "react-native-swiper";
- import AndroidUtil from "../../util/AndroidUtil";
- import BasePage from "../BasePage";
- const instructions = Platform.select({
- ios: "Press Cmd+R to reload,\n" + "Cmd+D or shake for dev menu",
- android:
- "Double tap R on your keyboard to reload,\n" +
- "Shake or press menu button for dev menu"
- });
- type Props = {};
- export default class MainPage extends BasePage {
- render() {
- return (
- <View style={{ flex: 1 }}>
- <FlatList
- style={{ flex: 1 }}
- ref="_flatlist"
- horizontal={false}
- removeClippedSubviews={false}
- ListHeaderComponent={() => this.headerorfooterComponent()}
- keyExtractor={(item, index) => item.key.toString()}
- renderItem={({ item }) => {
- return this.loadFlatItem(item);
- }}
- data={[
- {
- //轮播
- key: 111,
- typea: 1,
- text: "第一种类型"
- },
- {
- //标题类型
- key: 333,
- typea: 0,
- title: "全部课程全部课程全部课程全部课程全部课程全部课程"
- },
- {
- //只有一个标题下面两个图片
- key: 222,
- typea: 2,
- item: {
- item_type: 1,
- title: "课程表:第一周",
- icon_item: [
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第一张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第二张图片文字"
- }
- ]
- }
- },
- {
- //一个标题,大长图
- key: 444,
- typea: 3,
- title: "五月主题:五一启程,去看看不同世界",
- text: "每天30分钟,玩学两不误",
- icon_item: [
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第一张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第二张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第三张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第四张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第五张图片文字"
- }
- ]
- },
- {
- key: 555,
- typea: 4,
- title: "热门课程",
- text: "text",
- mask: false,
- icon_item: [
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第一张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第二张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第三张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第四张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第五张图片文字"
- }
- ]
- },
- {
- //标题类型
- key: 0,
- typea: 0,
- title: "全部课程"
- },
- {
- //一个标题,icon下有文字
- key: 666,
- typea: 4,
- title: "测试text为空的时候",
- text: "",
- mask: false,
- icon_item: [
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第一张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第二张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第三张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第四张图片文字"
- },
- {
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第五张图片文字"
- }
- ]
- },
- {
- key: 777,
- typea: 4,
- title: "测试观看记录",
- text: "",
- mask: true,
- icon_item: [
- {
- last_time: "2小时前",
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第一张图片文字",
- curriculum_name: "课件名字"
- },
- {
- last_time: "3小时前",
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第二张图片文字",
- curriculum_name: "课件名字1"
- },
- {
- last_time: "4小时前",
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第三张图片文字",
- curriculum_name: "课件名字2"
- },
- {
- last_time: "1天前",
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第四张图片文字",
- curriculum_name: "课件名字3"
- },
- {
- last_time: "2天前",
- icon:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg",
- name: "第五张图片文字",
- curriculum_name: "课件名字4"
- }
- ]
- }
- ]}
- />
- </View>
- );
- }
- headerorfooterComponent() {
- return (
- <ImageBackground
- style={{
- width: "100%",
- height: 130
- }}
- >
- <View
- style={{
- flex: 2,
- width: "90%",
- flexDirection: "column",
- justifyContent: "center",
- alignItems: "stretch"
- }}
- >
- <View
- style={{
- flex: 1,
- flexDirection: "row",
- alignItems: "stretch",
- justifyContent: "center",
- backgroundColor: "#FFFFFF"
- }}
- >
- <View
- style={{
- flex: 1
- }}
- />
- <TouchableOpacity
- activeOpacity={1}
- style={{
- flex: 1,
- justifyContent: "center",
- height: "100%"
- }}
- onPress={() => this.toNextPage("MainActivity")}
- >
- <Image
- // source={{
- // uri:
- // "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
- // }}
- style={{
- width: 56,
- justifyContent: "center",
- height: 56,
- borderRadius: 50,
- backgroundColor: "#828282"
- }}
- />
- </TouchableOpacity>
- <View
- style={{
- flex: 0.5
- }}
- />
- <View
- style={{
- flex: 9,
- marginLeft: 20,
- flexDirection: "column",
- alignItems: "center",
- justifyContent: "center",
- height: "100%"
- }}
- >
- <View
- style={{
- flex: 1,
- alignItems: "center",
- justifyContent: "center",
- height: "100%",
- justifyContent: "center",
- width: "100%"
- }}
- >
- <Text
- style={{
- textAlign: "left",
- height: 20,
- justifyContent: "center",
- width: "100%",
- fontSize: 18
- }}
- >
- 用户昵称
- </Text>
- </View>
- <View
- style={{
- flex: 1,
- alignItems: "center",
- flexDirection: "row",
- justifyContent: "center",
- width: "100%"
- }}
- >
- <Image
- source={{
- uri:
- "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
- }}
- style={{
- width: 22,
- justifyContent: "center",
- alignItems: "center",
- height: 22
- }}
- />
- <View
- style={{
- flex: 9,
- alignItems: "center",
- justifyContent: "center",
- height: "100%",
- width: "100%"
- }}
- >
- <Text
- style={{
- textAlign: "left",
- justifyContent: "center",
- width: "100%",
- fontSize: 18
- }}
- >
- 6548
- </Text>
- </View>
- </View>
- </View>
- <View
- style={{
- flex: 3,
- flexDirection: "row",
- alignItems: "center",
- justifyContent: "center"
- }}
- >
- <TouchableOpacity
- activeOpacity={1}
- onPress={() => this.toNextPage("MainActivity")}
- >
- <View
- style={{
- flexDirection: "row",
- alignItems: "center",
- justifyContent: "center",
- height: "80%",
- width: "100%"
- }}
- >
- <Image
- source={{
- uri:
- "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
- }}
- style={{
- width: 16,
- justifyContent: "center",
- alignItems: "center",
- marginRight: 5,
- height: 15
- }}
- />
- <View>
- <Text style={{}}>我的课程</Text>
- </View>
- </View>
- </TouchableOpacity>
- </View>
- <View
- style={{
- flex: 0.5
- }}
- />
- </View>
- <View
- style={{
- flex: 0.1,
- backgroundColor: "#F8F8F8"
- }}
- />
- <View
- //这里要改成活的
- style={{
- flex: 1,
- flexDirection: "column",
- alignItems: "center",
- justifyContent: "center",
- width: "100%"
- }}
- >
- <View
- style={{
- flexDirection: "row",
- flex: 1,
- width: "90%",
- backgroundColor: "#FFFFFF",
- alignItems: "center"
- }}
- >
- <Text
- style={{
- flex: 1.5,
- fontSize: 18,
- fontWeight: "bold",
- color: "black"
- }}
- >
- 学前
- </Text>
- <View
- style={{
- flex: 9
- }}
- />
- <View
- style={{
- flex: 2,
- alignItems: "center",
- justifyContent: "center",
- flexDirection: "row"
- }}
- >
- <Image
- source={{
- uri:
- "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
- }}
- style={{
- width: 14,
- justifyContent: "center",
- alignItems: "center",
- height: 13,
- marginRight: 5
- }}
- />
- <Text style={{}}>切换学龄</Text>
- </View>
- </View>
- <View
- style={{
- flex: 0.1,
- width: "90%",
- backgroundColor: "#F8F8F8"
- }}
- />
- </View>
- </View>
- </ImageBackground>
- );
- }
- loadFlatItem(data) {
- switch (data.typea) {
- case 0:
- return (
- <View
- style={{
- height: 50,
- width: "100%",
- justifyContent: "center",
- alignItems: "center",
- backgroundColor: "#F8F8F8"
- }}
- >
- <View
- style={{
- height: "60%",
- justifyContent: "center",
- alignItems: "center",
- width: "90%",
- backgroundColor: "#ffffffff",
- borderRadius: 20,
- flexDirection: "row"
- }}
- >
- <View style={{ flex: 0.2 }} />
- <Text
- numberOfLines={1}
- style={{
- flex: 12,
- justifyContent: "center",
- alignItems: "center",
- fontSize: 18,
- fontWeight: "bold",
- color: "#3E455B"
- }}
- >
- {data.title}
- </Text>
- <View
- style={{
- flex: 1,
- height: "100%",
- justifyContent: "center",
- alignItems: "center"
- }}
- >
- <Image
- source={{
- uri:
- "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
- }}
- style={{
- width: "50%",
- height: "50%",
- justifyContent: "center",
- alignItems: "center",
- borderRadius: 30
- }}
- />
- </View>
- </View>
- </View>
- );
- break;
- case 1:
- return (
- <View
- style={{
- marginTop: 10,
- flex: 1,
- justifyContent: "center",
- alignItems: "center",
- flexDirection: "row"
- }}
- >
- <View
- style={{
- width: "90%",
- overflow: "hidden",
- height: 150
- }}
- >
- <Swiper
- style={{ flex: 1 }}
- horizontal={true}
- autoplayTimeout={3}
- autoplay={true}
- activeDotColor="#fff"
- >
- <View key="1" style={{ flex: 1 }}>
- <Image
- source={{
- uri:
- "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
- }}
- style={{
- width: "100%",
- height: "100%",
- justifyContent: "center",
- alignItems: "center",
- borderRadius: 10
- }}
- />
- </View>
- <View key="2" style={{ flex: 1 }}>
- <TouchableOpacity
- activeOpacity={1}
- onPress={() => this.toNextPage("MainActivity")}
- >
- <Image
- source={{
- uri:
- "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1556277324856&di=dc1548a0c5ba10481af922e174912937&imgtype=0&src=http%3A%2F%2Fwww.51pptmoban.com%2Fd%2Ffile%2F2012%2F05%2F12%2F82c4568a90055adcf8fbb896f0841c69.jpg"
- }}
- style={{
- width: "100%",
- height: "100%",
- justifyContent: "center",
- alignItems: "center",
- borderRadius: 10
- }}
- />
- </TouchableOpacity>
- </View>
- </Swiper>
- </View>
- </View>
- );
- break;
- case 2:
- let arr = [];
- let index = 0;
- for (let item of data.item.icon_item) {
- arr.push(
- <TouchableOpacity
- style={{ flex: 2 }}
- onPress={() => {
- alert(item.name);
- }}
- key={index}
- activeOpacity={1}
- >
- <Image
- source={{
- uri: item.icon
- }}
- key={index}
- style={{
- width: "100%",
- height: "100%",
- justifyContent: "center",
- alignItems: "center",
- borderRadius: 10
- }}
- />
- </TouchableOpacity>
- );
- if (index < data.item.icon_item.length - 1) {
- arr.push(
- <View
- key={item.name}
- style={{
- flex: 0.1
- }}
- />
- );
- }
- index++;
- }
- return (
- <View
- style={{
- marginTop: 20,
- flex: 1,
- justifyContent: "center",
- alignItems: "center"
- }}
- >
- <View
- style={{
- flex: 1,
- flexDirection: "column",
- width: "90%",
- height: 150
- }}
- >
- <Text
- style={{
- flex: 0.5,
- fontSize: 18,
- fontWeight: "bold",
- color: "#3E455B"
- }}
- >
- {data.item.title}
- </Text>
- <View
- style={{
- flex: 2,
- flexDirection: "row",
- justifyContent: "space-between"
- }}
- >
- {arr}
- </View>
- </View>
- </View>
- );
- break;
- case 3:
- return (
- <View
- style={{
- marginTop: 20,
- flex: 1,
- justifyContent: "center",
- alignItems: "center"
- }}
- >
- <View
- style={{
- width: "90%",
- height: 200,
- flexDirection: "column"
- }}
- >
- <View
- style={{
- flex: 0.5,
- justifyContent: "center",
- alignItems: "center",
- flexDirection: "row"
- }}
- >
- <View
- style={{
- flex: 0.1,
- height: 14,
- justifyContent: "flex-start",
- alignItems: "center",
- backgroundColor: "#01AFFE",
- borderRadius: 20
- }}
- />
- <View
- style={{
- flex: 0.1
- }}
- />
- <Text
- numberOfLines={1}
- style={{
- flex: 11,
- fontSize: 18,
- fontWeight: "bold",
- color: "#3E455B"
- }}
- >
- {data.title}
- </Text>
- </View>
- {text_z}
- <View
- style={{
- flex: 3
- }}
- >
- <FlatList
- style={{
- flex: 1
- }}
- ItemSeparatorComponent={() => (
- <View
- style={{
- width: 10
- }}
- />
- )}
- showsHorizontalScrollIndicator={false}
- keyExtractor={(item, index) => item.name.toString()}
- data={data.icon_item}
- horizontal={true}
- renderItem={({ item }) => {
- return (
- <TouchableOpacity
- style={{
- flex: 1,
- height: "100%",
- width: this.getWindowWidth() * 0.9
- }}
- onPress={() => {
- alert(item.name);
- }}
- activeOpacity={1}
- >
- <Image
- source={{
- uri: item.icon
- }}
- style={{
- height: "100%",
- width: "100%",
- justifyContent: "center",
- alignItems: "center",
- borderRadius: 20
- }}
- />
- </TouchableOpacity>
- );
- }}
- />
- </View>
- </View>
- </View>
- );
- break;
- case 4:
- let text_z = [];
- let zhezhao = [];
- let view_height = 190;
- //判断是否需要text
- if (data.text != "") {
- view_height = 217;
- text_z.push(
- <View
- key={data.text}
- style={{
- flex: 0.5,
- justifyContent: "center",
- alignItems: "center",
- flexDirection: "row"
- }}
- >
- <View
- style={{
- flex: 1,
- flexDirection: "row"
- }}
- >
- <View
- style={{
- flex: 0.2
- }}
- />
- <Text
- style={{
- flex: 11,
- color: "#8F94AA"
- }}
- >
- {data.text}
- </Text>
- </View>
- </View>
- );
- }
- return (
- <View
- style={{
- marginTop: 20,
- flex: 1,
- justifyContent: "center",
- alignItems: "center"
- }}
- >
- <View
- style={{
- width: "90%",
- height: view_height,
- flexDirection: "column"
- }}
- >
- <View
- style={{
- flex: 0.5,
- justifyContent: "center",
- alignItems: "center",
- flexDirection: "row"
- }}
- >
- <View
- style={{
- flex: 0.1,
- height: 14,
- justifyContent: "flex-start",
- alignItems: "center",
- backgroundColor: "#01AFFE",
- borderRadius: 15
- }}
- />
- <View
- style={{
- flex: 0.1
- }}
- />
- <Text
- style={{
- flex: 11,
- fontSize: 18,
- fontWeight: "bold",
- color: "#3E455B"
- }}
- >
- {data.title}
- </Text>
- </View>
- {text_z}
- <View
- style={{
- flex: 3
- }}
- >
- <FlatList
- style={{
- flex: 1
- }}
- ItemSeparatorComponent={() => (
- <View
- style={{
- width: 10
- }}
- />
- )}
- showsHorizontalScrollIndicator={false}
- keyExtractor={(item, index) => item.name.toString()}
- data={data.icon_item}
- horizontal={true}
- renderItem={({ item }) => {
- //判断是否需要遮盖层(观看记录)
- if (data.mask) {
- zhezhao = [];
- zhezhao.push(
- <View
- key={item.name}
- style={{
- flex: 1,
- width: "100%",
- flexDirection: "column"
- }}
- >
- <View
- style={{
- flex: 2
- }}
- />
- <View
- style={{
- flex: 1,
- backgroundColor: "#344563",
- width: "100%",
- borderBottomLeftRadius: 15,
- borderBottomRightRadius: 15,
- flexDirection: "row"
- }}
- >
- <View
- style={{
- flex: 0.1
- }}
- />
- <View
- style={{
- flex: 1
- }}
- >
- <Text
- style={{
- flex: 1,
- color: "red",
- textAlign: "left"
- }}
- >
- {item.last_time + ":"}
- </Text>
- <Text
- style={{
- flex: 1,
- color: "red",
- textAlign: "left"
- }}
- >
- {item.curriculum_name}
- </Text>
- </View>
- </View>
- </View>
- );
- }
- return (
- <TouchableOpacity
- style={{
- flex: 1,
- height: "100%",
- width: this.getWindowWidth() * 0.22
- }}
- onPress={() => {
- alert(item.name);
- }}
- activeOpacity={1}
- >
- <View
- style={{
- flex: 1,
- height: "100%",
- width: "100%",
- justifyContent: "center",
- alignItems: "center"
- }}
- >
- <View
- style={{
- flex: 5,
- height: "100%",
- width: "100%",
- justifyContent: "center",
- alignItems: "center"
- }}
- >
- <ImageBackground
- source={{
- uri: item.icon
- }}
- style={{
- height: "100%",
- width: "100%",
- justifyContent: "center",
- alignItems: "center"
- }}
- imageStyle={{
- borderRadius: 20
- }}
- >
- {zhezhao}
- </ImageBackground>
- </View>
- <Text
- style={{
- justifyContent: "center",
- alignItems: "center",
- flex: 1,
- fontSize: 12
- }}
- >
- {item.name}
- </Text>
- </View>
- </TouchableOpacity>
- );
- }}
- />
- </View>
- </View>
- </View>
- );
- break;
- case 5:
- break;
- case 6:
- break;
- case 7:
- break;
- case 8:
- break;
- }
- }
- }
- const styles = StyleSheet.create({
- title_text: {
- justifyContent: "center",
- alignItems: "center",
- color: "red",
- fontSize: 30,
- textAlign: "center",
- marginTop: 30,
- marginBottom: 50
- }
- });
|