-
Notifications
You must be signed in to change notification settings - Fork 455
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
238 additions
and
103 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { | ||
View, | ||
Button, | ||
Icon, | ||
} from '../../index'; | ||
|
||
const createBackButton = navBarProps => sceneProps => ( | ||
<View virtual styleName="container"> | ||
<Button onPress={sceneProps.onNavigateBack}> | ||
<Icon name="back" animationName={navBarProps.animationName} /> | ||
</Button> | ||
</View> | ||
); | ||
|
||
const SceneComposer = { | ||
canCompose(navBarProps) { | ||
return !(navBarProps.scene.index === 0 || !navBarProps.onNavigateBack); | ||
}, | ||
compose(navBarProps) { | ||
return { | ||
renderLeftComponent: createBackButton(navBarProps), | ||
}; | ||
}, | ||
}; | ||
|
||
export default SceneComposer; |
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,13 @@ | ||
import NavBarComposer from './navbar-image.composer'; | ||
import TitleComposer from './title.composer'; | ||
import ShareComposer from './share.composer'; | ||
import BackButtonComposer from './back-button.composer'; | ||
|
||
const ChildrenComposers = [ | ||
NavBarComposer, | ||
TitleComposer, | ||
ShareComposer, | ||
BackButtonComposer, | ||
]; | ||
|
||
export default ChildrenComposers; |
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,51 @@ | ||
import React from 'react'; | ||
import _ from 'lodash'; | ||
import { NavigationBar } from '../NavigationBar'; | ||
import { Image } from '../../index'; | ||
|
||
const imageFitContainer = navBarProps => (NavigationBar.fitContainer || navBarProps.fitContainer); | ||
|
||
const interpolateNavBarStyle = navBarProps => ( | ||
_.get(navBarProps, 'style.navigationBarImage') || {} | ||
); | ||
|
||
const interpolateNavBarProps = (navBarProps) => { | ||
const { animationName } = navBarProps; | ||
const newProps = { | ||
resizeMode: imageFitContainer(navBarProps) ? 'cover' : 'contain', | ||
resizeMethod: imageFitContainer(navBarProps) ? 'scale' : 'auto', | ||
}; | ||
|
||
if (animationName) { | ||
_.assign(newProps, { | ||
animationName, | ||
}); | ||
} | ||
return newProps; | ||
}; | ||
|
||
const createNavBarBackgroundImage = navBarProps => () => { | ||
const navigationBarImage = | ||
(NavigationBar.globalNavigationBarImage || navBarProps.navigationBarImage); | ||
|
||
return ( | ||
<Image | ||
source={{ uri: navigationBarImage }} | ||
style={interpolateNavBarStyle(navBarProps)} | ||
{...interpolateNavBarProps(navBarProps)} | ||
/> | ||
); | ||
}; | ||
|
||
const NavBarComposer = { | ||
canCompose(navBarProps) { | ||
return !!(NavigationBar.globalNavigationBarImage || navBarProps.navigationBarImage); | ||
}, | ||
compose(navBarProps) { | ||
return { | ||
renderBackground: createNavBarBackgroundImage(navBarProps), | ||
}; | ||
}, | ||
}; | ||
|
||
export default NavBarComposer; |
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,33 @@ | ||
import React from 'react'; | ||
import _ from 'lodash'; | ||
import { | ||
View, | ||
ShareButton, | ||
} from '../../index'; | ||
|
||
const createShareButton = navBarProps => () => { | ||
const { title, text, link } = navBarProps.share; | ||
return ( | ||
<View virtual styleName="container"> | ||
<ShareButton | ||
animationName={navBarProps.animationName} | ||
title={title || navBarProps.title} | ||
message={text} | ||
url={link} | ||
/> | ||
</View> | ||
); | ||
}; | ||
|
||
const ShareComposer = { | ||
canCompose(navBarProps) { | ||
return _.get(navBarProps, 'share.link'); | ||
}, | ||
compose(navBarProps) { | ||
return { | ||
renderRightComponent: createShareButton(navBarProps), | ||
}; | ||
}, | ||
}; | ||
|
||
export default ShareComposer; |
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,49 @@ | ||
import React from 'react'; | ||
import _ from 'lodash'; | ||
import { | ||
View, | ||
Title, | ||
} from '../../index'; | ||
import { NavigationBar } from '../NavigationBar'; | ||
|
||
function hasBackgroundImage(navBarProps) { | ||
return (NavigationBar.globalNavigationBarImage || navBarProps.navigationBarImage); | ||
} | ||
|
||
/** | ||
* Check if title should be displayed or now | ||
* @param {bool} showTitle | ||
*/ | ||
function canShowTitle(navBarProps) { | ||
if (!hasBackgroundImage(navBarProps)) { | ||
return true; | ||
} else if (NavigationBar.showTitle === false) { | ||
return false; | ||
} | ||
return NavigationBar.showTitle; | ||
} | ||
|
||
const createTitle = navBarProps => () => { | ||
const value = navBarProps.title; | ||
return ( | ||
<View virtual styleName="container"> | ||
<Title animationName={navBarProps.animationName} numberOfLines={1}> | ||
{value || ''} | ||
</Title> | ||
</View> | ||
); | ||
}; | ||
|
||
const TitleComposer = { | ||
canCompose(navBarProps) { | ||
const value = navBarProps.title; | ||
return (!!value && canShowTitle(navBarProps)); | ||
}, | ||
compose(navBarProps) { | ||
return { | ||
renderTitleComponent: createTitle(navBarProps), | ||
}; | ||
}, | ||
}; | ||
|
||
export default TitleComposer; |
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.