MainPage.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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. Platform,
  11. StyleSheet,
  12. Text,
  13. View,
  14. Image,
  15. FlatList,
  16. TouchableOpacity,
  17. ImageBackground,
  18. TextInput,
  19. Button,
  20. ViewPagerAndroid,
  21. DeviceEventEmitter
  22. } from "react-native";
  23. import Swiper from "react-native-swiper";
  24. import AndroidUtil from "../../util/AndroidUtil";
  25. import BasePage from "../BasePage";
  26. import Header from "./Header";
  27. import MySwiper from "./Swiper";
  28. import Dimensions from '../utils/dimensions';
  29. import TopicTitle from './TopicTitle';
  30. export default class MainPage extends BasePage {
  31. constructor(props) {
  32. super(props);
  33. this.state = {
  34. grade: '大学',
  35. text: '小伙子'
  36. }
  37. }
  38. render() {
  39. return (
  40. <View style={{ flex: 1 }}>
  41. <FlatList
  42. style={{ flex: 1, backgroundColor: 'f0f1f5' }}
  43. ref="_flatlist"
  44. horizontal={false}
  45. removeClippedSubviews={false}
  46. ListHeaderComponent={() => this.headerorfooterComponent()}
  47. // searchSection={() => this.renderSearchSection()}
  48. keyExtractor={(item, index) => item.key.toString()}
  49. renderItem={({ item }) => {
  50. return this.loadFlatItem(item);
  51. }}
  52. data={[
  53. {
  54. //轮播
  55. key: 111,
  56. typea: 1,
  57. text: "第一种类型"
  58. },
  59. {
  60. //标题类型
  61. key: 333,
  62. typea: 0,
  63. title: "全部课程全部课程全部课程全部课程全部课程全部课程"
  64. },
  65. {
  66. //只有一个标题下面两个图片
  67. key: 222,
  68. typea: 2,
  69. item: {
  70. item_type: 1,
  71. title: "课程表:第一周",
  72. icon_item: [
  73. {
  74. icon:
  75. "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",
  76. name: "第一张图片文字"
  77. },
  78. {
  79. icon:
  80. "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",
  81. name: "第二张图片文字"
  82. }
  83. ]
  84. }
  85. },
  86. {
  87. //一个标题,大长图
  88. key: 444,
  89. typea: 3,
  90. title: "五月主题:五一启程,去看看不同世界",
  91. text: "每天30分钟,玩学两不误",
  92. icon_item: [
  93. {
  94. icon:
  95. "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",
  96. name: "第一张图片文字"
  97. },
  98. {
  99. icon:
  100. "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",
  101. name: "第二张图片文字"
  102. },
  103. {
  104. icon:
  105. "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",
  106. name: "第三张图片文字"
  107. },
  108. {
  109. icon:
  110. "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",
  111. name: "第四张图片文字"
  112. },
  113. {
  114. icon:
  115. "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",
  116. name: "第五张图片文字"
  117. }
  118. ]
  119. },
  120. {
  121. key: 555,
  122. typea: 4,
  123. title: "热门课程",
  124. text: "text",
  125. mask: false,
  126. icon_item: [
  127. {
  128. icon:
  129. "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",
  130. name: "第一张图片文字"
  131. },
  132. {
  133. icon:
  134. "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",
  135. name: "第二张图片文字"
  136. },
  137. {
  138. icon:
  139. "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",
  140. name: "第三张图片文字"
  141. },
  142. {
  143. icon:
  144. "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",
  145. name: "第四张图片文字"
  146. },
  147. {
  148. icon:
  149. "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",
  150. name: "第五张图片文字"
  151. }
  152. ]
  153. },
  154. {
  155. //标题类型
  156. key: 0,
  157. typea: 0,
  158. title: "全部课程"
  159. },
  160. {
  161. //一个标题,icon下有文字
  162. key: 666,
  163. typea: 4,
  164. title: "测试text为空的时候",
  165. text: "",
  166. mask: false,
  167. icon_item: [
  168. {
  169. icon:
  170. "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",
  171. name: "第一张图片文字"
  172. },
  173. {
  174. icon:
  175. "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",
  176. name: "第二张图片文字"
  177. },
  178. {
  179. icon:
  180. "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",
  181. name: "第三张图片文字"
  182. },
  183. {
  184. icon:
  185. "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",
  186. name: "第四张图片文字"
  187. },
  188. {
  189. icon:
  190. "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",
  191. name: "第五张图片文字"
  192. }
  193. ]
  194. },
  195. {
  196. key: 777,
  197. typea: 4,
  198. title: "测试观看记录",
  199. text: "",
  200. mask: true,
  201. icon_item: [
  202. {
  203. last_time: "2小时前",
  204. icon:
  205. "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",
  206. name: "第一张图片文字",
  207. curriculum_name: "课件名字"
  208. },
  209. {
  210. last_time: "3小时前",
  211. icon:
  212. "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",
  213. name: "第二张图片文字",
  214. curriculum_name: "课件名字1"
  215. },
  216. {
  217. last_time: "4小时前",
  218. icon:
  219. "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",
  220. name: "第三张图片文字",
  221. curriculum_name: "课件名字2"
  222. },
  223. {
  224. last_time: "1天前",
  225. icon:
  226. "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",
  227. name: "第四张图片文字",
  228. curriculum_name: "课件名字3"
  229. },
  230. {
  231. last_time: "2天前",
  232. icon:
  233. "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",
  234. name: "第五张图片文字",
  235. curriculum_name: "课件名字4"
  236. }
  237. ]
  238. }
  239. ]}
  240. />
  241. </View>
  242. );
  243. }
  244. // flat 头部组件
  245. headerorfooterComponent() {
  246. return (
  247. <View>
  248. <Header
  249. uri="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1295208965,3056573814&amp;fm=26&amp;gp=0.jpg"
  250. width={400}
  251. height={150}
  252. username="卡通笨笨熊"
  253. flowerNumber="123234"
  254. onPress={() => this.toNextPage("MainActivity")}
  255. />
  256. {/* 搜索区域 */}
  257. <View style={styles.searchSection}>
  258. <TextInput
  259. style={styles.searchBox}
  260. onChangeText={(text) => this.setState({ text })}
  261. value={this.state.text}
  262. />
  263. <View
  264. style={styles.rightBtn}
  265. >
  266. <Image
  267. source={{ uri: 'https://facebook.github.io/react-native/docs/assets/favicon.png' }}
  268. style={styles.rightBtnIcon}
  269. />
  270. <Text
  271. style={styles.rightBtnText}
  272. >
  273. {this.state.grade}
  274. </Text>
  275. </View>
  276. </View>
  277. </View>
  278. );
  279. }
  280. getSwiperElement() {
  281. return (
  282. <View
  283. style={{
  284. height: 193,
  285. flex: 1,
  286. justifyContent: "center",
  287. alignItems: "center",
  288. flexDirection: "row",
  289. }}
  290. >
  291. <View
  292. style={{
  293. // width: Dimensions.width,
  294. width: Dimensions.getDp(358),
  295. height: Dimensions.getDp(150),
  296. justifyContent: "center",
  297. overflow: 'hidden'
  298. }}
  299. >
  300. <MySwiper
  301. autoplay={true}
  302. loop={true}
  303. ifShowMiddle={true}
  304. />
  305. </View>
  306. </View>
  307. );
  308. }
  309. getScheduleElement(data) {
  310. let arr = [];
  311. let index = 0;
  312. for (let item of data.item.icon_item) {
  313. arr.push(
  314. <TouchableOpacity
  315. style={{ width: 172, height: 86, marginRight: 12, backgroundColor: 'red' }}
  316. onPress={() => {
  317. alert(item.name);
  318. }}
  319. key={index}
  320. activeOpacity={1}
  321. >
  322. <Image
  323. source={{
  324. uri: item.icon
  325. }}
  326. key={index}
  327. style={{
  328. flex: 1,
  329. justifyContent: "center",
  330. alignItems: "center",
  331. borderRadius: 10
  332. }}
  333. />
  334. </TouchableOpacity>
  335. );
  336. if (index < data.item.icon_item.length - 1) {
  337. arr.push(
  338. <View
  339. key={item.name}
  340. style={{
  341. flex: 0.1
  342. }}
  343. />
  344. );
  345. }
  346. index++;
  347. }
  348. return (
  349. <View
  350. style={{
  351. flex: 1,
  352. flexDirection: "column",
  353. height: 140,
  354. backgroundColor: 'blue'
  355. }}
  356. >
  357. <TopicTitle title={'课程表:第一周'} ifTubeShow={true} />
  358. <View
  359. style={{
  360. flex: 2,
  361. flexDirection: "row",
  362. backgroundColor: 'green',
  363. alignItems: 'center',
  364. paddingLeft: 10
  365. }}
  366. >
  367. {arr}
  368. </View>
  369. </View>
  370. );
  371. }
  372. loadFlatItem(data) {
  373. switch (data.typea) {
  374. case 1:
  375. return this.getSwiperElement();
  376. break;
  377. case 2:
  378. return this.getScheduleElement(data);
  379. break;
  380. case 3:
  381. return (
  382. <View
  383. style={{
  384. marginTop: 20,
  385. flex: 1,
  386. justifyContent: "center",
  387. alignItems: "center",
  388. backgroundColor: 'blue'
  389. }}
  390. >
  391. <View
  392. style={{
  393. width: "90%",
  394. height: 200,
  395. flexDirection: "column"
  396. }}
  397. >
  398. <View
  399. style={{
  400. flex: 0.5,
  401. justifyContent: "center",
  402. alignItems: "center",
  403. flexDirection: "row"
  404. }}
  405. >
  406. <View
  407. style={{
  408. flex: 0.1,
  409. height: 14,
  410. justifyContent: "flex-start",
  411. alignItems: "center",
  412. backgroundColor: "green",
  413. borderRadius: 20
  414. }}
  415. />
  416. <View
  417. style={{
  418. flex: 0.1
  419. }}
  420. />
  421. <Text
  422. numberOfLines={1}
  423. style={{
  424. flex: 11,
  425. fontSize: 18,
  426. fontWeight: "bold",
  427. color: "#3E455B"
  428. }}
  429. >
  430. {data.title}
  431. </Text>
  432. </View>
  433. {text_z}
  434. <View
  435. style={{
  436. flex: 3
  437. }}
  438. >
  439. <FlatList
  440. style={{
  441. flex: 1
  442. }}
  443. ItemSeparatorComponent={() => (
  444. <View
  445. style={{
  446. width: 10
  447. }}
  448. />
  449. )}
  450. showsHorizontalScrollIndicator={false}
  451. keyExtractor={(item, index) => item.name.toString()}
  452. data={data.icon_item}
  453. horizontal={true}
  454. renderItem={({ item }) => {
  455. return (
  456. <TouchableOpacity
  457. style={{
  458. flex: 1,
  459. height: "100%",
  460. width: this.getWindowWidth() * 0.9
  461. }}
  462. onPress={() => {
  463. alert(item.name);
  464. }}
  465. activeOpacity={1}
  466. >
  467. <Image
  468. source={{
  469. uri: item.icon
  470. }}
  471. style={{
  472. height: "100%",
  473. width: "100%",
  474. justifyContent: "center",
  475. alignItems: "center",
  476. borderRadius: 20
  477. }}
  478. />
  479. </TouchableOpacity>
  480. );
  481. }}
  482. />
  483. </View>
  484. </View>
  485. </View>
  486. );
  487. break;
  488. case 4:
  489. let text_z = [];
  490. let zhezhao = [];
  491. let view_height = 190;
  492. //判断是否需要text
  493. if (data.text != "") {
  494. view_height = 217;
  495. text_z.push(
  496. <View
  497. key={data.text}
  498. style={{
  499. flex: 0.5,
  500. justifyContent: "center",
  501. alignItems: "center",
  502. flexDirection: "row"
  503. }}
  504. >
  505. <View
  506. style={{
  507. flex: 1,
  508. flexDirection: "row"
  509. }}
  510. >
  511. <View
  512. style={{
  513. flex: 0.2
  514. }}
  515. />
  516. <Text
  517. style={{
  518. flex: 11,
  519. color: "#8F94AA"
  520. }}
  521. >
  522. {data.text}
  523. </Text>
  524. </View>
  525. </View>
  526. );
  527. }
  528. return (
  529. <View
  530. style={{
  531. marginTop: 20,
  532. flex: 1,
  533. justifyContent: "center",
  534. alignItems: "center"
  535. }}
  536. >
  537. <View
  538. style={{
  539. width: "90%",
  540. height: view_height,
  541. flexDirection: "column"
  542. }}
  543. >
  544. <View
  545. style={{
  546. flex: 0.5,
  547. justifyContent: "center",
  548. alignItems: "center",
  549. flexDirection: "row"
  550. }}
  551. >
  552. <View
  553. style={{
  554. flex: 0.1,
  555. height: 14,
  556. justifyContent: "flex-start",
  557. alignItems: "center",
  558. backgroundColor: "#01AFFE",
  559. borderRadius: 15
  560. }}
  561. />
  562. <View
  563. style={{
  564. flex: 0.1
  565. }}
  566. />
  567. <Text
  568. style={{
  569. flex: 11,
  570. fontSize: 18,
  571. fontWeight: "bold",
  572. color: "#3E455B"
  573. }}
  574. >
  575. {data.title}
  576. </Text>
  577. </View>
  578. {text_z}
  579. <View
  580. style={{
  581. flex: 3
  582. }}
  583. >
  584. <FlatList
  585. style={{
  586. flex: 1
  587. }}
  588. ItemSeparatorComponent={() => (
  589. <View
  590. style={{
  591. width: 10
  592. }}
  593. />
  594. )}
  595. showsHorizontalScrollIndicator={false}
  596. keyExtractor={(item, index) => item.name.toString()}
  597. data={data.icon_item}
  598. horizontal={true}
  599. renderItem={({ item }) => {
  600. //判断是否需要遮盖层(观看记录)
  601. if (data.mask) {
  602. zhezhao = [];
  603. zhezhao.push(
  604. <View
  605. key={item.name}
  606. style={{
  607. flex: 1,
  608. width: "100%",
  609. flexDirection: "column"
  610. }}
  611. >
  612. <View
  613. style={{
  614. flex: 2
  615. }}
  616. />
  617. <View
  618. style={{
  619. flex: 1,
  620. backgroundColor: "#344563",
  621. width: "100%",
  622. borderBottomLeftRadius: 15,
  623. borderBottomRightRadius: 15,
  624. flexDirection: "row"
  625. }}
  626. >
  627. <View
  628. style={{
  629. flex: 0.1
  630. }}
  631. />
  632. <View
  633. style={{
  634. flex: 1
  635. }}
  636. >
  637. <Text
  638. style={{
  639. flex: 1,
  640. color: "red",
  641. textAlign: "left"
  642. }}
  643. >
  644. {item.last_time + ":"}
  645. </Text>
  646. <Text
  647. style={{
  648. flex: 1,
  649. color: "red",
  650. textAlign: "left"
  651. }}
  652. >
  653. {item.curriculum_name}
  654. </Text>
  655. </View>
  656. </View>
  657. </View>
  658. );
  659. }
  660. return (
  661. <TouchableOpacity
  662. style={{
  663. flex: 1,
  664. height: "100%",
  665. width: this.getWindowWidth() * 0.22
  666. }}
  667. onPress={() => {
  668. alert(item.name);
  669. }}
  670. activeOpacity={1}
  671. >
  672. <View
  673. style={{
  674. flex: 1,
  675. height: "100%",
  676. width: "100%",
  677. justifyContent: "center",
  678. alignItems: "center"
  679. }}
  680. >
  681. <View
  682. style={{
  683. flex: 5,
  684. height: "100%",
  685. width: "100%",
  686. justifyContent: "center",
  687. alignItems: "center"
  688. }}
  689. >
  690. <ImageBackground
  691. source={{
  692. uri: item.icon
  693. }}
  694. style={{
  695. height: "100%",
  696. width: "100%",
  697. justifyContent: "center",
  698. alignItems: "center"
  699. }}
  700. imageStyle={{
  701. borderRadius: 20
  702. }}
  703. >
  704. {zhezhao}
  705. </ImageBackground>
  706. </View>
  707. <Text
  708. style={{
  709. justifyContent: "center",
  710. alignItems: "center",
  711. flex: 1,
  712. fontSize: 12
  713. }}
  714. >
  715. {item.name}
  716. </Text>
  717. </View>
  718. </TouchableOpacity>
  719. );
  720. }}
  721. />
  722. </View>
  723. </View>
  724. </View>
  725. );
  726. break;
  727. case 5:
  728. break;
  729. case 6:
  730. break;
  731. case 7:
  732. break;
  733. case 8:
  734. break;
  735. }
  736. }
  737. }
  738. const styles = StyleSheet.create({
  739. title_text: {
  740. justifyContent: "center",
  741. alignItems: "center",
  742. color: "red",
  743. fontSize: 30,
  744. textAlign: "center",
  745. marginTop: 30,
  746. marginBottom: 50
  747. },
  748. /* 搜索区域 */
  749. searchSection: {
  750. flex: 1,
  751. width: Dimensions.width,
  752. height: 60,
  753. flexDirection: 'row',
  754. alignItems: 'center',
  755. backgroundColor: '#f0f1f5',
  756. justifyContent: 'space-around'
  757. },
  758. searchBox: {
  759. width: 232,
  760. height: 40,
  761. backgroundColor: '#fff',
  762. borderRadius: 20
  763. },
  764. rightBtn: {
  765. width: 113,
  766. height: 40,
  767. backgroundColor: '#fff',
  768. borderRadius: 20,
  769. alignItems: 'center',
  770. justifyContent: 'center',
  771. justifyContent: 'space-around',
  772. flexDirection: 'row',
  773. paddingLeft: 20,
  774. paddingRight: 10,
  775. },
  776. rightBtnIcon: {
  777. width: 14,
  778. height: 14
  779. },
  780. rightBtnText: {
  781. color: '#151515',
  782. fontSize: 18,
  783. }
  784. /* 轮播图区域 */
  785. });