MainPage.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. /**
  2. * Sample React Native App
  3. * https://github.com/facebook/react-native
  4. *
  5. * @format
  6. * @flow
  7. */
  8. import React, { Component } from "react";
  9. import {
  10. StyleSheet,
  11. Text,
  12. View,
  13. Image,
  14. FlatList,
  15. TouchableOpacity,
  16. ImageBackground,
  17. Button,
  18. ViewPagerAndroid,
  19. DeviceEventEmitter
  20. } from "react-native";
  21. import AndroidUtil from "../../util/AndroidUtil";
  22. import BasePage from "../BasePage";
  23. import Swipers from './Swiper';
  24. type Props = {};
  25. export default class MainPage extends BasePage {
  26. render() {
  27. return (
  28. <View style={{ flex: 1 }}>
  29. <FlatList
  30. style={{ flex: 1 }}
  31. ref="_flatlist"
  32. horizontal={false}
  33. removeClippedSubviews={false}
  34. ListHeaderComponent={() => this.headerorfooterComponent()}
  35. keyExtractor={(item, index) => item.key.toString()}
  36. renderItem={({ item }) => {
  37. return this.loadFlatItem(item);
  38. }}
  39. data={[
  40. {
  41. //轮播
  42. key: 111,
  43. typea: 1,
  44. text: "第一种类型"
  45. },
  46. {
  47. //标题类型
  48. key: 333,
  49. typea: 0,
  50. title: "全部课程全部课程全部课程全部课程全部课程全部课程"
  51. },
  52. {
  53. //只有一个标题下面两个图片
  54. key: 222,
  55. typea: 2,
  56. item: {
  57. item_type: 1,
  58. title: "课程表:第一周",
  59. icon_item: [
  60. {
  61. icon:
  62. "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",
  63. name: "第一张图片文字"
  64. },
  65. {
  66. icon:
  67. "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",
  68. name: "第二张图片文字"
  69. }
  70. ]
  71. }
  72. },
  73. {
  74. //一个标题,大长图
  75. key: 444,
  76. typea: 3,
  77. title: "五月主题:五一启程,去看看不同世界",
  78. text: "每天30分钟,玩学两不误",
  79. icon_item: [
  80. {
  81. icon:
  82. "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",
  83. name: "第一张图片文字"
  84. },
  85. {
  86. icon:
  87. "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",
  88. name: "第二张图片文字"
  89. },
  90. {
  91. icon:
  92. "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",
  93. name: "第三张图片文字"
  94. },
  95. {
  96. icon:
  97. "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",
  98. name: "第四张图片文字"
  99. },
  100. {
  101. icon:
  102. "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",
  103. name: "第五张图片文字"
  104. }
  105. ]
  106. },
  107. {
  108. key: 555,
  109. typea: 4,
  110. title: "热门课程",
  111. text: "text",
  112. mask: false,
  113. icon_item: [
  114. {
  115. icon:
  116. "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",
  117. name: "第一张图片文字"
  118. },
  119. {
  120. icon:
  121. "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",
  122. name: "第二张图片文字"
  123. },
  124. {
  125. icon:
  126. "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",
  127. name: "第三张图片文字"
  128. },
  129. {
  130. icon:
  131. "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",
  132. name: "第四张图片文字"
  133. },
  134. {
  135. icon:
  136. "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",
  137. name: "第五张图片文字"
  138. }
  139. ]
  140. },
  141. {
  142. //标题类型
  143. key: 0,
  144. typea: 0,
  145. title: "全部课程"
  146. },
  147. {
  148. //一个标题,icon下有文字
  149. key: 666,
  150. typea: 4,
  151. title: "测试text为空的时候",
  152. text: "",
  153. mask: false,
  154. icon_item: [
  155. {
  156. icon:
  157. "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",
  158. name: "第一张图片文字"
  159. },
  160. {
  161. icon:
  162. "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",
  163. name: "第二张图片文字"
  164. },
  165. {
  166. icon:
  167. "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",
  168. name: "第三张图片文字"
  169. },
  170. {
  171. icon:
  172. "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",
  173. name: "第四张图片文字"
  174. },
  175. {
  176. icon:
  177. "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",
  178. name: "第五张图片文字"
  179. }
  180. ]
  181. },
  182. {
  183. key: 777,
  184. typea: 4,
  185. title: "测试观看记录",
  186. text: "",
  187. mask: true,
  188. icon_item: [
  189. {
  190. last_time: "2小时前",
  191. icon:
  192. "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",
  193. name: "第一张图片文字",
  194. curriculum_name: "课件名字"
  195. },
  196. {
  197. last_time: "3小时前",
  198. icon:
  199. "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",
  200. name: "第二张图片文字",
  201. curriculum_name: "课件名字1"
  202. },
  203. {
  204. last_time: "4小时前",
  205. icon:
  206. "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",
  207. name: "第三张图片文字",
  208. curriculum_name: "课件名字2"
  209. },
  210. {
  211. last_time: "1天前",
  212. icon:
  213. "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",
  214. name: "第四张图片文字",
  215. curriculum_name: "课件名字3"
  216. },
  217. {
  218. last_time: "2天前",
  219. icon:
  220. "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",
  221. name: "第五张图片文字",
  222. curriculum_name: "课件名字4"
  223. }
  224. ]
  225. }
  226. ]}
  227. />
  228. </View>
  229. );
  230. }
  231. headerorfooterComponent() {
  232. return (
  233. <ImageBackground
  234. style={{
  235. width: "100%",
  236. height: 130
  237. }}
  238. >
  239. <View
  240. style={{
  241. flex: 2,
  242. width: "90%",
  243. flexDirection: "column",
  244. justifyContent: "center",
  245. alignItems: "stretch"
  246. }}
  247. >
  248. <View
  249. style={{
  250. flex: 1,
  251. flexDirection: "row",
  252. alignItems: "stretch",
  253. justifyContent: "center",
  254. backgroundColor: "#FFFFFF"
  255. }}
  256. >
  257. <View
  258. style={{
  259. flex: 1
  260. }}
  261. />
  262. <TouchableOpacity
  263. activeOpacity={1}
  264. style={{
  265. flex: 1,
  266. justifyContent: "center",
  267. height: "100%"
  268. }}
  269. onPress={() => this.toNextPage("MainActivity")}
  270. >
  271. <Image
  272. // source={{
  273. // uri:
  274. // "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
  275. // }}
  276. style={{
  277. width: 56,
  278. justifyContent: "center",
  279. height: 56,
  280. borderRadius: 50,
  281. backgroundColor: "#828282"
  282. }}
  283. />
  284. </TouchableOpacity>
  285. <View
  286. style={{
  287. flex: 0.5
  288. }}
  289. />
  290. <View
  291. style={{
  292. flex: 9,
  293. marginLeft: 20,
  294. flexDirection: "column",
  295. alignItems: "center",
  296. justifyContent: "center",
  297. height: "100%"
  298. }}
  299. >
  300. <View
  301. style={{
  302. flex: 1,
  303. alignItems: "center",
  304. justifyContent: "center",
  305. height: "100%",
  306. justifyContent: "center",
  307. width: "100%"
  308. }}
  309. >
  310. <Text
  311. style={{
  312. textAlign: "left",
  313. height: 20,
  314. justifyContent: "center",
  315. width: "100%",
  316. fontSize: 18
  317. }}
  318. >
  319. 用户昵称
  320. </Text>
  321. </View>
  322. <View
  323. style={{
  324. flex: 1,
  325. alignItems: "center",
  326. flexDirection: "row",
  327. justifyContent: "center",
  328. width: "100%"
  329. }}
  330. >
  331. <Image
  332. source={{
  333. uri:
  334. "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
  335. }}
  336. style={{
  337. width: 22,
  338. justifyContent: "center",
  339. alignItems: "center",
  340. height: 22
  341. }}
  342. />
  343. <View
  344. style={{
  345. flex: 9,
  346. alignItems: "center",
  347. justifyContent: "center",
  348. height: "100%",
  349. width: "100%"
  350. }}
  351. >
  352. <Text
  353. style={{
  354. textAlign: "left",
  355. justifyContent: "center",
  356. width: "100%",
  357. fontSize: 18
  358. }}
  359. >
  360. 6548
  361. </Text>
  362. </View>
  363. </View>
  364. </View>
  365. <View
  366. style={{
  367. flex: 3,
  368. flexDirection: "row",
  369. alignItems: "center",
  370. justifyContent: "center"
  371. }}
  372. >
  373. <TouchableOpacity
  374. activeOpacity={1}
  375. onPress={() => this.toNextPage("MainActivity")}
  376. >
  377. <View
  378. style={{
  379. flexDirection: "row",
  380. alignItems: "center",
  381. justifyContent: "center",
  382. height: "80%",
  383. width: "100%"
  384. }}
  385. >
  386. <Image
  387. source={{
  388. uri:
  389. "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
  390. }}
  391. style={{
  392. width: 16,
  393. justifyContent: "center",
  394. alignItems: "center",
  395. marginRight: 5,
  396. height: 15
  397. }}
  398. />
  399. <View>
  400. <Text style={{}}>我的课程</Text>
  401. </View>
  402. </View>
  403. </TouchableOpacity>
  404. </View>
  405. <View
  406. style={{
  407. flex: 0.5
  408. }}
  409. />
  410. </View>
  411. <View
  412. style={{
  413. flex: 0.1,
  414. backgroundColor: "#F8F8F8"
  415. }}
  416. />
  417. <View
  418. //这里要改成活的
  419. style={{
  420. flex: 1,
  421. flexDirection: "column",
  422. alignItems: "center",
  423. justifyContent: "center",
  424. width: "100%"
  425. }}
  426. >
  427. <View
  428. style={{
  429. flexDirection: "row",
  430. flex: 1,
  431. width: "90%",
  432. backgroundColor: "#FFFFFF",
  433. alignItems: "center"
  434. }}
  435. >
  436. <Text
  437. style={{
  438. flex: 1.5,
  439. fontSize: 18,
  440. fontWeight: "bold",
  441. color: "black"
  442. }}
  443. >
  444. 学前
  445. </Text>
  446. <View
  447. style={{
  448. flex: 9
  449. }}
  450. />
  451. <View
  452. style={{
  453. flex: 2,
  454. alignItems: "center",
  455. justifyContent: "center",
  456. flexDirection: "row"
  457. }}
  458. >
  459. <Image
  460. source={{
  461. uri:
  462. "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=532481250,2026274152&fm=15&gp=0.jpg"
  463. }}
  464. style={{
  465. width: 14,
  466. justifyContent: "center",
  467. alignItems: "center",
  468. height: 13,
  469. marginRight: 5
  470. }}
  471. />
  472. <Text style={{}}>切换学龄</Text>
  473. </View>
  474. </View>
  475. <View
  476. style={{
  477. flex: 0.1,
  478. width: "90%",
  479. backgroundColor: "#F8F8F8"
  480. }}
  481. />
  482. </View>
  483. </View>
  484. </ImageBackground>
  485. );
  486. }
  487. loadFlatItem(data) {
  488. switch (data.typea) {
  489. case 0:
  490. return (
  491. <View
  492. style={{
  493. height: 50,
  494. width: "100%",
  495. justifyContent: "center",
  496. alignItems: "center",
  497. backgroundColor: "#F8F8F8"
  498. }}
  499. >
  500. <View
  501. style={{
  502. height: "60%",
  503. justifyContent: "center",
  504. alignItems: "center",
  505. width: "90%",
  506. backgroundColor: "#ffffffff",
  507. borderRadius: 20,
  508. flexDirection: "row"
  509. }}
  510. >
  511. <View style={{ flex: 0.2 }} />
  512. <Text
  513. numberOfLines={1}
  514. style={{
  515. flex: 12,
  516. justifyContent: "center",
  517. alignItems: "center",
  518. fontSize: 18,
  519. fontWeight: "bold",
  520. color: "#3E455B"
  521. }}
  522. >
  523. {data.title}
  524. </Text>
  525. <View
  526. style={{
  527. flex: 1,
  528. height: "100%",
  529. justifyContent: "center",
  530. alignItems: "center"
  531. }}
  532. >
  533. <Image
  534. source={{
  535. uri:
  536. "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&fm=26&gp=0.jpg"
  537. }}
  538. style={{
  539. width: "50%",
  540. height: "50%",
  541. justifyContent: "center",
  542. alignItems: "center",
  543. borderRadius: 30
  544. }}
  545. />
  546. </View>
  547. </View>
  548. </View>
  549. );
  550. break;
  551. case 1:
  552. return (
  553. <Swipers/>
  554. );
  555. break;
  556. case 2:
  557. let arr = [];
  558. let index = 0;
  559. for (let item of data.item.icon_item) {
  560. arr.push(
  561. <TouchableOpacity
  562. style={{ flex: 2 }}
  563. onPress={() => {
  564. alert(item.name);
  565. }}
  566. key={index}
  567. activeOpacity={1}
  568. >
  569. <Image
  570. source={{
  571. uri: item.icon
  572. }}
  573. key={index}
  574. style={{
  575. width: "100%",
  576. height: "100%",
  577. justifyContent: "center",
  578. alignItems: "center",
  579. borderRadius: 10
  580. }}
  581. />
  582. </TouchableOpacity>
  583. );
  584. if (index < data.item.icon_item.length - 1) {
  585. arr.push(
  586. <View
  587. key={item.name}
  588. style={{
  589. flex: 0.1
  590. }}
  591. />
  592. );
  593. }
  594. index++;
  595. }
  596. return (
  597. <View
  598. style={{
  599. marginTop: 20,
  600. flex: 1,
  601. justifyContent: "center",
  602. alignItems: "center"
  603. }}
  604. >
  605. <View
  606. style={{
  607. flex: 1,
  608. flexDirection: "column",
  609. width: "90%",
  610. height: 150
  611. }}
  612. >
  613. <Text
  614. style={{
  615. flex: 0.5,
  616. fontSize: 18,
  617. fontWeight: "bold",
  618. color: "#3E455B"
  619. }}
  620. >
  621. {data.item.title}
  622. </Text>
  623. <View
  624. style={{
  625. flex: 2,
  626. flexDirection: "row",
  627. justifyContent: "space-between"
  628. }}
  629. >
  630. {arr}
  631. </View>
  632. </View>
  633. </View>
  634. );
  635. break;
  636. case 3:
  637. return (
  638. <View
  639. style={{
  640. marginTop: 20,
  641. flex: 1,
  642. justifyContent: "center",
  643. alignItems: "center"
  644. }}
  645. >
  646. <View
  647. style={{
  648. width: "90%",
  649. height: 200,
  650. flexDirection: "column"
  651. }}
  652. >
  653. <View
  654. style={{
  655. flex: 0.5,
  656. justifyContent: "center",
  657. alignItems: "center",
  658. flexDirection: "row"
  659. }}
  660. >
  661. <View
  662. style={{
  663. flex: 0.1,
  664. height: 14,
  665. justifyContent: "flex-start",
  666. alignItems: "center",
  667. backgroundColor: "#01AFFE",
  668. borderRadius: 20
  669. }}
  670. />
  671. <View
  672. style={{
  673. flex: 0.1
  674. }}
  675. />
  676. <Text
  677. numberOfLines={1}
  678. style={{
  679. flex: 11,
  680. fontSize: 18,
  681. fontWeight: "bold",
  682. color: "#3E455B"
  683. }}
  684. >
  685. {data.title}
  686. </Text>
  687. </View>
  688. {text_z}
  689. <View
  690. style={{
  691. flex: 3
  692. }}
  693. >
  694. <FlatList
  695. style={{
  696. flex: 1
  697. }}
  698. ItemSeparatorComponent={() => (
  699. <View
  700. style={{
  701. width: 10
  702. }}
  703. />
  704. )}
  705. showsHorizontalScrollIndicator={false}
  706. keyExtractor={(item, index) => item.name.toString()}
  707. data={data.icon_item}
  708. horizontal={true}
  709. renderItem={({ item }) => {
  710. return (
  711. <TouchableOpacity
  712. style={{
  713. flex: 1,
  714. height: "100%",
  715. width: this.getWindowWidth() * 0.9
  716. }}
  717. onPress={() => {
  718. alert(item.name);
  719. }}
  720. activeOpacity={1}
  721. >
  722. <Image
  723. source={{
  724. uri: item.icon
  725. }}
  726. style={{
  727. height: "100%",
  728. width: "100%",
  729. justifyContent: "center",
  730. alignItems: "center",
  731. borderRadius: 20
  732. }}
  733. />
  734. </TouchableOpacity>
  735. );
  736. }}
  737. />
  738. </View>
  739. </View>
  740. </View>
  741. );
  742. break;
  743. case 4:
  744. let text_z = [];
  745. let zhezhao = [];
  746. let view_height = 190;
  747. //判断是否需要text
  748. if (data.text != "") {
  749. view_height = 217;
  750. text_z.push(
  751. <View
  752. key={data.text}
  753. style={{
  754. flex: 0.5,
  755. justifyContent: "center",
  756. alignItems: "center",
  757. flexDirection: "row"
  758. }}
  759. >
  760. <View
  761. style={{
  762. flex: 1,
  763. flexDirection: "row"
  764. }}
  765. >
  766. <View
  767. style={{
  768. flex: 0.2
  769. }}
  770. />
  771. <Text
  772. style={{
  773. flex: 11,
  774. color: "#8F94AA"
  775. }}
  776. >
  777. {data.text}
  778. </Text>
  779. </View>
  780. </View>
  781. );
  782. }
  783. return (
  784. <View
  785. style={{
  786. marginTop: 20,
  787. flex: 1,
  788. justifyContent: "center",
  789. alignItems: "center"
  790. }}
  791. >
  792. <View
  793. style={{
  794. width: "90%",
  795. height: view_height,
  796. flexDirection: "column"
  797. }}
  798. >
  799. <View
  800. style={{
  801. flex: 0.5,
  802. justifyContent: "center",
  803. alignItems: "center",
  804. flexDirection: "row"
  805. }}
  806. >
  807. <View
  808. style={{
  809. flex: 0.1,
  810. height: 14,
  811. justifyContent: "flex-start",
  812. alignItems: "center",
  813. backgroundColor: "#01AFFE",
  814. borderRadius: 15
  815. }}
  816. />
  817. <View
  818. style={{
  819. flex: 0.1
  820. }}
  821. />
  822. <Text
  823. style={{
  824. flex: 11,
  825. fontSize: 18,
  826. fontWeight: "bold",
  827. color: "#3E455B"
  828. }}
  829. >
  830. {data.title}
  831. </Text>
  832. </View>
  833. {text_z}
  834. <View
  835. style={{
  836. flex: 3
  837. }}
  838. >
  839. <FlatList
  840. style={{
  841. flex: 1
  842. }}
  843. ItemSeparatorComponent={() => (
  844. <View
  845. style={{
  846. width: 10
  847. }}
  848. />
  849. )}
  850. showsHorizontalScrollIndicator={false}
  851. keyExtractor={(item, index) => item.name.toString()}
  852. data={data.icon_item}
  853. horizontal={true}
  854. renderItem={({ item }) => {
  855. //判断是否需要遮盖层(观看记录)
  856. if (data.mask) {
  857. zhezhao = [];
  858. zhezhao.push(
  859. <View
  860. key={item.name}
  861. style={{
  862. flex: 1,
  863. width: "100%",
  864. flexDirection: "column"
  865. }}
  866. >
  867. <View
  868. style={{
  869. flex: 2
  870. }}
  871. />
  872. <View
  873. style={{
  874. flex: 1,
  875. backgroundColor: "#344563",
  876. width: "100%",
  877. borderBottomLeftRadius: 15,
  878. borderBottomRightRadius: 15,
  879. flexDirection: "row"
  880. }}
  881. >
  882. <View
  883. style={{
  884. flex: 0.1
  885. }}
  886. />
  887. <View
  888. style={{
  889. flex: 1
  890. }}
  891. >
  892. <Text
  893. style={{
  894. flex: 1,
  895. color: "red",
  896. textAlign: "left"
  897. }}
  898. >
  899. {item.last_time + ":"}
  900. </Text>
  901. <Text
  902. style={{
  903. flex: 1,
  904. color: "red",
  905. textAlign: "left"
  906. }}
  907. >
  908. {item.curriculum_name}
  909. </Text>
  910. </View>
  911. </View>
  912. </View>
  913. );
  914. }
  915. return (
  916. <TouchableOpacity
  917. style={{
  918. flex: 1,
  919. height: "100%",
  920. width: this.getWindowWidth() * 0.22
  921. }}
  922. onPress={() => {
  923. alert(item.name);
  924. }}
  925. activeOpacity={1}
  926. >
  927. <View
  928. style={{
  929. flex: 1,
  930. height: "100%",
  931. width: "100%",
  932. justifyContent: "center",
  933. alignItems: "center"
  934. }}
  935. >
  936. <View
  937. style={{
  938. flex: 5,
  939. height: "100%",
  940. width: "100%",
  941. justifyContent: "center",
  942. alignItems: "center"
  943. }}
  944. >
  945. <ImageBackground
  946. source={{
  947. uri: item.icon
  948. }}
  949. style={{
  950. height: "100%",
  951. width: "100%",
  952. justifyContent: "center",
  953. alignItems: "center"
  954. }}
  955. imageStyle={{
  956. borderRadius: 20
  957. }}
  958. >
  959. {zhezhao}
  960. </ImageBackground>
  961. </View>
  962. <Text
  963. style={{
  964. justifyContent: "center",
  965. alignItems: "center",
  966. flex: 1,
  967. fontSize: 12
  968. }}
  969. >
  970. {item.name}
  971. </Text>
  972. </View>
  973. </TouchableOpacity>
  974. );
  975. }}
  976. />
  977. </View>
  978. </View>
  979. </View>
  980. );
  981. break;
  982. case 5:
  983. break;
  984. case 6:
  985. break;
  986. case 7:
  987. break;
  988. case 8:
  989. break;
  990. }
  991. }
  992. }
  993. const styles = StyleSheet.create({
  994. title_text: {
  995. justifyContent: "center",
  996. alignItems: "center",
  997. color: "red",
  998. fontSize: 30,
  999. textAlign: "center",
  1000. marginTop: 30,
  1001. marginBottom: 50
  1002. }
  1003. });