react-native-acoustic-connect-beta 18.0.7 → 18.0.8
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/Examples/SampleUI/.bundle/config +2 -0
- package/Examples/SampleUI/.eslintrc.js +4 -0
- package/Examples/SampleUI/.prettierrc.js +7 -0
- package/Examples/SampleUI/.watchmanconfig +1 -0
- package/Examples/SampleUI/App.js +1 -0
- package/Examples/SampleUI/Gemfile +10 -0
- package/Examples/SampleUI/Gemfile.lock +121 -0
- package/Examples/SampleUI/README.md +79 -0
- package/Examples/SampleUI/__tests__/App.test.tsx +17 -0
- package/Examples/SampleUI/android/app/build.gradle +124 -0
- package/Examples/SampleUI/android/app/debug.keystore +0 -0
- package/Examples/SampleUI/android/app/proguard-rules.pro +10 -0
- package/Examples/SampleUI/android/app/src/debug/AndroidManifest.xml +9 -0
- package/Examples/SampleUI/android/app/src/main/AndroidManifest.xml +26 -0
- package/Examples/SampleUI/android/app/src/main/java/com/sampleui/MainActivity.kt +23 -0
- package/Examples/SampleUI/android/app/src/main/java/com/sampleui/MainApplication.kt +53 -0
- package/Examples/SampleUI/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/Examples/SampleUI/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/Examples/SampleUI/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/Examples/SampleUI/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/Examples/SampleUI/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/Examples/SampleUI/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/Examples/SampleUI/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/Examples/SampleUI/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/Examples/SampleUI/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/Examples/SampleUI/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/Examples/SampleUI/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/Examples/SampleUI/android/app/src/main/res/values/strings.xml +3 -0
- package/Examples/SampleUI/android/app/src/main/res/values/styles.xml +9 -0
- package/Examples/SampleUI/android/build.gradle +21 -0
- package/Examples/SampleUI/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/Examples/SampleUI/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/Examples/SampleUI/android/gradle.properties +39 -0
- package/Examples/SampleUI/android/gradlew +252 -0
- package/Examples/SampleUI/android/gradlew.bat +94 -0
- package/Examples/SampleUI/android/settings.gradle +21 -0
- package/Examples/SampleUI/app.json +51 -0
- package/Examples/SampleUI/assets/fonts/Abel-Regular.ttf +0 -0
- package/Examples/SampleUI/assets/fonts/NotoSans-Regular.ttf +0 -0
- package/Examples/SampleUI/assets/images/android-icon.png +0 -0
- package/Examples/SampleUI/assets/images/artist-1.jpg +0 -0
- package/Examples/SampleUI/assets/images/artist-2.jpg +0 -0
- package/Examples/SampleUI/assets/images/avatar.png +0 -0
- package/Examples/SampleUI/assets/images/beach.jpg +0 -0
- package/Examples/SampleUI/assets/images/bridge.jpg +0 -0
- package/Examples/SampleUI/assets/images/chameleon.jpg +0 -0
- package/Examples/SampleUI/assets/images/city.jpg +0 -0
- package/Examples/SampleUI/assets/images/email-icon.png +0 -0
- package/Examples/SampleUI/assets/images/favorite.png +0 -0
- package/Examples/SampleUI/assets/images/forest.jpg +0 -0
- package/Examples/SampleUI/assets/images/paper-icon.png +0 -0
- package/Examples/SampleUI/assets/images/players-2.jpg +0 -0
- package/Examples/SampleUI/assets/images/players.jpg +0 -0
- package/Examples/SampleUI/assets/images/restaurant-1.jpg +0 -0
- package/Examples/SampleUI/assets/images/restaurant-2.jpg +0 -0
- package/Examples/SampleUI/assets/images/song-1.jpg +0 -0
- package/Examples/SampleUI/assets/images/song-2.jpg +0 -0
- package/Examples/SampleUI/assets/images/splash.png +0 -0
- package/Examples/SampleUI/assets/images/strawberries.jpg +0 -0
- package/Examples/SampleUI/assets/images/wrecked-ship.jpg +0 -0
- package/Examples/SampleUI/assets/styles/fonts.css +47 -0
- package/Examples/SampleUI/babel.config.js +22 -0
- package/Examples/SampleUI/index.js +9 -0
- package/Examples/SampleUI/ios/.xcode.env +11 -0
- package/Examples/SampleUI/ios/Podfile +58 -0
- package/Examples/SampleUI/ios/SampleUI/AppDelegate.h +7 -0
- package/Examples/SampleUI/ios/SampleUI/AppDelegate.mm +31 -0
- package/Examples/SampleUI/ios/SampleUI/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/Examples/SampleUI/ios/SampleUI/Images.xcassets/Contents.json +6 -0
- package/Examples/SampleUI/ios/SampleUI/Info.plist +52 -0
- package/Examples/SampleUI/ios/SampleUI/LaunchScreen.storyboard +47 -0
- package/Examples/SampleUI/ios/SampleUI/PrivacyInfo.xcprivacy +48 -0
- package/Examples/SampleUI/ios/SampleUI/main.m +10 -0
- package/Examples/SampleUI/ios/SampleUI.xcodeproj/project.pbxproj +785 -0
- package/Examples/SampleUI/ios/SampleUI.xcodeproj/xcshareddata/xcschemes/SampleUI.xcscheme +88 -0
- package/Examples/SampleUI/ios/SampleUI.xcworkspace/contents.xcworkspacedata +10 -0
- package/Examples/SampleUI/ios/SampleUITests/Info.plist +24 -0
- package/Examples/SampleUI/ios/SampleUITests/SampleUITests.m +66 -0
- package/Examples/SampleUI/jest.config.js +3 -0
- package/Examples/SampleUI/metro.config.js +53 -0
- package/Examples/SampleUI/package-lock.json +17033 -0
- package/Examples/SampleUI/package.json +62 -0
- package/Examples/SampleUI/src/DrawerItems.tsx +322 -0
- package/Examples/SampleUI/src/ExampleList.tsx +175 -0
- package/Examples/SampleUI/src/Examples/ActivityIndicatorExample.tsx +73 -0
- package/Examples/SampleUI/src/Examples/AnimatedFABExample/AnimatedFABExample.tsx +220 -0
- package/Examples/SampleUI/src/Examples/AnimatedFABExample/CustomFAB.tsx +70 -0
- package/Examples/SampleUI/src/Examples/AnimatedFABExample/CustomFABControls.tsx +146 -0
- package/Examples/SampleUI/src/Examples/AnimatedFABExample/index.ts +1 -0
- package/Examples/SampleUI/src/Examples/AppbarExample.tsx +263 -0
- package/Examples/SampleUI/src/Examples/AvatarExample.tsx +76 -0
- package/Examples/SampleUI/src/Examples/BadgeExample.tsx +97 -0
- package/Examples/SampleUI/src/Examples/BannerExample.tsx +152 -0
- package/Examples/SampleUI/src/Examples/BottomNavigationBarExample.tsx +94 -0
- package/Examples/SampleUI/src/Examples/BottomNavigationExample.tsx +205 -0
- package/Examples/SampleUI/src/Examples/ButtonExample.tsx +405 -0
- package/Examples/SampleUI/src/Examples/CardExample.tsx +245 -0
- package/Examples/SampleUI/src/Examples/CheckboxExample.tsx +87 -0
- package/Examples/SampleUI/src/Examples/CheckboxItemExample.tsx +72 -0
- package/Examples/SampleUI/src/Examples/ChipExample.tsx +432 -0
- package/Examples/SampleUI/src/Examples/DataTableExample.tsx +128 -0
- package/Examples/SampleUI/src/Examples/DialogExample.tsx +131 -0
- package/Examples/SampleUI/src/Examples/Dialogs/DialogTextComponent.tsx +31 -0
- package/Examples/SampleUI/src/Examples/Dialogs/DialogWithCustomColors.tsx +57 -0
- package/Examples/SampleUI/src/Examples/Dialogs/DialogWithDismissableBackButton.tsx +38 -0
- package/Examples/SampleUI/src/Examples/Dialogs/DialogWithIcon.tsx +42 -0
- package/Examples/SampleUI/src/Examples/Dialogs/DialogWithLoadingIndicator.tsx +48 -0
- package/Examples/SampleUI/src/Examples/Dialogs/DialogWithLongText.tsx +81 -0
- package/Examples/SampleUI/src/Examples/Dialogs/DialogWithRadioBtns.tsx +111 -0
- package/Examples/SampleUI/src/Examples/Dialogs/UndismissableDialog.tsx +30 -0
- package/Examples/SampleUI/src/Examples/Dialogs/index.tsx +7 -0
- package/Examples/SampleUI/src/Examples/DividerExample.tsx +30 -0
- package/Examples/SampleUI/src/Examples/FABExample.tsx +226 -0
- package/Examples/SampleUI/src/Examples/IconButtonExample.tsx +230 -0
- package/Examples/SampleUI/src/Examples/IconExample.tsx +50 -0
- package/Examples/SampleUI/src/Examples/ListAccordionExample.tsx +65 -0
- package/Examples/SampleUI/src/Examples/ListAccordionGroupExample.tsx +80 -0
- package/Examples/SampleUI/src/Examples/ListItemExample.tsx +310 -0
- package/Examples/SampleUI/src/Examples/ListSectionExample.tsx +159 -0
- package/Examples/SampleUI/src/Examples/MaterialBottomTabNavigatorExample.tsx +87 -0
- package/Examples/SampleUI/src/Examples/MenuExample.tsx +211 -0
- package/Examples/SampleUI/src/Examples/ProgressBarExample.tsx +142 -0
- package/Examples/SampleUI/src/Examples/RadioButtonExample.tsx +104 -0
- package/Examples/SampleUI/src/Examples/RadioButtonGroupExample.tsx +67 -0
- package/Examples/SampleUI/src/Examples/RadioButtonItemExample.tsx +77 -0
- package/Examples/SampleUI/src/Examples/SearchbarExample.tsx +249 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonCustomColorCheck.tsx +93 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonDefault.tsx +49 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonDisabled.tsx +47 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonMultiselect.tsx +50 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonMultiselectIcons.tsx +49 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonMultiselectRealCase.tsx +114 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonOnlyIcons.tsx +40 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonOnlyIconsWithCheck.tsx +43 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonRealCase.tsx +97 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonWithDensity.tsx +47 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/SegmentedButtonWithSelectedCheck.tsx +52 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtons/index.ts +9 -0
- package/Examples/SampleUI/src/Examples/SegmentedButtonsExample.tsx +57 -0
- package/Examples/SampleUI/src/Examples/SnackbarExample.tsx +141 -0
- package/Examples/SampleUI/src/Examples/SurfaceExample.tsx +130 -0
- package/Examples/SampleUI/src/Examples/SwitchExample.tsx +105 -0
- package/Examples/SampleUI/src/Examples/TeamDetails.tsx +291 -0
- package/Examples/SampleUI/src/Examples/TeamsList.tsx +57 -0
- package/Examples/SampleUI/src/Examples/TextExample.tsx +132 -0
- package/Examples/SampleUI/src/Examples/TextInputExample.tsx +914 -0
- package/Examples/SampleUI/src/Examples/ThemeExample.tsx +41 -0
- package/Examples/SampleUI/src/Examples/ThemingWithReactNavigation.tsx +75 -0
- package/Examples/SampleUI/src/Examples/ToggleButtonExample.tsx +128 -0
- package/Examples/SampleUI/src/Examples/TooltipExample.tsx +191 -0
- package/Examples/SampleUI/src/Examples/TouchableRippleExample.tsx +37 -0
- package/Examples/SampleUI/src/RootNavigator.tsx +86 -0
- package/Examples/SampleUI/src/ScreenWrapper.tsx +67 -0
- package/Examples/SampleUI/src/components/ActivityIndicator.tsx +254 -0
- package/Examples/SampleUI/src/components/Appbar/Appbar.tsx +364 -0
- package/Examples/SampleUI/src/components/Appbar/AppbarAction.tsx +132 -0
- package/Examples/SampleUI/src/components/Appbar/AppbarBackAction.tsx +77 -0
- package/Examples/SampleUI/src/components/Appbar/AppbarBackIcon.tsx +52 -0
- package/Examples/SampleUI/src/components/Appbar/AppbarContent.tsx +249 -0
- package/Examples/SampleUI/src/components/Appbar/AppbarHeader.tsx +174 -0
- package/Examples/SampleUI/src/components/Appbar/index.ts +22 -0
- package/Examples/SampleUI/src/components/Appbar/utils.ts +188 -0
- package/Examples/SampleUI/src/components/Avatar/Avatar.tsx +8 -0
- package/Examples/SampleUI/src/components/Avatar/AvatarIcon.tsx +87 -0
- package/Examples/SampleUI/src/components/Avatar/AvatarImage.tsx +128 -0
- package/Examples/SampleUI/src/components/Avatar/AvatarText.tsx +127 -0
- package/Examples/SampleUI/src/components/Badge.tsx +138 -0
- package/Examples/SampleUI/src/components/Banner.tsx +302 -0
- package/Examples/SampleUI/src/components/BottomNavigation/BottomNavigation.tsx +643 -0
- package/Examples/SampleUI/src/components/BottomNavigation/BottomNavigationBar.tsx +1039 -0
- package/Examples/SampleUI/src/components/BottomNavigation/BottomNavigationRouteScreen.tsx +31 -0
- package/Examples/SampleUI/src/components/BottomNavigation/utils.ts +70 -0
- package/Examples/SampleUI/src/components/Button/Button.tsx +503 -0
- package/Examples/SampleUI/src/components/Button/utils.tsx +272 -0
- package/Examples/SampleUI/src/components/Card/Card.tsx +373 -0
- package/Examples/SampleUI/src/components/Card/CardActions.tsx +74 -0
- package/Examples/SampleUI/src/components/Card/CardContent.tsx +99 -0
- package/Examples/SampleUI/src/components/Card/CardCover.tsx +96 -0
- package/Examples/SampleUI/src/components/Card/CardTitle.tsx +236 -0
- package/Examples/SampleUI/src/components/Card/utils.tsx +110 -0
- package/Examples/SampleUI/src/components/Checkbox/Checkbox.tsx +78 -0
- package/Examples/SampleUI/src/components/Checkbox/CheckboxAndroid.tsx +180 -0
- package/Examples/SampleUI/src/components/Checkbox/CheckboxIOS.tsx +104 -0
- package/Examples/SampleUI/src/components/Checkbox/CheckboxItem.tsx +236 -0
- package/Examples/SampleUI/src/components/Checkbox/index.ts +19 -0
- package/Examples/SampleUI/src/components/Checkbox/utils.ts +183 -0
- package/Examples/SampleUI/src/components/Chip/Chip.tsx +513 -0
- package/Examples/SampleUI/src/components/Chip/helpers.tsx +322 -0
- package/Examples/SampleUI/src/components/CrossFadeIcon.tsx +140 -0
- package/Examples/SampleUI/src/components/DataTable/DataTable.tsx +138 -0
- package/Examples/SampleUI/src/components/DataTable/DataTableCell.tsx +132 -0
- package/Examples/SampleUI/src/components/DataTable/DataTableHeader.tsx +82 -0
- package/Examples/SampleUI/src/components/DataTable/DataTablePagination.tsx +407 -0
- package/Examples/SampleUI/src/components/DataTable/DataTableRow.tsx +107 -0
- package/Examples/SampleUI/src/components/DataTable/DataTableTitle.tsx +208 -0
- package/Examples/SampleUI/src/components/Dialog/Dialog.tsx +191 -0
- package/Examples/SampleUI/src/components/Dialog/DialogActions.tsx +94 -0
- package/Examples/SampleUI/src/components/Dialog/DialogContent.tsx +54 -0
- package/Examples/SampleUI/src/components/Dialog/DialogIcon.tsx +100 -0
- package/Examples/SampleUI/src/components/Dialog/DialogScrollArea.tsx +88 -0
- package/Examples/SampleUI/src/components/Dialog/DialogTitle.tsx +94 -0
- package/Examples/SampleUI/src/components/Divider.tsx +102 -0
- package/Examples/SampleUI/src/components/Drawer/Drawer.tsx +8 -0
- package/Examples/SampleUI/src/components/Drawer/DrawerCollapsedItem.tsx +282 -0
- package/Examples/SampleUI/src/components/Drawer/DrawerItem.tsx +209 -0
- package/Examples/SampleUI/src/components/Drawer/DrawerSection.tsx +138 -0
- package/Examples/SampleUI/src/components/FAB/AnimatedFAB.tsx +619 -0
- package/Examples/SampleUI/src/components/FAB/FAB.tsx +371 -0
- package/Examples/SampleUI/src/components/FAB/FABGroup.tsx +532 -0
- package/Examples/SampleUI/src/components/FAB/index.ts +13 -0
- package/Examples/SampleUI/src/components/FAB/utils.ts +474 -0
- package/Examples/SampleUI/src/components/HelperText/HelperText.tsx +168 -0
- package/Examples/SampleUI/src/components/HelperText/utils.ts +30 -0
- package/Examples/SampleUI/src/components/Icon.tsx +170 -0
- package/Examples/SampleUI/src/components/IconButton/IconButton.tsx +234 -0
- package/Examples/SampleUI/src/components/IconButton/utils.ts +190 -0
- package/Examples/SampleUI/src/components/List/List.tsx +20 -0
- package/Examples/SampleUI/src/components/List/ListAccordion.tsx +391 -0
- package/Examples/SampleUI/src/components/List/ListAccordionGroup.tsx +88 -0
- package/Examples/SampleUI/src/components/List/ListIcon.tsx +79 -0
- package/Examples/SampleUI/src/components/List/ListImage.tsx +89 -0
- package/Examples/SampleUI/src/components/List/ListItem.tsx +313 -0
- package/Examples/SampleUI/src/components/List/ListSection.tsx +87 -0
- package/Examples/SampleUI/src/components/List/ListSubheader.tsx +79 -0
- package/Examples/SampleUI/src/components/List/utils.ts +113 -0
- package/Examples/SampleUI/src/components/MaterialCommunityIcon.tsx +121 -0
- package/Examples/SampleUI/src/components/Menu/Menu.tsx +711 -0
- package/Examples/SampleUI/src/components/Menu/MenuItem.tsx +257 -0
- package/Examples/SampleUI/src/components/Menu/utils.ts +110 -0
- package/Examples/SampleUI/src/components/Modal.tsx +245 -0
- package/Examples/SampleUI/src/components/Portal/Portal.tsx +69 -0
- package/Examples/SampleUI/src/components/Portal/PortalConsumer.tsx +44 -0
- package/Examples/SampleUI/src/components/Portal/PortalHost.tsx +143 -0
- package/Examples/SampleUI/src/components/Portal/PortalManager.tsx +54 -0
- package/Examples/SampleUI/src/components/ProgressBar.tsx +292 -0
- package/Examples/SampleUI/src/components/RadioButton/RadioButton.tsx +86 -0
- package/Examples/SampleUI/src/components/RadioButton/RadioButtonAndroid.tsx +202 -0
- package/Examples/SampleUI/src/components/RadioButton/RadioButtonGroup.tsx +67 -0
- package/Examples/SampleUI/src/components/RadioButton/RadioButtonIOS.tsx +130 -0
- package/Examples/SampleUI/src/components/RadioButton/RadioButtonItem.tsx +268 -0
- package/Examples/SampleUI/src/components/RadioButton/index.ts +22 -0
- package/Examples/SampleUI/src/components/RadioButton/utils.ts +37 -0
- package/Examples/SampleUI/src/components/Searchbar.tsx +459 -0
- package/Examples/SampleUI/src/components/SegmentedButtons/SegmentedButtonItem.tsx +271 -0
- package/Examples/SampleUI/src/components/SegmentedButtons/SegmentedButtons.tsx +197 -0
- package/Examples/SampleUI/src/components/SegmentedButtons/utils.ts +179 -0
- package/Examples/SampleUI/src/components/Snackbar.tsx +430 -0
- package/Examples/SampleUI/src/components/Surface.tsx +376 -0
- package/Examples/SampleUI/src/components/Switch/Switch.tsx +108 -0
- package/Examples/SampleUI/src/components/Switch/utils.ts +113 -0
- package/Examples/SampleUI/src/components/TextInput/Addons/Outline.tsx +64 -0
- package/Examples/SampleUI/src/components/TextInput/Addons/Underline.tsx +78 -0
- package/Examples/SampleUI/src/components/TextInput/Adornment/TextInputAdornment.tsx +208 -0
- package/Examples/SampleUI/src/components/TextInput/Adornment/TextInputAffix.tsx +212 -0
- package/Examples/SampleUI/src/components/TextInput/Adornment/TextInputIcon.tsx +195 -0
- package/Examples/SampleUI/src/components/TextInput/Adornment/enums.tsx +12 -0
- package/Examples/SampleUI/src/components/TextInput/Adornment/types.tsx +11 -0
- package/Examples/SampleUI/src/components/TextInput/Adornment/utils.ts +48 -0
- package/Examples/SampleUI/src/components/TextInput/Label/InputLabel.tsx +217 -0
- package/Examples/SampleUI/src/components/TextInput/Label/LabelBackground.tsx +100 -0
- package/Examples/SampleUI/src/components/TextInput/TextInput.tsx +572 -0
- package/Examples/SampleUI/src/components/TextInput/TextInputFlat.tsx +475 -0
- package/Examples/SampleUI/src/components/TextInput/TextInputOutlined.tsx +450 -0
- package/Examples/SampleUI/src/components/TextInput/constants.tsx +48 -0
- package/Examples/SampleUI/src/components/TextInput/helpers.tsx +612 -0
- package/Examples/SampleUI/src/components/TextInput/types.tsx +155 -0
- package/Examples/SampleUI/src/components/ToggleButton/ToggleButton.tsx +187 -0
- package/Examples/SampleUI/src/components/ToggleButton/ToggleButtonGroup.tsx +72 -0
- package/Examples/SampleUI/src/components/ToggleButton/ToggleButtonRow.tsx +107 -0
- package/Examples/SampleUI/src/components/ToggleButton/index.ts +16 -0
- package/Examples/SampleUI/src/components/ToggleButton/utils.ts +26 -0
- package/Examples/SampleUI/src/components/Tooltip/Tooltip.tsx +249 -0
- package/Examples/SampleUI/src/components/Tooltip/utils.ts +129 -0
- package/Examples/SampleUI/src/components/TouchableRipple/Pressable.tsx +41 -0
- package/Examples/SampleUI/src/components/TouchableRipple/TouchableRipple.native.tsx +145 -0
- package/Examples/SampleUI/src/components/TouchableRipple/TouchableRipple.tsx +317 -0
- package/Examples/SampleUI/src/components/TouchableRipple/utils.ts +66 -0
- package/Examples/SampleUI/src/components/Typography/AnimatedText.tsx +107 -0
- package/Examples/SampleUI/src/components/Typography/Text.tsx +184 -0
- package/Examples/SampleUI/src/components/Typography/types.tsx +5 -0
- package/Examples/SampleUI/src/components/Typography/v2/Caption.tsx +50 -0
- package/Examples/SampleUI/src/components/Typography/v2/Headline.tsx +52 -0
- package/Examples/SampleUI/src/components/Typography/v2/Paragraph.tsx +49 -0
- package/Examples/SampleUI/src/components/Typography/v2/StyledText.tsx +56 -0
- package/Examples/SampleUI/src/components/Typography/v2/Subheading.tsx +50 -0
- package/Examples/SampleUI/src/components/Typography/v2/Text.tsx +62 -0
- package/Examples/SampleUI/src/components/Typography/v2/Title.tsx +49 -0
- package/Examples/SampleUI/src/components/Typography/v2/index.ts +5 -0
- package/Examples/SampleUI/src/core/PaperProvider.tsx +122 -0
- package/Examples/SampleUI/src/core/SafeAreaProviderCompat.tsx +65 -0
- package/Examples/SampleUI/src/core/settings.tsx +23 -0
- package/Examples/SampleUI/src/core/theming.tsx +170 -0
- package/Examples/SampleUI/src/index.native.tsx +270 -0
- package/Examples/SampleUI/src/index.tsx +226 -0
- package/Examples/SampleUI/src/react-navigation/index.tsx +19 -0
- package/Examples/SampleUI/src/react-navigation/navigators/createMaterialBottomTabNavigator.tsx +72 -0
- package/Examples/SampleUI/src/react-navigation/types.tsx +126 -0
- package/Examples/SampleUI/src/react-navigation/views/MaterialBottomTabView.tsx +140 -0
- package/Examples/SampleUI/src/styles/__tests__/fonts.test.js +290 -0
- package/Examples/SampleUI/src/styles/fonts.tsx +143 -0
- package/Examples/SampleUI/src/styles/overlay.tsx +70 -0
- package/Examples/SampleUI/src/styles/shadow.tsx +109 -0
- package/Examples/SampleUI/src/styles/themes/index.ts +4 -0
- package/Examples/SampleUI/src/styles/themes/v2/DarkTheme.tsx +30 -0
- package/Examples/SampleUI/src/styles/themes/v2/LightTheme.tsx +30 -0
- package/Examples/SampleUI/src/styles/themes/v2/colors.tsx +277 -0
- package/Examples/SampleUI/src/styles/themes/v3/DarkTheme.tsx +66 -0
- package/Examples/SampleUI/src/styles/themes/v3/LightTheme.tsx +69 -0
- package/Examples/SampleUI/src/styles/themes/v3/tokens.tsx +230 -0
- package/Examples/SampleUI/src/utils/BackHandler/BackHandler.native.tsx +3 -0
- package/Examples/SampleUI/src/utils/BackHandler/BackHandler.tsx +11 -0
- package/Examples/SampleUI/src/utils/addEventListener.tsx +56 -0
- package/Examples/SampleUI/src/utils/forwardRef.tsx +23 -0
- package/Examples/SampleUI/src/utils/getContrastingColor.tsx +15 -0
- package/Examples/SampleUI/src/utils/hasTouchHandler.tsx +23 -0
- package/Examples/SampleUI/src/utils/roundLayoutSize.ts +2 -0
- package/Examples/SampleUI/src/utils/splitStyles.ts +60 -0
- package/Examples/SampleUI/src/utils/useAnimatedValue.tsx +9 -0
- package/Examples/SampleUI/src/utils/useAnimatedValueArray.tsx +13 -0
- package/Examples/SampleUI/src/utils/useIsKeyboardShown.tsx +55 -0
- package/Examples/SampleUI/src/utils/useLayout.tsx +29 -0
- package/Examples/SampleUI/src/utils/useLazyRef.tsx +11 -0
- package/Examples/SampleUI/tsconfig.json +3 -0
- package/Examples/SampleUI/utils/index.ts +1426 -0
- package/lib/typescript/jslib/TLTRN.d.ts +5 -5
- package/lib/typescript/jslib/TLTRN.d.ts.map +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
TextInput as NativeTextInput,
|
|
4
|
+
Animated,
|
|
5
|
+
TextStyle,
|
|
6
|
+
LayoutChangeEvent,
|
|
7
|
+
ColorValue,
|
|
8
|
+
StyleProp,
|
|
9
|
+
ViewProps,
|
|
10
|
+
ViewStyle,
|
|
11
|
+
NativeSyntheticEvent,
|
|
12
|
+
TextLayoutEventData,
|
|
13
|
+
} from 'react-native';
|
|
14
|
+
|
|
15
|
+
import type { $Omit, InternalTheme, ThemeProp } from './../../types';
|
|
16
|
+
|
|
17
|
+
export type TextInputLabelProp = string | React.ReactElement;
|
|
18
|
+
|
|
19
|
+
type TextInputProps = React.ComponentPropsWithRef<typeof NativeTextInput> & {
|
|
20
|
+
mode?: 'flat' | 'outlined';
|
|
21
|
+
left?: React.ReactNode;
|
|
22
|
+
right?: React.ReactNode;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
label?: TextInputLabelProp;
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
error?: boolean;
|
|
27
|
+
onChangeText?: Function;
|
|
28
|
+
selectionColor?: string;
|
|
29
|
+
cursorColor?: string;
|
|
30
|
+
underlineColor?: string;
|
|
31
|
+
activeUnderlineColor?: string;
|
|
32
|
+
outlineColor?: string;
|
|
33
|
+
activeOutlineColor?: string;
|
|
34
|
+
textColor?: string;
|
|
35
|
+
dense?: boolean;
|
|
36
|
+
multiline?: boolean;
|
|
37
|
+
numberOfLines?: number;
|
|
38
|
+
onFocus?: (args: any) => void;
|
|
39
|
+
onBlur?: (args: any) => void;
|
|
40
|
+
render?: (props: RenderProps) => React.ReactNode;
|
|
41
|
+
value?: string;
|
|
42
|
+
style?: StyleProp<TextStyle>;
|
|
43
|
+
theme?: ThemeProp;
|
|
44
|
+
testID?: string;
|
|
45
|
+
contentStyle?: StyleProp<TextStyle>;
|
|
46
|
+
outlineStyle?: StyleProp<ViewStyle>;
|
|
47
|
+
underlineStyle?: StyleProp<ViewStyle>;
|
|
48
|
+
scaledLabel?: boolean;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type RenderProps = {
|
|
52
|
+
ref: (a?: NativeTextInput | null) => void;
|
|
53
|
+
onChangeText?: (a: string) => void;
|
|
54
|
+
placeholder?: string;
|
|
55
|
+
placeholderTextColor?: ColorValue;
|
|
56
|
+
editable?: boolean;
|
|
57
|
+
selectionColor?: string;
|
|
58
|
+
cursorColor?: string;
|
|
59
|
+
onFocus?: (args: any) => void;
|
|
60
|
+
onBlur?: (args: any) => void;
|
|
61
|
+
underlineColorAndroid?: string;
|
|
62
|
+
onLayout?: (args: any) => void;
|
|
63
|
+
style: any;
|
|
64
|
+
multiline?: boolean;
|
|
65
|
+
numberOfLines?: number;
|
|
66
|
+
value?: string;
|
|
67
|
+
adjustsFontSizeToFit?: boolean;
|
|
68
|
+
testID?: string;
|
|
69
|
+
};
|
|
70
|
+
type TextInputTypesWithoutMode = $Omit<TextInputProps, 'mode'>;
|
|
71
|
+
export type State = {
|
|
72
|
+
labeled: Animated.Value;
|
|
73
|
+
error: Animated.Value;
|
|
74
|
+
focused: boolean;
|
|
75
|
+
displayPlaceholder: boolean;
|
|
76
|
+
value?: string;
|
|
77
|
+
labelTextLayout: { width: number };
|
|
78
|
+
labelLayout: { measured: boolean; width: number; height: number };
|
|
79
|
+
leftLayout: { height: number | null; width: number | null };
|
|
80
|
+
rightLayout: { height: number | null; width: number | null };
|
|
81
|
+
inputContainerLayout: { width: number };
|
|
82
|
+
contentStyle?: StyleProp<ViewProps>;
|
|
83
|
+
};
|
|
84
|
+
export type ChildTextInputProps = {
|
|
85
|
+
parentState: State;
|
|
86
|
+
innerRef: (ref?: NativeTextInput | null) => void;
|
|
87
|
+
onFocus?: (args: any) => void;
|
|
88
|
+
onBlur?: (args: any) => void;
|
|
89
|
+
forceFocus: () => void;
|
|
90
|
+
onChangeText?: (value: string) => void;
|
|
91
|
+
onInputLayout: (event: LayoutChangeEvent) => void;
|
|
92
|
+
onLayoutAnimatedText: (args: any) => void;
|
|
93
|
+
onLabelTextLayout: (event: NativeSyntheticEvent<TextLayoutEventData>) => void;
|
|
94
|
+
onLeftAffixLayoutChange: (event: LayoutChangeEvent) => void;
|
|
95
|
+
onRightAffixLayoutChange: (event: LayoutChangeEvent) => void;
|
|
96
|
+
} & $Omit<TextInputTypesWithoutMode, 'theme'> & { theme: InternalTheme };
|
|
97
|
+
|
|
98
|
+
export type LabelProps = {
|
|
99
|
+
mode?: 'flat' | 'outlined';
|
|
100
|
+
placeholderStyle: any;
|
|
101
|
+
placeholderOpacity:
|
|
102
|
+
| number
|
|
103
|
+
| Animated.Value
|
|
104
|
+
| Animated.AnimatedInterpolation<number>;
|
|
105
|
+
baseLabelTranslateX: number;
|
|
106
|
+
baseLabelTranslateY: number;
|
|
107
|
+
wiggleOffsetX: number;
|
|
108
|
+
labelScale: number;
|
|
109
|
+
fontSize: number;
|
|
110
|
+
lineHeight?: number | undefined;
|
|
111
|
+
fontWeight: TextStyle['fontWeight'];
|
|
112
|
+
font: any;
|
|
113
|
+
topPosition: number;
|
|
114
|
+
paddingLeft?: number;
|
|
115
|
+
paddingRight?: number;
|
|
116
|
+
labelTranslationXOffset?: number;
|
|
117
|
+
placeholderColor: string | null;
|
|
118
|
+
backgroundColor?: ColorValue;
|
|
119
|
+
label?: TextInputLabelProp | null;
|
|
120
|
+
hasActiveOutline?: boolean | null;
|
|
121
|
+
activeColor: string;
|
|
122
|
+
errorColor?: string;
|
|
123
|
+
labelError?: boolean | null;
|
|
124
|
+
onLayoutAnimatedText: (args: any) => void;
|
|
125
|
+
onLabelTextLayout: (event: NativeSyntheticEvent<TextLayoutEventData>) => void;
|
|
126
|
+
roundness: number;
|
|
127
|
+
maxFontSizeMultiplier?: number | undefined | null;
|
|
128
|
+
testID?: string;
|
|
129
|
+
contentStyle?: StyleProp<ViewProps>;
|
|
130
|
+
theme?: ThemeProp;
|
|
131
|
+
};
|
|
132
|
+
export type InputLabelProps = {
|
|
133
|
+
labeled: Animated.Value;
|
|
134
|
+
error: Animated.Value;
|
|
135
|
+
focused: boolean;
|
|
136
|
+
wiggle: boolean;
|
|
137
|
+
opacity: number;
|
|
138
|
+
labelLayoutMeasured: boolean;
|
|
139
|
+
labelLayoutWidth: number;
|
|
140
|
+
labelLayoutHeight: number;
|
|
141
|
+
inputContainerLayout: { width: number };
|
|
142
|
+
labelBackground?: any;
|
|
143
|
+
maxFontSizeMultiplier?: number | undefined | null;
|
|
144
|
+
isV3?: boolean;
|
|
145
|
+
scaledLabel?: boolean;
|
|
146
|
+
} & LabelProps;
|
|
147
|
+
|
|
148
|
+
export type LabelBackgroundProps = {
|
|
149
|
+
labelStyle: any;
|
|
150
|
+
labeled: Animated.Value;
|
|
151
|
+
labelLayoutWidth: number;
|
|
152
|
+
labelLayoutHeight: number;
|
|
153
|
+
maxFontSizeMultiplier?: number | undefined | null;
|
|
154
|
+
theme?: ThemeProp;
|
|
155
|
+
} & LabelProps;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
GestureResponderEvent,
|
|
4
|
+
StyleProp,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
View,
|
|
8
|
+
Animated,
|
|
9
|
+
ColorValue,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
|
|
12
|
+
import color from 'color';
|
|
13
|
+
|
|
14
|
+
import { ToggleButtonGroupContext } from './ToggleButtonGroup';
|
|
15
|
+
import { getToggleButtonColor } from './utils';
|
|
16
|
+
import { useInternalTheme } from '../../core/theming';
|
|
17
|
+
import { black, white } from '../../styles/themes/v2/colors';
|
|
18
|
+
import type { ThemeProp } from '../../types';
|
|
19
|
+
import { forwardRef } from '../../utils/forwardRef';
|
|
20
|
+
import type { IconSource } from '../Icon';
|
|
21
|
+
import IconButton from '../IconButton/IconButton';
|
|
22
|
+
|
|
23
|
+
export type Props = {
|
|
24
|
+
/**
|
|
25
|
+
* Icon to display for the `ToggleButton`.
|
|
26
|
+
*/
|
|
27
|
+
icon: IconSource;
|
|
28
|
+
/**
|
|
29
|
+
* Size of the icon.
|
|
30
|
+
*/
|
|
31
|
+
size?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Custom text color for button.
|
|
34
|
+
*/
|
|
35
|
+
iconColor?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Color of the ripple effect.
|
|
38
|
+
*/
|
|
39
|
+
rippleColor?: ColorValue;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the button is disabled.
|
|
42
|
+
*/
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Accessibility label for the `ToggleButton`. This is read by the screen reader when the user taps the button.
|
|
46
|
+
*/
|
|
47
|
+
accessibilityLabel?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Function to execute on press.
|
|
50
|
+
*/
|
|
51
|
+
onPress?: (value?: GestureResponderEvent | string) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Value of button.
|
|
54
|
+
*/
|
|
55
|
+
value?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Status of button.
|
|
58
|
+
*/
|
|
59
|
+
status?: 'checked' | 'unchecked';
|
|
60
|
+
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
|
|
61
|
+
/**
|
|
62
|
+
* @optional
|
|
63
|
+
*/
|
|
64
|
+
theme?: ThemeProp;
|
|
65
|
+
ref?: React.RefObject<View>;
|
|
66
|
+
/**
|
|
67
|
+
* testID to be used on tests.
|
|
68
|
+
*/
|
|
69
|
+
testID?: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Toggle buttons can be used to group related options. To emphasize groups of related toggle buttons,
|
|
74
|
+
* a group should share a common container.
|
|
75
|
+
*
|
|
76
|
+
* ## Usage
|
|
77
|
+
* ```js
|
|
78
|
+
* import * as React from 'react';
|
|
79
|
+
* import { ToggleButton } from 'react-native-paper';
|
|
80
|
+
*
|
|
81
|
+
* const ToggleButtonExample = () => {
|
|
82
|
+
* const [status, setStatus] = React.useState('checked');
|
|
83
|
+
*
|
|
84
|
+
* const onButtonToggle = value => {
|
|
85
|
+
* setStatus(status === 'checked' ? 'unchecked' : 'checked');
|
|
86
|
+
* };
|
|
87
|
+
*
|
|
88
|
+
* return (
|
|
89
|
+
* <ToggleButton
|
|
90
|
+
* icon="bluetooth"
|
|
91
|
+
* value="bluetooth"
|
|
92
|
+
* status={status}
|
|
93
|
+
* onPress={onButtonToggle}
|
|
94
|
+
* />
|
|
95
|
+
* );
|
|
96
|
+
* };
|
|
97
|
+
*
|
|
98
|
+
* export default ToggleButtonExample;
|
|
99
|
+
*
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
const ToggleButton = forwardRef<View, Props>(
|
|
103
|
+
(
|
|
104
|
+
{
|
|
105
|
+
icon,
|
|
106
|
+
size,
|
|
107
|
+
theme: themeOverrides,
|
|
108
|
+
accessibilityLabel,
|
|
109
|
+
disabled,
|
|
110
|
+
style,
|
|
111
|
+
value,
|
|
112
|
+
status,
|
|
113
|
+
onPress,
|
|
114
|
+
rippleColor,
|
|
115
|
+
...rest
|
|
116
|
+
}: Props,
|
|
117
|
+
ref
|
|
118
|
+
) => {
|
|
119
|
+
const theme = useInternalTheme(themeOverrides);
|
|
120
|
+
const borderRadius = theme.roundness;
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<ToggleButtonGroupContext.Consumer>
|
|
124
|
+
{(
|
|
125
|
+
context: { value: string | null; onValueChange: Function } | null
|
|
126
|
+
) => {
|
|
127
|
+
const checked: boolean | null =
|
|
128
|
+
(context && context.value === value) || status === 'checked';
|
|
129
|
+
|
|
130
|
+
const backgroundColor = getToggleButtonColor({ theme, checked });
|
|
131
|
+
const borderColor = theme.isV3
|
|
132
|
+
? theme.colors.outline
|
|
133
|
+
: color(theme.dark ? white : black)
|
|
134
|
+
.alpha(0.29)
|
|
135
|
+
.rgb()
|
|
136
|
+
.string();
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<IconButton
|
|
140
|
+
borderless={false}
|
|
141
|
+
icon={icon}
|
|
142
|
+
onPress={(e?: GestureResponderEvent | string) => {
|
|
143
|
+
if (onPress) {
|
|
144
|
+
onPress(e);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (context) {
|
|
148
|
+
context.onValueChange(!checked ? value : null);
|
|
149
|
+
}
|
|
150
|
+
}}
|
|
151
|
+
size={size}
|
|
152
|
+
accessibilityLabel={accessibilityLabel}
|
|
153
|
+
accessibilityState={{ disabled, selected: checked }}
|
|
154
|
+
disabled={disabled}
|
|
155
|
+
style={[
|
|
156
|
+
styles.content,
|
|
157
|
+
{
|
|
158
|
+
backgroundColor,
|
|
159
|
+
borderRadius,
|
|
160
|
+
borderColor,
|
|
161
|
+
},
|
|
162
|
+
style,
|
|
163
|
+
]}
|
|
164
|
+
ref={ref}
|
|
165
|
+
theme={theme}
|
|
166
|
+
rippleColor={rippleColor}
|
|
167
|
+
{...rest}
|
|
168
|
+
/>
|
|
169
|
+
);
|
|
170
|
+
}}
|
|
171
|
+
</ToggleButtonGroupContext.Consumer>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const styles = StyleSheet.create({
|
|
177
|
+
content: {
|
|
178
|
+
width: 42,
|
|
179
|
+
height: 42,
|
|
180
|
+
margin: 0,
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
export default ToggleButton;
|
|
185
|
+
|
|
186
|
+
// @component-docs ignore-next-line
|
|
187
|
+
export { ToggleButton };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export type Props<Value = string> = {
|
|
4
|
+
/**
|
|
5
|
+
* Function to execute on selection change.
|
|
6
|
+
*/
|
|
7
|
+
onValueChange: (value: Value) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Value of the currently selected toggle button.
|
|
10
|
+
*/
|
|
11
|
+
value: Value | null;
|
|
12
|
+
/**
|
|
13
|
+
* React elements containing toggle buttons.
|
|
14
|
+
*/
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type ToggleButtonContextType<Value> = {
|
|
19
|
+
value: Value | null;
|
|
20
|
+
onValueChange: (item: Value) => void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const ToggleButtonGroupContext =
|
|
24
|
+
//@ts-expect-error: TS can't ensure the type from Group to children
|
|
25
|
+
React.createContext<ToggleButtonContextType>(null as any);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Toggle group allows to control a group of toggle buttons.</br>
|
|
29
|
+
* It doesn't change the appearance of the toggle buttons. If you want to group them in a row, check out [ToggleButton.Row](ToggleButtonRow).
|
|
30
|
+
*
|
|
31
|
+
* ## Usage
|
|
32
|
+
* ```js
|
|
33
|
+
* import * as React from 'react';
|
|
34
|
+
* import { ToggleButton } from 'react-native-paper';
|
|
35
|
+
*
|
|
36
|
+
* const MyComponent = () => {
|
|
37
|
+
* const [value, setValue] = React.useState('left');
|
|
38
|
+
*
|
|
39
|
+
* return (
|
|
40
|
+
* <ToggleButton.Group
|
|
41
|
+
* onValueChange={value => setValue(value)}
|
|
42
|
+
* value={value}>
|
|
43
|
+
* <ToggleButton icon="format-align-left" value="left" />
|
|
44
|
+
* <ToggleButton icon="format-align-right" value="right" />
|
|
45
|
+
* </ToggleButton.Group>
|
|
46
|
+
* );
|
|
47
|
+
* };
|
|
48
|
+
*
|
|
49
|
+
* export default MyComponent;
|
|
50
|
+
*```
|
|
51
|
+
*/
|
|
52
|
+
const ToggleButtonGroup = <Value = string,>({
|
|
53
|
+
value,
|
|
54
|
+
onValueChange,
|
|
55
|
+
children,
|
|
56
|
+
}: Props<Value>) => (
|
|
57
|
+
<ToggleButtonGroupContext.Provider
|
|
58
|
+
value={{
|
|
59
|
+
value,
|
|
60
|
+
onValueChange,
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</ToggleButtonGroupContext.Provider>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
ToggleButtonGroup.displayName = 'ToggleButton.Group';
|
|
68
|
+
|
|
69
|
+
export default ToggleButtonGroup;
|
|
70
|
+
|
|
71
|
+
// @component-docs ignore-next-line
|
|
72
|
+
export { ToggleButtonGroup };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { StyleSheet, View, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import ToggleButton from './ToggleButton';
|
|
5
|
+
import ToggleButtonGroup from './ToggleButtonGroup';
|
|
6
|
+
|
|
7
|
+
export type Props = {
|
|
8
|
+
/**
|
|
9
|
+
* Function to execute on selection change.
|
|
10
|
+
*/
|
|
11
|
+
onValueChange: (value: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Value of the currently selected toggle button.
|
|
14
|
+
*/
|
|
15
|
+
value: string;
|
|
16
|
+
/**
|
|
17
|
+
* React elements containing toggle buttons.
|
|
18
|
+
*/
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
style?: StyleProp<ViewStyle>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Toggle button row renders a group of toggle buttons in a row.
|
|
25
|
+
*
|
|
26
|
+
* ## Usage
|
|
27
|
+
* ```js
|
|
28
|
+
* import * as React from 'react';
|
|
29
|
+
* import { ToggleButton } from 'react-native-paper';
|
|
30
|
+
*
|
|
31
|
+
* const MyComponent = () => {
|
|
32
|
+
* const [value, setValue] = React.useState('left');
|
|
33
|
+
*
|
|
34
|
+
* return (
|
|
35
|
+
* <ToggleButton.Row onValueChange={value => setValue(value)} value={value}>
|
|
36
|
+
* <ToggleButton icon="format-align-left" value="left" />
|
|
37
|
+
* <ToggleButton icon="format-align-right" value="right" />
|
|
38
|
+
* </ToggleButton.Row>
|
|
39
|
+
* );
|
|
40
|
+
* };
|
|
41
|
+
*
|
|
42
|
+
* export default MyComponent;
|
|
43
|
+
*
|
|
44
|
+
*```
|
|
45
|
+
*/
|
|
46
|
+
const ToggleButtonRow = ({ value, onValueChange, children, style }: Props) => {
|
|
47
|
+
const count = React.Children.count(children);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<ToggleButtonGroup value={value} onValueChange={onValueChange}>
|
|
51
|
+
<View style={[styles.row, style]}>
|
|
52
|
+
{React.Children.map(children, (child, i) => {
|
|
53
|
+
// @ts-expect-error: TypeScript complains about child.type but it doesn't matter
|
|
54
|
+
if (child && child.type === ToggleButton) {
|
|
55
|
+
// @ts-expect-error: We're sure that child is a React Element
|
|
56
|
+
return React.cloneElement(child, {
|
|
57
|
+
style: [
|
|
58
|
+
styles.button,
|
|
59
|
+
i === 0
|
|
60
|
+
? styles.first
|
|
61
|
+
: i === count - 1
|
|
62
|
+
? styles.last
|
|
63
|
+
: styles.middle,
|
|
64
|
+
// @ts-expect-error: We're sure that child is a React Element
|
|
65
|
+
child.props.style,
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return child;
|
|
71
|
+
})}
|
|
72
|
+
</View>
|
|
73
|
+
</ToggleButtonGroup>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
ToggleButtonRow.displayName = 'ToggleButton.Row';
|
|
78
|
+
|
|
79
|
+
const styles = StyleSheet.create({
|
|
80
|
+
row: {
|
|
81
|
+
flexDirection: 'row',
|
|
82
|
+
},
|
|
83
|
+
button: {
|
|
84
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
first: {
|
|
88
|
+
borderTopRightRadius: 0,
|
|
89
|
+
borderBottomRightRadius: 0,
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
middle: {
|
|
93
|
+
borderRadius: 0,
|
|
94
|
+
borderLeftWidth: 0,
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
last: {
|
|
98
|
+
borderLeftWidth: 0,
|
|
99
|
+
borderTopLeftRadius: 0,
|
|
100
|
+
borderBottomLeftRadius: 0,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export default ToggleButtonRow;
|
|
105
|
+
|
|
106
|
+
// @component-docs ignore-next-line
|
|
107
|
+
export { ToggleButtonRow };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import ToggleButtonComponent from './ToggleButton';
|
|
2
|
+
import ToggleButtonGroup from './ToggleButtonGroup';
|
|
3
|
+
import ToggleButtonRow from './ToggleButtonRow';
|
|
4
|
+
|
|
5
|
+
const ToggleButton = Object.assign(
|
|
6
|
+
// @component ./ToggleButton.tsx
|
|
7
|
+
ToggleButtonComponent,
|
|
8
|
+
{
|
|
9
|
+
// @component ./ToggleButtonGroup.tsx
|
|
10
|
+
Group: ToggleButtonGroup,
|
|
11
|
+
// @component ./ToggleButtonRow.tsx
|
|
12
|
+
Row: ToggleButtonRow,
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export default ToggleButton;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import color from 'color';
|
|
2
|
+
|
|
3
|
+
import { tokens } from '../../styles/themes/v3/tokens';
|
|
4
|
+
import type { InternalTheme } from '../../types';
|
|
5
|
+
|
|
6
|
+
export const getToggleButtonColor = ({
|
|
7
|
+
theme,
|
|
8
|
+
checked,
|
|
9
|
+
}: {
|
|
10
|
+
theme: InternalTheme;
|
|
11
|
+
checked: boolean | null;
|
|
12
|
+
}) => {
|
|
13
|
+
if (checked) {
|
|
14
|
+
if (theme.isV3) {
|
|
15
|
+
return color(theme.colors.onSecondaryContainer)
|
|
16
|
+
.alpha(tokens.md.ref.opacity.level2)
|
|
17
|
+
.rgb()
|
|
18
|
+
.string();
|
|
19
|
+
}
|
|
20
|
+
if (theme.dark) {
|
|
21
|
+
return 'rgba(255, 255, 255, .12)';
|
|
22
|
+
}
|
|
23
|
+
return 'rgba(0, 0, 0, .08)';
|
|
24
|
+
}
|
|
25
|
+
return 'transparent';
|
|
26
|
+
};
|