1+ import React , { Component } from 'react' ;
2+ import { StyleSheet , View } from 'react-native' ;
3+ import Layout , { Container } from '../../Layout' ;
4+ import { Tabs , Icon , IconsName } from '@uiw/react-native' ;
5+ import { ComProps } from '../../routes' ;
6+ import { Text } from 'react-native-svg' ;
7+
8+ const { Header, Body, Card, Footer } = Layout ;
9+
10+ export interface listItem {
11+ title : string | React . ReactElement | React . ReactNode ,
12+ icon : IconsName | React . ReactElement | React . ReactNode ,
13+ }
14+ export interface IndexProps extends ComProps { }
15+ export interface IndexState {
16+ flag1 : string ,
17+ flag : string ,
18+ color1 : string ,
19+ }
20+
21+ export default class Index extends Component < IndexProps , IndexState > {
22+ constructor ( props : IndexProps ) {
23+ super ( props )
24+ this . state = {
25+ flag : '喜欢' ,
26+ flag1 : '喜欢' ,
27+ color1 : '#f18700'
28+ }
29+ }
30+ onPress1 = ( val : string ) => {
31+ this . setState ( { flag : val } )
32+ }
33+ onPress = ( val : string ) => {
34+ this . setState ( { flag1 : val } )
35+ }
36+ render ( ) {
37+ const { route } = this . props ;
38+ const description = route . params . description ;
39+ const title = route . params . title ;
40+ const { Item } = Tabs
41+ return (
42+ < Container >
43+ < Layout >
44+ < Header title = { title } description = { description } />
45+ < Body >
46+ < Tabs >
47+ < Item
48+ title = { '喜欢' }
49+ icon = 'heart-on'
50+ style = { {
51+ iconColor : this . state . flag === '喜欢' ?this . state . color1 :undefined ,
52+ titleColor : this . state . flag === '喜欢' ?this . state . color1 :undefined
53+ } }
54+ border = { this . state . flag === '喜欢' }
55+ onPress = { this . onPress1 }
56+ />
57+ < Tabs . Item
58+ title = { "关注" }
59+ style = { {
60+ titleColor : this . state . flag === '关注' ?this . state . color1 :undefined
61+ } }
62+ icon = { < Icon name = 'star-on' color = { this . state . flag === '关注' ?this . state . color1 :"#fff" } size = { 24 } /> }
63+ border = { this . state . flag === '关注' }
64+ onPress = { this . onPress1 }
65+ />
66+ < Tabs . Item
67+ title = { "信息" }
68+ icon = 'mail'
69+ style = { {
70+ iconColor : this . state . flag === '信息' ?this . state . color1 :undefined ,
71+ titleColor : this . state . flag === '信息' ?this . state . color1 :undefined
72+ } }
73+ border = { this . state . flag === '信息' }
74+ onPress = { this . onPress1 }
75+ />
76+ </ Tabs >
77+
78+ < View style = { styles . divider } />
79+
80+ < Tabs >
81+ < Tabs . Item
82+ title = { '喜欢' }
83+ border = { this . state . flag1 === '喜欢' }
84+ onPress = { this . onPress }
85+ style = { {
86+ titleColor : this . state . flag1 === '喜欢' ?this . state . color1 :undefined ,
87+ borderColor : this . state . flag1 === '喜欢' ?this . state . color1 :undefined
88+ } }
89+ />
90+ < Tabs . Item
91+ title = { "关注" }
92+ border = { this . state . flag1 === '关注' }
93+ onPress = { this . onPress }
94+ style = { {
95+ titleColor : this . state . flag1 === '关注' ?this . state . color1 :undefined ,
96+ borderColor : this . state . flag1 === '关注' ?this . state . color1 :undefined
97+ } }
98+ />
99+ < Tabs . Item
100+ title = { "信息" }
101+ border = { this . state . flag1 === '信息' }
102+ onPress = { this . onPress }
103+ style = { {
104+ titleColor : this . state . flag1 === '信息' ?this . state . color1 :undefined ,
105+ borderColor : this . state . flag1 === '信息' ?this . state . color1 :undefined
106+ } }
107+ />
108+ < Tabs . Item
109+ title = { "我的" }
110+ border = { this . state . flag1 === '我的' }
111+ onPress = { this . onPress }
112+ style = { {
113+ titleColor : this . state . flag1 === '我的' ?this . state . color1 :undefined ,
114+ borderColor : this . state . flag1 === '我的' ?this . state . color1 :undefined
115+ } }
116+ />
117+ < Tabs . Item
118+ title = { "偏好" }
119+ border = { this . state . flag1 === '偏好' }
120+ onPress = { this . onPress }
121+ style = { {
122+ titleColor : this . state . flag1 === '偏好' ?this . state . color1 :undefined ,
123+ borderColor : this . state . flag1 === '偏好' ?this . state . color1 :undefined
124+ } }
125+ />
126+ </ Tabs >
127+ </ Body >
128+ < Footer />
129+ </ Layout >
130+ </ Container >
131+ ) ;
132+ }
133+ }
134+
135+ const styles = StyleSheet . create ( {
136+ card : {
137+ backgroundColor : '#fff' ,
138+ paddingLeft : 20 ,
139+ paddingRight : 20 ,
140+ } ,
141+ divider : {
142+ marginVertical : 10
143+ }
144+ } ) ;
0 commit comments