react-native-platform-components 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PlatformComponents.podspec +1 -1
- package/README.md +33 -31
- package/android/src/main/java/com/platformcomponents/PCButtonGroupView.kt +175 -9
- package/android/src/main/java/com/platformcomponents/PCButtonGroupViewManager.kt +52 -2
- package/android/src/main/java/com/platformcomponents/PCButtonSupport.kt +44 -12
- package/android/src/main/java/com/platformcomponents/PCButtonView.kt +187 -5
- package/android/src/main/java/com/platformcomponents/PCButtonViewManager.kt +85 -7
- package/android/src/main/java/com/platformcomponents/PCContextMenuView.kt +41 -151
- package/android/src/main/java/com/platformcomponents/PCContextMenuViewManager.kt +7 -63
- package/android/src/main/java/com/platformcomponents/PCDatePickerView.kt +310 -115
- package/android/src/main/java/com/platformcomponents/PCDatePickerViewManager.kt +23 -3
- package/android/src/main/java/com/platformcomponents/PCExpressive.kt +6 -1
- package/android/src/main/java/com/platformcomponents/PCFloatingActionButtonView.kt +485 -0
- package/android/src/main/java/com/platformcomponents/PCFloatingActionButtonViewManager.kt +109 -0
- package/android/src/main/java/com/platformcomponents/PCFloatingToolbarView.kt +132 -0
- package/android/src/main/java/com/platformcomponents/PCFloatingToolbarViewManager.kt +8 -0
- package/android/src/main/java/com/platformcomponents/PCHaptics.kt +46 -0
- package/android/src/main/java/com/platformcomponents/PCImageLoader.kt +42 -7
- package/android/src/main/java/com/platformcomponents/PCLiquidGlassContainerView.kt +32 -0
- package/android/src/main/java/com/platformcomponents/PCLiquidGlassContainerViewManager.kt +31 -0
- package/android/src/main/java/com/platformcomponents/PCLiquidGlassView.kt +32 -6
- package/android/src/main/java/com/platformcomponents/PCLiquidGlassViewManager.kt +4 -0
- package/android/src/main/java/com/platformcomponents/PCMenuSupport.kt +280 -0
- package/android/src/main/java/com/platformcomponents/PCNavigationBarSupport.kt +332 -0
- package/android/src/main/java/com/platformcomponents/PCNavigationRailView.kt +448 -0
- package/android/src/main/java/com/platformcomponents/PCNavigationRailViewManager.kt +176 -0
- package/android/src/main/java/com/platformcomponents/PCSegmentedControlView.kt +24 -14
- package/android/src/main/java/com/platformcomponents/PCSegmentedControlViewManager.kt +14 -2
- package/android/src/main/java/com/platformcomponents/PCSelectionMenuView.kt +371 -39
- package/android/src/main/java/com/platformcomponents/PCSelectionMenuViewManager.kt +18 -4
- package/android/src/main/java/com/platformcomponents/PCTabBarView.kt +397 -0
- package/android/src/main/java/com/platformcomponents/PCTabBarViewManager.kt +182 -0
- package/android/src/main/java/com/platformcomponents/PCTextFieldView.kt +415 -40
- package/android/src/main/java/com/platformcomponents/PCTextFieldViewManager.kt +109 -3
- package/android/src/main/java/com/platformcomponents/PCThemeSupport.kt +37 -0
- package/android/src/main/java/com/platformcomponents/PlatformComponentsPackage.kt +4 -0
- package/android/src/main/res/drawable/pc_ic_search.xml +12 -0
- package/android/src/main/res/values/ids.xml +5 -0
- package/android/src/main/res/values/styles.xml +24 -0
- package/ios/PCButton.mm +122 -7
- package/ios/PCButtonGroup.mm +68 -1
- package/ios/PCButtonGroupView.swift +225 -6
- package/ios/PCButtonSupport.swift +181 -10
- package/ios/PCButtonView.swift +297 -14
- package/ios/PCConstants.swift +23 -2
- package/ios/PCContextMenu.mm +28 -110
- package/ios/PCContextMenu.swift +106 -167
- package/ios/PCDatePicker.mm +21 -9
- package/ios/PCDatePickerView.swift +94 -20
- package/ios/PCFloatingActionButton.h +10 -0
- package/ios/PCFloatingActionButton.mm +177 -0
- package/ios/PCFloatingActionButtonView.swift +426 -0
- package/ios/PCFloatingToolbar.mm +27 -0
- package/ios/PCFloatingToolbarView.swift +241 -0
- package/ios/PCHaptics.swift +91 -0
- package/ios/PCImageLoader.swift +76 -12
- package/ios/PCLiquidGlass.mm +36 -0
- package/ios/PCLiquidGlass.swift +221 -114
- package/ios/PCLiquidGlassContainer.h +10 -0
- package/ios/PCLiquidGlassContainer.mm +84 -0
- package/ios/PCLiquidGlassContainer.swift +69 -0
- package/ios/PCMenuItems.h +76 -0
- package/ios/PCMenuSupport.swift +350 -0
- package/ios/PCNavigationRail.h +10 -0
- package/ios/PCNavigationRail.mm +270 -0
- package/ios/PCNavigationRailView.swift +415 -0
- package/ios/PCSegmentedControl.mm +17 -2
- package/ios/PCSegmentedControl.swift +57 -7
- package/ios/PCSelectionMenu.mm +36 -8
- package/ios/PCSelectionMenu.swift +224 -48
- package/ios/PCTabBar.h +10 -0
- package/ios/PCTabBar.mm +285 -0
- package/ios/PCTabBarAccessory.h +10 -0
- package/ios/PCTabBarAccessory.mm +93 -0
- package/ios/PCTabBarAccessoryView.swift +96 -0
- package/ios/PCTabBarView.swift +671 -0
- package/ios/PCTextField.mm +159 -4
- package/ios/PCTextFieldView.swift +603 -57
- package/lib/commonjs/Button.js +73 -1
- package/lib/commonjs/Button.js.map +1 -1
- package/lib/commonjs/ButtonGroup.js +13 -3
- package/lib/commonjs/ButtonGroup.js.map +1 -1
- package/lib/commonjs/ButtonGroupNativeComponent.ts +74 -4
- package/lib/commonjs/ButtonNativeComponent.ts +119 -3
- package/lib/commonjs/ContextMenu.js +9 -48
- package/lib/commonjs/ContextMenu.js.map +1 -1
- package/lib/commonjs/ContextMenuNativeComponent.ts +47 -49
- package/lib/commonjs/DatePicker.js +98 -2
- package/lib/commonjs/DatePicker.js.map +1 -1
- package/lib/commonjs/DatePickerNativeComponent.ts +19 -2
- package/lib/commonjs/FloatingActionButton.js +60 -0
- package/lib/commonjs/FloatingActionButton.js.map +1 -0
- package/lib/commonjs/FloatingActionButtonNativeComponent.ts +58 -0
- package/lib/commonjs/FloatingToolbar.js +9 -1
- package/lib/commonjs/FloatingToolbar.js.map +1 -1
- package/lib/commonjs/FloatingToolbarNativeComponent.ts +16 -0
- package/lib/commonjs/LiquidGlass.js +7 -1
- package/lib/commonjs/LiquidGlass.js.map +1 -1
- package/lib/commonjs/LiquidGlassContainer.js +32 -0
- package/lib/commonjs/LiquidGlassContainer.js.map +1 -0
- package/lib/commonjs/LiquidGlassContainerNativeComponent.ts +17 -0
- package/lib/commonjs/LiquidGlassNativeComponent.ts +8 -0
- package/lib/commonjs/NavigationRail.js +104 -0
- package/lib/commonjs/NavigationRail.js.map +1 -0
- package/lib/commonjs/NavigationRailNativeComponent.ts +107 -0
- package/lib/commonjs/PlatformComponentsProvider.js +18 -0
- package/lib/commonjs/PlatformComponentsProvider.js.map +1 -0
- package/lib/commonjs/SegmentedControl.js +7 -0
- package/lib/commonjs/SegmentedControl.js.map +1 -1
- package/lib/commonjs/SegmentedControlNativeComponent.ts +11 -0
- package/lib/commonjs/SelectionMenu.js +27 -3
- package/lib/commonjs/SelectionMenu.js.map +1 -1
- package/lib/commonjs/SelectionMenuNativeComponent.ts +26 -4
- package/lib/commonjs/SplitButton.js +98 -0
- package/lib/commonjs/SplitButton.js.map +1 -0
- package/lib/commonjs/TabBar.js +203 -0
- package/lib/commonjs/TabBar.js.map +1 -0
- package/lib/commonjs/TabBarAccessoryNativeComponent.ts +19 -0
- package/lib/commonjs/TabBarNativeComponent.ts +145 -0
- package/lib/commonjs/TextField.js +171 -8
- package/lib/commonjs/TextField.js.map +1 -1
- package/lib/commonjs/TextFieldNativeComponent.ts +110 -4
- package/lib/commonjs/focusRegistry.js +2 -1
- package/lib/commonjs/focusRegistry.js.map +1 -1
- package/lib/commonjs/haptics.js +2 -0
- package/lib/commonjs/haptics.js.map +1 -0
- package/lib/commonjs/icons.js +15 -1
- package/lib/commonjs/icons.js.map +1 -1
- package/lib/commonjs/index.js +77 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +156 -92
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/jest.js +910 -0
- package/lib/commonjs/jest.js.map +1 -0
- package/lib/commonjs/menuItems.js +68 -0
- package/lib/commonjs/menuItems.js.map +1 -0
- package/lib/commonjs/selectionIdentifiers.js +18 -0
- package/lib/commonjs/selectionIdentifiers.js.map +1 -0
- package/lib/commonjs/submitBehavior.js +19 -0
- package/lib/commonjs/submitBehavior.js.map +1 -0
- package/lib/commonjs/tabItems.js +49 -0
- package/lib/commonjs/tabItems.js.map +1 -0
- package/lib/commonjs/web/Button.js +170 -0
- package/lib/commonjs/web/Button.js.map +1 -0
- package/lib/commonjs/web/ButtonGroup.js +119 -0
- package/lib/commonjs/web/ButtonGroup.js.map +1 -0
- package/lib/commonjs/web/DatePicker.js +168 -0
- package/lib/commonjs/web/DatePicker.js.map +1 -0
- package/lib/commonjs/web/DateRangePicker.js +137 -0
- package/lib/commonjs/web/DateRangePicker.js.map +1 -0
- package/lib/commonjs/web/Dialog.js +54 -0
- package/lib/commonjs/web/Dialog.js.map +1 -0
- package/lib/commonjs/web/FloatingActionButton.js +98 -0
- package/lib/commonjs/web/FloatingActionButton.js.map +1 -0
- package/lib/commonjs/web/Icon.js +34 -0
- package/lib/commonjs/web/Icon.js.map +1 -0
- package/lib/commonjs/web/NativeTheme.js +28 -0
- package/lib/commonjs/web/NativeTheme.js.map +1 -0
- package/lib/commonjs/web/NavigationRail.js +139 -0
- package/lib/commonjs/web/NavigationRail.js.map +1 -0
- package/lib/commonjs/web/PlatformComponentsProvider.js +51 -0
- package/lib/commonjs/web/PlatformComponentsProvider.js.map +1 -0
- package/lib/commonjs/web/SegmentedControl.js +117 -0
- package/lib/commonjs/web/SegmentedControl.js.map +1 -0
- package/lib/commonjs/web/SelectionMenu.js +142 -0
- package/lib/commonjs/web/SelectionMenu.js.map +1 -0
- package/lib/commonjs/web/SplitButton.js +35 -0
- package/lib/commonjs/web/SplitButton.js.map +1 -0
- package/lib/commonjs/web/TabBar.js +131 -0
- package/lib/commonjs/web/TabBar.js.map +1 -0
- package/lib/commonjs/web/TextField.js +322 -0
- package/lib/commonjs/web/TextField.js.map +1 -0
- package/lib/commonjs/web/components.js +36 -0
- package/lib/commonjs/web/components.js.map +1 -0
- package/lib/commonjs/web/containers.js +121 -0
- package/lib/commonjs/web/containers.js.map +1 -0
- package/lib/commonjs/web/dateInput.js +116 -0
- package/lib/commonjs/web/dateInput.js.map +1 -0
- package/lib/commonjs/web/shared.js +192 -0
- package/lib/commonjs/web/shared.js.map +1 -0
- package/lib/commonjs/webComponents.js +6 -0
- package/lib/commonjs/webComponents.js.map +1 -0
- package/lib/module/Button.js +74 -2
- package/lib/module/Button.js.map +1 -1
- package/lib/module/ButtonGroup.js +13 -3
- package/lib/module/ButtonGroup.js.map +1 -1
- package/lib/module/ButtonGroupNativeComponent.ts +74 -4
- package/lib/module/ButtonNativeComponent.ts +119 -3
- package/lib/module/ContextMenu.js +9 -48
- package/lib/module/ContextMenu.js.map +1 -1
- package/lib/module/ContextMenuNativeComponent.ts +47 -49
- package/lib/module/DatePicker.js +98 -4
- package/lib/module/DatePicker.js.map +1 -1
- package/lib/module/DatePickerNativeComponent.ts +19 -2
- package/lib/module/FloatingActionButton.js +53 -0
- package/lib/module/FloatingActionButton.js.map +1 -0
- package/lib/module/FloatingActionButtonNativeComponent.ts +58 -0
- package/lib/module/FloatingToolbar.js +9 -1
- package/lib/module/FloatingToolbar.js.map +1 -1
- package/lib/module/FloatingToolbarNativeComponent.ts +16 -0
- package/lib/module/LiquidGlass.js +7 -1
- package/lib/module/LiquidGlass.js.map +1 -1
- package/lib/module/LiquidGlassContainer.js +26 -0
- package/lib/module/LiquidGlassContainer.js.map +1 -0
- package/lib/module/LiquidGlassContainerNativeComponent.ts +17 -0
- package/lib/module/LiquidGlassNativeComponent.ts +8 -0
- package/lib/module/NavigationRail.js +99 -0
- package/lib/module/NavigationRail.js.map +1 -0
- package/lib/module/NavigationRailNativeComponent.ts +107 -0
- package/lib/module/PlatformComponentsProvider.js +13 -0
- package/lib/module/PlatformComponentsProvider.js.map +1 -0
- package/lib/module/SegmentedControl.js +9 -1
- package/lib/module/SegmentedControl.js.map +1 -1
- package/lib/module/SegmentedControlNativeComponent.ts +11 -0
- package/lib/module/SelectionMenu.js +27 -3
- package/lib/module/SelectionMenu.js.map +1 -1
- package/lib/module/SelectionMenuNativeComponent.ts +26 -4
- package/lib/module/SplitButton.js +91 -0
- package/lib/module/SplitButton.js.map +1 -0
- package/lib/module/TabBar.js +196 -0
- package/lib/module/TabBar.js.map +1 -0
- package/lib/module/TabBarAccessoryNativeComponent.ts +19 -0
- package/lib/module/TabBarNativeComponent.ts +145 -0
- package/lib/module/TextField.js +172 -9
- package/lib/module/TextField.js.map +1 -1
- package/lib/module/TextFieldNativeComponent.ts +110 -4
- package/lib/module/focusRegistry.js +1 -0
- package/lib/module/focusRegistry.js.map +1 -1
- package/lib/module/haptics.js +2 -0
- package/lib/module/haptics.js.map +1 -0
- package/lib/module/icons.js +15 -1
- package/lib/module/icons.js.map +1 -1
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +12 -87
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/jest.js +840 -0
- package/lib/module/jest.js.map +1 -0
- package/lib/module/menuItems.js +65 -0
- package/lib/module/menuItems.js.map +1 -0
- package/lib/module/selectionIdentifiers.js +14 -0
- package/lib/module/selectionIdentifiers.js.map +1 -0
- package/lib/module/submitBehavior.js +15 -0
- package/lib/module/submitBehavior.js.map +1 -0
- package/lib/module/tabItems.js +45 -0
- package/lib/module/tabItems.js.map +1 -0
- package/lib/module/web/Button.js +164 -0
- package/lib/module/web/Button.js.map +1 -0
- package/lib/module/web/ButtonGroup.js +113 -0
- package/lib/module/web/ButtonGroup.js.map +1 -0
- package/lib/module/web/DatePicker.js +162 -0
- package/lib/module/web/DatePicker.js.map +1 -0
- package/lib/module/web/DateRangePicker.js +131 -0
- package/lib/module/web/DateRangePicker.js.map +1 -0
- package/lib/module/web/Dialog.js +48 -0
- package/lib/module/web/Dialog.js.map +1 -0
- package/lib/module/web/FloatingActionButton.js +94 -0
- package/lib/module/web/FloatingActionButton.js.map +1 -0
- package/lib/module/web/Icon.js +29 -0
- package/lib/module/web/Icon.js.map +1 -0
- package/lib/module/web/NativeTheme.js +23 -0
- package/lib/module/web/NativeTheme.js.map +1 -0
- package/lib/module/web/NavigationRail.js +133 -0
- package/lib/module/web/NavigationRail.js.map +1 -0
- package/lib/module/web/PlatformComponentsProvider.js +44 -0
- package/lib/module/web/PlatformComponentsProvider.js.map +1 -0
- package/lib/module/web/SegmentedControl.js +112 -0
- package/lib/module/web/SegmentedControl.js.map +1 -0
- package/lib/module/web/SelectionMenu.js +137 -0
- package/lib/module/web/SelectionMenu.js.map +1 -0
- package/lib/module/web/SplitButton.js +30 -0
- package/lib/module/web/SplitButton.js.map +1 -0
- package/lib/module/web/TabBar.js +126 -0
- package/lib/module/web/TabBar.js.map +1 -0
- package/lib/module/web/TextField.js +316 -0
- package/lib/module/web/TextField.js.map +1 -0
- package/lib/module/web/components.js +33 -0
- package/lib/module/web/components.js.map +1 -0
- package/lib/module/web/containers.js +112 -0
- package/lib/module/web/containers.js.map +1 -0
- package/lib/module/web/dateInput.js +109 -0
- package/lib/module/web/dateInput.js.map +1 -0
- package/lib/module/web/shared.js +179 -0
- package/lib/module/web/shared.js.map +1 -0
- package/lib/module/webComponents.js +4 -0
- package/lib/module/webComponents.js.map +1 -0
- package/lib/typescript/commonjs/docs/sidebars.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/Button.d.ts +111 -3
- package/lib/typescript/commonjs/src/Button.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/ButtonGroup.d.ts +21 -6
- package/lib/typescript/commonjs/src/ButtonGroup.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/ButtonGroupNativeComponent.d.ts +64 -3
- package/lib/typescript/commonjs/src/ButtonGroupNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/ButtonNativeComponent.d.ts +94 -3
- package/lib/typescript/commonjs/src/ButtonNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/ContextMenu.d.ts +20 -33
- package/lib/typescript/commonjs/src/ContextMenu.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/ContextMenuNativeComponent.d.ts +45 -47
- package/lib/typescript/commonjs/src/ContextMenuNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/DatePicker.d.ts +74 -1
- package/lib/typescript/commonjs/src/DatePicker.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/DatePickerNativeComponent.d.ts +16 -1
- package/lib/typescript/commonjs/src/DatePickerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/FloatingActionButton.d.ts +67 -0
- package/lib/typescript/commonjs/src/FloatingActionButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/FloatingActionButtonNativeComponent.d.ts +43 -0
- package/lib/typescript/commonjs/src/FloatingActionButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/FloatingToolbar.d.ts +30 -0
- package/lib/typescript/commonjs/src/FloatingToolbar.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/FloatingToolbarNativeComponent.d.ts +12 -0
- package/lib/typescript/commonjs/src/FloatingToolbarNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/LiquidGlass.d.ts +17 -0
- package/lib/typescript/commonjs/src/LiquidGlass.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/LiquidGlassContainer.d.ts +27 -0
- package/lib/typescript/commonjs/src/LiquidGlassContainer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/LiquidGlassContainerNativeComponent.d.ts +13 -0
- package/lib/typescript/commonjs/src/LiquidGlassContainerNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/LiquidGlassNativeComponent.d.ts +7 -0
- package/lib/typescript/commonjs/src/LiquidGlassNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NavigationRail.d.ts +86 -0
- package/lib/typescript/commonjs/src/NavigationRail.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/NavigationRailNativeComponent.d.ts +81 -0
- package/lib/typescript/commonjs/src/NavigationRailNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/PlatformComponentsProvider.d.ts +6 -0
- package/lib/typescript/commonjs/src/PlatformComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/SegmentedControl.d.ts +18 -1
- package/lib/typescript/commonjs/src/SegmentedControl.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/SegmentedControlNativeComponent.d.ts +9 -0
- package/lib/typescript/commonjs/src/SegmentedControlNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/SelectionMenu.d.ts +44 -2
- package/lib/typescript/commonjs/src/SelectionMenu.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/SelectionMenuNativeComponent.d.ts +20 -4
- package/lib/typescript/commonjs/src/SelectionMenuNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/SplitButton.d.ts +83 -0
- package/lib/typescript/commonjs/src/SplitButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/TabBar.d.ts +144 -0
- package/lib/typescript/commonjs/src/TabBar.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/TabBarAccessoryNativeComponent.d.ts +13 -0
- package/lib/typescript/commonjs/src/TabBarAccessoryNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/TabBarNativeComponent.d.ts +110 -0
- package/lib/typescript/commonjs/src/TabBarNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/TextField.d.ts +166 -8
- package/lib/typescript/commonjs/src/TextField.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/TextFieldNativeComponent.d.ts +81 -3
- package/lib/typescript/commonjs/src/TextFieldNativeComponent.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/focusRegistry.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/haptics.d.ts +20 -0
- package/lib/typescript/commonjs/src/haptics.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/icons.d.ts +7 -1
- package/lib/typescript/commonjs/src/icons.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +7 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.web.d.ts +25 -254
- package/lib/typescript/commonjs/src/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/jest.d.ts +139 -0
- package/lib/typescript/commonjs/src/jest.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/menuItems.d.ts +100 -0
- package/lib/typescript/commonjs/src/menuItems.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/selectionIdentifiers.d.ts +3 -0
- package/lib/typescript/commonjs/src/selectionIdentifiers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/submitBehavior.d.ts +9 -0
- package/lib/typescript/commonjs/src/submitBehavior.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/tabItems.d.ts +55 -0
- package/lib/typescript/commonjs/src/tabItems.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/Button.d.ts +9 -0
- package/lib/typescript/commonjs/src/web/Button.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/ButtonGroup.d.ts +11 -0
- package/lib/typescript/commonjs/src/web/ButtonGroup.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/DatePicker.d.ts +14 -0
- package/lib/typescript/commonjs/src/web/DatePicker.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/DateRangePicker.d.ts +11 -0
- package/lib/typescript/commonjs/src/web/DateRangePicker.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/Dialog.d.ts +12 -0
- package/lib/typescript/commonjs/src/web/Dialog.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/FloatingActionButton.d.ts +8 -0
- package/lib/typescript/commonjs/src/web/FloatingActionButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/Icon.d.ts +12 -0
- package/lib/typescript/commonjs/src/web/Icon.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/NativeTheme.d.ts +10 -0
- package/lib/typescript/commonjs/src/web/NativeTheme.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/NavigationRail.d.ts +8 -0
- package/lib/typescript/commonjs/src/web/NavigationRail.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/PlatformComponentsProvider.d.ts +10 -0
- package/lib/typescript/commonjs/src/web/PlatformComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/SegmentedControl.d.ts +8 -0
- package/lib/typescript/commonjs/src/web/SegmentedControl.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/SelectionMenu.d.ts +10 -0
- package/lib/typescript/commonjs/src/web/SelectionMenu.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/SplitButton.d.ts +9 -0
- package/lib/typescript/commonjs/src/web/SplitButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/TabBar.d.ts +9 -0
- package/lib/typescript/commonjs/src/web/TabBar.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/TextField.d.ts +9 -0
- package/lib/typescript/commonjs/src/web/TextField.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/components.d.ts +17 -0
- package/lib/typescript/commonjs/src/web/components.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/containers.d.ts +24 -0
- package/lib/typescript/commonjs/src/web/containers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/dateInput.d.ts +20 -0
- package/lib/typescript/commonjs/src/web/dateInput.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/web/shared.d.ts +43 -0
- package/lib/typescript/commonjs/src/web/shared.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/webComponents.d.ts +43 -0
- package/lib/typescript/commonjs/src/webComponents.d.ts.map +1 -0
- package/lib/typescript/module/docs/sidebars.d.ts.map +1 -1
- package/lib/typescript/module/src/Button.d.ts +111 -3
- package/lib/typescript/module/src/Button.d.ts.map +1 -1
- package/lib/typescript/module/src/ButtonGroup.d.ts +21 -6
- package/lib/typescript/module/src/ButtonGroup.d.ts.map +1 -1
- package/lib/typescript/module/src/ButtonGroupNativeComponent.d.ts +64 -3
- package/lib/typescript/module/src/ButtonGroupNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/ButtonNativeComponent.d.ts +94 -3
- package/lib/typescript/module/src/ButtonNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/ContextMenu.d.ts +20 -33
- package/lib/typescript/module/src/ContextMenu.d.ts.map +1 -1
- package/lib/typescript/module/src/ContextMenuNativeComponent.d.ts +45 -47
- package/lib/typescript/module/src/ContextMenuNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/DatePicker.d.ts +74 -1
- package/lib/typescript/module/src/DatePicker.d.ts.map +1 -1
- package/lib/typescript/module/src/DatePickerNativeComponent.d.ts +16 -1
- package/lib/typescript/module/src/DatePickerNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/FloatingActionButton.d.ts +67 -0
- package/lib/typescript/module/src/FloatingActionButton.d.ts.map +1 -0
- package/lib/typescript/module/src/FloatingActionButtonNativeComponent.d.ts +43 -0
- package/lib/typescript/module/src/FloatingActionButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/FloatingToolbar.d.ts +30 -0
- package/lib/typescript/module/src/FloatingToolbar.d.ts.map +1 -1
- package/lib/typescript/module/src/FloatingToolbarNativeComponent.d.ts +12 -0
- package/lib/typescript/module/src/FloatingToolbarNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/LiquidGlass.d.ts +17 -0
- package/lib/typescript/module/src/LiquidGlass.d.ts.map +1 -1
- package/lib/typescript/module/src/LiquidGlassContainer.d.ts +27 -0
- package/lib/typescript/module/src/LiquidGlassContainer.d.ts.map +1 -0
- package/lib/typescript/module/src/LiquidGlassContainerNativeComponent.d.ts +13 -0
- package/lib/typescript/module/src/LiquidGlassContainerNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/LiquidGlassNativeComponent.d.ts +7 -0
- package/lib/typescript/module/src/LiquidGlassNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/NavigationRail.d.ts +86 -0
- package/lib/typescript/module/src/NavigationRail.d.ts.map +1 -0
- package/lib/typescript/module/src/NavigationRailNativeComponent.d.ts +81 -0
- package/lib/typescript/module/src/NavigationRailNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/PlatformComponentsProvider.d.ts +6 -0
- package/lib/typescript/module/src/PlatformComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/module/src/SegmentedControl.d.ts +18 -1
- package/lib/typescript/module/src/SegmentedControl.d.ts.map +1 -1
- package/lib/typescript/module/src/SegmentedControlNativeComponent.d.ts +9 -0
- package/lib/typescript/module/src/SegmentedControlNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/SelectionMenu.d.ts +44 -2
- package/lib/typescript/module/src/SelectionMenu.d.ts.map +1 -1
- package/lib/typescript/module/src/SelectionMenuNativeComponent.d.ts +20 -4
- package/lib/typescript/module/src/SelectionMenuNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/SplitButton.d.ts +83 -0
- package/lib/typescript/module/src/SplitButton.d.ts.map +1 -0
- package/lib/typescript/module/src/TabBar.d.ts +144 -0
- package/lib/typescript/module/src/TabBar.d.ts.map +1 -0
- package/lib/typescript/module/src/TabBarAccessoryNativeComponent.d.ts +13 -0
- package/lib/typescript/module/src/TabBarAccessoryNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/TabBarNativeComponent.d.ts +110 -0
- package/lib/typescript/module/src/TabBarNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/TextField.d.ts +166 -8
- package/lib/typescript/module/src/TextField.d.ts.map +1 -1
- package/lib/typescript/module/src/TextFieldNativeComponent.d.ts +81 -3
- package/lib/typescript/module/src/TextFieldNativeComponent.d.ts.map +1 -1
- package/lib/typescript/module/src/focusRegistry.d.ts.map +1 -1
- package/lib/typescript/module/src/haptics.d.ts +20 -0
- package/lib/typescript/module/src/haptics.d.ts.map +1 -0
- package/lib/typescript/module/src/icons.d.ts +7 -1
- package/lib/typescript/module/src/icons.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +7 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/index.web.d.ts +25 -254
- package/lib/typescript/module/src/index.web.d.ts.map +1 -1
- package/lib/typescript/module/src/jest.d.ts +139 -0
- package/lib/typescript/module/src/jest.d.ts.map +1 -0
- package/lib/typescript/module/src/menuItems.d.ts +100 -0
- package/lib/typescript/module/src/menuItems.d.ts.map +1 -0
- package/lib/typescript/module/src/selectionIdentifiers.d.ts +3 -0
- package/lib/typescript/module/src/selectionIdentifiers.d.ts.map +1 -0
- package/lib/typescript/module/src/submitBehavior.d.ts +9 -0
- package/lib/typescript/module/src/submitBehavior.d.ts.map +1 -0
- package/lib/typescript/module/src/tabItems.d.ts +55 -0
- package/lib/typescript/module/src/tabItems.d.ts.map +1 -0
- package/lib/typescript/module/src/web/Button.d.ts +9 -0
- package/lib/typescript/module/src/web/Button.d.ts.map +1 -0
- package/lib/typescript/module/src/web/ButtonGroup.d.ts +11 -0
- package/lib/typescript/module/src/web/ButtonGroup.d.ts.map +1 -0
- package/lib/typescript/module/src/web/DatePicker.d.ts +14 -0
- package/lib/typescript/module/src/web/DatePicker.d.ts.map +1 -0
- package/lib/typescript/module/src/web/DateRangePicker.d.ts +11 -0
- package/lib/typescript/module/src/web/DateRangePicker.d.ts.map +1 -0
- package/lib/typescript/module/src/web/Dialog.d.ts +12 -0
- package/lib/typescript/module/src/web/Dialog.d.ts.map +1 -0
- package/lib/typescript/module/src/web/FloatingActionButton.d.ts +8 -0
- package/lib/typescript/module/src/web/FloatingActionButton.d.ts.map +1 -0
- package/lib/typescript/module/src/web/Icon.d.ts +12 -0
- package/lib/typescript/module/src/web/Icon.d.ts.map +1 -0
- package/lib/typescript/module/src/web/NativeTheme.d.ts +10 -0
- package/lib/typescript/module/src/web/NativeTheme.d.ts.map +1 -0
- package/lib/typescript/module/src/web/NavigationRail.d.ts +8 -0
- package/lib/typescript/module/src/web/NavigationRail.d.ts.map +1 -0
- package/lib/typescript/module/src/web/PlatformComponentsProvider.d.ts +10 -0
- package/lib/typescript/module/src/web/PlatformComponentsProvider.d.ts.map +1 -0
- package/lib/typescript/module/src/web/SegmentedControl.d.ts +8 -0
- package/lib/typescript/module/src/web/SegmentedControl.d.ts.map +1 -0
- package/lib/typescript/module/src/web/SelectionMenu.d.ts +10 -0
- package/lib/typescript/module/src/web/SelectionMenu.d.ts.map +1 -0
- package/lib/typescript/module/src/web/SplitButton.d.ts +9 -0
- package/lib/typescript/module/src/web/SplitButton.d.ts.map +1 -0
- package/lib/typescript/module/src/web/TabBar.d.ts +9 -0
- package/lib/typescript/module/src/web/TabBar.d.ts.map +1 -0
- package/lib/typescript/module/src/web/TextField.d.ts +9 -0
- package/lib/typescript/module/src/web/TextField.d.ts.map +1 -0
- package/lib/typescript/module/src/web/components.d.ts +17 -0
- package/lib/typescript/module/src/web/components.d.ts.map +1 -0
- package/lib/typescript/module/src/web/containers.d.ts +24 -0
- package/lib/typescript/module/src/web/containers.d.ts.map +1 -0
- package/lib/typescript/module/src/web/dateInput.d.ts +20 -0
- package/lib/typescript/module/src/web/dateInput.d.ts.map +1 -0
- package/lib/typescript/module/src/web/shared.d.ts +43 -0
- package/lib/typescript/module/src/web/shared.d.ts.map +1 -0
- package/lib/typescript/module/src/webComponents.d.ts +43 -0
- package/lib/typescript/module/src/webComponents.d.ts.map +1 -0
- package/package.json +32 -2
- package/plugin/build/index.cjs +79 -6
- package/plugin/build/index.d.ts +27 -2
- package/plugin/build/index.d.ts.map +1 -1
- package/plugin/tsconfig.json +2 -1
- package/react-native.config.js +3 -0
- package/shared/PCFloatingActionButtonComponentDescriptors-custom.h +22 -0
- package/shared/PCFloatingActionButtonShadowNode-custom.cpp +48 -0
- package/shared/PCFloatingActionButtonShadowNode-custom.h +54 -0
- package/shared/PCFloatingActionButtonState-custom.h +61 -0
- package/shared/PCNavigationRailComponentDescriptors-custom.h +47 -0
- package/shared/PCNavigationRailShadowNode-custom.h +42 -0
- package/shared/PCNavigationRailState-custom.h +62 -0
- package/shared/PCTabBarComponentDescriptors-custom.h +22 -0
- package/shared/PCTabBarShadowNode-custom.cpp +54 -0
- package/shared/PCTabBarShadowNode-custom.h +54 -0
- package/shared/PCTabBarState-custom.h +62 -0
- package/shared/react/renderer/components/PlatformComponentsViewSpec/ComponentDescriptors.h +3 -0
- package/src/Button.tsx +222 -7
- package/src/ButtonGroup.tsx +29 -11
- package/src/ButtonGroupNativeComponent.ts +74 -4
- package/src/ButtonNativeComponent.ts +119 -3
- package/src/ContextMenu.tsx +34 -81
- package/src/ContextMenuNativeComponent.ts +47 -49
- package/src/DatePicker.tsx +182 -4
- package/src/DatePickerNativeComponent.ts +19 -2
- package/src/FloatingActionButton.tsx +121 -0
- package/src/FloatingActionButtonNativeComponent.ts +58 -0
- package/src/FloatingToolbar.tsx +54 -3
- package/src/FloatingToolbarNativeComponent.ts +16 -0
- package/src/LiquidGlass.tsx +24 -1
- package/src/LiquidGlassContainer.tsx +42 -0
- package/src/LiquidGlassContainerNativeComponent.ts +17 -0
- package/src/LiquidGlassNativeComponent.ts +8 -0
- package/src/NavigationRail.tsx +203 -0
- package/src/NavigationRailNativeComponent.ts +107 -0
- package/src/PlatformComponentsProvider.tsx +15 -0
- package/src/SegmentedControl.tsx +31 -1
- package/src/SegmentedControlNativeComponent.ts +11 -0
- package/src/SelectionMenu.tsx +81 -6
- package/src/SelectionMenuNativeComponent.ts +26 -4
- package/src/SplitButton.tsx +198 -0
- package/src/TabBar.tsx +373 -0
- package/src/TabBarAccessoryNativeComponent.ts +19 -0
- package/src/TabBarNativeComponent.ts +145 -0
- package/src/TextField.tsx +428 -14
- package/src/TextFieldNativeComponent.ts +110 -4
- package/src/focusRegistry.ts +1 -0
- package/src/haptics.ts +31 -0
- package/src/icons.ts +28 -1
- package/src/index.tsx +7 -0
- package/src/index.web.tsx +51 -391
- package/src/jest.tsx +958 -0
- package/src/menuItems.ts +152 -0
- package/src/selectionIdentifiers.ts +17 -0
- package/src/submitBehavior.ts +16 -0
- package/src/tabItems.ts +113 -0
- package/src/web/Button.tsx +201 -0
- package/src/web/ButtonGroup.tsx +154 -0
- package/src/web/DatePicker.tsx +204 -0
- package/src/web/DateRangePicker.tsx +135 -0
- package/src/web/Dialog.tsx +54 -0
- package/src/web/FloatingActionButton.tsx +76 -0
- package/src/web/Icon.tsx +33 -0
- package/src/web/NativeTheme.ts +23 -0
- package/src/web/NavigationRail.tsx +148 -0
- package/src/web/PlatformComponentsProvider.tsx +48 -0
- package/src/web/SegmentedControl.tsx +127 -0
- package/src/web/SelectionMenu.tsx +149 -0
- package/src/web/SplitButton.tsx +32 -0
- package/src/web/TabBar.tsx +150 -0
- package/src/web/TextField.tsx +361 -0
- package/src/web/components.tsx +71 -0
- package/src/web/containers.tsx +130 -0
- package/src/web/dateInput.ts +137 -0
- package/src/web/shared.ts +176 -0
- package/src/webComponents.ts +45 -0
- package/android/src/main/java/com/platformcomponents/DateConstraints.kt +0 -83
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
/// One menu item bridged from JS (src/menuItems.ts). The action tree arrives
|
|
4
|
+
/// flattened: each item points at its parent submenu or section by index.
|
|
5
|
+
struct PCMenuItem {
|
|
6
|
+
/// Position in the flattened list
|
|
7
|
+
let index: Int
|
|
8
|
+
let id: String
|
|
9
|
+
let title: String
|
|
10
|
+
let subtitle: String
|
|
11
|
+
/// Index of the parent submenu or section; -1 at the top level
|
|
12
|
+
let parent: Int
|
|
13
|
+
/// "action" | "menu" | "section"
|
|
14
|
+
let kind: String
|
|
15
|
+
let icon: PCButtonSupport.Icon
|
|
16
|
+
let imageColor: String
|
|
17
|
+
let destructive: Bool
|
|
18
|
+
let disabled: Bool
|
|
19
|
+
let keepsMenuPresented: Bool
|
|
20
|
+
/// "" | "off" | "on" | "mixed"
|
|
21
|
+
let state: String
|
|
22
|
+
/// The item's own `haptics`; "" = the component's
|
|
23
|
+
let haptics: String
|
|
24
|
+
|
|
25
|
+
init(
|
|
26
|
+
index: Int,
|
|
27
|
+
id: String,
|
|
28
|
+
title: String,
|
|
29
|
+
subtitle: String = "",
|
|
30
|
+
parent: Int = -1,
|
|
31
|
+
kind: String = "action",
|
|
32
|
+
icon: PCButtonSupport.Icon = .none,
|
|
33
|
+
imageColor: String = "",
|
|
34
|
+
destructive: Bool = false,
|
|
35
|
+
disabled: Bool = false,
|
|
36
|
+
keepsMenuPresented: Bool = false,
|
|
37
|
+
state: String = "",
|
|
38
|
+
haptics: String = ""
|
|
39
|
+
) {
|
|
40
|
+
self.index = index
|
|
41
|
+
self.id = id
|
|
42
|
+
self.title = title
|
|
43
|
+
self.subtitle = subtitle
|
|
44
|
+
self.parent = parent
|
|
45
|
+
self.kind = kind
|
|
46
|
+
self.icon = icon
|
|
47
|
+
self.imageColor = imageColor
|
|
48
|
+
self.destructive = destructive
|
|
49
|
+
self.disabled = disabled
|
|
50
|
+
self.keepsMenuPresented = keepsMenuPresented
|
|
51
|
+
self.state = state
|
|
52
|
+
self.haptics = haptics
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// Reads an item bridged from ObjC++ as a dictionary (see PCMenuItems.h).
|
|
56
|
+
init(index: Int, dictionary dict: [String: Any]) {
|
|
57
|
+
func string(_ key: String) -> String { (dict[key] as? String) ?? "" }
|
|
58
|
+
self.init(
|
|
59
|
+
index: index,
|
|
60
|
+
id: string("id"),
|
|
61
|
+
title: string("title"),
|
|
62
|
+
subtitle: string("subtitle"),
|
|
63
|
+
parent: (dict["parent"] as? NSNumber)?.intValue ?? -1,
|
|
64
|
+
kind: string("kind").isEmpty ? "action" : string("kind"),
|
|
65
|
+
icon: PCButtonSupport.Icon(dictionary: dict),
|
|
66
|
+
imageColor: string("imageColor"),
|
|
67
|
+
destructive: string("destructive") == "true",
|
|
68
|
+
disabled: string("disabled") == "true",
|
|
69
|
+
keepsMenuPresented: string("keepsMenuPresented") == "true",
|
|
70
|
+
state: string("state"),
|
|
71
|
+
haptics: string("haptics")
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/// Images currently displayed by one view's menu. A menu rebuild must reuse its
|
|
77
|
+
/// loaded images even when the request bypasses the shared cache or the response
|
|
78
|
+
/// forbids caching. Removed icons release both their image and pending entry.
|
|
79
|
+
/// Must be used from the main thread.
|
|
80
|
+
final class PCMenuImageState {
|
|
81
|
+
private final class Entry {
|
|
82
|
+
var image: UIImage?
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private var entries: [PCButtonSupport.Icon: Entry] = [:]
|
|
86
|
+
|
|
87
|
+
func retain(icons: [PCButtonSupport.Icon]) {
|
|
88
|
+
let current = Set(icons)
|
|
89
|
+
entries = entries.filter { current.contains($0.key) }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
func image(for icon: PCButtonSupport.Icon, onImageLoaded: @escaping () -> Void) -> UIImage? {
|
|
93
|
+
if let entry = entries[icon] { return entry.image }
|
|
94
|
+
let entry = Entry()
|
|
95
|
+
entries[icon] = entry
|
|
96
|
+
entry.image = PCButtonSupport.image(for: icon) { [weak self, weak entry] image in
|
|
97
|
+
guard let self, let entry, self.entries[icon] === entry else { return }
|
|
98
|
+
entry.image = image
|
|
99
|
+
if image != nil { onImageLoaded() }
|
|
100
|
+
}
|
|
101
|
+
return entry.image
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// Builds UIKit menus from flattened menu items: actions, submenus, inline
|
|
106
|
+
/// sections, subtitles, icons (SF Symbols, asset catalog names and React
|
|
107
|
+
/// Native image sources), attributes and states. Shared by the components
|
|
108
|
+
/// that show a native menu.
|
|
109
|
+
///
|
|
110
|
+
/// Must be used from the main thread.
|
|
111
|
+
enum PCMenuSupport {
|
|
112
|
+
/// Parses the array of dictionaries ObjC++ bridges.
|
|
113
|
+
static func items(from array: [Any]) -> [PCMenuItem] {
|
|
114
|
+
array.enumerated().compactMap { index, any in
|
|
115
|
+
guard let dict = any as? [String: Any] else { return nil }
|
|
116
|
+
return PCMenuItem(index: index, dictionary: dict)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/// The root menu. Its identifier is UIKit's own, different for every
|
|
121
|
+
/// build; `updatedVisibleMenu` finds it through the menu it replaces.
|
|
122
|
+
///
|
|
123
|
+
/// - `imageState`: retained by the view across menu rebuilds, holding only
|
|
124
|
+
/// the current menu's images.
|
|
125
|
+
/// - `onImageLoaded`: called when an image icon has loaded; build the menu
|
|
126
|
+
/// again then using the same image state.
|
|
127
|
+
/// - `handler`: called with the item when an action is performed.
|
|
128
|
+
static func menu(
|
|
129
|
+
title: String,
|
|
130
|
+
options: UIMenu.Options = [],
|
|
131
|
+
items: [PCMenuItem],
|
|
132
|
+
imageState: PCMenuImageState,
|
|
133
|
+
onImageLoaded: @escaping () -> Void,
|
|
134
|
+
handler: @escaping (PCMenuItem) -> Void
|
|
135
|
+
) -> UIMenu {
|
|
136
|
+
imageState.retain(icons: items.map(\.icon))
|
|
137
|
+
return UIMenu(
|
|
138
|
+
title: title,
|
|
139
|
+
options: options,
|
|
140
|
+
children: elements(for: items, imageState: imageState, onImageLoaded: onImageLoaded, handler: handler)
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/// The top-level elements of the menu. Submenus and sections without
|
|
145
|
+
/// children are left out.
|
|
146
|
+
static func elements(
|
|
147
|
+
for items: [PCMenuItem],
|
|
148
|
+
imageState: PCMenuImageState,
|
|
149
|
+
onImageLoaded: @escaping () -> Void,
|
|
150
|
+
handler: @escaping (PCMenuItem) -> Void
|
|
151
|
+
) -> [UIMenuElement] {
|
|
152
|
+
let children = Dictionary(grouping: items, by: { $0.parent })
|
|
153
|
+
|
|
154
|
+
func build(_ parent: Int) -> [UIMenuElement] {
|
|
155
|
+
(children[parent] ?? []).compactMap { item in
|
|
156
|
+
switch item.kind {
|
|
157
|
+
case "menu", "section":
|
|
158
|
+
let elements = build(item.index)
|
|
159
|
+
guard !elements.isEmpty else { return nil }
|
|
160
|
+
let inline = item.kind == "section"
|
|
161
|
+
let menu = UIMenu(
|
|
162
|
+
title: item.title,
|
|
163
|
+
image: inline ? nil : image(for: item, imageState: imageState, onImageLoaded: onImageLoaded),
|
|
164
|
+
identifier: identifier(for: item),
|
|
165
|
+
options: inline ? .displayInline : [],
|
|
166
|
+
children: elements
|
|
167
|
+
)
|
|
168
|
+
if !item.subtitle.isEmpty { menu.subtitle = item.subtitle }
|
|
169
|
+
return menu
|
|
170
|
+
default:
|
|
171
|
+
return action(for: item, imageState: imageState, onImageLoaded: onImageLoaded, handler: handler)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return build(-1)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
static func action(
|
|
180
|
+
for item: PCMenuItem,
|
|
181
|
+
imageState: PCMenuImageState,
|
|
182
|
+
onImageLoaded: @escaping () -> Void,
|
|
183
|
+
handler: @escaping (PCMenuItem) -> Void
|
|
184
|
+
) -> UIAction {
|
|
185
|
+
var attributes: UIMenuElement.Attributes = []
|
|
186
|
+
if item.destructive { attributes.insert(.destructive) }
|
|
187
|
+
if item.disabled { attributes.insert(.disabled) }
|
|
188
|
+
if item.keepsMenuPresented, #available(iOS 16.0, *) {
|
|
189
|
+
attributes.insert(.keepsMenuPresented)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return UIAction(
|
|
193
|
+
title: item.title,
|
|
194
|
+
subtitle: item.subtitle.isEmpty ? nil : item.subtitle,
|
|
195
|
+
image: image(for: item, imageState: imageState, onImageLoaded: onImageLoaded),
|
|
196
|
+
attributes: attributes,
|
|
197
|
+
state: state(item.state)
|
|
198
|
+
) { _ in
|
|
199
|
+
handler(item)
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
static func state(_ value: String) -> UIMenuElement.State {
|
|
204
|
+
switch value {
|
|
205
|
+
case "on": return .on
|
|
206
|
+
case "mixed": return .mixed
|
|
207
|
+
default: return .off
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/// Submenus are identified by their action id, so an open submenu can be
|
|
212
|
+
/// found again when the menu is rebuilt (`updatedVisibleMenu`).
|
|
213
|
+
static func identifier(for item: PCMenuItem) -> UIMenu.Identifier {
|
|
214
|
+
UIMenu.Identifier("com.platformcomponents.menu.\(item.id)")
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/// The item's icon. SF Symbol and asset catalog names resolve right away;
|
|
218
|
+
/// an image source that is still loading gives nil and calls
|
|
219
|
+
/// `onImageLoaded` when it arrives.
|
|
220
|
+
static func image(for item: PCMenuItem, imageState: PCMenuImageState, onImageLoaded: @escaping () -> Void) -> UIImage? {
|
|
221
|
+
let icon = item.icon
|
|
222
|
+
var image: UIImage?
|
|
223
|
+
switch icon.type {
|
|
224
|
+
case "sfSymbol":
|
|
225
|
+
// SF Symbols are templates already; asset catalog images keep the
|
|
226
|
+
// rendering mode set in the catalog.
|
|
227
|
+
image = PCImageLoader.symbol(named: icon.name)
|
|
228
|
+
case "image":
|
|
229
|
+
image = imageState.image(for: icon, onImageLoaded: onImageLoaded)
|
|
230
|
+
default:
|
|
231
|
+
return nil
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if let color = color(hex: item.imageColor) {
|
|
235
|
+
image = image?.withTintColor(color, renderingMode: .alwaysOriginal)
|
|
236
|
+
}
|
|
237
|
+
return image
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/// The menu in `root` that replaces the one showing, for
|
|
241
|
+
/// `updateVisibleMenu`: `root` itself when the root of `oldRoot` is
|
|
242
|
+
/// showing, else the submenu with the visible submenu's identifier. Falls
|
|
243
|
+
/// back to the visible menu, unchanged, when it no longer exists.
|
|
244
|
+
static func updatedVisibleMenu(_ visible: UIMenu, in root: UIMenu, replacing oldRoot: UIMenu? = nil) -> UIMenu {
|
|
245
|
+
if let oldRoot, visible.identifier == oldRoot.identifier { return root }
|
|
246
|
+
func find(_ menu: UIMenu) -> UIMenu? {
|
|
247
|
+
if menu.identifier == visible.identifier { return menu }
|
|
248
|
+
for case let child as UIMenu in menu.children {
|
|
249
|
+
if let found = find(child) { return found }
|
|
250
|
+
}
|
|
251
|
+
return nil
|
|
252
|
+
}
|
|
253
|
+
return find(root) ?? visible
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/// "#RRGGBB" or "RRGGBB"; nil for anything else.
|
|
257
|
+
static func color(hex string: String) -> UIColor? {
|
|
258
|
+
var hex = string.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
259
|
+
if hex.hasPrefix("#") { hex = String(hex.dropFirst()) }
|
|
260
|
+
guard hex.count == 6, let rgb = UInt64(hex, radix: 16) else { return nil }
|
|
261
|
+
return UIColor(
|
|
262
|
+
red: CGFloat((rgb & 0xFF0000) >> 16) / 255,
|
|
263
|
+
green: CGFloat((rgb & 0x00FF00) >> 8) / 255,
|
|
264
|
+
blue: CGFloat(rgb & 0x0000FF) / 255,
|
|
265
|
+
alpha: 1
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/// A button that shows its `menu` as its primary action and reports when the
|
|
271
|
+
/// menu opens and closes, through UIControl's context menu delegate methods.
|
|
272
|
+
/// Used as an invisible anchor that presents a system menu over React
|
|
273
|
+
/// content.
|
|
274
|
+
final class PCMenuButton: UIButton {
|
|
275
|
+
var onMenuOpen: (() -> Void)?
|
|
276
|
+
/// Called once the menu has finished dismissing.
|
|
277
|
+
var onMenuClose: (() -> Void)?
|
|
278
|
+
|
|
279
|
+
private(set) var isMenuVisible = false
|
|
280
|
+
|
|
281
|
+
override init(frame: CGRect) {
|
|
282
|
+
super.init(frame: frame)
|
|
283
|
+
showsMenuAsPrimaryAction = true
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
required init?(coder: NSCoder) {
|
|
287
|
+
super.init(coder: coder)
|
|
288
|
+
showsMenuAsPrimaryAction = true
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/// Replaces the menu. While it is open, `updatingVisibleMenu` also
|
|
292
|
+
/// updates it in place (for actions that keep the menu presented); pass
|
|
293
|
+
/// false when the change comes from a pick, while the menu is closing.
|
|
294
|
+
func setMenu(_ newMenu: UIMenu?, updatingVisibleMenu: Bool = true) {
|
|
295
|
+
let oldMenu = menu
|
|
296
|
+
menu = newMenu
|
|
297
|
+
guard updatingVisibleMenu, isMenuVisible, let newMenu,
|
|
298
|
+
let interaction = contextMenuInteraction else { return }
|
|
299
|
+
interaction.updateVisibleMenu { visible in
|
|
300
|
+
PCMenuSupport.updatedVisibleMenu(visible, in: newMenu, replacing: oldMenu)
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/// Whether `presentMenu()` can open the menu without a touch:
|
|
305
|
+
/// `UIControl.performPrimaryAction()`, iOS 17.4+.
|
|
306
|
+
static var canPresentMenuProgrammatically: Bool {
|
|
307
|
+
if #available(iOS 17.4, *) { return true }
|
|
308
|
+
return false
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/// Opens the menu without a touch. Returns false where UIKit has no public
|
|
312
|
+
/// API for it (before iOS 17.4).
|
|
313
|
+
@discardableResult
|
|
314
|
+
func presentMenu() -> Bool {
|
|
315
|
+
guard #available(iOS 17.4, *) else { return false }
|
|
316
|
+
performPrimaryAction()
|
|
317
|
+
return true
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/// Closes the menu if it is open; a closed menu's interaction is left alone.
|
|
321
|
+
func dismissMenu() {
|
|
322
|
+
guard isMenuVisible else { return }
|
|
323
|
+
contextMenuInteraction?.dismissMenu()
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
override func contextMenuInteraction(
|
|
327
|
+
_ interaction: UIContextMenuInteraction,
|
|
328
|
+
willDisplayMenuFor configuration: UIContextMenuConfiguration,
|
|
329
|
+
animator: UIContextMenuInteractionAnimating?
|
|
330
|
+
) {
|
|
331
|
+
super.contextMenuInteraction(interaction, willDisplayMenuFor: configuration, animator: animator)
|
|
332
|
+
isMenuVisible = true
|
|
333
|
+
onMenuOpen?()
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
override func contextMenuInteraction(
|
|
337
|
+
_ interaction: UIContextMenuInteraction,
|
|
338
|
+
willEndFor configuration: UIContextMenuConfiguration,
|
|
339
|
+
animator: UIContextMenuInteractionAnimating?
|
|
340
|
+
) {
|
|
341
|
+
super.contextMenuInteraction(interaction, willEndFor: configuration, animator: animator)
|
|
342
|
+
isMenuVisible = false
|
|
343
|
+
// Report after the dismissal, when a selected action has run.
|
|
344
|
+
if let animator {
|
|
345
|
+
animator.addCompletion { [weak self] in self?.onMenuClose?() }
|
|
346
|
+
} else {
|
|
347
|
+
DispatchQueue.main.async { [weak self] in self?.onMenuClose?() }
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// PCNavigationRail.mm
|
|
2
|
+
|
|
3
|
+
#import "PCNavigationRail.h"
|
|
4
|
+
|
|
5
|
+
#import <React/RCTComponentViewFactory.h>
|
|
6
|
+
#import <React/RCTConversions.h>
|
|
7
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
8
|
+
#import <React/RCTFont.h>
|
|
9
|
+
|
|
10
|
+
#import <react/renderer/components/PlatformComponentsViewSpec/ComponentDescriptors.h>
|
|
11
|
+
#import <react/renderer/components/PlatformComponentsViewSpec/EventEmitters.h>
|
|
12
|
+
#import <react/renderer/components/PlatformComponentsViewSpec/Props.h>
|
|
13
|
+
#import <react/renderer/core/LayoutPrimitives.h>
|
|
14
|
+
|
|
15
|
+
#if __has_include(<PlatformComponents/PlatformComponents-Swift.h>)
|
|
16
|
+
#import <PlatformComponents/PlatformComponents-Swift.h>
|
|
17
|
+
#else
|
|
18
|
+
#import "PlatformComponents-Swift.h"
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#import "PCNavigationRailComponentDescriptors-custom.h"
|
|
22
|
+
#import "PCNavigationRailShadowNode-custom.h"
|
|
23
|
+
#import "PCNavigationRailState-custom.h"
|
|
24
|
+
|
|
25
|
+
using namespace facebook::react;
|
|
26
|
+
|
|
27
|
+
namespace {
|
|
28
|
+
static inline bool ItemsEqual(
|
|
29
|
+
const std::vector<PCNavigationRailItemsStruct> &a,
|
|
30
|
+
const std::vector<PCNavigationRailItemsStruct> &b) {
|
|
31
|
+
if (a.size() != b.size()) return false;
|
|
32
|
+
for (size_t i = 0; i < a.size(); i++) {
|
|
33
|
+
const auto &x = a[i];
|
|
34
|
+
const auto &y = b[i];
|
|
35
|
+
if (x.label != y.label || x.value != y.value || x.disabled != y.disabled ||
|
|
36
|
+
x.iconType != y.iconType || x.iconName != y.iconName || x.iconRequest != y.iconRequest || x.iconUri != y.iconUri ||
|
|
37
|
+
x.iconScale != y.iconScale || x.iconTinted != y.iconTinted ||
|
|
38
|
+
x.selectedIconType != y.selectedIconType || x.selectedIconName != y.selectedIconName ||
|
|
39
|
+
x.selectedIconRequest != y.selectedIconRequest || x.selectedIconUri != y.selectedIconUri || x.selectedIconScale != y.selectedIconScale ||
|
|
40
|
+
x.selectedIconTinted != y.selectedIconTinted || x.badge != y.badge ||
|
|
41
|
+
x.accessibilityLabel != y.accessibilityLabel || x.testID != y.testID ||
|
|
42
|
+
x.role != y.role) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static inline NSString *NSStringFromStd(const std::string &s, NSString *fallback) {
|
|
50
|
+
return s.empty() ? fallback : [NSString stringWithUTF8String:s.c_str()];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static inline bool LabelStyleEqual(
|
|
54
|
+
const PCNavigationRailLabelStyleStruct &a,
|
|
55
|
+
const PCNavigationRailLabelStyleStruct &b) {
|
|
56
|
+
return a.fontFamily == b.fontFamily && a.fontSize == b.fontSize &&
|
|
57
|
+
a.fontWeight == b.fontWeight && a.fontStyle == b.fontStyle;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/// Builds the label font from RN-style font props, or nil when every field is
|
|
61
|
+
/// unset so the rail keeps its default. Without a fontSize the size follows
|
|
62
|
+
/// Dynamic Type (the caption style), capped at maxFontSizeMultiplier times its
|
|
63
|
+
/// default size when that is 1 or more.
|
|
64
|
+
static UIFont *FontFromLabelStyle(const PCNavigationRailLabelStyleStruct &style, double maxFontSizeMultiplier) {
|
|
65
|
+
if (style.fontFamily.empty() && style.fontSize <= 0 &&
|
|
66
|
+
style.fontWeight.empty() && style.fontStyle.empty() && maxFontSizeMultiplier < 1) {
|
|
67
|
+
return nil;
|
|
68
|
+
}
|
|
69
|
+
UIFont *caption = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
|
|
70
|
+
NSNumber *size = style.fontSize > 0 ? @(style.fontSize) : nil;
|
|
71
|
+
if (!size && maxFontSizeMultiplier >= 1) {
|
|
72
|
+
UITraitCollection *defaultTraits =
|
|
73
|
+
[UITraitCollection traitCollectionWithPreferredContentSizeCategory:UIContentSizeCategoryLarge];
|
|
74
|
+
CGFloat baseSize = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1
|
|
75
|
+
compatibleWithTraitCollection:defaultTraits].pointSize;
|
|
76
|
+
size = @(MIN(caption.pointSize, baseSize * maxFontSizeMultiplier));
|
|
77
|
+
}
|
|
78
|
+
return [RCTFont updateFont:[UIFont systemFontOfSize:caption.pointSize weight:UIFontWeightMedium]
|
|
79
|
+
withFamily:NSStringFromStd(style.fontFamily, nil)
|
|
80
|
+
size:size
|
|
81
|
+
weight:NSStringFromStd(style.fontWeight, nil)
|
|
82
|
+
style:NSStringFromStd(style.fontStyle, nil)
|
|
83
|
+
variant:nil
|
|
84
|
+
scaleMultiplier:1.0];
|
|
85
|
+
}
|
|
86
|
+
} // namespace
|
|
87
|
+
|
|
88
|
+
@interface PCNavigationRail ()
|
|
89
|
+
|
|
90
|
+
- (void)updateMeasurements;
|
|
91
|
+
|
|
92
|
+
@end
|
|
93
|
+
|
|
94
|
+
@implementation PCNavigationRail {
|
|
95
|
+
PCNavigationRailView *_view;
|
|
96
|
+
MeasuringPCNavigationRailShadowNode::ConcreteState::Shared _state;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider {
|
|
100
|
+
return concreteComponentDescriptorProvider<MeasuringPCNavigationRailComponentDescriptor>();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
- (instancetype)initWithFrame:(CGRect)frame {
|
|
104
|
+
if (self = [super initWithFrame:frame]) {
|
|
105
|
+
// Fabric views seed _props with their own defaults: RCTViewComponentView
|
|
106
|
+
// asserts on it in debug builds of React Native core, and the first
|
|
107
|
+
// updateProps would otherwise read the base ViewProps as the component's.
|
|
108
|
+
static const auto defaultProps = std::make_shared<const PCNavigationRailProps>();
|
|
109
|
+
_props = defaultProps;
|
|
110
|
+
|
|
111
|
+
// A plain subview rather than the contentView, which Fabric sizes to the
|
|
112
|
+
// content frame: the width padding (see shared/) would leave it none
|
|
113
|
+
_view = [PCNavigationRailView new];
|
|
114
|
+
[self addSubview:_view];
|
|
115
|
+
|
|
116
|
+
__weak __typeof(self) weakSelf = self;
|
|
117
|
+
|
|
118
|
+
_view.onItemPress = ^(NSInteger index, NSString *value, BOOL reselected) {
|
|
119
|
+
__typeof(self) strongSelf = weakSelf;
|
|
120
|
+
if (!strongSelf) return;
|
|
121
|
+
|
|
122
|
+
[strongSelf->_view.haptics performIn:strongSelf->_view];
|
|
123
|
+
|
|
124
|
+
auto eventEmitter =
|
|
125
|
+
std::static_pointer_cast<const PCNavigationRailEventEmitter>(strongSelf->_eventEmitter);
|
|
126
|
+
if (!eventEmitter) return;
|
|
127
|
+
|
|
128
|
+
PCNavigationRailEventEmitter::OnItemPress payload = {
|
|
129
|
+
.index = (int)index,
|
|
130
|
+
.value = value.UTF8String,
|
|
131
|
+
.reselected = reselected ? "true" : "false",
|
|
132
|
+
};
|
|
133
|
+
eventEmitter->onItemPress(payload);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
_view.onNeedsRemeasure = ^{
|
|
137
|
+
__typeof(self) strongSelf = weakSelf;
|
|
138
|
+
if (!strongSelf) return;
|
|
139
|
+
[strongSelf updateMeasurements];
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return self;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
- (void)layoutSubviews {
|
|
146
|
+
[super layoutSubviews];
|
|
147
|
+
_view.frame = self.bounds;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// The header goes above the destinations; the rail places it
|
|
151
|
+
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
|
|
152
|
+
[_view.headerContainer insertSubview:childComponentView atIndex:index];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index {
|
|
156
|
+
[childComponentView removeFromSuperview];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
- (void)updateProps:(Props::Shared const &)props
|
|
160
|
+
oldProps:(Props::Shared const &)oldProps {
|
|
161
|
+
const auto &newProps = *std::static_pointer_cast<const PCNavigationRailProps>(props);
|
|
162
|
+
const auto prevProps = std::static_pointer_cast<const PCNavigationRailProps>(oldProps);
|
|
163
|
+
|
|
164
|
+
if (!prevProps || newProps.expanded != prevProps->expanded) {
|
|
165
|
+
_view.expanded = newProps.expanded == "true";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!prevProps || newProps.labelVisibility != prevProps->labelVisibility) {
|
|
169
|
+
_view.labelVisibility = NSStringFromStd(newProps.labelVisibility, @"auto");
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (!prevProps || newProps.menuGravity != prevProps->menuGravity) {
|
|
173
|
+
_view.menuGravity = NSStringFromStd(newProps.menuGravity, @"top");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (!prevProps || !ItemsEqual(newProps.items, prevProps->items)) {
|
|
177
|
+
NSMutableArray *arr = [NSMutableArray new];
|
|
178
|
+
for (const auto &item : newProps.items) {
|
|
179
|
+
[arr addObject:@{
|
|
180
|
+
@"label" : NSStringFromStd(item.label, @""),
|
|
181
|
+
@"value" : NSStringFromStd(item.value, @""),
|
|
182
|
+
@"disabled" : NSStringFromStd(item.disabled, @"enabled"),
|
|
183
|
+
@"iconType" : NSStringFromStd(item.iconType, @""),
|
|
184
|
+
@"iconName" : NSStringFromStd(item.iconName, @""),
|
|
185
|
+
@"iconRequest" : NSStringFromStd(item.iconRequest, @""),
|
|
186
|
+
@"iconUri" : NSStringFromStd(item.iconUri, @""),
|
|
187
|
+
@"iconScale" : @(item.iconScale),
|
|
188
|
+
@"iconTinted" : NSStringFromStd(item.iconTinted, @"true"),
|
|
189
|
+
@"selectedIconType" : NSStringFromStd(item.selectedIconType, @""),
|
|
190
|
+
@"selectedIconName" : NSStringFromStd(item.selectedIconName, @""),
|
|
191
|
+
@"selectedIconRequest" : NSStringFromStd(item.selectedIconRequest, @""),
|
|
192
|
+
@"selectedIconUri" : NSStringFromStd(item.selectedIconUri, @""),
|
|
193
|
+
@"selectedIconScale" : @(item.selectedIconScale),
|
|
194
|
+
@"selectedIconTinted" : NSStringFromStd(item.selectedIconTinted, @"true"),
|
|
195
|
+
@"badge" : NSStringFromStd(item.badge, @""),
|
|
196
|
+
@"accessibilityLabel" : NSStringFromStd(item.accessibilityLabel, @""),
|
|
197
|
+
@"testID" : NSStringFromStd(item.testID, @""),
|
|
198
|
+
@"role" : NSStringFromStd(item.role, @""),
|
|
199
|
+
}];
|
|
200
|
+
}
|
|
201
|
+
_view.items = arr;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (!prevProps || newProps.selectedValue != prevProps->selectedValue) {
|
|
205
|
+
_view.selectedValue = NSStringFromStd(newProps.selectedValue, @"");
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Colors arrive as SharedColor (already processed by React Native)
|
|
209
|
+
if (!prevProps || newProps.activeTintColor != prevProps->activeTintColor) {
|
|
210
|
+
_view.activeTintColor = RCTUIColorFromSharedColor(newProps.activeTintColor);
|
|
211
|
+
}
|
|
212
|
+
if (!prevProps || newProps.inactiveTintColor != prevProps->inactiveTintColor) {
|
|
213
|
+
_view.inactiveTintColor = RCTUIColorFromSharedColor(newProps.inactiveTintColor);
|
|
214
|
+
}
|
|
215
|
+
if (!prevProps || newProps.railColor != prevProps->railColor) {
|
|
216
|
+
_view.railColor = RCTUIColorFromSharedColor(newProps.railColor);
|
|
217
|
+
}
|
|
218
|
+
if (!prevProps || newProps.badgeBackgroundColor != prevProps->badgeBackgroundColor) {
|
|
219
|
+
_view.badgeBackgroundColor = RCTUIColorFromSharedColor(newProps.badgeBackgroundColor);
|
|
220
|
+
}
|
|
221
|
+
if (!prevProps || newProps.badgeTextColor != prevProps->badgeTextColor) {
|
|
222
|
+
_view.badgeTextColor = RCTUIColorFromSharedColor(newProps.badgeTextColor);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (!prevProps || !LabelStyleEqual(newProps.labelStyle, prevProps->labelStyle) ||
|
|
226
|
+
newProps.maxFontSizeMultiplier != prevProps->maxFontSizeMultiplier) {
|
|
227
|
+
_view.labelFont = FontFromLabelStyle(newProps.labelStyle, newProps.maxFontSizeMultiplier);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// items' systemItem: TabBar only
|
|
231
|
+
if (!prevProps || newProps.haptics != prevProps->haptics) {
|
|
232
|
+
_view.haptics.kind = NSStringFromStd(newProps.haptics, @"");
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// androidIndicatorColor / androidRippleColor: Android only
|
|
236
|
+
|
|
237
|
+
[super updateProps:props oldProps:oldProps];
|
|
238
|
+
|
|
239
|
+
[self updateMeasurements];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
#pragma mark - State (Measuring)
|
|
243
|
+
|
|
244
|
+
- (void)updateState:(const State::Shared &)state
|
|
245
|
+
oldState:(const State::Shared &)oldState {
|
|
246
|
+
_state = std::static_pointer_cast<const MeasuringPCNavigationRailShadowNode::ConcreteState>(state);
|
|
247
|
+
|
|
248
|
+
if (oldState == nullptr) {
|
|
249
|
+
[self updateMeasurements];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
[super updateState:state oldState:oldState];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
- (void)updateMeasurements {
|
|
256
|
+
if (_state == nullptr) return;
|
|
257
|
+
|
|
258
|
+
// The rail's natural width; the height is the app's
|
|
259
|
+
PCNavigationRailStateFrameSize next;
|
|
260
|
+
next.frameSize = {(Float)[_view naturalWidth], 0};
|
|
261
|
+
if (_state->getData() != next) {
|
|
262
|
+
_state->updateState(std::move(next));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@end
|
|
267
|
+
|
|
268
|
+
Class<RCTComponentViewProtocol> PCNavigationRailCls(void) {
|
|
269
|
+
return PCNavigationRail.class;
|
|
270
|
+
}
|