Skip to content

Commit afa371e

Browse files
authored
style changes (#1356)
1 parent 2350559 commit afa371e

File tree

3 files changed

+12
-10
lines changed
  • demo/src/screens/componentScreens/TabControllerScreen
  • generatedTypes/components/tabController
  • src/components/tabController

3 files changed

+12
-10
lines changed

demo/src/screens/componentScreens/TabControllerScreen/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class TabControllerScreen extends Component<{}, State> {
146146
key={key}
147147
// uppercase
148148
// indicatorStyle={{backgroundColor: 'green', height: 3}}
149-
// wideIndicator
149+
// indicatorInsets={0}
150150
// spreadItems={false}
151151
// labelColor={'green'}
152152
// selectedLabelColor={'red'}

generatedTypes/components/tabController/TabBar.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export interface TabControllerBarProps {
2727
*/
2828
indicatorStyle?: StyleProp<ViewStyle>;
2929
/**
30-
* Whether the indicator should be wide (as the item)
30+
* the indicator insets (default: Spacings.s4, set to 0 to make it wide as the item)
3131
*/
32-
wideIndicator?: boolean;
32+
indicatorInsets?: number;
3333
/**
3434
* custom label style
3535
*/

src/components/tabController/TabBar.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ export interface TabControllerBarProps {
6464
*/
6565
indicatorStyle?: StyleProp<ViewStyle>;
6666
/**
67-
* Whether the indicator should be wide (as the item)
67+
* the indicator insets (default: Spacings.s4, set to 0 to make it wide as the item)
6868
*/
69-
wideIndicator?: boolean;
69+
indicatorInsets?: number;
7070
/**
7171
* custom label style
7272
*/
@@ -145,7 +145,7 @@ const TabBar = (props: Props) => {
145145
shadowStyle: propsShadowStyle,
146146
// minTabsForScroll,
147147
indicatorStyle,
148-
wideIndicator,
148+
indicatorInsets = Spacings.s4,
149149
labelStyle,
150150
selectedLabelStyle,
151151
labelColor,
@@ -163,7 +163,6 @@ const TabBar = (props: Props) => {
163163
children: propsChildren
164164
} = props;
165165

166-
const indicatorInset = wideIndicator ? 0 : Spacings.s4;
167166
const context = useContext(TabBarContext);
168167
// @ts-ignore // TODO: typescript
169168
const {itemStates, items: contextItems, currentPage, targetPage, registerTabItems, selectedIndex} = context;
@@ -322,7 +321,7 @@ const TabBar = (props: Props) => {
322321

323322
const selectedIndicator =
324323
itemsWidths && itemsWidths.length > 0 ? (
325-
<Reanimated.View style={[styles.selectedIndicator, {marginHorizontal: indicatorInset}, indicatorStyle, _indicatorTransitionStyle]}/>
324+
<Reanimated.View style={[styles.selectedIndicator, {marginHorizontal: indicatorInsets}, indicatorStyle, _indicatorTransitionStyle]}/>
326325
) : undefined;
327326

328327
const renderCodeBlock = _.memoize(() => {
@@ -336,7 +335,7 @@ const TabBar = (props: Props) => {
336335
nodes.push(set(_indicatorWidth,
337336
interpolate(currentPage, {
338337
inputRange: itemsWidths.map((_v, i) => i),
339-
outputRange: itemsWidths.map(v => v - 2 * indicatorInset)
338+
outputRange: itemsWidths.map(v => v - 2 * indicatorInsets)
340339
})));
341340

342341
nodes.push(Reanimated.onChange(targetPage, Reanimated.call([targetPage], focusIndex as any)));
@@ -354,7 +353,7 @@ const TabBar = (props: Props) => {
354353
}, [shadowStyle, containerWidth, containerStyle]);
355354

356355
const indicatorContainerStyle = useMemo(() => {
357-
return [styles.tabBar, {flex: spreadItems ? 1 : undefined}, !_.isUndefined(height) && {height}, {backgroundColor}];
356+
return [styles.tabBar, spreadItems && styles.spreadItems, !_.isUndefined(height) && {height}, {backgroundColor}];
358357
}, [height, backgroundColor]);
359358

360359
const scrollViewContainerStyle = useMemo(() => {
@@ -431,6 +430,9 @@ const styles = StyleSheet.create({
431430
backgroundColor: Colors.white
432431
}
433432
})
433+
},
434+
spreadItems: {
435+
flex: 1
434436
}
435437
});
436438

0 commit comments

Comments
 (0)