Skip to content

Commit b53ce4a

Browse files
committed
fix(ios): emit onPageScroll for setPageWithoutAnimation to sync consumers
1 parent 0c4413a commit b53ce4a

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

example/src/MaterialTopTabExample.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ const PreAuthScreen = (props: any) => {
2828
);
2929
};
3030

31+
function Tab3() {
32+
return (
33+
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
34+
<Text>Tab 3</Text>
35+
</View>
36+
);
37+
}
38+
39+
function Tab4() {
40+
return (
41+
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
42+
<Text>Tab 4</Text>
43+
</View>
44+
);
45+
}
46+
3147
const PostAuthScreen = (props: any) => {
3248
const { Navigator, Screen } = createMaterialTopTabNavigator();
3349
const onLogout = () => {
@@ -43,6 +59,8 @@ const PostAuthScreen = (props: any) => {
4359
<Screen name="Tab2">
4460
{(props: any) => <Tab2 {...props} onLogout={onLogout} />}
4561
</Screen>
62+
<Screen name="Tab3" component={Tab3} />
63+
<Screen name="Tab4" component={Tab4} />
4664
</Navigator>
4765
</View>
4866
);

ios/PagerViewProvider.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ import UIKit
9898
}
9999
} else {
100100
props.currentPage = index
101+
// For non-animated navigation, no scroll events fire, so emit the
102+
// final onPageScroll explicitly to keep consumers in sync.
103+
delegate?.onPageScroll(data: OnPageScrollEventData(position: Double(index), offset: 0))
101104
}
102105
}
103106

0 commit comments

Comments
 (0)