Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,13 @@ class Carousel extends Component<CarouselProps, CarouselState> {
}

renderCounter() {
const {pageWidth, showCounter, counterTextStyle} = this.props;
const {pageWidth, showCounter, counterContainerStyle, counterTextStyle} = this.props;
const {currentStandingPage} = this.state;
const pagesCount = presenter.getChildrenLength(this.props);

if (showCounter && !pageWidth) {
return (
<View center style={styles.counter}>
<View center style={[styles.counter, counterContainerStyle]}>
<Text grey80 text90 style={[{fontWeight: 'bold'}, counterTextStyle]}>
{currentStandingPage + 1}/{pagesCount}
</Text>
Expand Down
4 changes: 4 additions & 0 deletions src/components/carousel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export interface CarouselProps extends ScrollViewProps {
* whether to show a page counter (will not work with 'pageWidth' prop)
*/
showCounter?: boolean;
/**
* the counter's container style
*/
counterContainerStyle?: StyleProp<ViewStyle>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alwaysintune @adids1221
Generally, we should avoid adding styles for each view in the hierarchy.
Let's try to find a solution that solves the issue without an additional prop.
Please open a ticket if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the only solution to add margin to the right

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To elaborate more - currently counter has an absolute position. Absolute position forces item design to conform, fill the full width, whilst carousel is written with use cases in mind, so a lot of props can't be used together (i. e. loop and item spacings).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixing with banners leads to cases where it would be best to have a different position for counter because it conflicts with dismiss x action

/**
* the counter's text style
*/
Expand Down