Skip to content

Instantly share code, notes, and snippets.

@t1amat9409
Last active March 24, 2020 09:22
Show Gist options
  • Save t1amat9409/80813882d4859df8e6f42e7618c88bb6 to your computer and use it in GitHub Desktop.
Save t1amat9409/80813882d4859df8e6f42e7618c88bb6 to your computer and use it in GitHub Desktop.
import { Tabs, TabStrip, TabStripItem, TabContentItem } from '@nativescript/core/ui/tabs'; //Import
class AppContainer extends React.Component<Props, State> {
private readonly pageRef: React.RefObject<Page> = React.createRef<Page>();
private readonly tabs = new Tabs();
componentDidMount() {
const frame: Frame = this.mainFrame.current!;
frame.navigate({
create: () => {
const page: Page = this.pageRef.current!;
const {tabs} = this;
const tabStrip = new TabStrip();
//TabStipItems
const tabStripItem1 = new TabStripItem();
tabStripItem1.title = "Timeline";
const tabStripItem2 = new TabStripItem();
tabStripItem2.title = "Videos";
const tabStripItem3 = new TabStripItem();
tabStripItem3.title = "Photos";
tabStrip.items = [tabStripItem1, tabStripItem2, tabStripItem3];
//Tab Contents
const tabContentItem1 = new TabContentItem();
const tabContentItem1Content = new StackLayout();
tabContentItem1.content = tabContentItem2Content;
const tabContentItem2 = new TabContentItem();
const tabContentItem2Content = new StackLayout();
tabContentItem2.content = tabContentItem2Content;
const tabContentItem3 = new TabContentItem();
const tabContentItem3Content = new StackLayout();
tabContentItem3.content = tabContentItem2Content;
tabs.items = [
tabContentItem1,
tabContentItem2,
tabContentItem3
];
tabs.tabStrip = tabStrip;
tabs.id = 'tabs';
page.content = tabs;
tabs.selectedIndex = 0;
return page;
}
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment