Skip to content

Commit

Permalink
feat: add ascii toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Dec 1, 2020
1 parent 7ce4696 commit 7d96f06
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/components/Search/AsciiToggle.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import 'react-native'
import React from 'react'
import { render, fireEvent } from '@testing-library/react-native'

import AsciiToggle from './AsciiToggle'

describe( '<AsciiToggle />', () => {
it( 'should fire onPress event', () => {
const onPressMock = jest.fn()

const { getByTestId } = render(
<AsciiToggle onPress={onPressMock} testID="ascii-toggle" />,
)

fireEvent.press( getByTestId( 'ascii-toggle' ) )

expect( onPressMock ).toHaveBeenCalled()
} )
} )
27 changes: 27 additions & 0 deletions src/components/Search/AsciiToggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import { Text, Pressable, StyleSheet, PressableProps } from 'react-native'

const styles = StyleSheet.create( {
asciiToggle: {
padding: 8,
borderRadius: 10,
shadowOpacity: 0.2,
flexDirection: 'row',
shadowOffset: { width: 0, height: 2 },
backgroundColor: 'rgb(255,255,255)',
},
gurmukhi: {
fontFamily: 'OpenGurbaniAkhar-Black',
},
} )

type AsciiToggleProps = Omit<PressableProps, 'style'>

const AsciiToggle = ( { ...props }:AsciiToggleProps ) => (
<Pressable style={styles.asciiToggle} {...props}>
<Text style={styles.gurmukhi}>A</Text>
<Text>A</Text>
</Pressable>
)

export default AsciiToggle
1 change: 1 addition & 0 deletions src/components/Search/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as SearchBar } from './Bar'
export { default as SearchFilter } from './Filter'
export { default as AsciiToggle } from './AsciiToggle'
14 changes: 13 additions & 1 deletion src/screens/SearchScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import React, { useState } from 'react'
import { StyleSheet, View } from 'react-native'

import { SearchBar, SearchFilter } from '../components/Search'
import { SearchBar, SearchFilter, AsciiToggle } from '../components/Search'
import BackButton from '../components/BackButton'
import Container from '../components/Container'
import Colours from '../themes/colours'
import { mx, px } from '../themes/utils'

const styles = StyleSheet.create( {
asciiToggle: {
...mx,
marginLeft: -10,
marginRight: 10,
},
backButton: {
...mx,
marginLeft: 5,
Expand Down Expand Up @@ -55,10 +60,17 @@ const SearchScreen = () => {
<View style={styles.searchZone}>

<View style={styles.searchStrip}>

<View style={styles.asciiToggle}>
<AsciiToggle />
</View>

<View style={styles.searchBar}>
<SearchBar onChangeText={handleTextChange} />
</View>

<BackButton style={styles.backButton} />

</View>

<View style={styles.filterZone}>
Expand Down

0 comments on commit 7d96f06

Please sign in to comment.