|
| 1 | +open Core; |
| 2 | + |
| 3 | +type options; |
| 4 | + |
| 5 | +module BottomTabNavigationProp = (M: { |
| 6 | + type params; |
| 7 | + type options; |
| 8 | + }) => { |
| 9 | + include NavigationScreenProp(M); |
| 10 | + |
| 11 | + type t = navigation; |
| 12 | + |
| 13 | + [@bs.send] external jumpTo: (t, string) => unit = "jumpTo"; |
| 14 | + [@bs.send] |
| 15 | + external jumpToWithParams: (t, string, M.params) => unit = "jumpTo"; |
| 16 | +}; |
| 17 | + |
| 18 | +module Make = (M: {type params;}) => { |
| 19 | + module Navigation = |
| 20 | + BottomTabNavigationProp({ |
| 21 | + include M; |
| 22 | + type nonrec options = options; |
| 23 | + }); |
| 24 | + |
| 25 | + type animatedNode = ReactNative.Animated.Value.t; |
| 26 | + |
| 27 | + type scene = { |
| 28 | + . |
| 29 | + "index": int, |
| 30 | + "focused": bool, |
| 31 | + "tintColor": string, |
| 32 | + }; |
| 33 | + |
| 34 | + class type virtual baseBottomTabBarOptions = { |
| 35 | + pub keyboardHidesTabBar: option(bool); |
| 36 | + pub activeBackgroundColor: option(string); |
| 37 | + pub inactiveBackgroundColor: option(string); |
| 38 | + pub allowFontScaling: option(bool); |
| 39 | + pub showLabel: option(bool); |
| 40 | + pub showIcon: option(bool); |
| 41 | + pub labelStyle: option(ReactNative.Style.t); |
| 42 | + pub tabStyle: option(ReactNative.Style.t); |
| 43 | + pub labelPosition: option({. "deviceOrientation": string} => string); |
| 44 | + pub adaptive: option(bool); |
| 45 | + pub style: option(ReactNative.Style.t); |
| 46 | + }; |
| 47 | + |
| 48 | + class type virtual bottomTabBarOptions = { |
| 49 | + as 'self; |
| 50 | + constraint 'self = #baseBottomTabBarOptions; |
| 51 | + pub activeTintColor: option(string); |
| 52 | + pub inactiveTintColor: option(string); |
| 53 | + }; |
| 54 | + |
| 55 | + type accessibilityRole = string; |
| 56 | + type accessibilityStates = array(string); |
| 57 | + class type virtual bottomTabBarProps = { |
| 58 | + as 'self; |
| 59 | + constraint 'self = #baseBottomTabBarOptions; |
| 60 | + pub state: navigationState(M.params); |
| 61 | + pub navigation: navigation; |
| 62 | + pub onTabPress: {. "route": route(M.params)} => unit; |
| 63 | + pub onTabLongPress: {. "route": route(M.params)} => unit; |
| 64 | + pub getAccessibilityLabel: |
| 65 | + {. "route": route(M.params)} => Js.nullable(string); |
| 66 | + pub getAccessibilityRole: |
| 67 | + {. "route": route(M.params)} => Js.nullable(accessibilityRole); |
| 68 | + pub getAccessibilityStates: |
| 69 | + {. "route": route(M.params)} => Js.nullable(accessibilityStates); |
| 70 | + pub getButtonComponent: |
| 71 | + {. "route": route(M.params)} => Js.nullable(React.element); |
| 72 | + //pub getLabelText: {. "route": route(M.params)} => ...; |
| 73 | + pub getTestID: {. "route": route(M.params)} => Js.nullable(string); |
| 74 | + pub renderIcon: |
| 75 | + { |
| 76 | + . |
| 77 | + "route": route(M.params), |
| 78 | + "focused": bool, |
| 79 | + "tintColor": string, |
| 80 | + "horizontal": bool, |
| 81 | + } => |
| 82 | + React.element; |
| 83 | + pub activeTintColor: string; |
| 84 | + pub inactiveTintColor: string; |
| 85 | + }; |
| 86 | + |
| 87 | + [@bs.obj] |
| 88 | + external bottomTabBarOptions: |
| 89 | + ( |
| 90 | + ~keyboardHidesTabBar: bool=?, |
| 91 | + ~activeTintColor: string=?, |
| 92 | + ~inactiveTintColor: string=?, |
| 93 | + ~activeBackgroundColor: string=?, |
| 94 | + ~inactiveBackgroundColor: string=?, |
| 95 | + ~allowFontScaling: bool=?, |
| 96 | + ~showLabel: bool=?, |
| 97 | + ~showIcon: bool=?, |
| 98 | + ~labelStyle: ReactNative.Style.t=?, |
| 99 | + ~tabStyle: ReactNative.Style.t=?, |
| 100 | + ~labelPosition: {. "deviceOrientation": string} => string=?, |
| 101 | + ~adaptive: bool=?, |
| 102 | + ~style: ReactNative.Style.t=? |
| 103 | + ) => |
| 104 | + bottomTabBarOptions = |
| 105 | + ""; |
| 106 | + |
| 107 | + [@bs.obj] |
| 108 | + external options: |
| 109 | + ( |
| 110 | + ~title: string=?, |
| 111 | + //TODO: dynamic, missing static option: React.ReactNode |
| 112 | + ~tabBarLabel: scene => React.element=?, |
| 113 | + //TODO: dynamic, missing static option: React.ReactNode |
| 114 | + ~tabBarIcon: scene => React.element=?, |
| 115 | + ~tabBarAccessibilityLabel: string=?, |
| 116 | + ~tabBarTestID: string=?, |
| 117 | + ~tabBarVisible: bool=?, |
| 118 | + ~tabBarButtonComponent: React.element=?, |
| 119 | + unit |
| 120 | + ) => |
| 121 | + options = |
| 122 | + ""; |
| 123 | + |
| 124 | + type optionsProps = |
| 125 | + { |
| 126 | + . |
| 127 | + "navigation": navigation, |
| 128 | + "route": route(M.params), |
| 129 | + } => |
| 130 | + options; |
| 131 | + |
| 132 | + type navigatorProps; |
| 133 | + |
| 134 | + type screenProps; |
| 135 | + |
| 136 | + [@bs.module "@react-navigation/bottom-tabs"] |
| 137 | + external make: |
| 138 | + unit => |
| 139 | + { |
| 140 | + . |
| 141 | + "Navigator": navigatorProps => React.element, |
| 142 | + "Screen": screenProps => React.element, |
| 143 | + } = |
| 144 | + "createBottomTabNavigator"; |
| 145 | + |
| 146 | + let stack = make(); |
| 147 | + |
| 148 | + module Screen = { |
| 149 | + [@bs.obj] |
| 150 | + external makeProps: |
| 151 | + ( |
| 152 | + ~name: string, |
| 153 | + ~options: optionsProps=?, |
| 154 | + ~initialParams: M.params=?, |
| 155 | + ~component: React.component({. "navigation": navigation}), |
| 156 | + unit |
| 157 | + ) => |
| 158 | + screenProps = |
| 159 | + ""; |
| 160 | + let make = stack##"Screen"; |
| 161 | + }; |
| 162 | + |
| 163 | + module Navigator = { |
| 164 | + [@bs.obj] |
| 165 | + external makeProps: |
| 166 | + ( |
| 167 | + ~initialRouteName: string=?, |
| 168 | + ~screenOptions: optionsProps=?, |
| 169 | + ~children: React.element, |
| 170 | + ~_lazy: bool=?, |
| 171 | + ~tabBarComponent: React.component(Js.t(bottomTabBarProps))=?, |
| 172 | + ~tabBarOptions: bottomTabBarOptions=?, |
| 173 | + unit |
| 174 | + ) => |
| 175 | + navigatorProps = |
| 176 | + ""; |
| 177 | + |
| 178 | + let make = stack##"Navigator"; |
| 179 | + }; |
| 180 | +}; |
0 commit comments