123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589 |
- const React = require('react');
- const Root = require('../components/Root');
- const Button = require('../components/Button')
- const {
- WELCOME_SCREEN_HEADER,
- STACK_BTN,
- BOTTOM_TABS_BTN,
- BOTTOM_TABS,
- SIDE_MENU_BTN
- } = require('../testIDs');
- const Screens = require('./Screens');
- const Navigation = require('../services/Navigation');
- const {stack, component} = require('../commons/Layouts');
-
- class LayoutsScreen extends React.Component {
- static options() {
- return {
- topBar: {
- testID: WELCOME_SCREEN_HEADER,
- title: {
- text: 'React Native Navigation'
- }
- }
- };
- }
-
- render() {
- return (
- <Root componentId={this.props.componentId}>
- <Button label='Stack' testID={STACK_BTN} onPress={this.stack} />
- <Button label='BottomTabs' testID={BOTTOM_TABS_BTN} onPress={this.bottomTabs} />
- <Button label='SideMenu' testID={SIDE_MENU_BTN} onPress={this.sideMenu} />
- </Root>
- );
- }
-
- stack = () => Navigation.showModal(Screens.StackScreen);
-
- bottomTabs = () => Navigation.showModal({
- bottomTabs: {
- children: [
- stack(Screens.FirstBottomTabsScreen),
- stack({
- component: {
- name: Screens.SecondBottomTabsScreen
- }
- }, 'SecondTab'
- )
- ],
- options: {
- bottomTabs: {
- testID: BOTTOM_TABS
- }
- }
- }
- });
-
- sideMenu = () => Navigation.showModal({
- sideMenu: {
- left: {...component(Screens.SideMenuLeft)},
- center: {
- ...stack({
- component: {
- id: 'SideMenuCenter',
- name: Screens.SideMenuCenter
- }
- })
- },
- right: {...component(Screens.SideMenuRight)}
- }
- });
-
- onClickSwitchToTabs = () => {
- Navigation.setRoot({
- root: {
- bottomTabs: {
- id: 'BottomTabs',
- children: [
- {
- stack: {
- id: 'TAB1_ID',
- children: [
- {
- component: {
- name: 'navigation.playground.TextScreen',
- passProps: {
- text: 'This is tab 1',
- myFunction: () => 'Hello from a function!'
- },
- options: {
- topBar: {
- visible: true,
- animate: false,
- title: {
- text: 'React Native Navigation!'
- }
- },
- bottomTab: {
- text: 'Tab 1',
- icon: require('../images/colored_tab_icon.png'),
- testID: testIDs.FIRST_TAB_BAR_BUTTON
- }
- }
- }
- }
- ],
- options: {
- topBar: {
- visible: false
- }
- }
- }
- },
- {
- stack: {
- children: [
- {
- component: {
- name: 'navigation.playground.TextScreen',
- passProps: {
- text: 'This is tab 2'
- }
- }
- }
- ],
- options: {
- bottomTab: {
- text: 'Tab 2',
- icon: require('../images/two.png'),
- iconColor: '#1B4C77',
- selectedIconColor: '#0f0',
- testID: testIDs.SECOND_TAB_BAR_BUTTON
- }
- }
- }
- },
- {
- component: {
- name: 'navigation.playground.TextScreen',
- passProps: {
- text: 'This is tab 3',
- myFunction: () => 'Hello from a function!'
- },
- options: {
- topBar: {
- visible: true,
- animate: false
- },
- bottomTab: {
- text: 'Tab 3',
- icon: require('../images/one.png'),
- iconColor: '#1B4C77',
- selectedIconColor: '#0f0',
- selectedIcon: require('../images/one.png')
- }
- }
- }
- }
- ],
- options: {
- bottomTabs: {
- titleDisplayMode: 'alwaysShow',
- testID: testIDs.BOTTOM_TABS_ELEMENT
- }
- }
- }
- }
- });
- }
-
- onClickSwitchToSideMenus = () => {
- Navigation.setRoot({
- root: {
- sideMenu: {
- left: {
- component: {
- name: 'navigation.playground.SideMenuScreen',
- passProps: {
- side: 'left'
- }
- }
- },
- center: {
- bottomTabs: {
- children: [
- {
- stack: {
- id: 'tab1Stack',
- children: [
- {
- component: {
- name: 'navigation.playground.TextScreen',
- passProps: {
- text: 'This is a side menu center screen tab 1'
- }
- }
- }
- ],
- options: {
- bottomTab: {
- iconColor: 'red',
- textColor: 'red',
- selectedIconColor: 'purple',
- selectedTextColor: 'purple',
- text: 'Tab 1',
- icon: require('../images/one.png'),
- testID: testIDs.FIRST_TAB_BAR_BUTTON
- }
- }
- }
- },
- {
- stack: {
- children: [
- {
- component: {
- name: 'navigation.playground.TextScreen',
- passProps: {
- text: 'This is a side menu center screen tab 2'
- }
- }
- }
- ],
- options: {
- bottomTab: {
- text: 'Tab 2',
- icon: require('../images/two.png'),
- testID: testIDs.SECOND_TAB_BAR_BUTTON
- }
- }
- }
- },
- {
- stack: {
- children: [
- {
- component: {
- name: 'navigation.playground.TextScreen',
- passProps: {
- text: 'This is a side menu center screen tab 3'
- }
- }
- }
- ],
- options: {
- bottomTab: {
- text: 'Tab 3',
- icon: require('../images/three.png'),
- testID: testIDs.SECOND_TAB_BAR_BUTTON
- }
- }
- }
- }
- ],
- options: {
- bottomTab: {
- textColor: '#AED581',
- iconColor: '#AED581',
- selectedTextColor: '#90CAF9',
- selectedIconColor: '#90CAF9',
- fontFamily: 'HelveticaNeue-Italic',
- fontSize: 13
- }
- }
- }
- },
- right: {
- component: {
- name: 'navigation.playground.SideMenuScreen',
- passProps: {
- side: 'right'
- }
- }
- }
- }
- }
- });
- }
-
- onClickPush = async () => {
- await Navigation.push(this.props.componentId, {
- component: {
- name: 'navigation.playground.PushedScreen',
- options: {
- layout: {
-
- },
- topBar: {
- title: {
- text: 'pushed',
- color: '#0000ff',
- fontSize: 14
- },
- subtitle: {
- text: 'subtitle',
- fontSize: 10,
- color: '#00ff00'
- }
- }
- }
- }
- });
- }
-
- onClickPushContextScreen = async () => {
- await Navigation.push(this.props.componentId, {
- component: {
- name: 'navigation.playground.ContextScreen',
- }
- })
- }
-
- onClickPushExternalComponent = async () => {
- await Navigation.push(this.props.componentId, {
- externalComponent: {
- name: 'RNNCustomComponent',
- passProps: {
- text: 'This is an external component'
- },
- options: {
- topBar: {
- title: {
- text: 'pushed'
- },
- visible: true,
- testID: testIDs.TOP_BAR_ELEMENT
- }
- }
- }
- });
- }
-
- onClickLifecycleScreen = () => {
- Navigation.push(this.props.componentId, {
- component: {
- name: 'navigation.playground.LifecycleScreen'
- }
- });
- }
-
- onClickShowStaticLifecycleOverlay = () => {
- Navigation.showOverlay({
- component: {
- name: 'navigation.playground.StaticLifecycleOverlay',
- options: {
- overlay: {
- interceptTouchOutside: false
- }
- }
- }
- });
- }
-
- onClickShowModal = async () => {
- await Navigation.showModal({
- stack: {
- children: [
- {
- component: {
- name: 'navigation.playground.ModalScreen'
- }
- }
- ]
- }
- });
- }
-
- onClickShowRedbox = () => {
- undefined();
- }
-
- onClickShowPreview = async ({reactTag}) => {
- await Navigation.push(this.props.componentId, {
- component: {
- name: 'navigation.playground.PushedScreen',
- options: {
- animations: {
- push: {
- enabled: false
- }
- },
- preview: reactTag ? {
- reactTag,
- height: 300,
- commit: true,
- actions: [{
- id: 'action-cancel',
- title: 'Cancel'
- }, {
- id: 'action-delete',
- title: 'Delete',
- actions: [{
- id: 'action-delete-sure',
- title: 'Are you sure?',
- style: 'destructive'
- }]
- }]
- } : undefined,
- }
- }
- });
- }
-
- onClickPushOptionsScreen = () => {
- Navigation.push(this.props.componentId, {
- component: {
- name: 'navigation.playground.OptionsScreen',
- options: {
- animations: {
- push: {
- enabled: false
- }
- }
- }
- }
- });
- }
-
- onClickPushTopTabsScreen = () => {
- Navigation.push(this.props.componentId, {
- topTabs: {
- children: [
- {
- component: {
- name: 'navigation.playground.TopTabOptionsScreen',
- passProps: {
- title: 'Tab 1',
- text: 'This is top tab 1'
- },
- options: {
- topTab: {
- title: 'Tab 1'
- },
- topBar: {
- title: {
- text: 'One'
- }
- }
- }
- }
- },
- {
- component: {
- name: 'navigation.playground.TopTabScreen',
- passProps: {
- title: 'Tab 2',
- text: 'This is top tab 2'
- },
- options: {
- topTab: {
- title: 'Tab 2',
- titleFontFamily: 'HelveticaNeue-Italic'
- },
- topBar: {
- title: {
- text: 'Two'
- }
- }
- }
- }
- },
- {
- component: {
- name: 'navigation.playground.TopTabScreen',
- passProps: {
- title: 'Tab 3',
- text: 'This is top tab 3'
- },
- options: {
- topTab: {
- title: 'Tab 3'
- },
- topBar: {
- title: {
- text: 'Three'
- }
- }
- }
- }
- }
- ],
- options: {
- topTabs: {
- selectedTabColor: '#12766b',
- unselectedTabColor: 'red',
- fontSize: 6
- }
- }
- }
- });
- }
-
- onClickBackHandler = () => {
- Navigation.push(this.props.componentId, {
- component: {
- name: 'navigation.playground.BackHandlerScreen'
- }
- });
- }
-
- onClickPushOrientationMenuScreen = () => {
- Navigation.push(this.props.componentId, {
- component: {
- name: 'navigation.playground.OrientationSelectScreen'
- }
- });
- }
-
- onClickProvidedId = () => {
- Navigation.showModal({
- stack: {
- children: [
- {
- component: {
- name: 'navigation.playground.TextScreen',
- id: 'my unique id'
- }
- }
- ]
- }
- });
- Navigation.mergeOptions('my unique id', {
- topBar: {
- title: {
- text: 'User provided id'
- }
- }
- });
- }
-
- onClickComplexLayout = () => {
- Navigation.showModal({
- component: {
- name: 'navigation.playground.ComplexLayout'
- }
- });
- }
-
- onClickSplitView = () => {
- Navigation.setRoot({
- root: {
- splitView: {
- id: 'SPLITVIEW_ID',
- master: {
- stack: {
- id: 'MASTER_ID',
- children: [
- {
- component: {
- name: 'navigation.playground.WelcomeScreen'
- },
- },
- ]
- },
- },
- detail: {
- stack: {
- id: 'DETAILS_ID',
- children: [
- {
- component: {
- name: 'navigation.playground.WelcomeScreen'
- },
- },
- ]
- }
- },
- options: {
- displayMode: 'auto',
- primaryEdge: 'leading',
- minWidth: 150,
- maxWidth: 300,
- },
- },
- },
- });
- }
-
- onClickSearchBar = () => {
- Navigation.push(this.props.componentId, {
- component: {
- name: 'navigation.playground.SearchControllerScreen'
- }
- });
- };
- }
-
- module.exports = LayoutsScreen;
|