Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stack navigator and search screen #114

Merged
merged 21 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8fb1d67
build: remove drawer navigator
saihaj Sep 16, 2020
e26514e
build: add react native masked view required by stack navigator
saihaj Sep 16, 2020
c8aeb24
build: jest transform stub for importing non JavaScript assets
saihaj Sep 16, 2020
0de5a74
test: update config to handle static assets
saihaj Sep 16, 2020
d36acc4
feat: setup stack navigator
saihaj Sep 16, 2020
8c46a99
ci: disable require default props
saihaj Sep 17, 2020
5631884
build: update react-native-safe-area-context
saihaj Sep 17, 2020
40aa822
feat: use safe area context in `Container`
saihaj Sep 17, 2020
973f7bb
feat: back button components
saihaj Sep 17, 2020
8545b61
feat: mockup search screen
saihaj Sep 17, 2020
965b781
refactor: colors into a theme colors file
saihaj Sep 18, 2020
4c8440c
feat: implement SafeArea from react-native
saihaj Sep 18, 2020
f2150dd
build: add eslint plugin to enforce grouping of imports and closest a…
saihaj Sep 18, 2020
b77cd22
refactor: rename `color` to `colours` and use PascalCase
saihaj Sep 18, 2020
86519ac
refactor: move inline styles to stylesheet
saihaj Sep 18, 2020
a790fe9
refactor: move centering logic to a shared util
saihaj Sep 18, 2020
88c308f
refactor: use object expansion instead of ternary
saihaj Sep 18, 2020
87de63b
refactor: change import order
saihaj Sep 22, 2020
5a2c348
refactor: use camelCase
saihaj Sep 22, 2020
6cc1278
feat: component based style utils to reusable objects
saihaj Sep 24, 2020
2bf68ed
build: disable max body length rule for commitlint
saihaj Sep 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["react-native"],
"plugins": ["react-native", "simple-import-sort"],
"rules": {
// Spacing in brackets is consistent and readable
"array-bracket-spacing": ["error", "always"],
Expand Down Expand Up @@ -136,6 +136,17 @@
{
"ignoreStyleProperties": true
}
],
// Prefer passing in ES6 default values to function components (ideal solution resolve #113)
"react/require-default-props": "off",
// This plugin sorts alphabetically by default
"simple-import-sort/sort": "off",
// Add new line between imports
"import/order": [
"error",
{
"newlines-between": "always"
}
]
}
}
12 changes: 9 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ PODS:
- React-cxxreact (= 0.63.2)
- React-jsi (= 0.63.2)
- React-jsinspector (0.63.2)
- react-native-safe-area-context (3.1.7):
- React
- react-native-safe-area-context (3.1.8):
- React-Core
- React-RCTActionSheet (0.63.2):
- React-Core/RCTActionSheetHeaders (= 0.63.2)
- React-RCTAnimation (0.63.2):
Expand Down Expand Up @@ -247,6 +247,8 @@ PODS:
- React-Core (= 0.63.2)
- React-cxxreact (= 0.63.2)
- React-jsi (= 0.63.2)
- RNCMaskedView (0.1.10):
- React
- RNGestureHandler (1.8.0):
- React
- RNReanimated (1.13.0):
Expand Down Expand Up @@ -288,6 +290,7 @@ DEPENDENCIES:
- React-RCTText (from `../node_modules/react-native/Libraries/Text`)
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
- RNScreens (from `../node_modules/react-native-screens`)
Expand Down Expand Up @@ -352,6 +355,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/Libraries/Vibration"
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
RNCMaskedView:
:path: "../node_modules/@react-native-community/masked-view"
RNGestureHandler:
:path: "../node_modules/react-native-gesture-handler"
RNReanimated:
Expand Down Expand Up @@ -382,7 +387,7 @@ SPEC CHECKSUMS:
React-jsi: 54245e1d5f4b690dec614a73a3795964eeef13a8
React-jsiexecutor: 8ca588cc921e70590820ce72b8789b02c67cce38
React-jsinspector: b14e62ebe7a66e9231e9581279909f2fc3db6606
react-native-safe-area-context: fcece23844742b6f7f0627c3715b806a7deff946
react-native-safe-area-context: 01158a92c300895d79dee447e980672dc3fb85a6
React-RCTActionSheet: 910163b6b09685a35c4ebbc52b66d1bfbbe39fc5
React-RCTAnimation: 9a883bbe1e9d2e158d4fb53765ed64c8dc2200c6
React-RCTBlob: 39cf0ece1927996c4466510e25d2105f67010e13
Expand All @@ -393,6 +398,7 @@ SPEC CHECKSUMS:
React-RCTText: 1b6773e776e4b33f90468c20fe3b16ca3e224bb8
React-RCTVibration: 4d2e726957f4087449739b595f107c0d4b6c2d2d
ReactCommon: a0a1edbebcac5e91338371b72ffc66aa822792ce
RNCMaskedView: f5c7d14d6847b7b44853f7acb6284c1da30a3459
RNGestureHandler: 7a5833d0f788dbd107fbb913e09aa0c1ff333c39
RNReanimated: 89f5e0a04d1dd52fbf27e7e7030d8f80a646a3fc
RNScreens: b748efec66e095134c7166ca333b628cd7e6f3e2
Expand Down
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,10 @@ module.exports = {
'<rootDir>/test/setupJest.js',
],
moduleFileExtensions: [ 'ts', 'tsx', 'js', 'jsx', 'json', 'node' ],
// https://github.com/react-navigation/react-navigation/issues/7950#issuecomment-615220412
moduleNameMapper: {
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$':
'jest-transform-stub',
'\\.(css|less)$': 'identity-obj-proxy',
},
}
32 changes: 20 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"postinstall": "pod-install ios"
},
"dependencies": {
"@react-native-community/masked-view": "^0.1.10",
"@react-native-community/toolbar-android": "0.1.0-rc.2",
"@react-navigation/drawer": "^5.9.0",
"@react-navigation/material-bottom-tabs": "^5.2.16",
"@react-navigation/native": "^5.7.3",
"@react-navigation/stack": "^5.9.0",
Expand All @@ -30,7 +30,7 @@
"react-native": "0.63.2",
"react-native-gesture-handler": "^1.8.0",
"react-native-reanimated": "^1.13.0",
"react-native-safe-area-context": "^3.1.7",
"react-native-safe-area-context": "^3.1.8",
"react-native-screens": "^2.10.1",
"react-native-vector-icons": "^7.1.0",
"reanimated-bottom-sheet": "^1.0.0-alpha.22"
Expand All @@ -55,8 +55,10 @@
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.2",
"eslint-plugin-react-native": "^3.9.1",
"eslint-plugin-simple-import-sort": "^5.0.3",
"husky": "^4.3.0",
"jest": "^26.4.2",
"jest-transform-stub": "^2.0.0",
"jetifier": "^1.6.6",
"metro-react-native-babel-preset": "^0.63.0",
"npm-run-all": "^4.1.5",
Expand Down
13 changes: 6 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import React from 'react'
import { NavigationContainer } from '@react-navigation/native'
import { createDrawerNavigator } from '@react-navigation/drawer'
import { createStackNavigator } from '@react-navigation/stack'

import HomeScreen from './screens/HomeScreen'
import SearchScreen from './screens/SearchScreen'

import Screens from './lib/screens'

const Drawer = createDrawerNavigator()
const Stack = createStackNavigator()

const App = () => (
<NavigationContainer>
<Drawer.Navigator>
<Drawer.Screen name={Screens.Home} component={HomeScreen} />
<Drawer.Screen name={Screens.Search} component={SearchScreen} />
</Drawer.Navigator>
<Stack.Navigator headerMode="none">
<Stack.Screen name={Screens.Home} component={HomeScreen} />
<Stack.Screen name={Screens.Search} component={SearchScreen} />
</Stack.Navigator>
</NavigationContainer>
)

Expand Down
34 changes: 34 additions & 0 deletions src/components/BackButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react'
import { Text, StyleSheet, TouchableOpacityProps } from 'react-native'
import { useNavigation } from '@react-navigation/native'
import { TouchableOpacity } from 'react-native-gesture-handler'

import Colours from '../themes/colours'

type BackButtonProps = {
/**
* Value back button should display
saihaj marked this conversation as resolved.
Show resolved Hide resolved
*/
label?: string,
} & Omit<TouchableOpacityProps, 'onPress' | 'children'>

const styles = StyleSheet.create( {
label: {
color: Colours.Blue,
fontSize: 16,
},
} )

const BackButton = ( { label = 'Cancel', ...props }: BackButtonProps ) => {
const navigation = useNavigation()

const goBack = () => navigation.goBack()

return (
<TouchableOpacity onPress={goBack} {...props}>
<Text style={styles.label}>{label}</Text>
</TouchableOpacity>
)
}

export default BackButton
38 changes: 30 additions & 8 deletions src/components/Container.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,46 @@
import React, { ReactNode } from 'react'
import { Platform, Dimensions, StyleSheet, View, ViewProps } from 'react-native'
import {
StyleSheet,
View,
SafeAreaView,
ViewProps,
ColorValue,
} from 'react-native'

const { height: deviceHeight } = Dimensions.get( 'window' )
import Colours from '../themes/colours'

const styles = StyleSheet.create( {
main: {
flex: 1,
height: Platform.OS === 'ios' ? deviceHeight : deviceHeight - 20,
backgroundColor: 'white',
backgroundColor: Colours.White,
},
safeArea: {
flex: 0,
},
} )

type ContainerProps = {
children: ReactNode,
/**
* Color value for Status Bar
*/
statusBarColor?: ColorValue,
} & ViewProps

const Container = ( { children, ...props }: ContainerProps ) => (
<View style={styles.main} {...props}>
{children}
</View>
const Container = ( {
children,
statusBarColor = Colours.White,
style,
...props
}: ContainerProps ) => (
<>
<SafeAreaView
style={[ styles.safeArea, { backgroundColor: statusBarColor } ]}
/>
<View style={[ styles.main, style ]} {...props}>
{children}
</View>
</>
)

export default Container
13 changes: 10 additions & 3 deletions src/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ import React from 'react'
import { View, StyleSheet, TextInput } from 'react-native'
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'

import { OS } from '../lib/consts'
import Colours from '../themes/colours'
import StyleUtil from '../themes/utils'

const styles = StyleSheet.create( {
searchBar: {
padding: 10,
...( OS.android && { paddingLeft: 10 } ),
...( OS.ios && { padding: 10 } ),
flexDirection: 'row',
borderRadius: 10,
backgroundColor: Colours.DarkGray,
},
searchInputBox: {
flex: 1,
Expand All @@ -21,10 +28,10 @@ type SearchBarProps = {

const SearchBar = ( { handleTextChanges }: SearchBarProps ) => (
<View style={styles.searchBar}>
<Icon name="magnify" size={25} />
<Icon name="magnify" size={25} style={StyleUtil.mx} />
saihaj marked this conversation as resolved.
Show resolved Hide resolved
<TextInput
placeholder="Koj"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bhajneet do we want to bake in internationalisation from the start? This would be an example of where to start.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related #39

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes absolutely, how can I help?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think search screen cannot be a candidate yet since we will only support Punjabi search. Having that screen internationalized won’t make much sense unless we figure out how to convert search into languages we support with internationalization.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The placeholder can be "Search" or "Khoj" or whatever language is chosen.

style={styles.searchInputBox}
style={[ styles.searchInputBox, StyleUtil.mx ]}
saihaj marked this conversation as resolved.
Show resolved Hide resolved
clearButtonMode="always"
autoCorrect={false}
autoCapitalize="none"
Expand Down
4 changes: 3 additions & 1 deletion src/components/ShortcutDrawer/Icons.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react'
import { StyleSheet } from 'react-native'
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'

import Colours from '../../themes/colours'

import { IconProps, IconsType } from './Icons.types'

const styles = StyleSheet.create( {
Expand All @@ -13,7 +15,7 @@ const styles = StyleSheet.create( {

const iconProps = {
size: 30,
color: 'rgb(47, 124, 246)',
color: Colours.Blue,
}

type StyledIconProps = IconProps & { name: string }
Expand Down
7 changes: 4 additions & 3 deletions src/components/ShortcutDrawer/Icons.ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import React from 'react'
import { StyleSheet } from 'react-native'
import { createIconSetFromFontello } from 'react-native-vector-icons'

import { IconProps, IconsType } from './Icons.types'

import fontelloConfig from '../../../assets/fonts/fontello-icons.json'
import Colours from '../../themes/colours'

import { IconProps, IconsType } from './Icons.types'

const Icon = createIconSetFromFontello( fontelloConfig )

Expand All @@ -17,7 +18,7 @@ const styles = StyleSheet.create( {

const iconProps = {
size: 20,
color: 'rgb(47, 124, 246)',
color: Colours.Blue,
}

type StyledIconProps = IconProps & { name: string }
Expand Down
Loading