-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1401 from kaloudis/component-header
Components: Header
- Loading branch information
Showing
53 changed files
with
606 additions
and
1,131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react'; | ||
import { Header, Icon } from 'react-native-elements'; | ||
import { themeColor } from '../utils/ThemeUtils'; | ||
|
||
interface HeaderProps { | ||
leftComponent?: 'Back' | 'Close' | JSX.Element; | ||
centerComponent?: JSX.Element; | ||
rightComponent?: JSX.Element; | ||
containerStyle?: any; | ||
placement?: 'left' | 'center' | 'right' | undefined; | ||
navigation?: any; | ||
onBack?: () => void; | ||
} | ||
|
||
function ZeusHeader(props: HeaderProps) { | ||
const BackButton = (onBack?: () => void) => ( | ||
<Icon | ||
name="arrow-back" | ||
onPress={() => { | ||
if (onBack) onBack(); | ||
props.navigation.goBack(); | ||
}} | ||
color={themeColor('text')} | ||
underlayColor="transparent" | ||
/> | ||
); | ||
|
||
const CloseButton = (onBack?: () => void) => ( | ||
<Icon | ||
name="close" | ||
onPress={() => { | ||
if (onBack) onBack(); | ||
props.navigation.goBack(); | ||
}} | ||
color={themeColor('text')} | ||
underlayColor="transparent" | ||
/> | ||
); | ||
|
||
const { | ||
leftComponent, | ||
centerComponent, | ||
rightComponent, | ||
containerStyle, | ||
placement, | ||
onBack | ||
} = props; | ||
return ( | ||
<Header | ||
leftComponent={ | ||
leftComponent === 'Back' | ||
? BackButton(onBack) | ||
: leftComponent === 'Close' | ||
? CloseButton(onBack) | ||
: leftComponent | ||
? leftComponent | ||
: undefined | ||
} | ||
centerComponent={centerComponent ? centerComponent : undefined} | ||
rightComponent={rightComponent ? rightComponent : undefined} | ||
backgroundColor="transparent" | ||
containerStyle={{ | ||
...containerStyle, | ||
borderBottomWidth: 0 | ||
}} | ||
placement={placement} | ||
/> | ||
); | ||
} | ||
|
||
export default ZeusHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.