diff --git a/Example/example/exampleMain.js b/Example/example/exampleMain.js
index 9efde10..97e3683 100644
--- a/Example/example/exampleMain.js
+++ b/Example/example/exampleMain.js
@@ -1,55 +1,82 @@
import React, { Component } from 'react';
import {
- StyleSheet,
- Text,
- View
+ StyleSheet,
+ Text,
+ View
} from 'react-native';
import SegmentedControlTab from 'react-native-segmented-control-tab'
class ExampleMain extends Component {
- constructor(props) {
+ constructor(props) {
super(props)
- this.handleSegmentChange = this.handleSegmentChange.bind(this)
this.state = {
- secondTab: false
+ selectedIndex: 0,
+ selectedIndices: [0],
+ customStyleIndex: 0,
}
}
- handleSegmentChange(index) {
+
+ handleSingleIndexSelect = (index) => {
this.setState({
- secondTab: index == 1
- })
- console.log(index)
+ ...this.state,
+ selectedIndex: index,
+ });
}
- render() {
- return (
-
-
- Default segmented control
-
+
+ handleMultipleIndexSelect = (index) => {
+ if (this.state.selectedIndices.includes(index)) {
+ this.setState({
+ ...this.state,
+ selectedIndices: this.state.selectedIndices.filter((i) => i !== index),
+ });
+ }
+ else {
+ this.setState({
+ ...this.state,
+ selectedIndices: [
+ ...this.state.selectedIndices,
+ index,
+ ],
+ });
+ }
+ }
+
+ handleCustomIndexSelect = (index) => {
+ this.setState({
+ ...this.state,
+ customStyleIndex: index,
+ });
+ }
+
+ render() {
+ return (
+
+ Default segmented control with single selection
+
- Default segmented control with Multile tab selection
-
+ Default segmented control with multiple selection
+
-
- Custom segmented control with custom styles
- this.handleSegmentChange(index) }
- borderRadius={0}
- tabsContainerStyle={{height: 50, backgroundColor: '#F2F2F2'}}
- tabStyle={{backgroundColor: '#F2F2F2', borderWidth: 0}}
- activeTabStyle={{backgroundColor: 'white', marginTop: 2}}
- tabTextStyle={{color: '#444444', fontWeight: 'bold'}}
- activeTabTextStyle={{color: '#888888'}}/>
- {!this.state.secondTab &&
- First tab!!
- }
- {this.state.secondTab &&
- Second tab!!
- }
-
- );
- }
+ Custom segmented control with custom styles
+
+
+ );
+ }
}
const styles = StyleSheet.create({
@@ -79,6 +106,8 @@ const styles = StyleSheet.create({
borderTopColor: '#888888',
marginTop: 24
}
-});
+})
+
+
export default ExampleMain
diff --git a/SegmentedControlTab.js b/SegmentedControlTab.js
index 5531222..ee2a660 100644
--- a/SegmentedControlTab.js
+++ b/SegmentedControlTab.js
@@ -35,8 +35,7 @@ const TabOption = ({
+ isTabActive ? [styles.activeTabTextStyle, activeTabTextStyle] : {}]}>
{text}