Files
Folo/apps/mobile/native/ios/Modules/TabBar/TabBarModule.swift
T
Innei a350950672 feat(tabbar): add onTabItemPress event and enhance TabBar functionality
- Introduced onTabItemPress event in TabBarRootView to handle tab item presses.
- Updated TabBarModule to include the new event in the definition.
- Modified TabBarRootWrapper to accept onTabItemPress and selectedIndex props.
- Enhanced TabRoot to utilize the onTabItemPress callback for scroll-to-top functionality.

This update improves user interaction with the tab bar by allowing for additional actions on tab item presses.

Signed-off-by: Innei <tukon479@gmail.com>
2025-09-22 22:26:39 +08:00

38 lines
812 B
Swift

//
// TabBarModule.swift
// FollowNative
//
// Created by Innei on 2025/3/16.
//
import ExpoModulesCore
public class TabBarModule: Module {
public func definition() -> ModuleDefinition {
Name("TabBarRoot")
Function("switchTab") { [weak self] (reactTag: Int, index: Int) in
DispatchQueue.main.async {
guard let bridge = self?.appContext?.reactBridge else {
return
}
if let sourceView = bridge.uiManager.view(forReactTag: NSNumber(value: reactTag))
as! TabBarRootView?
{
sourceView.switchToTab(index: index)
}
}
}
View(TabBarRootView.self) {
Prop("selectedIndex") { (view, index: Int) in
view.switchToTab(index: index)
}
Events("onTabIndexChange", "onTabItemPress")
}
}
}