Skip to content

Commit

Permalink
fix: Moved search bar out of <Header>
Browse files Browse the repository at this point in the history
  • Loading branch information
glouvigny committed Feb 26, 2019
1 parent a172729 commit 2e8f9de
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 56 deletions.
22 changes: 3 additions & 19 deletions client/react-native/common/components/Library/Header.js
@@ -1,8 +1,8 @@
import { View } from 'react-native'
import React, { PureComponent } from 'react'
import { Button, Flex, Text, SearchBar } from '.'
import { Button, Flex, Text } from '.'
import { colors } from '../../constants'
import { padding, borderBottom, paddingBottom } from '../../styles'
import { padding, borderBottom } from '../../styles'
import { isRTL } from '../../i18n'

const [defaultTextColor, defaultBackColor] = [colors.black, colors.white]
Expand All @@ -21,8 +21,6 @@ export default class Header extends PureComponent {
rightBtn,
rightBtnIcon,
onPressRightBtn,
searchBar,
searchHandler,
} = this.props

const colorText =
Expand All @@ -38,24 +36,12 @@ export default class Header extends PureComponent {
? defaultTextColor
: this.props.colorBtnRight

let searchBarComponent = null
if (searchBar === true) {
searchBarComponent = (
<SearchBar onChangeText={text => searchHandler(text)} />
)
} else if (searchBar !== undefined && searchBar !== false) {
searchBarComponent = searchBar
}

// todo calc height in function of dev status bar and search bar
// let height

return (
<View
style={[
{
backgroundColor: colorBack,
height: searchBar && true ? 110 : 70,
height: 70,
},
borderBottom,
padding,
Expand All @@ -66,7 +52,6 @@ export default class Header extends PureComponent {
size={1}
justify='between'
align='center'
style={[searchBar ? paddingBottom : {}]}
>
{backBtn && (
<HeaderButton
Expand Down Expand Up @@ -106,7 +91,6 @@ export default class Header extends PureComponent {
/>
)}
</Flex.Cols>
{searchBarComponent}
</Flex.Rows>
</View>
)
Expand Down
4 changes: 2 additions & 2 deletions client/react-native/common/components/Library/SearchBar.js
Expand Up @@ -3,11 +3,11 @@ import React from 'react'

import { Flex } from '.'
import { colors } from '../../constants'
import { paddingBottom, paddingLeft, paddingRight } from '../../styles'
import { paddingLeft, paddingRight } from '../../styles'
import { withNamespaces } from 'react-i18next'

const SearchBar = props => (
<Flex.Cols size={1} style={[paddingBottom]}>
<Flex.Cols size={1}>
<TextInput
underlineColorAndroid='transparent'
autoCorrect={
Expand Down
23 changes: 19 additions & 4 deletions client/react-native/common/components/Screens/Chats/Add.js
Expand Up @@ -4,8 +4,20 @@ import I18n from 'i18next'
import React, { Component, PureComponent } from 'react'

import { Pagination, RelayContext } from '../../../relay'
import { Screen, Flex, Text, Header, Avatar } from '../../Library'
import { border, borderBottom, marginHorizontal } from '../../../styles'
import {
Screen,
Flex,
Text,
Header,
Avatar,
SearchBar,
} from '../../Library'
import {
border,
borderBottom,
marginHorizontal,
padding,
} from '../../../styles'
import { colors } from '../../../constants'
import { fragments } from '../../../graphql'

Expand Down Expand Up @@ -86,9 +98,7 @@ class ListScreen extends Component {
titleIcon='users'
rightBtn={navigation.getParam('rightBtn')}
rightBtnIcon='check-circle'
searchBar
backBtn
searchHandler={navigation.getParam('searchHandler')} // Placeholder
onPressRightBtn={navigation.getParam('onSubmit')}
/>
),
Expand Down Expand Up @@ -162,6 +172,11 @@ class ListScreen extends Component {
variables={queries.ContactList.defaultVariables}
fragment={fragments.ContactList}
alias='ContactList'
ListHeaderComponent={
<View style={padding}>
<SearchBar onChangeText={() => { console.warn('not implemented') }} />
</View>
}
renderItem={props =>
props.data.status !== 42 ? (
<Item
Expand Down
8 changes: 6 additions & 2 deletions client/react-native/common/components/Screens/Chats/List.js
Expand Up @@ -8,6 +8,7 @@ import {
Screen,
Text,
Badge,
SearchBar,
} from '../../Library'
import { Pagination, RelayContext } from '../../../relay'
import { borderBottom, marginLeft, padding } from '../../../styles'
Expand Down Expand Up @@ -162,8 +163,6 @@ class ListScreen extends PureComponent {
title={I18n.t('chats.title')}
titleIcon='message-circle'
rightBtnIcon='edit'
searchBar
searchHandler={navigation.getParam('searchHandler')} // Placeholder
onPressRightBtn={() => ListScreen.onPress(navigation)}
/>
),
Expand Down Expand Up @@ -201,6 +200,11 @@ class ListScreen extends PureComponent {
renderItem={props => (
<Item {...props} context={context} navigation={navigation} />
)}
ListHeaderComponent={
<View style={padding}>
<SearchBar onChangeText={() => { console.warn('not implemented') }} />
</View>
}
emptyItem={() => (
<EmptyList
source={require('../../../static/img/empty-conversation.png')}
Expand Down
@@ -1,4 +1,4 @@
import { Text, TouchableOpacity } from 'react-native'
import { Text, TouchableOpacity, View } from 'react-native'
import React, { PureComponent } from 'react'
import moment from 'moment'

Expand Down Expand Up @@ -52,7 +52,7 @@ const Item = fragments.Event(({ data, navigation }) => (
}[data.direction]
}{' '}
<Text style={{ fontWeight: 'bold' }}>
{enums.ValueBertyP2pKindInputKind[data.kind]}
{enums.ValueBertyEntityKindInputKind[data.kind]}
</Text>
{' (' + data.kind + ')'}
</Text>
Expand Down Expand Up @@ -126,24 +126,6 @@ export default class EventList extends PureComponent {
navigation={navigation}
title='List events'
titleIcon='list'
searchBar={
<SearchBar onChangeText={navigation.getParam('searchHandler')}>
<LibText
size={0}
height={34}
icon='filter'
padding
middle
large
onPress={() =>
navigation.navigate('modal/devtools/event/list/filters', {
defaultData: navigation.getParam('filters'),
onSave: filters => navigation.setParams({ filters }),
})
}
/>
</SearchBar>
}
backBtn
/>
),
Expand All @@ -168,6 +150,26 @@ export default class EventList extends PureComponent {
fragment={fragments.EventList}
alias='EventList'
renderItem={props => <Item {...props} navigation={navigation} />}
ListHeaderComponent={
<View style={padding}>
<SearchBar onChangeText={(search) => this.searchHandler(search)}>
<LibText
size={0}
height={34}
icon='filter'
padding
middle
large
onPress={() =>
navigation.navigate('modal/devtools/event/list/filters', {
defaultData: navigation.getParam('filters'),
onSave: filters => navigation.setParams({ filters }),
})
}
/>
</SearchBar>
</View>
}
/>
</Screen>
)
Expand Down
Expand Up @@ -48,11 +48,6 @@ export default class Peers extends Component {
navigation={navigation}
title='Peers List'
titleIcon='list'
searchBar={
<SearchBar onChangeText={navigation.getParam('peerFilter')}>
<LibText size={0} height={34} padding middle large />
</SearchBar>
}
backBtn
/>
),
Expand Down Expand Up @@ -80,10 +75,6 @@ export default class Peers extends Component {
}

componentDidMount () {
this.props.navigation.setParams({
peerFilter: this.peerFilter,
})

this.fetchPeers()
}

Expand Down Expand Up @@ -189,6 +180,9 @@ export default class Peers extends Component {
}`}
</Text>
</View>
<SearchBar onChangeText={filter => this.peerFilter(filter)}>
<LibText size={0} height={34} padding middle large />
</SearchBar>
<Accordion
sections={filteredPeers.slice(0, 100)}
activeSections={this.state.opened}
Expand Down
1 change: 1 addition & 0 deletions client/react-native/common/relay/Pagination.js
Expand Up @@ -68,6 +68,7 @@ class PaginationContainer extends Component {
return (
<>
<FlatList
ListHeaderComponent={this.props.ListHeaderComponent}
data={data[alias].edges}
inverted={inverted}
refreshing={this.state.refetching}
Expand Down

0 comments on commit 2e8f9de

Please sign in to comment.