From c2b01a34bd206ba7441b78da460afb4fab29fbcc Mon Sep 17 00:00:00 2001 From: Wojciech Lewicki Date: Wed, 16 Nov 2022 18:50:34 +0100 Subject: [PATCH 01/33] feat: add FabricExample app --- FabricExample/.buckconfig | 6 + FabricExample/.bundle/config | 2 + FabricExample/.eslintrc.js | 4 + FabricExample/.flowconfig | 66 + FabricExample/.gitignore | 64 + FabricExample/.prettierrc.js | 7 + FabricExample/.ruby-version | 1 + FabricExample/.watchmanconfig | 1 + FabricExample/App.tsx | 87 + FabricExample/Gemfile | 6 + FabricExample/PickerExample.tsx | 317 + FabricExample/PickerIOSExample.tsx | 168 + FabricExample/PickerWindowsExamples.js | 23 + FabricExample/__tests__/App-test.js | 14 + FabricExample/_node-version | 1 + FabricExample/android/app/_BUCK | 55 + FabricExample/android/app/build.gradle | 313 + FabricExample/android/app/build_defs.bzl | 19 + FabricExample/android/app/debug.keystore | Bin 0 -> 2257 bytes FabricExample/android/app/proguard-rules.pro | 10 + .../android/app/src/debug/AndroidManifest.xml | 13 + .../com/fabricexample/ReactNativeFlipper.java | 73 + .../android/app/src/main/AndroidManifest.xml | 26 + .../java/com/fabricexample/MainActivity.java | 48 + .../com/fabricexample/MainApplication.java | 91 + .../MainApplicationReactNativeHost.java | 116 + .../components/MainComponentsRegistry.java | 36 + ...ApplicationTurboModuleManagerDelegate.java | 48 + .../android/app/src/main/jni/CMakeLists.txt | 7 + .../jni/MainApplicationModuleProvider.cpp | 32 + .../main/jni/MainApplicationModuleProvider.h | 16 + ...nApplicationTurboModuleManagerDelegate.cpp | 45 + ...ainApplicationTurboModuleManagerDelegate.h | 38 + .../src/main/jni/MainComponentsRegistry.cpp | 65 + .../app/src/main/jni/MainComponentsRegistry.h | 32 + .../android/app/src/main/jni/OnLoad.cpp | 11 + .../res/drawable/rn_edit_text_material.xml | 36 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3056 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5024 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2096 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2858 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4569 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7098 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6464 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10676 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9250 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15523 bytes .../app/src/main/res/values/strings.xml | 3 + .../app/src/main/res/values/styles.xml | 9 + FabricExample/android/build.gradle | 51 + FabricExample/android/gradle.properties | 40 + .../android/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59821 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 + FabricExample/android/gradlew | 234 + FabricExample/android/gradlew.bat | 89 + FabricExample/android/settings.gradle | 11 + FabricExample/app.json | 4 + FabricExample/babel.config.js | 3 + FabricExample/index.js | 9 + .../FabricExample.xcodeproj/project.pbxproj | 702 ++ .../xcschemes/FabricExample.xcscheme | 88 + .../contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + FabricExample/ios/FabricExample/AppDelegate.h | 8 + .../ios/FabricExample/AppDelegate.mm | 133 + .../AppIcon.appiconset/Contents.json | 53 + .../Images.xcassets/Contents.json | 6 + FabricExample/ios/FabricExample/Info.plist | 55 + .../ios/FabricExample/LaunchScreen.storyboard | 47 + FabricExample/ios/FabricExample/main.m | 10 + .../FabricExampleTests/FabricExampleTests.m | 66 + .../ios/FabricExampleTests/Info.plist | 24 + FabricExample/ios/Podfile | 45 + FabricExample/ios/Podfile.lock | 938 +++ FabricExample/ios/_xcode.env | 11 + FabricExample/metro.config.js | 39 + FabricExample/package.json | 30 + FabricExample/yarn.lock | 6809 +++++++++++++++++ ios/RNCPicker.m | 140 - ios/RNCPickerLabel.m | 31 - ios/RNCPickerManager.m | 59 - 81 files changed, 11437 insertions(+), 230 deletions(-) create mode 100644 FabricExample/.buckconfig create mode 100644 FabricExample/.bundle/config create mode 100644 FabricExample/.eslintrc.js create mode 100644 FabricExample/.flowconfig create mode 100644 FabricExample/.gitignore create mode 100644 FabricExample/.prettierrc.js create mode 100644 FabricExample/.ruby-version create mode 100644 FabricExample/.watchmanconfig create mode 100644 FabricExample/App.tsx create mode 100644 FabricExample/Gemfile create mode 100644 FabricExample/PickerExample.tsx create mode 100644 FabricExample/PickerIOSExample.tsx create mode 100644 FabricExample/PickerWindowsExamples.js create mode 100644 FabricExample/__tests__/App-test.js create mode 100644 FabricExample/_node-version create mode 100644 FabricExample/android/app/_BUCK create mode 100644 FabricExample/android/app/build.gradle create mode 100644 FabricExample/android/app/build_defs.bzl create mode 100644 FabricExample/android/app/debug.keystore create mode 100644 FabricExample/android/app/proguard-rules.pro create mode 100644 FabricExample/android/app/src/debug/AndroidManifest.xml create mode 100644 FabricExample/android/app/src/debug/java/com/fabricexample/ReactNativeFlipper.java create mode 100644 FabricExample/android/app/src/main/AndroidManifest.xml create mode 100644 FabricExample/android/app/src/main/java/com/fabricexample/MainActivity.java create mode 100644 FabricExample/android/app/src/main/java/com/fabricexample/MainApplication.java create mode 100644 FabricExample/android/app/src/main/java/com/fabricexample/newarchitecture/MainApplicationReactNativeHost.java create mode 100644 FabricExample/android/app/src/main/java/com/fabricexample/newarchitecture/components/MainComponentsRegistry.java create mode 100644 FabricExample/android/app/src/main/java/com/fabricexample/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java create mode 100644 FabricExample/android/app/src/main/jni/CMakeLists.txt create mode 100644 FabricExample/android/app/src/main/jni/MainApplicationModuleProvider.cpp create mode 100644 FabricExample/android/app/src/main/jni/MainApplicationModuleProvider.h create mode 100644 FabricExample/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp create mode 100644 FabricExample/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h create mode 100644 FabricExample/android/app/src/main/jni/MainComponentsRegistry.cpp create mode 100644 FabricExample/android/app/src/main/jni/MainComponentsRegistry.h create mode 100644 FabricExample/android/app/src/main/jni/OnLoad.cpp create mode 100644 FabricExample/android/app/src/main/res/drawable/rn_edit_text_material.xml create mode 100644 FabricExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 FabricExample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 FabricExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 FabricExample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 FabricExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 FabricExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 FabricExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 FabricExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 FabricExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 FabricExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 FabricExample/android/app/src/main/res/values/strings.xml create mode 100644 FabricExample/android/app/src/main/res/values/styles.xml create mode 100644 FabricExample/android/build.gradle create mode 100644 FabricExample/android/gradle.properties create mode 100644 FabricExample/android/gradle/wrapper/gradle-wrapper.jar create mode 100644 FabricExample/android/gradle/wrapper/gradle-wrapper.properties create mode 100755 FabricExample/android/gradlew create mode 100644 FabricExample/android/gradlew.bat create mode 100644 FabricExample/android/settings.gradle create mode 100644 FabricExample/app.json create mode 100644 FabricExample/babel.config.js create mode 100644 FabricExample/index.js create mode 100644 FabricExample/ios/FabricExample.xcodeproj/project.pbxproj create mode 100644 FabricExample/ios/FabricExample.xcodeproj/xcshareddata/xcschemes/FabricExample.xcscheme create mode 100644 FabricExample/ios/FabricExample.xcworkspace/contents.xcworkspacedata create mode 100644 FabricExample/ios/FabricExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 FabricExample/ios/FabricExample/AppDelegate.h create mode 100644 FabricExample/ios/FabricExample/AppDelegate.mm create mode 100644 FabricExample/ios/FabricExample/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 FabricExample/ios/FabricExample/Images.xcassets/Contents.json create mode 100644 FabricExample/ios/FabricExample/Info.plist create mode 100644 FabricExample/ios/FabricExample/LaunchScreen.storyboard create mode 100644 FabricExample/ios/FabricExample/main.m create mode 100644 FabricExample/ios/FabricExampleTests/FabricExampleTests.m create mode 100644 FabricExample/ios/FabricExampleTests/Info.plist create mode 100644 FabricExample/ios/Podfile create mode 100644 FabricExample/ios/Podfile.lock create mode 100644 FabricExample/ios/_xcode.env create mode 100644 FabricExample/metro.config.js create mode 100644 FabricExample/package.json create mode 100644 FabricExample/yarn.lock delete mode 100644 ios/RNCPicker.m delete mode 100644 ios/RNCPickerLabel.m delete mode 100644 ios/RNCPickerManager.m diff --git a/FabricExample/.buckconfig b/FabricExample/.buckconfig new file mode 100644 index 0000000000..934256cb29 --- /dev/null +++ b/FabricExample/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/FabricExample/.bundle/config b/FabricExample/.bundle/config new file mode 100644 index 0000000000..848943bb52 --- /dev/null +++ b/FabricExample/.bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/FabricExample/.eslintrc.js b/FabricExample/.eslintrc.js new file mode 100644 index 0000000000..40c6dcd05f --- /dev/null +++ b/FabricExample/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: '@react-native-community', +}; diff --git a/FabricExample/.flowconfig b/FabricExample/.flowconfig new file mode 100644 index 0000000000..3782e447cd --- /dev/null +++ b/FabricExample/.flowconfig @@ -0,0 +1,66 @@ +[ignore] +; We fork some components by platform +.*/*[.]android.js + +; Ignore "BUCK" generated dirs +/\.buckd/ + +; Ignore polyfills +node_modules/react-native/Libraries/polyfills/.* + +; Flow doesn't support platforms +.*/Libraries/Utilities/LoadingView.js + +.*/node_modules/resolve/test/resolver/malformed_package_json/package\.json$ + +[untyped] +.*/node_modules/@react-native-community/cli/.*/.* + +[include] + +[libs] +node_modules/react-native/interface.js +node_modules/react-native/flow/ + +[options] +emoji=true + +exact_by_default=true + +format.bracket_spacing=false + +module.file_ext=.js +module.file_ext=.json +module.file_ext=.ios.js + +munge_underscores=true + +module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' +module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' + +suppress_type=$FlowIssue +suppress_type=$FlowFixMe +suppress_type=$FlowFixMeProps +suppress_type=$FlowFixMeState + +[lints] +sketchy-null-number=warn +sketchy-null-mixed=warn +sketchy-number=warn +untyped-type-import=warn +nonstrict-import=warn +deprecated-type=warn +unsafe-getters-setters=warn +unnecessary-invariant=warn + +[strict] +deprecated-type +nonstrict-import +sketchy-null +unclear-type +unsafe-getters-setters +untyped-import +untyped-type-import + +[version] +^0.182.0 diff --git a/FabricExample/.gitignore b/FabricExample/.gitignore new file mode 100644 index 0000000000..2423126f72 --- /dev/null +++ b/FabricExample/.gitignore @@ -0,0 +1,64 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +ios/.xcode.env.local + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml +*.hprof +.cxx/ + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# BUCK +buck-out/ +\.buckd/ +*.keystore +!debug.keystore + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +**/fastlane/report.xml +**/fastlane/Preview.html +**/fastlane/screenshots +**/fastlane/test_output + +# Bundle artifact +*.jsbundle + +# Ruby / CocoaPods +/ios/Pods/ +/vendor/bundle/ diff --git a/FabricExample/.prettierrc.js b/FabricExample/.prettierrc.js new file mode 100644 index 0000000000..2b540746a7 --- /dev/null +++ b/FabricExample/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + arrowParens: 'avoid', + bracketSameLine: true, + bracketSpacing: false, + singleQuote: true, + trailingComma: 'all', +}; diff --git a/FabricExample/.ruby-version b/FabricExample/.ruby-version new file mode 100644 index 0000000000..a603bb50a2 --- /dev/null +++ b/FabricExample/.ruby-version @@ -0,0 +1 @@ +2.7.5 diff --git a/FabricExample/.watchmanconfig b/FabricExample/.watchmanconfig new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/FabricExample/.watchmanconfig @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/FabricExample/App.tsx b/FabricExample/App.tsx new file mode 100644 index 0000000000..00de3943fc --- /dev/null +++ b/FabricExample/App.tsx @@ -0,0 +1,87 @@ +import * as React from 'react'; +import { + Platform, + ScrollView, + StyleSheet, + Text, + View, + SafeAreaView, + I18nManager, + Switch, +} from 'react-native'; + +import * as PickerExamples from './PickerExample'; +import * as PickerIOSExamples from './PickerIOSExample'; + +export default function App() { + const [isRTL, setIsRTL] = React.useState(I18nManager.isRTL); + React.useEffect(() => { + I18nManager.allowRTL(true); + }, []); + + console.log(Platform.constants); + return ( + + + + { + setIsRTL(newValue); + I18nManager.forceRTL(newValue); + }} + /> + {I18nManager.isRTL ? 'RTL' : 'LTR'} + + + Picker Examples + {PickerExamples.examples.map((element) => ( + + {element.title} + {element.render()} + + ))} + {Platform.OS === 'ios' && ( + PickerIOS Examples + )} + {Platform.OS === 'ios' && + PickerIOSExamples.examples.map((element) => ( + + {element.title} + {element.render()} + + ))} + {Platform.OS === 'windows' && ( + PickerWindows Examples + )} + + + + ); +} + +const styles = StyleSheet.create({ + main: { + backgroundColor: '#F5FCFF', + }, + container: { + padding: 24, + paddingBottom: 60, + }, + title: { + fontSize: 18, + }, + elementContainer: { + marginTop: 8, + }, + heading: { + fontSize: 22, + color: 'black', + }, + rtlSwitchContainer: { + flexDirection: 'row', + justifyContent: 'space-between', + paddingHorizontal: 40, + paddingTop: 20, + }, +}); diff --git a/FabricExample/Gemfile b/FabricExample/Gemfile new file mode 100644 index 0000000000..5efda89f45 --- /dev/null +++ b/FabricExample/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version +ruby '2.7.5' + +gem 'cocoapods', '~> 1.11', '>= 1.11.2' diff --git a/FabricExample/PickerExample.tsx b/FabricExample/PickerExample.tsx new file mode 100644 index 0000000000..fe597c04ff --- /dev/null +++ b/FabricExample/PickerExample.tsx @@ -0,0 +1,317 @@ +import * as React from 'react'; +import {Text, View, StyleSheet, Button} from 'react-native'; +import {Picker} from '@react-native-picker/picker'; + +const Item: any = Picker.Item; + +export function BasicPickerExample() { + const [value, setValue] = React.useState('key1'); + return ( + setValue(v)} + accessibilityLabel="Basic Picker Accessibility Label"> + + + + ); +} + +function StyledPickerExample() { + const [value, setValue] = React.useState('key1'); + return ( + setValue(v)} + accessibilityLabel="Styled Picker Accessibility Label"> + + + + + ); +} + +function DisabledPickerExample() { + const [value] = React.useState('key1'); + + return ( + + + + + ); +} + +function DisabledSpecificPickerExample() { + const [value] = React.useState('key1'); + + return ( + + + + + + ); +} + +function DropdownPickerExample() { + const [value, setValue] = React.useState('key1'); + + return ( + setValue(v)} + mode="dropdown"> + + + + ); +} + +function DropdownMultilinePickerExample() { + const [value, setValue] = React.useState('key1'); + + return ( + setValue(v)} + mode="dropdown"> + + + + ); +} + +function PromptPickerExample() { + const [value, setValue] = React.useState('key1'); + return ( + setValue(v)} + prompt="Pick one, just one"> + + + + ); +} + +function PromptMultilinePickerExample() { + const [value, setValue] = React.useState('key1'); + return ( + setValue(v)} + prompt="Pick one, just one"> + + + + ); +} + +function CustomDropdownArrowColorPickerExample() { + return ( + + + + + + + ); +} + +function NoListenerPickerExample() { + return ( + + + + + + + Cannot change the value of this picker because it doesn't update + selectedValue. + + + ); +} + +function ThemeVariantOverridePickerExample() { + const [themeVariantValue, setThemeVariantValue] = React.useState('dark'); + const isDarkMode = themeVariantValue === 'dark'; + + const handleSelect = ({nativeEvent: {newValue}}) => + setThemeVariantValue(newValue); + + return ( + + + + + + + ); +} + +function ColorPickerExample() { + const [value, setValue] = React.useState('red'); + const [isFocused, setIsFocused] = React.useState(false); + const [isSecondFocused, setIsSecondFocused] = React.useState(false); + const pickerRef = React.useRef(null); + + return ( + <> +