├── example ├── .watchmanconfig ├── src │ ├── view │ │ ├── index.tsx │ │ └── Space.tsx │ ├── alert-modal-example │ │ ├── index.tsx │ │ ├── alert-modal.tsx │ │ └── alert-modal-example-screen.tsx │ ├── simple-modal-example │ │ ├── index.tsx │ │ ├── simple-modal-example-screen.tsx │ │ └── simple-modal.tsx │ ├── text-input-modal-example │ │ ├── index.tsx │ │ ├── text-input-modal-example-screen.tsx │ │ └── text-input-modal.tsx │ ├── show-modal-continuously-example │ │ ├── index.tsx │ │ └── show-modal-continuously-example-screen.tsx │ ├── simple-bottom-sheet-modal-example │ │ ├── index.tsx │ │ ├── simple-bottom-sheet-modal-example-screen.tsx │ │ └── simple-bottom-sheet-modal.tsx │ ├── forwarded-alert-modal-example │ │ ├── forwarded-alert-modal-example-screen.tsx │ │ └── alert-modal.tsx │ ├── home-screen.tsx │ └── App.tsx ├── _editorconfig ├── app.json ├── .eslintrc.js ├── android │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── values │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.xml │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ └── mipmap-xxxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ │ └── MainApplication.java │ │ │ │ └── AndroidManifest.xml │ │ │ └── debug │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── ReactNativeFlipper.java │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ ├── build_defs.bzl │ │ ├── _BUCK │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ ├── build.gradle │ ├── gradle.properties │ ├── gradlew.bat │ └── gradlew ├── ios │ ├── example │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── Info.plist │ │ ├── AppDelegate.m │ │ └── LaunchScreen.storyboard │ ├── example.xcworkspace │ │ └── contents.xcworkspacedata │ ├── exampleTests │ │ ├── Info.plist │ │ └── exampleTests.m │ ├── Podfile │ ├── example.xcodeproj │ │ ├── xcshareddata │ │ │ └── xcschemes │ │ │ │ └── example.xcscheme │ │ └── project.pbxproj │ └── Podfile.lock ├── .buckconfig ├── .gitattributes ├── .prettierrc.js ├── index.js ├── __tests__ │ └── App-test.tsx ├── babel.config.js ├── .gitignore ├── metro.config.js └── package.json ├── .env.example ├── src ├── __tests__ │ └── index.test.tsx ├── modal-result-type.ts ├── util │ ├── is-not-nil.ts │ └── forwarde-ref.ts ├── modal-confirm-function.ts ├── event.ts ├── modal-instance.ts ├── modal-result.ts ├── modal-context.tsx ├── index.tsx ├── modal-id-generator.ts ├── create-use-notification-modal.tsx ├── create-use-bottom-sheet-modal.tsx ├── create-create-use-modal.ts ├── create-use-forwarded-modal.tsx ├── create-use-modal.tsx ├── modal-provider.tsx ├── use-modal.tsx ├── create-forwarded-modal.tsx ├── create-modal.tsx ├── use-forwarded-modal-view-model.tsx └── use-modal-view-model.tsx ├── .gitattributes ├── tsconfig.build.json ├── babel.config.js ├── .yarnrc ├── .editorconfig ├── scripts └── bootstrap.js ├── tsconfig.json ├── LICENSE ├── .circleci └── config.yml ├── package.json ├── .gitignore ├── CONTRIBUTING.md └── README.md /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | GITHUB_TOKEN="f941e0..." 2 | -------------------------------------------------------------------------------- /example/src/view/index.tsx: -------------------------------------------------------------------------------- 1 | export * from './Space'; 2 | -------------------------------------------------------------------------------- /src/__tests__/index.test.tsx: -------------------------------------------------------------------------------- 1 | it.todo('write a test'); 2 | -------------------------------------------------------------------------------- /example/_editorconfig: -------------------------------------------------------------------------------- 1 | # Windows files 2 | [*.bat] 3 | end_of_line = crlf 4 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "displayName": "example" 4 | } 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | # specific for windows script files 3 | *.bat text eol=crlf -------------------------------------------------------------------------------- /example/src/alert-modal-example/index.tsx: -------------------------------------------------------------------------------- 1 | export * from './alert-modal-example-screen'; 2 | -------------------------------------------------------------------------------- /example/src/simple-modal-example/index.tsx: -------------------------------------------------------------------------------- 1 | export * from './simple-modal-example-screen'; 2 | -------------------------------------------------------------------------------- /src/modal-result-type.ts: -------------------------------------------------------------------------------- 1 | export enum ModalResultType { 2 | CONFIRM, 3 | CANCEL, 4 | } 5 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "extends": "./tsconfig", 4 | "exclude": ["example"] 5 | } 6 | -------------------------------------------------------------------------------- /example/src/text-input-modal-example/index.tsx: -------------------------------------------------------------------------------- 1 | export * from './text-input-modal-example-screen'; 2 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /example/src/show-modal-continuously-example/index.tsx: -------------------------------------------------------------------------------- 1 | export * from './show-modal-continuously-example-screen'; 2 | -------------------------------------------------------------------------------- /example/src/simple-bottom-sheet-modal-example/index.tsx: -------------------------------------------------------------------------------- 1 | export * from './simple-bottom-sheet-modal-example-screen'; 2 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | example 3 | 4 | -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | # Override Yarn command so we can automatically setup the repo on running `yarn` 2 | 3 | yarn-path "scripts/bootstrap.js" 4 | -------------------------------------------------------------------------------- /example/ios/example/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/app/debug.keystore -------------------------------------------------------------------------------- /src/util/is-not-nil.ts: -------------------------------------------------------------------------------- 1 | export const isNotNil = (value: T | undefined | null): value is T => 2 | value !== null && value !== undefined; 3 | -------------------------------------------------------------------------------- /src/modal-confirm-function.ts: -------------------------------------------------------------------------------- 1 | export type ModalConfirmFunction = T extends void 2 | ? () => void 3 | : (data: T) => void; 4 | -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | # Windows files should use crlf line endings 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | *.bat text eol=crlf 4 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/event.ts: -------------------------------------------------------------------------------- 1 | export class Event { 2 | value: T; 3 | 4 | constructor(...[value]: T extends void ? [] : [T]) { 5 | // @ts-ignore 6 | this.value = value; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | arrowParens: 'avoid', 7 | }; 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Soomgo-Mobile/react-native-use-modal/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'example' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | import 'react-native-gesture-handler'; 2 | import {AppRegistry} from 'react-native'; 3 | import App from './src/App'; 4 | import {name as appName} from './app.json'; 5 | 6 | AppRegistry.registerComponent(appName, () => App); 7 | -------------------------------------------------------------------------------- /example/ios/example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /example/ios/example/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /src/modal-instance.ts: -------------------------------------------------------------------------------- 1 | import type { ModalResult } from './modal-result'; 2 | 3 | export interface ModalInstance { 4 | show: Param extends void 5 | ? () => Promise> 6 | : (param: Param) => Promise>; 7 | } 8 | -------------------------------------------------------------------------------- /src/modal-result.ts: -------------------------------------------------------------------------------- 1 | import type { ModalResultType } from './modal-result-type'; 2 | 3 | export type ModalResult = 4 | | { 5 | type: ModalResultType.CONFIRM; 6 | data: Data; 7 | } 8 | | { 9 | type: ModalResultType.CANCEL; 10 | }; 11 | -------------------------------------------------------------------------------- /src/modal-context.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export const ModalContext = React.createContext<{ 4 | set: (id: string, node: React.ReactNode) => void; // add or update modal 5 | delete: (id: string) => void; // remove modal 6 | }>({ 7 | set: () => {}, 8 | delete: () => {}, 9 | }); 10 | -------------------------------------------------------------------------------- /example/src/view/Space.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {View} from 'react-native'; 3 | 4 | export const Space = ({height, width}: {height?: number; width?: number}) => { 5 | return ( 6 | 12 | ); 13 | }; 14 | -------------------------------------------------------------------------------- /example/ios/example.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/util/forwarde-ref.ts: -------------------------------------------------------------------------------- 1 | import type React from 'react'; 2 | import type { ComponentPropsWithRef } from 'react'; 3 | 4 | export type ForwardedRef< 5 | Component extends React.ForwardRefExoticComponent 6 | > = NonNullable< 7 | Exclude< 8 | NonNullable['ref']>, 9 | Function 10 | >['current'] 11 | >; 12 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | indent_style = space 10 | indent_size = 2 11 | 12 | end_of_line = lf 13 | charset = utf-8 14 | trim_trailing_whitespace = true 15 | insert_final_newline = true 16 | -------------------------------------------------------------------------------- /example/__tests__/App-test.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../src/App'; 8 | 9 | // Note: test renderer must be required after react-native. 10 | import renderer from 'react-test-renderer'; 11 | 12 | it('renders correctly', () => { 13 | renderer.create(); 14 | }); 15 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | export * from './use-modal'; 2 | export * from './modal-provider'; 3 | export * from './create-modal'; 4 | export * from './modal-result-type'; 5 | export * from './create-use-modal'; 6 | export * from './create-use-forwarded-modal'; 7 | export * from './create-forwarded-modal'; 8 | export * from './create-create-use-modal'; 9 | export * from './create-use-bottom-sheet-modal'; 10 | export * from './create-use-notification-modal'; 11 | -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const pak = require('../package.json'); 3 | 4 | module.exports = { 5 | presets: ['module:metro-react-native-babel-preset'], 6 | plugins: [ 7 | [ 8 | 'module-resolver', 9 | { 10 | extensions: ['.tsx', '.ts', '.js', '.json'], 11 | alias: { 12 | [pak.name]: path.join(__dirname, '..', pak.source), 13 | }, 14 | }, 15 | ], 16 | ], 17 | }; 18 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "example"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/modal-id-generator.ts: -------------------------------------------------------------------------------- 1 | export class ModalIdGenerator { 2 | private static INSTANCE: ModalIdGenerator | null = null; 3 | 4 | private lastId: number = 1; 5 | 6 | private constructor() {} 7 | 8 | static getInstance() { 9 | if (ModalIdGenerator.INSTANCE === null) { 10 | ModalIdGenerator.INSTANCE = new ModalIdGenerator(); 11 | } 12 | return ModalIdGenerator.INSTANCE; 13 | } 14 | 15 | generate() { 16 | return ++this.lastId; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/create-use-notification-modal.tsx: -------------------------------------------------------------------------------- 1 | import { createCreateUseModal } from './create-create-use-modal'; 2 | 3 | /** 4 | * Modal hook creation function with default set to BottomSheet style 5 | */ 6 | export const createUseNotificationModal = createCreateUseModal({ 7 | modalProps: { 8 | style: { 9 | margin: 0, 10 | padding: 0, 11 | justifyContent: 'flex-start', 12 | }, 13 | animationIn: 'slideOutDown', 14 | animationOut: 'slideInUp', 15 | }, 16 | }); 17 | -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /src/create-use-bottom-sheet-modal.tsx: -------------------------------------------------------------------------------- 1 | import { createCreateUseModal } from './create-create-use-modal'; 2 | 3 | /** 4 | * Modal hook creation function with default set to BottomSheet style 5 | */ 6 | export const createUseBottomSheetModal = createCreateUseModal({ 7 | modalProps: { 8 | style: { 9 | margin: 0, 10 | padding: 0, 11 | justifyContent: 'flex-end', 12 | }, 13 | animationIn: 'slideInUp', 14 | animationOut: 'slideOutDown', 15 | }, 16 | cancelOnBackButtonPress: true, 17 | cancelOnBackdropPress: true, 18 | }); 19 | -------------------------------------------------------------------------------- /src/create-create-use-modal.ts: -------------------------------------------------------------------------------- 1 | import { createUseModal } from './create-use-modal'; 2 | import type { CreateModalOption } from './create-modal'; 3 | import _ from 'lodash'; 4 | 5 | /** 6 | * createUseModal creation function with default value of option argument set 7 | */ 8 | export const createCreateUseModal = 9 | (_option: CreateModalOption): typeof createUseModal => 10 | (...param) => { 11 | const [Content, option] = param; 12 | const composedOption = _.defaultsDeep(option, _option); 13 | return createUseModal(Content, composedOption); 14 | }; 15 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/create-use-forwarded-modal.tsx: -------------------------------------------------------------------------------- 1 | import { useModal } from './use-modal'; 2 | import React from 'react'; 3 | import type { CreateForwardedModalFunctionParam } from './create-forwarded-modal'; 4 | import { createForwardedModal } from './create-forwarded-modal'; 5 | 6 | export const createUseForwardedModal = < 7 | Data extends unknown = void, 8 | Param extends unknown = void 9 | >( 10 | ...param: CreateForwardedModalFunctionParam 11 | ) => { 12 | const Modal = createForwardedModal(...param); 13 | const modalElement = ; 14 | return () => useModal(modalElement); 15 | }; 16 | -------------------------------------------------------------------------------- /src/create-use-modal.tsx: -------------------------------------------------------------------------------- 1 | import { createModal, CreateModalFunctionParam } from './create-modal'; 2 | import { useModal } from './use-modal'; 3 | import React from 'react'; 4 | 5 | /** 6 | * A function that creates a custom hook that returns an object with a modal display function. 7 | */ 8 | export const createUseModal = < 9 | Data extends unknown = void, 10 | Param extends unknown = void 11 | >( 12 | ...param: CreateModalFunctionParam 13 | ) => { 14 | const Modal = createModal(...param); 15 | const modalElement = ; 16 | return () => useModal(modalElement); 17 | }; 18 | -------------------------------------------------------------------------------- /example/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /scripts/bootstrap.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const child_process = require('child_process'); 3 | 4 | const root = path.resolve(__dirname, '..'); 5 | const args = process.argv.slice(2); 6 | const options = { 7 | cwd: process.cwd(), 8 | env: process.env, 9 | stdio: 'inherit', 10 | encoding: 'utf-8', 11 | }; 12 | 13 | let result; 14 | 15 | if (process.cwd() !== root || args.length) { 16 | // We're not in the root of the project, or additional arguments were passed 17 | // In this case, forward the command to `yarn` 18 | result = child_process.spawnSync('yarn', args, options); 19 | } else { 20 | // If `yarn` is run without arguments, perform bootstrap 21 | result = child_process.spawnSync('yarn', ['bootstrap'], options); 22 | } 23 | 24 | process.exitCode = result.status; 25 | -------------------------------------------------------------------------------- /example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "./", 4 | "paths": { 5 | "react-native-use-modal": ["./src/index"] 6 | }, 7 | "allowUnreachableCode": false, 8 | "allowUnusedLabels": false, 9 | "esModuleInterop": true, 10 | "importsNotUsedAsValues": "error", 11 | "forceConsistentCasingInFileNames": true, 12 | "jsx": "react", 13 | "lib": ["esnext"], 14 | "module": "esnext", 15 | "moduleResolution": "node", 16 | "noFallthroughCasesInSwitch": true, 17 | "noImplicitReturns": true, 18 | "noImplicitUseStrict": false, 19 | "noStrictGenericChecks": false, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "resolveJsonModule": true, 23 | "skipLibCheck": true, 24 | "strict": true, 25 | "target": "esnext" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /example/ios/exampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'example' do 7 | config = use_native_modules! 8 | 9 | use_react_native!( 10 | :path => config[:reactNativePath], 11 | # to enable hermes on iOS, change `false` to `true` and then install pods 12 | :hermes_enabled => false 13 | ) 14 | 15 | target 'exampleTests' do 16 | inherit! :complete 17 | # Pods for testing 18 | end 19 | 20 | # Enables Flipper. 21 | # 22 | # Note that if you have use_frameworks! enabled, Flipper will not work and 23 | # you should disable the next line. 24 | use_flipper!() 25 | 26 | post_install do |installer| 27 | react_native_post_install(installer) 28 | end 29 | end 30 | 31 | pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons' 32 | -------------------------------------------------------------------------------- /example/src/simple-bottom-sheet-modal-example/simple-bottom-sheet-modal-example-screen.tsx: -------------------------------------------------------------------------------- 1 | import {Button, StyleSheet, View} from 'react-native'; 2 | import React, {useCallback} from 'react'; 3 | import {useSimpleBottomSheetModal} from './simple-bottom-sheet-modal'; 4 | import {Title} from 'react-native-paper'; 5 | 6 | export const SimpleBottomSheetModalExampleScreen = () => { 7 | const simpleModal = useSimpleBottomSheetModal(); 8 | 9 | const handlePress = useCallback(() => { 10 | simpleModal.show(); 11 | }, [simpleModal]); 12 | 13 | return ( 14 | 15 | Simple Bottom Sheet 16 | 17 | 18 | 19 | 20 | 21 | ); 22 | }); 23 | 24 | const styles = StyleSheet.create({ 25 | container: { 26 | backgroundColor: '#fff', 27 | margin: 16, 28 | borderRadius: 12, 29 | paddingHorizontal: 16, 30 | paddingVertical: 16, 31 | }, 32 | buttonContainer: { 33 | flexDirection: 'row', 34 | alignSelf: 'flex-end', 35 | }, 36 | }); 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Jimmy Lee 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /example/src/alert-modal-example/alert-modal-example-screen.tsx: -------------------------------------------------------------------------------- 1 | import React, {useCallback} from 'react'; 2 | import {Button, StyleSheet, View} from 'react-native'; 3 | import {useAlertModal} from './alert-modal'; 4 | import {ModalResultType} from 'react-native-use-modal'; 5 | 6 | export const AlertModalExampleScreen = () => { 7 | const alertModal = useAlertModal(); 8 | 9 | const handlePress = useCallback(async () => { 10 | const result = await alertModal.show({ 11 | title: 'Title passed by param', 12 | message: 13 | 'Message passed by param.\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec eget lectus tortor.', 14 | }); 15 | 16 | if (result.type === ModalResultType.CONFIRM) { 17 | // handle confirm 18 | } else { 19 | // handle cancel 20 | } 21 | }, [alertModal]); 22 | 23 | return ( 24 | 25 | 21 | 22 | 23 | 24 | ); 25 | }); 26 | 27 | const styles = StyleSheet.create({ 28 | container: { 29 | backgroundColor: '#fff', 30 | margin: 16, 31 | borderRadius: 12, 32 | paddingHorizontal: 16, 33 | paddingVertical: 8, 34 | }, 35 | buttonContainer: { 36 | flexDirection: 'row', 37 | alignSelf: 'flex-end', 38 | }, 39 | }); 40 | -------------------------------------------------------------------------------- /example/android/app/_BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.example", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.example", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /src/use-modal.tsx: -------------------------------------------------------------------------------- 1 | import React, { 2 | RefAttributes, 3 | useCallback, 4 | useContext, 5 | useEffect, 6 | useMemo, 7 | useState, 8 | } from 'react'; 9 | import { BehaviorSubject, firstValueFrom } from 'rxjs'; 10 | import { filter } from 'rxjs/operators'; 11 | import { ModalContext } from './modal-context'; 12 | import type { ModalInstance } from './modal-instance'; 13 | import type { ForwardedRef } from './util/forwarde-ref'; 14 | import { isNotNil } from './util/is-not-nil'; 15 | import { ModalIdGenerator } from './modal-id-generator'; 16 | 17 | type ModalRef = RefAttributes>; 18 | 19 | /** 20 | * 모달을 등록하는 hook 21 | */ 22 | export const useModal = < 23 | Component extends React.ForwardRefExoticComponent 24 | >( 25 | modal: React.ReactElement 26 | ) => { 27 | const context = useContext(ModalContext); 28 | // 모달 ID 29 | const modalId = useMemo( 30 | () => String(ModalIdGenerator.getInstance().generate()), 31 | [] 32 | ); 33 | 34 | const [instance$] = useState( 35 | () => new BehaviorSubject | null>(null) 36 | ); 37 | 38 | useEffect(() => { 39 | const clone = React.cloneElement(modal, { 40 | ref: (instance) => { 41 | instance$.next(instance); 42 | }, 43 | }); 44 | context.set(modalId, clone); 45 | 46 | return () => { 47 | context.delete(modalId); 48 | }; 49 | }, [context, instance$, modal, modalId]); 50 | 51 | const show = useCallback['show']>( 52 | async (param) => 53 | (await firstValueFrom(instance$.pipe(filter(isNotNil)))).show(param), 54 | [instance$] 55 | ); 56 | 57 | return useMemo>(() => { 58 | return { 59 | show, 60 | } as ForwardedRef; 61 | }, [show]); 62 | }; 63 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "test": "jest", 10 | "lint": "eslint . --ext .js,.jsx,.ts,.tsx", 11 | "reset": "watchman watch-del-all && yarn start -- --reset-cache" 12 | }, 13 | "dependencies": { 14 | "@react-native-community/masked-view": "^0.1.11", 15 | "@react-navigation/native": "^5.9.4", 16 | "@react-navigation/stack": "^5.14.5", 17 | "lodash": "^4.17.21", 18 | "react": "17.0.1", 19 | "react-native": "0.64.1", 20 | "react-native-gesture-handler": "^1.10.3", 21 | "react-native-paper": "^4.9.1", 22 | "react-native-reanimated": "^2.2.0", 23 | "react-native-safe-area-context": "^3.2.0", 24 | "react-native-screens": "^3.3.0", 25 | "react-native-vector-icons": "^8.1.0" 26 | }, 27 | "devDependencies": { 28 | "@babel/core": "^7.12.9", 29 | "@babel/runtime": "^7.12.5", 30 | "@react-native-community/eslint-config": "^2.0.0", 31 | "@types/jest": "^26.0.23", 32 | "@types/lodash": "^4.14.170", 33 | "@types/react-native": "^0.64.5", 34 | "@types/react-test-renderer": "^16.9.2", 35 | "babel-jest": "^26.6.3", 36 | "babel-plugin-module-resolver": "^4.1.0", 37 | "eslint": "^7.14.0", 38 | "jest": "^26.6.3", 39 | "metro-react-native-babel-preset": "^0.64.0", 40 | "react-test-renderer": "17.0.1", 41 | "typescript": "^3.8.3" 42 | }, 43 | "resolutions": { 44 | "@types/react": "^17" 45 | }, 46 | "jest": { 47 | "preset": "react-native", 48 | "moduleFileExtensions": [ 49 | "ts", 50 | "tsx", 51 | "js", 52 | "jsx", 53 | "json", 54 | "node" 55 | ] 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /example/src/simple-bottom-sheet-modal-example/simple-bottom-sheet-modal.tsx: -------------------------------------------------------------------------------- 1 | import {StyleSheet, View} from 'react-native'; 2 | import React from 'react'; 3 | import {Button, Paragraph, Title} from 'react-native-paper'; 4 | import {createUseBottomSheetModal} from 'react-native-use-modal'; 5 | import {useSafeAreaInsets} from 'react-native-safe-area-context'; 6 | 7 | export const useSimpleBottomSheetModal = createUseBottomSheetModal( 8 | ({confirm, cancel}) => { 9 | const safeAreaInsets = useSafeAreaInsets(); 10 | return ( 11 | 18 | Title of modal 19 | 20 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sed ex 21 | scelerisque, consectetur magna id, pulvinar mauris. Duis eu aliquet 22 | diam. Vestibulum congue est lacus, eu ullamcorper arcu eleifend a. 23 | Pellentesque habitant morbi tristique senectus et netus et malesuada 24 | fames ac turpis egestas. Pellentesque habitant morbi tristique 25 | senectus et netus et malesuada fames ac turpis egestas. Sed vitae nunc 26 | in nibh venenatis luctus. 27 | 28 | 29 | 30 | 31 | 32 | 33 | ); 34 | }, 35 | ); 36 | 37 | const styles = StyleSheet.create({ 38 | container: { 39 | backgroundColor: '#fff', 40 | borderRadius: 12, 41 | paddingHorizontal: 16, 42 | paddingVertical: 8, 43 | }, 44 | buttonContainer: { 45 | flexDirection: 'row', 46 | alignSelf: 'flex-end', 47 | }, 48 | }); 49 | -------------------------------------------------------------------------------- /src/create-forwarded-modal.tsx: -------------------------------------------------------------------------------- 1 | import React, { useCallback } from 'react'; 2 | import type { ModalConfirmFunction } from './modal-confirm-function'; 3 | import type { ModalInstance } from './modal-instance'; 4 | import { useForwardedModalViewModel } from './use-forwarded-modal-view-model'; 5 | 6 | // 모달 내용 컴포넌트 7 | type ContentComponent< 8 | Data extends unknown = void, // 모달 결과로 받을 값의 타입 9 | Param extends unknown = void 10 | > = React.VoidFunctionComponent<{ 11 | confirm: ModalConfirmFunction; // 모달 종료 함수 (승인) 12 | cancel: () => void; // 모달 종료 함수 (취소) 13 | param: Param | null; 14 | onHide: () => void; 15 | isVisible: boolean; 16 | }>; 17 | 18 | type Option = { 19 | handleHide?: boolean; 20 | }; 21 | 22 | export type CreateForwardedModalFunctionParam< 23 | Data extends unknown = void, 24 | Param extends unknown = void 25 | > = [Content: ContentComponent, option?: Option]; 26 | 27 | /** 28 | * 모달 컴포넌트 생성 함수 29 | */ 30 | export const createForwardedModal = < 31 | Data extends unknown = void, // 모달 결과로 받을 값의 타입 32 | Param extends unknown = void 33 | >( 34 | ...[Content, { handleHide = false } = {}]: CreateForwardedModalFunctionParam< 35 | Data, 36 | Param 37 | > 38 | ) => 39 | (() => { 40 | return React.forwardRef>((_, ref) => { 41 | const { confirm, cancel, desiredVisibility, param, setHidingFinished } = 42 | useForwardedModalViewModel(ref, { handleHide }); 43 | 44 | const handleOnHide = useCallback(() => { 45 | setHidingFinished(); 46 | }, [setHidingFinished]); 47 | 48 | return ( 49 | 56 | ); 57 | }); 58 | })(); 59 | -------------------------------------------------------------------------------- /example/src/home-screen.tsx: -------------------------------------------------------------------------------- 1 | import {Button, ScrollView, StyleSheet, View} from 'react-native'; 2 | import React from 'react'; 3 | import {useNavigation} from '@react-navigation/native'; 4 | import type {RootStackNavigationProp} from './App'; 5 | 6 | export const HomeScreen = () => { 7 | const navigation = useNavigation(); 8 | 9 | return ( 10 | 11 | 12 | 46 | 47 | 48 | 49 | ); 50 | }); 51 | 52 | const styles = StyleSheet.create({ 53 | container: { 54 | backgroundColor: '#fff', 55 | margin: 16, 56 | borderRadius: 12, 57 | paddingHorizontal: 16, 58 | paddingVertical: 8, 59 | }, 60 | buttonContainer: { 61 | flexDirection: 'row', 62 | alignSelf: 'flex-end', 63 | }, 64 | }); 65 | -------------------------------------------------------------------------------- /example/src/forwarded-alert-modal-example/alert-modal.tsx: -------------------------------------------------------------------------------- 1 | /** 2 | * This is an example of converting an existing alert modal into a hook using createUseForwardedModal. 3 | */ 4 | 5 | import {createUseForwardedModal} from 'react-native-use-modal'; 6 | import Modal from 'react-native-modal'; 7 | import {Button, Paragraph, Title} from 'react-native-paper'; 8 | import {Space} from '../view'; 9 | import {StyleSheet, View} from 'react-native'; 10 | import React from 'react'; 11 | 12 | /** 13 | * The existing modal 14 | */ 15 | const ExistingModal = ({ 16 | title, 17 | isVisible, 18 | onConfirm, 19 | onCancel, 20 | message, 21 | }: { 22 | title?: string; 23 | message?: string; 24 | onCancel: () => void; 25 | onConfirm: () => void; 26 | isVisible: boolean; 27 | }) => { 28 | return ( 29 | 30 | 31 | {title} 32 | {message} 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | ); 41 | }; 42 | 43 | /** 44 | * Convert existing modal to hook 45 | */ 46 | export const useAlertModal = createUseForwardedModal< 47 | void, 48 | {title: string; message: string} 49 | >(({confirm, cancel, param, isVisible}) => { 50 | return ( 51 | 58 | ); 59 | }); 60 | 61 | const styles = StyleSheet.create({ 62 | container: { 63 | backgroundColor: '#fff', 64 | margin: 16, 65 | borderRadius: 12, 66 | paddingHorizontal: 16, 67 | paddingVertical: 16, 68 | }, 69 | buttonContainer: { 70 | flexDirection: 'row', 71 | alignSelf: 'flex-end', 72 | }, 73 | }); 74 | -------------------------------------------------------------------------------- /example/ios/exampleTests/exampleTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface exampleTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation exampleTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 38 | if (level >= RCTLogLevelError) { 39 | redboxError = message; 40 | } 41 | }); 42 | #endif 43 | 44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | 48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 50 | return YES; 51 | } 52 | return NO; 53 | }]; 54 | } 55 | 56 | #ifdef DEBUG 57 | RCTSetLogFunction(RCTDefaultLogFunction); 58 | #endif 59 | 60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 62 | } 63 | 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /example/ios/example/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | #import 6 | 7 | #ifdef FB_SONARKIT_ENABLED 8 | #import 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | 15 | static void InitializeFlipper(UIApplication *application) { 16 | FlipperClient *client = [FlipperClient sharedClient]; 17 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 18 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 19 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 20 | [client addPlugin:[FlipperKitReactPlugin new]]; 21 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 22 | [client start]; 23 | } 24 | #endif 25 | 26 | @implementation AppDelegate 27 | 28 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 29 | { 30 | #ifdef FB_SONARKIT_ENABLED 31 | InitializeFlipper(application); 32 | #endif 33 | 34 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 35 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 36 | moduleName:@"example" 37 | initialProperties:nil]; 38 | 39 | if (@available(iOS 13.0, *)) { 40 | rootView.backgroundColor = [UIColor systemBackgroundColor]; 41 | } else { 42 | rootView.backgroundColor = [UIColor whiteColor]; 43 | } 44 | 45 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 46 | UIViewController *rootViewController = [UIViewController new]; 47 | rootViewController.view = rootView; 48 | self.window.rootViewController = rootViewController; 49 | [self.window makeKeyAndVisible]; 50 | return YES; 51 | } 52 | 53 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 54 | { 55 | #if DEBUG 56 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 57 | #else 58 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 59 | #endif 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | executors: 4 | default: 5 | docker: 6 | - image: circleci/node:10 7 | working_directory: ~/project 8 | 9 | commands: 10 | attach_project: 11 | steps: 12 | - attach_workspace: 13 | at: ~/project 14 | 15 | jobs: 16 | install-dependencies: 17 | executor: default 18 | steps: 19 | - checkout 20 | - attach_project 21 | - restore_cache: 22 | keys: 23 | - dependencies-{{ checksum "package.json" }} 24 | - dependencies- 25 | - restore_cache: 26 | keys: 27 | - dependencies-example-{{ checksum "example/package.json" }} 28 | - dependencies-example- 29 | - run: 30 | name: Install dependencies 31 | command: | 32 | yarn install --cwd example --frozen-lockfile 33 | yarn install --frozen-lockfile 34 | - save_cache: 35 | key: dependencies-{{ checksum "package.json" }} 36 | paths: node_modules 37 | - save_cache: 38 | key: dependencies-example-{{ checksum "example/package.json" }} 39 | paths: example/node_modules 40 | - persist_to_workspace: 41 | root: . 42 | paths: . 43 | 44 | lint: 45 | executor: default 46 | steps: 47 | - attach_project 48 | - run: 49 | name: Lint files 50 | command: | 51 | yarn lint 52 | 53 | typescript: 54 | executor: default 55 | steps: 56 | - attach_project 57 | - run: 58 | name: Typecheck files 59 | command: | 60 | yarn typescript 61 | 62 | unit-tests: 63 | executor: default 64 | steps: 65 | - attach_project 66 | - run: 67 | name: Run unit tests 68 | command: | 69 | yarn test --coverage 70 | - store_artifacts: 71 | path: coverage 72 | destination: coverage 73 | 74 | build-package: 75 | executor: default 76 | steps: 77 | - attach_project 78 | - run: 79 | name: Build package 80 | command: | 81 | yarn prepare 82 | 83 | workflows: 84 | build-and-test: 85 | jobs: 86 | - install-dependencies 87 | - lint: 88 | requires: 89 | - install-dependencies 90 | - typescript: 91 | requires: 92 | - install-dependencies 93 | - unit-tests: 94 | requires: 95 | - install-dependencies 96 | - build-package: 97 | requires: 98 | - install-dependencies 99 | -------------------------------------------------------------------------------- /example/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import {ModalProvider} from 'react-native-use-modal'; 3 | import {NavigationContainer} from '@react-navigation/native'; 4 | import { 5 | createStackNavigator, 6 | StackNavigationProp, 7 | } from '@react-navigation/stack'; 8 | import {HomeScreen} from './home-screen'; 9 | import {SimpleModalExampleScreen} from './simple-modal-example'; 10 | import {TextInputModalExampleScreen} from './text-input-modal-example'; 11 | import {AlertModalExampleScreen} from './alert-modal-example'; 12 | import {ShowModalContinuouslyExampleScreen} from './show-modal-continuously-example'; 13 | import {ForwardedAlertModalExampleScreen} from './forwarded-alert-modal-example/forwarded-alert-modal-example-screen'; 14 | import {SimpleBottomSheetModalExampleScreen} from './simple-bottom-sheet-modal-example'; 15 | import {SafeAreaProvider} from 'react-native-safe-area-context'; 16 | 17 | type RootStackParamList = { 18 | SIMPLE_MODAL_EXAMPLE: undefined; 19 | HOME: undefined; 20 | TEXT_INPUT_MODAL_EXAMPLE: undefined; 21 | ALERT_MODAL_EXAMPLE: undefined; 22 | SHOW_MODAL_CONTINUOUSLY_EXAMPLE: undefined; 23 | FORWARDED_ALERT_MODAL_EXAMPLE: undefined; 24 | SIMPLE_BOTTOM_SHEET_MODAL_EXAMPLE: undefined; 25 | }; 26 | 27 | export type RootStackNavigationProp = StackNavigationProp; 28 | 29 | const Stack = createStackNavigator(); 30 | 31 | export default function App() { 32 | return ( 33 | 34 | 35 | 36 | 37 | 38 | 42 | 46 | 50 | 54 | 58 | 62 | 63 | 64 | 65 | 66 | ); 67 | } 68 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import com.facebook.react.PackageList; 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.soloader.SoLoader; 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.util.List; 13 | 14 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = 17 | new ReactNativeHost(this) { 18 | @Override 19 | public boolean getUseDeveloperSupport() { 20 | return BuildConfig.DEBUG; 21 | } 22 | 23 | @Override 24 | protected List getPackages() { 25 | @SuppressWarnings("UnnecessaryLocalVariable") 26 | List packages = new PackageList(this).getPackages(); 27 | // Packages that cannot be autolinked yet can be added manually here, for example: 28 | // packages.add(new MyReactNativePackage()); 29 | return packages; 30 | } 31 | 32 | @Override 33 | protected String getJSMainModuleName() { 34 | return "index"; 35 | } 36 | }; 37 | 38 | @Override 39 | public ReactNativeHost getReactNativeHost() { 40 | return mReactNativeHost; 41 | } 42 | 43 | @Override 44 | public void onCreate() { 45 | super.onCreate(); 46 | SoLoader.init(this, /* native exopackage */ false); 47 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 48 | } 49 | 50 | /** 51 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like 52 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 53 | * 54 | * @param context 55 | * @param reactInstanceManager 56 | */ 57 | private static void initializeFlipper( 58 | Context context, ReactInstanceManager reactInstanceManager) { 59 | if (BuildConfig.DEBUG) { 60 | try { 61 | /* 62 | We use reflection here to pick up the class that initializes Flipper, 63 | since Flipper library is not available in release mode 64 | */ 65 | Class aClass = Class.forName("com.example.ReactNativeFlipper"); 66 | aClass 67 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 68 | .invoke(null, context, reactInstanceManager); 69 | } catch (ClassNotFoundException e) { 70 | e.printStackTrace(); 71 | } catch (NoSuchMethodException e) { 72 | e.printStackTrace(); 73 | } catch (IllegalAccessException e) { 74 | e.printStackTrace(); 75 | } catch (InvocationTargetException e) { 76 | e.printStackTrace(); 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /example/android/app/src/debug/java/com/example/ReactNativeFlipper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.example; 8 | 9 | import android.content.Context; 10 | import com.facebook.flipper.android.AndroidFlipperClient; 11 | import com.facebook.flipper.android.utils.FlipperUtils; 12 | import com.facebook.flipper.core.FlipperClient; 13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin; 14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin; 15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin; 16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping; 17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin; 18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor; 19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin; 20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin; 21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin; 22 | import com.facebook.react.ReactInstanceManager; 23 | import com.facebook.react.bridge.ReactContext; 24 | import com.facebook.react.modules.network.NetworkingModule; 25 | import okhttp3.OkHttpClient; 26 | 27 | public class ReactNativeFlipper { 28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) { 29 | if (FlipperUtils.shouldEnableFlipper(context)) { 30 | final FlipperClient client = AndroidFlipperClient.getInstance(context); 31 | 32 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults())); 33 | client.addPlugin(new ReactFlipperPlugin()); 34 | client.addPlugin(new DatabasesFlipperPlugin(context)); 35 | client.addPlugin(new SharedPreferencesFlipperPlugin(context)); 36 | client.addPlugin(CrashReporterPlugin.getInstance()); 37 | 38 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin(); 39 | NetworkingModule.setCustomClientBuilder( 40 | new NetworkingModule.CustomClientBuilder() { 41 | @Override 42 | public void apply(OkHttpClient.Builder builder) { 43 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin)); 44 | } 45 | }); 46 | client.addPlugin(networkFlipperPlugin); 47 | client.start(); 48 | 49 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized 50 | // Hence we run if after all native modules have been initialized 51 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext(); 52 | if (reactContext == null) { 53 | reactInstanceManager.addReactInstanceEventListener( 54 | new ReactInstanceManager.ReactInstanceEventListener() { 55 | @Override 56 | public void onReactContextInitialized(ReactContext reactContext) { 57 | reactInstanceManager.removeReactInstanceEventListener(this); 58 | reactContext.runOnNativeModulesQueueThread( 59 | new Runnable() { 60 | @Override 61 | public void run() { 62 | client.addPlugin(new FrescoFlipperPlugin()); 63 | } 64 | }); 65 | } 66 | }); 67 | } else { 68 | client.addPlugin(new FrescoFlipperPlugin()); 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 53 | 55 | 61 | 62 | 63 | 64 | 70 | 72 | 78 | 79 | 80 | 81 | 83 | 84 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /src/create-modal.tsx: -------------------------------------------------------------------------------- 1 | import React, { useCallback } from 'react'; 2 | import type { ModalProps } from 'react-native-modal'; 3 | import Modal from 'react-native-modal'; 4 | import type { ModalConfirmFunction } from './modal-confirm-function'; 5 | import { useModalViewModel } from './use-modal-view-model'; 6 | import { StyleSheet } from 'react-native'; 7 | import type { ModalInstance } from './modal-instance'; 8 | 9 | export type CreateModalOption = { 10 | cancelOnBackdropPress?: boolean; // 배경 클릭시 취소 여부 11 | cancelOnBackButtonPress?: boolean; // 뒤로가기 버튼 클릭시 취소 여부 12 | modalProps?: Omit, 'isVisible'>; 13 | }; 14 | 15 | export type CreateModalFunctionParam< 16 | Data extends unknown = void, // 모달 결과로 받을 값의 타입 17 | Param extends unknown = void 18 | > = [ 19 | // 모달 내용 컴포넌트 20 | Content: React.VoidFunctionComponent<{ 21 | confirm: ModalConfirmFunction; // 모달 종료 함수 (승인) 22 | cancel: () => void; // 모달 종료 함수 (취소) 23 | param: Param; 24 | }>, 25 | option?: CreateModalOption 26 | ]; 27 | 28 | /** 29 | * 모달 컴포넌트 생성 함수 30 | */ 31 | export const createModal = < 32 | Data extends unknown = void, // 모달 결과로 받을 값의 타입 33 | Param extends unknown = void 34 | >( 35 | ...[ 36 | Content, 37 | { 38 | cancelOnBackButtonPress = false, 39 | cancelOnBackdropPress = false, 40 | modalProps = {}, 41 | } = {}, 42 | ]: CreateModalFunctionParam 43 | ) => 44 | React.forwardRef>((_, ref) => { 45 | const { 46 | handleBackButtonPress, 47 | handleBackdropPress, 48 | cancel, 49 | confirm, 50 | desiredVisibility, 51 | handleModalHidden, 52 | handleModalShown, 53 | param, 54 | visibility, 55 | } = useModalViewModel(ref, { 56 | cancelOnBackButtonPress, 57 | cancelOnBackdropPress, 58 | }); 59 | 60 | const { 61 | backdropTransitionOutTiming, 62 | onBackdropPress, 63 | onBackButtonPress, 64 | onModalHide, 65 | onModalWillShow, 66 | style, 67 | ...restModalProps 68 | } = modalProps; 69 | 70 | const _handleBackdropPress = useCallback< 71 | ModalProps['onBackdropPress'] 72 | >(() => { 73 | handleBackdropPress(); 74 | onBackdropPress?.(); 75 | }, [handleBackdropPress, onBackdropPress]); 76 | 77 | const _handleBackButtonPress = useCallback< 78 | ModalProps['onBackButtonPress'] 79 | >(() => { 80 | handleBackButtonPress(); 81 | onBackButtonPress?.(); 82 | }, [handleBackButtonPress, onBackButtonPress]); 83 | 84 | const _handleModalHide = useCallback(() => { 85 | handleModalHidden(); 86 | onModalHide?.(); 87 | }, [handleModalHidden, onModalHide]); 88 | 89 | const _handleModalWillShow = useCallback< 90 | ModalProps['onModalWillShow'] 91 | >(() => { 92 | handleModalShown(); 93 | onModalWillShow?.(); 94 | }, [handleModalShown, onModalWillShow]); 95 | 96 | return ( 97 | 107 | {visibility === 'SHOWN' && ( 108 | 109 | )} 110 | 111 | ); 112 | }); 113 | 114 | const styles = StyleSheet.create({ 115 | modal: { 116 | margin: 0, 117 | padding: 0, 118 | }, 119 | }); 120 | -------------------------------------------------------------------------------- /example/ios/example/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/use-forwarded-modal-view-model.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | MutableRefObject, 3 | useCallback, 4 | useEffect, 5 | useImperativeHandle, 6 | useMemo, 7 | useState, 8 | } from 'react'; 9 | import { BehaviorSubject, EMPTY, firstValueFrom, Subject } from 'rxjs'; 10 | import { filter, first, switchMap, tap } from 'rxjs/operators'; 11 | import type { ModalInstance } from './modal-instance'; 12 | import type { ModalResult } from './modal-result'; 13 | import type { ModalConfirmFunction } from './modal-confirm-function'; 14 | import { ModalResultType } from './modal-result-type'; 15 | import { Event } from './event'; 16 | 17 | type ModalVisibility = 'HIDDEN' | 'SHOWN'; 18 | 19 | export const useForwardedModalViewModel = < 20 | Data extends unknown = void, // 모달 결과로 받을 값의 타입 21 | Param extends unknown = void 22 | >( 23 | ref: 24 | | ((instance: ModalInstance | null) => void) 25 | | MutableRefObject | null> 26 | | null, 27 | { 28 | handleHide, 29 | }: { 30 | handleHide: boolean; 31 | } 32 | ) => { 33 | // desired 표시 상태 (이 값이 true 라고 해서 모달이 표시된 상태는 아닙니다. false 도 마찬가지) 34 | const [desiredVisibility, setDesiredVisibility] = useState(false); 35 | 36 | // AlertResult Subject 37 | const [result$] = useState(() => new Subject>()); 38 | // 보여짐/숨겨짐 상태 39 | const [visibility$] = useState( 40 | () => new BehaviorSubject('HIDDEN') 41 | ); 42 | const [param, setParam] = useState(null); 43 | const [hidingFinishedEvent$] = useState(() => new Subject()); 44 | const [hideCommand$] = useState(() => new Subject()); 45 | 46 | useEffect(() => { 47 | const subscription = hideCommand$ 48 | .pipe( 49 | switchMap(() => { 50 | setDesiredVisibility(false); 51 | if (handleHide) { 52 | return hidingFinishedEvent$.pipe( 53 | first(), 54 | tap(() => { 55 | visibility$.next('HIDDEN'); 56 | }) 57 | ); 58 | } else { 59 | visibility$.next('HIDDEN'); 60 | return EMPTY; 61 | } 62 | }) 63 | ) 64 | .subscribe(); 65 | 66 | return () => { 67 | subscription.unsubscribe(); 68 | }; 69 | }, [handleHide, hideCommand$, hidingFinishedEvent$, visibility$]); 70 | 71 | const hide = useCallback(() => { 72 | hideCommand$.next(new Event()); 73 | }, [hideCommand$]); 74 | 75 | const show = useCallback(() => { 76 | setDesiredVisibility(true); 77 | visibility$.next('SHOWN'); 78 | }, [visibility$]); 79 | 80 | useImperativeHandle( 81 | ref, 82 | () => ({ 83 | // @ts-ignore 84 | show: (_param: Param) => { 85 | setParam(_param); 86 | show(); 87 | // 모달 결과 Subject 에서 88 | return firstValueFrom(result$); 89 | }, 90 | }), 91 | [result$, show] 92 | ); 93 | 94 | // 모달 종료 (승인) 95 | const confirm = useCallback>( 96 | // @ts-ignore 97 | (data) => { 98 | hide(); 99 | // 숨김 상태로 변경되면 result 발행 100 | visibility$ 101 | .pipe( 102 | filter((value) => value === 'HIDDEN'), 103 | first() 104 | ) 105 | .subscribe(() => { 106 | result$.next({ 107 | type: ModalResultType.CONFIRM, 108 | // @ts-ignore 109 | data, 110 | }); 111 | }); 112 | }, 113 | [hide, result$, visibility$] 114 | ); 115 | 116 | // 모달 종료 (취소) 117 | const cancel = useCallback(() => { 118 | hide(); 119 | // 숨김 상태로 변경되면 result 발행 120 | visibility$ 121 | .pipe( 122 | filter((value) => value === 'HIDDEN'), 123 | first() 124 | ) 125 | .subscribe(() => { 126 | result$.next({ 127 | type: ModalResultType.CANCEL, 128 | }); 129 | }); 130 | }, [hide, result$, visibility$]); 131 | 132 | const setHidingFinished = useCallback(() => { 133 | hidingFinishedEvent$.next(new Event()); 134 | }, [hidingFinishedEvent$]); 135 | 136 | return useMemo( 137 | () => ({ 138 | confirm, 139 | cancel, 140 | param, 141 | setHidingFinished, 142 | desiredVisibility, 143 | }), 144 | [confirm, cancel, param, setHidingFinished, desiredVisibility] 145 | ); 146 | }; 147 | -------------------------------------------------------------------------------- /src/use-modal-view-model.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | MutableRefObject, 3 | useCallback, 4 | useEffect, 5 | useImperativeHandle, 6 | useMemo, 7 | useState, 8 | } from 'react'; 9 | import { BehaviorSubject, firstValueFrom, Subject } from 'rxjs'; 10 | import { filter, first } from 'rxjs/operators'; 11 | import type { ModalInstance } from './modal-instance'; 12 | import type { ModalResult } from './modal-result'; 13 | import type { ModalConfirmFunction } from './modal-confirm-function'; 14 | import { ModalResultType } from './modal-result-type'; 15 | 16 | type ModalVisibility = 'HIDDEN' | 'SHOWN'; 17 | 18 | export const useModalViewModel = < 19 | Data extends unknown = void, // 모달 결과로 받을 값의 타입 20 | Param extends unknown = void 21 | >( 22 | ref: 23 | | ((instance: ModalInstance | null) => void) 24 | | MutableRefObject | null> 25 | | null, 26 | { 27 | cancelOnBackButtonPress = false, 28 | cancelOnBackdropPress = false, 29 | }: { 30 | cancelOnBackdropPress?: boolean; // 배경 클릭시 취소 여부 31 | cancelOnBackButtonPress?: boolean; // 뒤로가기 버튼 클릭시 취소 여부 32 | } = {} 33 | ) => { 34 | // desired 표시 상태 (이 값이 true 라고 해서 모달이 표시된 상태는 아닙니다. false 도 마찬가지) 35 | const [desiredVisibility, setDesiredVisibility] = useState(false); 36 | // AlertResult Subject 37 | const [result$] = useState(() => new Subject>()); 38 | // 보여짐/숨겨짐 상태 39 | const [visibility$] = useState( 40 | () => new BehaviorSubject('HIDDEN') 41 | ); 42 | const [param, setParam] = useState(); 43 | const [visibility, setVisibility] = useState( 44 | visibility$.value 45 | ); 46 | 47 | useEffect(() => { 48 | const subscription = visibility$.subscribe((value) => { 49 | setVisibility(value); 50 | }); 51 | return () => subscription.unsubscribe(); 52 | }, [visibility$]); 53 | 54 | useImperativeHandle( 55 | ref, 56 | () => ({ 57 | // @ts-ignore 58 | show: (_param: Param) => { 59 | setParam(_param); 60 | // 모달 표시 상태로 변경 시작 61 | setDesiredVisibility(true); 62 | visibility$.next('SHOWN'); 63 | // 모달 결과 Subject 에서 64 | return firstValueFrom(result$); 65 | }, 66 | }), 67 | [result$, visibility$] 68 | ); 69 | 70 | // 모달 종료 (승인) 71 | const confirm = useCallback>( 72 | // @ts-ignore 73 | (data) => { 74 | // 숨김 상태로 변경 시작 75 | setDesiredVisibility(false); 76 | // 숨김 상태로 변경되면 result 발행 77 | visibility$ 78 | .pipe( 79 | filter((value) => value === 'HIDDEN'), 80 | first() 81 | ) 82 | .subscribe(() => { 83 | result$.next({ 84 | type: ModalResultType.CONFIRM, 85 | // @ts-ignore 86 | data, 87 | }); 88 | }); 89 | }, 90 | [result$, visibility$] 91 | ); 92 | 93 | // 모달 종료 (취소) 94 | const cancel = useCallback(() => { 95 | // 숨김 상태로 변경 시작 96 | setDesiredVisibility(false); 97 | // 숨김 상태로 변경되면 result 발행 98 | visibility$ 99 | .pipe( 100 | filter((value) => value === 'HIDDEN'), 101 | first() 102 | ) 103 | .subscribe(() => { 104 | result$.next({ 105 | type: ModalResultType.CANCEL, 106 | }); 107 | }); 108 | }, [result$, visibility$]); 109 | 110 | // 배경 클릭 핸들 111 | const handleBackdropPress = useCallback(() => { 112 | cancelOnBackdropPress && cancel(); 113 | }, [cancel, cancelOnBackdropPress]); 114 | 115 | // 뒤로가기 버튼 클릭 핸들 116 | const handleBackButtonPress = useCallback(() => { 117 | cancelOnBackButtonPress && cancel(); 118 | }, [cancel, cancelOnBackButtonPress]); 119 | 120 | // 모달 보여짐 이벤트 핸들 121 | const handleModalShown = useCallback(() => { 122 | visibility$.next('SHOWN'); 123 | }, [visibility$]); 124 | 125 | // 모달 숨겨짐 이벤트 핸들 126 | const handleModalHidden = useCallback(() => { 127 | visibility$.next('HIDDEN'); 128 | }, [visibility$]); 129 | 130 | return useMemo( 131 | () => ({ 132 | confirm, 133 | cancel, 134 | desiredVisibility, 135 | handleBackButtonPress, 136 | handleBackdropPress, 137 | handleModalShown, 138 | handleModalHidden, 139 | param, 140 | visibility, 141 | }), 142 | [ 143 | confirm, 144 | cancel, 145 | desiredVisibility, 146 | handleBackButtonPress, 147 | handleBackdropPress, 148 | handleModalShown, 149 | handleModalHidden, 150 | param, 151 | visibility, 152 | ] 153 | ); 154 | }; 155 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-use-modal", 3 | "version": "1.0.2", 4 | "description": "hooks for the react native modal", 5 | "main": "lib/commonjs/index", 6 | "module": "lib/module/index", 7 | "types": "lib/typescript/index.d.ts", 8 | "react-native": "src/index", 9 | "source": "src/index", 10 | "files": [ 11 | "src", 12 | "lib", 13 | "android", 14 | "ios", 15 | "cpp", 16 | "react-native-use-modal.podspec", 17 | "!lib/typescript/example", 18 | "!android/build", 19 | "!ios/build", 20 | "!**/__tests__", 21 | "!**/__fixtures__", 22 | "!**/__mocks__" 23 | ], 24 | "scripts": { 25 | "test": "jest", 26 | "typescript": "tsc --noEmit", 27 | "lint": "eslint \"**/*.{js,ts,tsx}\"", 28 | "prepare": "bob build", 29 | "release": "dotenv release-it", 30 | "example": "yarn --cwd example", 31 | "pods": "cd example && pod-install --quiet", 32 | "bootstrap": "yarn example && yarn && yarn pods", 33 | "update:readme": "doctoc README.md --title '## Table of Contents'" 34 | }, 35 | "keywords": [ 36 | "react-native", 37 | "ios", 38 | "android" 39 | ], 40 | "repository": "https://github.com/zeallat/react-native-use-modal", 41 | "author": "Jimmy Lee (https://github.com/zeallat)", 42 | "license": "MIT", 43 | "bugs": { 44 | "url": "https://github.com/zeallat/react-native-use-modal/issues" 45 | }, 46 | "homepage": "https://github.com/zeallat/react-native-use-modal#readme", 47 | "publishConfig": { 48 | "registry": "https://registry.npmjs.org/" 49 | }, 50 | "devDependencies": { 51 | "@commitlint/config-conventional": "^11.0.0", 52 | "@react-native-community/eslint-config": "^2.0.0", 53 | "@release-it/conventional-changelog": "^2.0.0", 54 | "@types/jest": "^26.0.0", 55 | "@types/lodash": "^4.14.171", 56 | "@types/react": "^16.9.19", 57 | "@types/react-native": "0.62.13", 58 | "commitlint": "^11.0.0", 59 | "doctoc": "^2.0.1", 60 | "dotenv-cli": "^7.0.0", 61 | "eslint": "^7.2.0", 62 | "eslint-config-prettier": "^7.0.0", 63 | "eslint-plugin-prettier": "^3.1.3", 64 | "husky": "^4.2.5", 65 | "jest": "^26.0.1", 66 | "pod-install": "^0.1.0", 67 | "prettier": "^2.0.5", 68 | "react": "16.13.1", 69 | "react-native": "0.63.4", 70 | "react-native-builder-bob": "^0.18.0", 71 | "release-it": "^14.2.2", 72 | "typescript": "^4.1.3" 73 | }, 74 | "peerDependencies": { 75 | "react": "*", 76 | "react-native": "*" 77 | }, 78 | "jest": { 79 | "preset": "react-native", 80 | "modulePathIgnorePatterns": [ 81 | "/example/node_modules", 82 | "/lib/" 83 | ] 84 | }, 85 | "husky": { 86 | "hooks": { 87 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS", 88 | "pre-commit": "yarn lint && yarn typescript" 89 | } 90 | }, 91 | "commitlint": { 92 | "extends": [ 93 | "@commitlint/config-conventional" 94 | ] 95 | }, 96 | "release-it": { 97 | "git": { 98 | "commitMessage": "chore: release ${version}", 99 | "tagName": "v${version}" 100 | }, 101 | "npm": { 102 | "publish": true 103 | }, 104 | "github": { 105 | "release": true 106 | }, 107 | "plugins": { 108 | "@release-it/conventional-changelog": { 109 | "preset": "angular" 110 | } 111 | } 112 | }, 113 | "eslintConfig": { 114 | "root": true, 115 | "extends": [ 116 | "@react-native-community", 117 | "prettier" 118 | ], 119 | "rules": { 120 | "prettier/prettier": [ 121 | "error", 122 | { 123 | "quoteProps": "consistent", 124 | "singleQuote": true, 125 | "tabWidth": 2, 126 | "trailingComma": "es5", 127 | "useTabs": false 128 | } 129 | ] 130 | } 131 | }, 132 | "eslintIgnore": [ 133 | "node_modules/", 134 | "lib/" 135 | ], 136 | "prettier": { 137 | "quoteProps": "consistent", 138 | "singleQuote": true, 139 | "tabWidth": 2, 140 | "trailingComma": "es5", 141 | "useTabs": false 142 | }, 143 | "react-native-builder-bob": { 144 | "source": "src", 145 | "output": "lib", 146 | "targets": [ 147 | "commonjs", 148 | "module", 149 | [ 150 | "typescript", 151 | { 152 | "project": "tsconfig.build.json" 153 | } 154 | ] 155 | ] 156 | }, 157 | "dependencies": { 158 | "lodash": "^4.17.21", 159 | "react-native-modal": "^13.0.1", 160 | "rxjs": "^7.1.0" 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # XDE 6 | .expo/ 7 | 8 | # VSCode 9 | .vscode/ 10 | jsconfig.json 11 | 12 | # Xcode 13 | # 14 | build/ 15 | *.pbxuser 16 | !default.pbxuser 17 | *.mode1v3 18 | !default.mode1v3 19 | *.mode2v3 20 | !default.mode2v3 21 | *.perspectivev3 22 | !default.perspectivev3 23 | xcuserdata 24 | *.xccheckout 25 | *.moved-aside 26 | DerivedData 27 | *.hmap 28 | *.ipa 29 | *.xcuserstate 30 | project.xcworkspace 31 | 32 | # Android/IJ 33 | # 34 | .idea 35 | .gradle 36 | local.properties 37 | android.iml 38 | 39 | # Cocoapods 40 | # 41 | example/ios/Pods 42 | 43 | # node.js 44 | # 45 | node_modules/ 46 | npm-debug.log 47 | yarn-debug.log 48 | yarn-error.log 49 | 50 | # BUCK 51 | buck-out/ 52 | \.buckd/ 53 | android/app/libs 54 | android/keystores/debug.keystore 55 | 56 | # Expo 57 | .expo/* 58 | 59 | # generated by bob 60 | lib/ 61 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 62 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 63 | 64 | # User-specific stuff 65 | .idea/**/workspace.xml 66 | .idea/**/tasks.xml 67 | .idea/**/usage.statistics.xml 68 | .idea/**/dictionaries 69 | .idea/**/shelf 70 | 71 | # AWS User-specific 72 | .idea/**/aws.xml 73 | 74 | # Generated files 75 | .idea/**/contentModel.xml 76 | 77 | # Sensitive or high-churn files 78 | .idea/**/dataSources/ 79 | .idea/**/dataSources.ids 80 | .idea/**/dataSources.local.xml 81 | .idea/**/sqlDataSources.xml 82 | .idea/**/dynamic.xml 83 | .idea/**/uiDesigner.xml 84 | .idea/**/dbnavigator.xml 85 | 86 | # Gradle 87 | .idea/**/gradle.xml 88 | .idea/**/libraries 89 | 90 | # Gradle and Maven with auto-import 91 | # When using Gradle or Maven with auto-import, you should exclude module files, 92 | # since they will be recreated, and may cause churn. Uncomment if using 93 | # auto-import. 94 | # .idea/artifacts 95 | # .idea/compiler.xml 96 | # .idea/jarRepositories.xml 97 | # .idea/modules.xml 98 | # .idea/*.iml 99 | # .idea/modules 100 | # *.iml 101 | # *.ipr 102 | 103 | # CMake 104 | cmake-build-*/ 105 | 106 | # Mongo Explorer plugin 107 | .idea/**/mongoSettings.xml 108 | 109 | # File-based project format 110 | *.iws 111 | 112 | # IntelliJ 113 | out/ 114 | 115 | # mpeltonen/sbt-idea plugin 116 | .idea_modules/ 117 | 118 | # JIRA plugin 119 | atlassian-ide-plugin.xml 120 | 121 | # Cursive Clojure plugin 122 | .idea/replstate.xml 123 | 124 | # SonarLint plugin 125 | .idea/sonarlint/ 126 | 127 | # Crashlytics plugin (for Android Studio and IntelliJ) 128 | com_crashlytics_expor# Logs 129 | logs 130 | *.log 131 | npm-debug.log* 132 | yarn-debug.log* 133 | yarn-error.log* 134 | lerna-debug.log* 135 | .pnpm-debug.log* 136 | 137 | # Diagnostic reports (https://nodejs.org/api/report.html) 138 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 139 | 140 | # Runtime data 141 | pids 142 | *.pid 143 | *.seed 144 | *.pid.lock 145 | 146 | # Directory for instrumented libs generated by jscoverage/JSCover 147 | lib-cov 148 | 149 | # Coverage directory used by tools like istanbul 150 | coverage 151 | *.lcov 152 | 153 | # nyc test coverage 154 | .nyc_output 155 | 156 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 157 | .grunt 158 | 159 | # Bower dependency directory (https://bower.io/) 160 | bower_components 161 | 162 | # node-waf configuration 163 | .lock-wscript 164 | 165 | # Compiled binary addons (https://nodejs.org/api/addons.html) 166 | build/Release 167 | 168 | # Dependency directories 169 | node_modules/ 170 | jspm_packages/ 171 | 172 | # Snowpack dependency directory (https://snowpack.dev/) 173 | web_modules/ 174 | 175 | # TypeScript cache 176 | *.tsbuildinfo 177 | 178 | # Optional npm cache directory 179 | .npm 180 | 181 | # Optional eslint cache 182 | .eslintcache 183 | 184 | # Optional stylelint cache 185 | .stylelintcache 186 | 187 | # Microbundle cache 188 | .rpt2_cache/ 189 | .rts2_cache_cjs/ 190 | .rts2_cache_es/ 191 | .rts2_cache_umd/ 192 | 193 | # Optional REPL history 194 | .node_repl_history 195 | 196 | # Output of 'npm pack' 197 | *.tgz 198 | 199 | # Yarn Integrity file 200 | .yarn-integrity 201 | 202 | # dotenv environment variable files 203 | .env 204 | .env.development.local 205 | .env.test.local 206 | .env.production.local 207 | .env.local 208 | 209 | # parcel-bundler cache (https://parceljs.org/) 210 | .cache 211 | .parcel-cache 212 | 213 | # Next.js build output 214 | t_strings.xml 215 | crashlytics.properties 216 | crashlytics-build.properties 217 | fabric.properties 218 | 219 | # Editor-based Rest Client 220 | .idea/httpRequests 221 | 222 | # Android studio 3.1+ serialized cache file 223 | .idea/caches/build_file_checksums.ser 224 | .next 225 | out 226 | 227 | # Nuxt.js build / generate output 228 | .nuxt 229 | dist 230 | 231 | # Gatsby files 232 | .cache/ 233 | # Comment in the public line in if your project uses Gatsby and not Next.js 234 | # https://nextjs.org/blog/next-9-1#public-directory-support 235 | # public 236 | 237 | # vuepress build output 238 | .vuepress/dist 239 | 240 | # vuepress v2.x temp and cache directory 241 | .temp 242 | .cache 243 | 244 | # Docusaurus cache and generated files 245 | .docusaurus 246 | 247 | # Serverless directories 248 | .serverless/ 249 | 250 | # FuseBox cache 251 | .fusebox/ 252 | 253 | # DynamoDB Local files 254 | .dynamodb/ 255 | 256 | # TernJS port file 257 | .tern-port 258 | 259 | # Stores VSCode versions used for testing VSCode extensions 260 | .vscode-test 261 | 262 | # yarn v2 263 | .yarn/cache 264 | .yarn/unplugged 265 | .yarn/build-state.yml 266 | .yarn/install-state.gz 267 | .pnp.* 268 | .vscode/* 269 | !.vscode/settings.json 270 | !.vscode/tasks.json 271 | !.vscode/launch.json 272 | !.vscode/extensions.json 273 | !.vscode/*.code-snippets 274 | 275 | # Local History for Visual Studio Code 276 | .history/ 277 | 278 | # Built Visual Studio Code Extensions 279 | *.vsix 280 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project. 4 | 5 | ## Development workflow 6 | 7 | To get started with the project, run `yarn` in the root directory to install the required dependencies for each package: 8 | 9 | ```sh 10 | yarn 11 | ``` 12 | 13 | > While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development. 14 | 15 | While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app. 16 | 17 | To start the packager: 18 | 19 | ```sh 20 | yarn example start 21 | ``` 22 | 23 | To run the example app on Android: 24 | 25 | ```sh 26 | yarn example android 27 | ``` 28 | 29 | To run the example app on iOS: 30 | 31 | ```sh 32 | yarn example ios 33 | ``` 34 | 35 | To run the example app on Web: 36 | 37 | ```sh 38 | yarn example web 39 | ``` 40 | 41 | Make sure your code passes TypeScript and ESLint. Run the following to verify: 42 | 43 | ```sh 44 | yarn typescript 45 | yarn lint 46 | ``` 47 | 48 | To fix formatting errors, run the following: 49 | 50 | ```sh 51 | yarn lint --fix 52 | ``` 53 | 54 | Remember to add tests for your change if possible. Run the unit tests by: 55 | 56 | ```sh 57 | yarn test 58 | ``` 59 | 60 | ### Commit message convention 61 | 62 | We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages: 63 | 64 | - `fix`: bug fixes, e.g. fix crash due to deprecated method. 65 | - `feat`: new features, e.g. add new method to the module. 66 | - `refactor`: code refactor, e.g. migrate from class components to hooks. 67 | - `docs`: changes into documentation, e.g. add usage example for the module.. 68 | - `test`: adding or updating tests, e.g. add integration tests using detox. 69 | - `chore`: tooling changes, e.g. change CI config. 70 | 71 | Our pre-commit hooks verify that your commit message matches this format when committing. 72 | 73 | ### Linting and tests 74 | 75 | [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/) 76 | 77 | We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing. 78 | 79 | Our pre-commit hooks verify that the linter and tests pass when committing. 80 | 81 | ### Publishing to npm 82 | 83 | We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc. 84 | 85 | To publish new versions, run the following: 86 | 87 | ```sh 88 | yarn release 89 | ``` 90 | 91 | ### Scripts 92 | 93 | The `package.json` file contains various scripts for common tasks: 94 | 95 | - `yarn bootstrap`: setup project by installing all dependencies and pods. 96 | - `yarn typescript`: type-check files with TypeScript. 97 | - `yarn lint`: lint files with ESLint. 98 | - `yarn test`: run unit tests with Jest. 99 | - `yarn example start`: start the Metro server for the example app. 100 | - `yarn example android`: run the example app on Android. 101 | - `yarn example ios`: run the example app on iOS. 102 | 103 | ### Sending a pull request 104 | 105 | > **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github). 106 | 107 | When you're sending a pull request: 108 | 109 | - Prefer small pull requests focused on one change. 110 | - Verify that linters and tests are passing. 111 | - Review the documentation to make sure it looks good. 112 | - Follow the pull request template when opening a pull request. 113 | - For pull requests that change the API or implementation, discuss with maintainers first by opening an issue. 114 | 115 | ## Code of Conduct 116 | 117 | ### Our Pledge 118 | 119 | We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. 120 | 121 | We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. 122 | 123 | ### Our Standards 124 | 125 | Examples of behavior that contributes to a positive environment for our community include: 126 | 127 | - Demonstrating empathy and kindness toward other people 128 | - Being respectful of differing opinions, viewpoints, and experiences 129 | - Giving and gracefully accepting constructive feedback 130 | - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience 131 | - Focusing on what is best not just for us as individuals, but for the overall community 132 | 133 | Examples of unacceptable behavior include: 134 | 135 | - The use of sexualized language or imagery, and sexual attention or 136 | advances of any kind 137 | - Trolling, insulting or derogatory comments, and personal or political attacks 138 | - Public or private harassment 139 | - Publishing others' private information, such as a physical or email 140 | address, without their explicit permission 141 | - Other conduct which could reasonably be considered inappropriate in a 142 | professional setting 143 | 144 | ### Enforcement Responsibilities 145 | 146 | Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. 147 | 148 | Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. 149 | 150 | ### Scope 151 | 152 | This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. 153 | 154 | ### Enforcement 155 | 156 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly. 157 | 158 | All community leaders are obligated to respect the privacy and security of the reporter of any incident. 159 | 160 | ### Enforcement Guidelines 161 | 162 | Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: 163 | 164 | #### 1. Correction 165 | 166 | **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. 167 | 168 | **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. 169 | 170 | #### 2. Warning 171 | 172 | **Community Impact**: A violation through a single incident or series of actions. 173 | 174 | **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. 175 | 176 | #### 3. Temporary Ban 177 | 178 | **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. 179 | 180 | **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. 181 | 182 | #### 4. Permanent Ban 183 | 184 | **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. 185 | 186 | **Consequence**: A permanent ban from any sort of public interaction within the community. 187 | 188 | ### Attribution 189 | 190 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, 191 | available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 192 | 193 | Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). 194 | 195 | [homepage]: https://www.contributor-covenant.org 196 | 197 | For answers to common questions about this code of conduct, see the FAQ at 198 | https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. 199 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | project.ext.vectoricons = [ 4 | iconFontNames: [ 'MaterialIcons.ttf' ] // Name of the font files you want to copy 5 | ] 6 | apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" 7 | 8 | import com.android.build.OutputFile 9 | 10 | /** 11 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 12 | * and bundleReleaseJsAndAssets). 13 | * These basically call `react-native bundle` with the correct arguments during the Android build 14 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 15 | * bundle directly from the development server. Below you can see all the possible configurations 16 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 17 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 18 | * 19 | * project.ext.react = [ 20 | * // the name of the generated asset file containing your JS bundle 21 | * bundleAssetName: "index.android.bundle", 22 | * 23 | * // the entry file for bundle generation. If none specified and 24 | * // "index.android.js" exists, it will be used. Otherwise "index.js" is 25 | * // default. Can be overridden with ENTRY_FILE environment variable. 26 | * entryFile: "index.android.js", 27 | * 28 | * // https://reactnative.dev/docs/performance#enable-the-ram-format 29 | * bundleCommand: "ram-bundle", 30 | * 31 | * // whether to bundle JS and assets in debug mode 32 | * bundleInDebug: false, 33 | * 34 | * // whether to bundle JS and assets in release mode 35 | * bundleInRelease: true, 36 | * 37 | * // whether to bundle JS and assets in another build variant (if configured). 38 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 39 | * // The configuration property can be in the following formats 40 | * // 'bundleIn${productFlavor}${buildType}' 41 | * // 'bundleIn${buildType}' 42 | * // bundleInFreeDebug: true, 43 | * // bundleInPaidRelease: true, 44 | * // bundleInBeta: true, 45 | * 46 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 47 | * // for example: to disable dev mode in the staging build type (if configured) 48 | * devDisabledInStaging: true, 49 | * // The configuration property can be in the following formats 50 | * // 'devDisabledIn${productFlavor}${buildType}' 51 | * // 'devDisabledIn${buildType}' 52 | * 53 | * // the root of your project, i.e. where "package.json" lives 54 | * root: "../../", 55 | * 56 | * // where to put the JS bundle asset in debug mode 57 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 58 | * 59 | * // where to put the JS bundle asset in release mode 60 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 61 | * 62 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 63 | * // require('./image.png')), in debug mode 64 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 65 | * 66 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 67 | * // require('./image.png')), in release mode 68 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 69 | * 70 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 71 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 72 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 73 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 74 | * // for example, you might want to remove it from here. 75 | * inputExcludes: ["android/**", "ios/**"], 76 | * 77 | * // override which node gets called and with what additional arguments 78 | * nodeExecutableAndArgs: ["node"], 79 | * 80 | * // supply additional arguments to the packager 81 | * extraPackagerArgs: [] 82 | * ] 83 | */ 84 | 85 | project.ext.react = [ 86 | enableHermes: false, // clean and rebuild if changing 87 | ] 88 | 89 | apply from: "../../node_modules/react-native/react.gradle" 90 | 91 | /** 92 | * Set this to true to create two separate APKs instead of one: 93 | * - An APK that only works on ARM devices 94 | * - An APK that only works on x86 devices 95 | * The advantage is the size of the APK is reduced by about 4MB. 96 | * Upload all the APKs to the Play Store and people will download 97 | * the correct one based on the CPU architecture of their device. 98 | */ 99 | def enableSeparateBuildPerCPUArchitecture = false 100 | 101 | /** 102 | * Run Proguard to shrink the Java bytecode in release builds. 103 | */ 104 | def enableProguardInReleaseBuilds = false 105 | 106 | /** 107 | * The preferred build flavor of JavaScriptCore. 108 | * 109 | * For example, to use the international variant, you can use: 110 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` 111 | * 112 | * The international variant includes ICU i18n library and necessary data 113 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that 114 | * give correct results when using with locales other than en-US. Note that 115 | * this variant is about 6MiB larger per architecture than default. 116 | */ 117 | def jscFlavor = 'org.webkit:android-jsc:+' 118 | 119 | /** 120 | * Whether to enable the Hermes VM. 121 | * 122 | * This should be set on project.ext.react and mirrored here. If it is not set 123 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode 124 | * and the benefits of using Hermes will therefore be sharply reduced. 125 | */ 126 | def enableHermes = project.ext.react.get("enableHermes", false); 127 | 128 | android { 129 | ndkVersion rootProject.ext.ndkVersion 130 | 131 | compileSdkVersion rootProject.ext.compileSdkVersion 132 | 133 | compileOptions { 134 | sourceCompatibility JavaVersion.VERSION_1_8 135 | targetCompatibility JavaVersion.VERSION_1_8 136 | } 137 | 138 | defaultConfig { 139 | applicationId "com.example" 140 | minSdkVersion rootProject.ext.minSdkVersion 141 | targetSdkVersion rootProject.ext.targetSdkVersion 142 | versionCode 1 143 | versionName "1.0" 144 | } 145 | splits { 146 | abi { 147 | reset() 148 | enable enableSeparateBuildPerCPUArchitecture 149 | universalApk false // If true, also generate a universal APK 150 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 151 | } 152 | } 153 | signingConfigs { 154 | debug { 155 | storeFile file('debug.keystore') 156 | storePassword 'android' 157 | keyAlias 'androiddebugkey' 158 | keyPassword 'android' 159 | } 160 | } 161 | buildTypes { 162 | debug { 163 | signingConfig signingConfigs.debug 164 | } 165 | release { 166 | // Caution! In production, you need to generate your own keystore file. 167 | // see https://reactnative.dev/docs/signed-apk-android. 168 | signingConfig signingConfigs.debug 169 | minifyEnabled enableProguardInReleaseBuilds 170 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 171 | } 172 | } 173 | 174 | // applicationVariants are e.g. debug, release 175 | applicationVariants.all { variant -> 176 | variant.outputs.each { output -> 177 | // For each separate APK per architecture, set a unique version code as described here: 178 | // https://developer.android.com/studio/build/configure-apk-splits.html 179 | // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. 180 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 181 | def abi = output.getFilter(OutputFile.ABI) 182 | if (abi != null) { // null for the universal-debug, universal-release variants 183 | output.versionCodeOverride = 184 | defaultConfig.versionCode * 1000 + versionCodes.get(abi) 185 | } 186 | 187 | } 188 | } 189 | } 190 | 191 | dependencies { 192 | implementation fileTree(dir: "libs", include: ["*.jar"]) 193 | //noinspection GradleDynamicVersion 194 | implementation "com.facebook.react:react-native:+" // From node_modules 195 | 196 | implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" 197 | 198 | debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { 199 | exclude group:'com.facebook.fbjni' 200 | } 201 | 202 | debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { 203 | exclude group:'com.facebook.flipper' 204 | exclude group:'com.squareup.okhttp3', module:'okhttp' 205 | } 206 | 207 | debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { 208 | exclude group:'com.facebook.flipper' 209 | } 210 | 211 | if (enableHermes) { 212 | def hermesPath = "../../node_modules/hermes-engine/android/"; 213 | debugImplementation files(hermesPath + "hermes-debug.aar") 214 | releaseImplementation files(hermesPath + "hermes-release.aar") 215 | } else { 216 | implementation jscFlavor 217 | } 218 | } 219 | 220 | // Run this once to be able to run the application with BUCK 221 | // puts all compile dependencies into folder libs for BUCK to use 222 | task copyDownloadableDepsToLibs(type: Copy) { 223 | from configurations.compile 224 | into 'libs' 225 | } 226 | 227 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) 228 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-use-modal 2 | 3 | [![npm](https://img.shields.io/npm/v/react-native-use-modal?color=brightgreen)](https://www.npmjs.com/package/react-native-use-modal) 4 | [![npm](https://img.shields.io/npm/dw/react-native-use-modal)](https://www.npmjs.com/package/react-native-use-modal) 5 | [![license](https://badgen.net/github/license/zeallat/react-native-use-modal)](./LICENSE) 6 | 7 | A way to create modals that are easily reusable, encapsulated, and handle the results. 8 | 9 | The goal of `react-native-use-modal` is to make all the functions of `react-native-modal` available and convenient to use at the same time. 10 | 11 | ## Feature 12 | 13 | - Show modal and get result as promise 14 | - Easy to show multiple modal continuously 15 | - Pass parameters to modal when call `show` 16 | - Get result data from modal when hide (as promise) 17 | - modal encapsulation 18 | - No need to explicitly place modal at component tree 19 | - Fully customizable 20 | 21 | 22 | 23 | ## Table of Contents 24 | 25 | - [Installation](#installation) 26 | - [Place `ModalProvider` at your app's root component](#place-modalprovider-at-your-apps-root-component) 27 | - [Usage](#usage) 28 | - [Declare modal as hook with `createUseModal`](#declare-modal-as-hook-with-createusemodal) 29 | - [Show modal using hook](#show-modal-using-hook) 30 | - [Handling the modal's result](#handling-the-modals-result) 31 | - [Declare modal that require parameters](#declare-modal-that-require-parameters) 32 | - [Show modal that require parameters](#show-modal-that-require-parameters) 33 | - [Declare modal that return values](#declare-modal-that-return-values) 34 | - [Handling the modal's result with value](#handling-the-modals-result-with-value) 35 | - [Customize modal config](#customize-modal-config) 36 | - [Make cancelable when press backdrop or back button](#make-cancelable-when-press-backdrop-or-back-button) 37 | - [Creating a preconfigured createUseModal](#creating-a-preconfigured-createusemodal) 38 | - [Making a third-party modal or an existing modal into a 'hook'](#making-a-third-party-modal-or-an-existing-modal-into-a-hook) 39 | - [Workflow example](#workflow-example) 40 | - [Contributing](#contributing) 41 | - [License](#license) 42 | 43 | 44 | 45 | ## Installation 46 | 47 | ```sh 48 | yarn add react-native-use-modal 49 | 50 | # or 51 | 52 | npm i react-native-use-modal 53 | ``` 54 | 55 | ### Place `ModalProvider` at your app's root component 56 | 57 | ```tsx 58 | // App.tsx 59 | import {ModalProvider} from 'react-native-use-modal'; 60 | 61 | const App = () => { 62 | return 63 | // ... 64 | ; 65 | }; 66 | ``` 67 | 68 | If you are already using a different provider, make the `ModalProvider` a child of the other provider. 69 | Otherwise, the modal will not get the values broadcast by other providers. 70 | 71 | ```tsx 72 | import {Provider} from 'react-redux'; 73 | 74 | const App = () => { 75 | return ( 76 | 77 | 78 | 79 | 80 | // ... 81 | 82 | 83 | 84 | 85 | ); 86 | }; 87 | ``` 88 | 89 | ## Usage 90 | 91 | ### Declare modal as hook with `createUseModal` 92 | 93 | `createUseModal` function receives a functional component of the specified type as the first argument. 94 | This component will later be displayed as a modal. 95 | 96 | ```tsx 97 | // useSimpleModal.tsx 98 | import {createUseModal} from 'react-native-use-modal'; 99 | 100 | // createUseModal creates a hook and returns it. 101 | const useSimpleModal = createUseModal( 102 | ({ 103 | confirm, // Call this function to finish (confirm) modal 104 | cancel, // Call this function to finish (cancel) modal 105 | }) => { 106 | // return react node to show as modal 107 | return ( 108 | 109 | /* any view to presentation */ 110 | 111 | 112 | 113 | ); 114 | }, 115 | ); 116 | ``` 117 | 118 | ### Show modal using hook 119 | 120 | ..from any other react component 121 | 122 | ```tsx 123 | // FooView.tsx 124 | 125 | const FooView = () => { 126 | // Call the hook you declared earlier 127 | // By calling the hook created with createUseModal, you can get an object that can display modal. 128 | const simpleModal = useSimpleModal(); 129 | 130 | const handlePressButton = () => { 131 | // Show modal! 132 | // This returns a Promise 133 | simpleModal.show(); 134 | }; 135 | }; 136 | ``` 137 | 138 | ### Handling the modal's result 139 | 140 | You can wait for modal to return the result with await 141 | 142 | ```tsx 143 | // FooView.tsx 144 | const handlePressButton = async () => { 145 | // Show modal! 146 | // This returns a Promise 147 | const result = await simpleModal.show(); 148 | if (result.type === ModalResultType.CONFIRM) { 149 | // handle confirm here 150 | // ... 151 | } else { 152 | // handle cancel here 153 | // ... 154 | } 155 | }; 156 | ``` 157 | 158 | ### Declare modal that require parameters 159 | 160 | We sometimes need parameters to configure the modal. 161 | 162 | `createUseModal` receives two generic types, the first is the type of data to be included in the result of modal, and the second is the type of parameter passed when calling modal. 163 | 164 | If not used, just declare it as void type. The default is void. 165 | 166 | ```tsx 167 | // useAlertModal.tsx 168 | import {createUseModal} from 'react-native-use-modal'; 169 | 170 | const useAlertModal = createUseModal< 171 | void, // Result data type. In this case it is not used, so it is void. 172 | {title: string; message: string} // Parameters type 173 | >(({confirm, cancel, param}) => { // Parameters are passed in props 174 | return ( 175 | 176 | {param.title} 177 | {param.message} 178 | 179 | 180 | 181 | 182 | 183 | ); 184 | }); 185 | ``` 186 | 187 | ### Show modal that require parameters 188 | 189 | ```tsx 190 | // BarView.tsx 191 | const BarView = () => { 192 | // Call the hook you declared earlier 193 | const alertModal = useAlertModal(); 194 | 195 | const handlePressButton = () => { 196 | // Show modal! 197 | // This returns a Promise 198 | alertModal.show({ 199 | title: 'Title', 200 | message: 'Message', 201 | }); 202 | }; 203 | }; 204 | ``` 205 | 206 | ### Declare modal that return values 207 | 208 | Sometimes we may want to return a result from Modal. 209 | ```tsx 210 | // Pass the result data type as the first Generic argument. 211 | // In this case, no parameters are used, so the second generic argument does not need to be passed. 212 | // Now, the confirm function passed as props receives the value of the data type declared as generic. 213 | export const useTextInputModal = createUseModal(({confirm, cancel}) => { 214 | const [value, setValue] = useState(''); 215 | 216 | const handlePressConfirm = () => confirm(value); 217 | 218 | return ( 219 | 220 | 224 | 225 | 226 | 227 | 228 | 229 | ); 230 | }); 231 | ``` 232 | 233 | ### Handling the modal's result with value 234 | ```tsx 235 | // BazView.tsx 236 | const BazView = () => { 237 | const textInputModal = useTextInputModal(); 238 | 239 | const handlePressButton = async () => { 240 | // Show modal! 241 | // This returns a Promise> 242 | const result = await textInputModal.show(); 243 | if (result.type === ModalResultType.CONFIRM) { 244 | // handle confirm here 245 | // You can find the entered value in result 246 | console.log('entered: ' + result.data); 247 | } else { 248 | // handle cancel here 249 | // ... 250 | } 251 | }; 252 | }; 253 | ``` 254 | 255 | ### Customize modal config 256 | This package depends on `react-native-modal` and accept all its props. 257 | You can set this in the second argument of the `createUseModal`. 258 | For example, an animation could be set up like this: 259 | 260 | ```tsx 261 | export const useSimpleModal = createUseModal( 262 | ({confirm, cancel}) => { 263 | /* render here */ 264 | }, 265 | { 266 | modalProps: { 267 | animationIn: 'fadeIn', 268 | animationOut: 'fadeOut', 269 | }, 270 | }, 271 | ); 272 | ``` 273 | `createUseModal` supports all props, except for the `isVisible` property. We internally manage this property. 274 | 275 | ### Make cancelable when press backdrop or back button 276 | With these option, modal will cancel when press backdrop or back button. 277 | Each option can be set independently. 278 | ```tsx 279 | export const useSimpleModal = createUseModal( 280 | ({confirm, cancel}) => { 281 | /* render here */ 282 | }, 283 | { 284 | cancelOnBackButtonPress: true, // Default is false 285 | cancelOnBackdropPress: true, // Default is false 286 | }, 287 | ); 288 | ``` 289 | 290 | ### Creating a preconfigured createUseModal 291 | You can use the `createCreateUseModal` function to create createUseModal with predefined options. 292 | For example, if you need to create several bottom sheet modal, you can use it in a way such as defining the modalOption value for creating a bottom sheet modal in advance. 293 | 294 | An example usage can be found at [create-use-bottom-sheet-modal.tsx](src/create-use-bottom-sheet-modal.tsx). 295 | 296 | ### Making a third-party modal or an existing modal into a 'hook' 297 | Using `createUseForwardedModal`, You can make a normal modal (modal that receives the visible property as props) a 'hook'. 298 | It can be used when you want to make a modal component provided by the design component library into a 'hook' or to make an existing modal component into a 'hook' with minimal effort. 299 | 300 | An example usage can be found at [forwarded-alert-modal-example-screen.tsx](example/src/forwarded-alert-modal-example/forwarded-alert-modal-example-screen.tsx). 301 | 302 | ## Workflow example 303 | 304 | You can clone this project and test examples by running the following command: 305 | 306 | ```shell 307 | # iOS 308 | yarn && yarn example ios 309 | # Android 310 | yarn && yarn example android 311 | ``` 312 | 313 | Examples provided are: 314 | 315 | - [Alert modal](example/src/alert-modal-example) 316 | - [Simple modal](example/src/simple-modal-example) 317 | - [Text input modal](example/src/text-input-modal-example) 318 | - [Show modal continuously](example/src/show-modal-continuously-example) 319 | 320 | ## Contributing 321 | 322 | See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. 323 | 324 | ## License 325 | 326 | MIT 327 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - boost-for-react-native (1.63.0) 3 | - CocoaAsyncSocket (7.6.5) 4 | - DoubleConversion (1.1.6) 5 | - FBLazyVector (0.64.1) 6 | - FBReactNativeSpec (0.64.1): 7 | - RCT-Folly (= 2020.01.13.00) 8 | - RCTRequired (= 0.64.1) 9 | - RCTTypeSafety (= 0.64.1) 10 | - React-Core (= 0.64.1) 11 | - React-jsi (= 0.64.1) 12 | - ReactCommon/turbomodule/core (= 0.64.1) 13 | - Flipper (0.75.1): 14 | - Flipper-Folly (~> 2.5) 15 | - Flipper-RSocket (~> 1.3) 16 | - Flipper-DoubleConversion (1.1.7) 17 | - Flipper-Folly (2.5.3): 18 | - boost-for-react-native 19 | - Flipper-DoubleConversion 20 | - Flipper-Glog 21 | - libevent (~> 2.1.12) 22 | - OpenSSL-Universal (= 1.1.180) 23 | - Flipper-Glog (0.3.6) 24 | - Flipper-PeerTalk (0.0.4) 25 | - Flipper-RSocket (1.3.1): 26 | - Flipper-Folly (~> 2.5) 27 | - FlipperKit (0.75.1): 28 | - FlipperKit/Core (= 0.75.1) 29 | - FlipperKit/Core (0.75.1): 30 | - Flipper (~> 0.75.1) 31 | - FlipperKit/CppBridge 32 | - FlipperKit/FBCxxFollyDynamicConvert 33 | - FlipperKit/FBDefines 34 | - FlipperKit/FKPortForwarding 35 | - FlipperKit/CppBridge (0.75.1): 36 | - Flipper (~> 0.75.1) 37 | - FlipperKit/FBCxxFollyDynamicConvert (0.75.1): 38 | - Flipper-Folly (~> 2.5) 39 | - FlipperKit/FBDefines (0.75.1) 40 | - FlipperKit/FKPortForwarding (0.75.1): 41 | - CocoaAsyncSocket (~> 7.6) 42 | - Flipper-PeerTalk (~> 0.0.4) 43 | - FlipperKit/FlipperKitHighlightOverlay (0.75.1) 44 | - FlipperKit/FlipperKitLayoutPlugin (0.75.1): 45 | - FlipperKit/Core 46 | - FlipperKit/FlipperKitHighlightOverlay 47 | - FlipperKit/FlipperKitLayoutTextSearchable 48 | - YogaKit (~> 1.18) 49 | - FlipperKit/FlipperKitLayoutTextSearchable (0.75.1) 50 | - FlipperKit/FlipperKitNetworkPlugin (0.75.1): 51 | - FlipperKit/Core 52 | - FlipperKit/FlipperKitReactPlugin (0.75.1): 53 | - FlipperKit/Core 54 | - FlipperKit/FlipperKitUserDefaultsPlugin (0.75.1): 55 | - FlipperKit/Core 56 | - FlipperKit/SKIOSNetworkPlugin (0.75.1): 57 | - FlipperKit/Core 58 | - FlipperKit/FlipperKitNetworkPlugin 59 | - glog (0.3.5) 60 | - libevent (2.1.12) 61 | - OpenSSL-Universal (1.1.180) 62 | - RCT-Folly (2020.01.13.00): 63 | - boost-for-react-native 64 | - DoubleConversion 65 | - glog 66 | - RCT-Folly/Default (= 2020.01.13.00) 67 | - RCT-Folly/Default (2020.01.13.00): 68 | - boost-for-react-native 69 | - DoubleConversion 70 | - glog 71 | - RCTRequired (0.64.1) 72 | - RCTTypeSafety (0.64.1): 73 | - FBLazyVector (= 0.64.1) 74 | - RCT-Folly (= 2020.01.13.00) 75 | - RCTRequired (= 0.64.1) 76 | - React-Core (= 0.64.1) 77 | - React (0.64.1): 78 | - React-Core (= 0.64.1) 79 | - React-Core/DevSupport (= 0.64.1) 80 | - React-Core/RCTWebSocket (= 0.64.1) 81 | - React-RCTActionSheet (= 0.64.1) 82 | - React-RCTAnimation (= 0.64.1) 83 | - React-RCTBlob (= 0.64.1) 84 | - React-RCTImage (= 0.64.1) 85 | - React-RCTLinking (= 0.64.1) 86 | - React-RCTNetwork (= 0.64.1) 87 | - React-RCTSettings (= 0.64.1) 88 | - React-RCTText (= 0.64.1) 89 | - React-RCTVibration (= 0.64.1) 90 | - React-callinvoker (0.64.1) 91 | - React-Core (0.64.1): 92 | - glog 93 | - RCT-Folly (= 2020.01.13.00) 94 | - React-Core/Default (= 0.64.1) 95 | - React-cxxreact (= 0.64.1) 96 | - React-jsi (= 0.64.1) 97 | - React-jsiexecutor (= 0.64.1) 98 | - React-perflogger (= 0.64.1) 99 | - Yoga 100 | - React-Core/CoreModulesHeaders (0.64.1): 101 | - glog 102 | - RCT-Folly (= 2020.01.13.00) 103 | - React-Core/Default 104 | - React-cxxreact (= 0.64.1) 105 | - React-jsi (= 0.64.1) 106 | - React-jsiexecutor (= 0.64.1) 107 | - React-perflogger (= 0.64.1) 108 | - Yoga 109 | - React-Core/Default (0.64.1): 110 | - glog 111 | - RCT-Folly (= 2020.01.13.00) 112 | - React-cxxreact (= 0.64.1) 113 | - React-jsi (= 0.64.1) 114 | - React-jsiexecutor (= 0.64.1) 115 | - React-perflogger (= 0.64.1) 116 | - Yoga 117 | - React-Core/DevSupport (0.64.1): 118 | - glog 119 | - RCT-Folly (= 2020.01.13.00) 120 | - React-Core/Default (= 0.64.1) 121 | - React-Core/RCTWebSocket (= 0.64.1) 122 | - React-cxxreact (= 0.64.1) 123 | - React-jsi (= 0.64.1) 124 | - React-jsiexecutor (= 0.64.1) 125 | - React-jsinspector (= 0.64.1) 126 | - React-perflogger (= 0.64.1) 127 | - Yoga 128 | - React-Core/RCTActionSheetHeaders (0.64.1): 129 | - glog 130 | - RCT-Folly (= 2020.01.13.00) 131 | - React-Core/Default 132 | - React-cxxreact (= 0.64.1) 133 | - React-jsi (= 0.64.1) 134 | - React-jsiexecutor (= 0.64.1) 135 | - React-perflogger (= 0.64.1) 136 | - Yoga 137 | - React-Core/RCTAnimationHeaders (0.64.1): 138 | - glog 139 | - RCT-Folly (= 2020.01.13.00) 140 | - React-Core/Default 141 | - React-cxxreact (= 0.64.1) 142 | - React-jsi (= 0.64.1) 143 | - React-jsiexecutor (= 0.64.1) 144 | - React-perflogger (= 0.64.1) 145 | - Yoga 146 | - React-Core/RCTBlobHeaders (0.64.1): 147 | - glog 148 | - RCT-Folly (= 2020.01.13.00) 149 | - React-Core/Default 150 | - React-cxxreact (= 0.64.1) 151 | - React-jsi (= 0.64.1) 152 | - React-jsiexecutor (= 0.64.1) 153 | - React-perflogger (= 0.64.1) 154 | - Yoga 155 | - React-Core/RCTImageHeaders (0.64.1): 156 | - glog 157 | - RCT-Folly (= 2020.01.13.00) 158 | - React-Core/Default 159 | - React-cxxreact (= 0.64.1) 160 | - React-jsi (= 0.64.1) 161 | - React-jsiexecutor (= 0.64.1) 162 | - React-perflogger (= 0.64.1) 163 | - Yoga 164 | - React-Core/RCTLinkingHeaders (0.64.1): 165 | - glog 166 | - RCT-Folly (= 2020.01.13.00) 167 | - React-Core/Default 168 | - React-cxxreact (= 0.64.1) 169 | - React-jsi (= 0.64.1) 170 | - React-jsiexecutor (= 0.64.1) 171 | - React-perflogger (= 0.64.1) 172 | - Yoga 173 | - React-Core/RCTNetworkHeaders (0.64.1): 174 | - glog 175 | - RCT-Folly (= 2020.01.13.00) 176 | - React-Core/Default 177 | - React-cxxreact (= 0.64.1) 178 | - React-jsi (= 0.64.1) 179 | - React-jsiexecutor (= 0.64.1) 180 | - React-perflogger (= 0.64.1) 181 | - Yoga 182 | - React-Core/RCTSettingsHeaders (0.64.1): 183 | - glog 184 | - RCT-Folly (= 2020.01.13.00) 185 | - React-Core/Default 186 | - React-cxxreact (= 0.64.1) 187 | - React-jsi (= 0.64.1) 188 | - React-jsiexecutor (= 0.64.1) 189 | - React-perflogger (= 0.64.1) 190 | - Yoga 191 | - React-Core/RCTTextHeaders (0.64.1): 192 | - glog 193 | - RCT-Folly (= 2020.01.13.00) 194 | - React-Core/Default 195 | - React-cxxreact (= 0.64.1) 196 | - React-jsi (= 0.64.1) 197 | - React-jsiexecutor (= 0.64.1) 198 | - React-perflogger (= 0.64.1) 199 | - Yoga 200 | - React-Core/RCTVibrationHeaders (0.64.1): 201 | - glog 202 | - RCT-Folly (= 2020.01.13.00) 203 | - React-Core/Default 204 | - React-cxxreact (= 0.64.1) 205 | - React-jsi (= 0.64.1) 206 | - React-jsiexecutor (= 0.64.1) 207 | - React-perflogger (= 0.64.1) 208 | - Yoga 209 | - React-Core/RCTWebSocket (0.64.1): 210 | - glog 211 | - RCT-Folly (= 2020.01.13.00) 212 | - React-Core/Default (= 0.64.1) 213 | - React-cxxreact (= 0.64.1) 214 | - React-jsi (= 0.64.1) 215 | - React-jsiexecutor (= 0.64.1) 216 | - React-perflogger (= 0.64.1) 217 | - Yoga 218 | - React-CoreModules (0.64.1): 219 | - FBReactNativeSpec (= 0.64.1) 220 | - RCT-Folly (= 2020.01.13.00) 221 | - RCTTypeSafety (= 0.64.1) 222 | - React-Core/CoreModulesHeaders (= 0.64.1) 223 | - React-jsi (= 0.64.1) 224 | - React-RCTImage (= 0.64.1) 225 | - ReactCommon/turbomodule/core (= 0.64.1) 226 | - React-cxxreact (0.64.1): 227 | - boost-for-react-native (= 1.63.0) 228 | - DoubleConversion 229 | - glog 230 | - RCT-Folly (= 2020.01.13.00) 231 | - React-callinvoker (= 0.64.1) 232 | - React-jsi (= 0.64.1) 233 | - React-jsinspector (= 0.64.1) 234 | - React-perflogger (= 0.64.1) 235 | - React-runtimeexecutor (= 0.64.1) 236 | - React-jsi (0.64.1): 237 | - boost-for-react-native (= 1.63.0) 238 | - DoubleConversion 239 | - glog 240 | - RCT-Folly (= 2020.01.13.00) 241 | - React-jsi/Default (= 0.64.1) 242 | - React-jsi/Default (0.64.1): 243 | - boost-for-react-native (= 1.63.0) 244 | - DoubleConversion 245 | - glog 246 | - RCT-Folly (= 2020.01.13.00) 247 | - React-jsiexecutor (0.64.1): 248 | - DoubleConversion 249 | - glog 250 | - RCT-Folly (= 2020.01.13.00) 251 | - React-cxxreact (= 0.64.1) 252 | - React-jsi (= 0.64.1) 253 | - React-perflogger (= 0.64.1) 254 | - React-jsinspector (0.64.1) 255 | - react-native-safe-area-context (3.2.0): 256 | - React-Core 257 | - React-perflogger (0.64.1) 258 | - React-RCTActionSheet (0.64.1): 259 | - React-Core/RCTActionSheetHeaders (= 0.64.1) 260 | - React-RCTAnimation (0.64.1): 261 | - FBReactNativeSpec (= 0.64.1) 262 | - RCT-Folly (= 2020.01.13.00) 263 | - RCTTypeSafety (= 0.64.1) 264 | - React-Core/RCTAnimationHeaders (= 0.64.1) 265 | - React-jsi (= 0.64.1) 266 | - ReactCommon/turbomodule/core (= 0.64.1) 267 | - React-RCTBlob (0.64.1): 268 | - FBReactNativeSpec (= 0.64.1) 269 | - RCT-Folly (= 2020.01.13.00) 270 | - React-Core/RCTBlobHeaders (= 0.64.1) 271 | - React-Core/RCTWebSocket (= 0.64.1) 272 | - React-jsi (= 0.64.1) 273 | - React-RCTNetwork (= 0.64.1) 274 | - ReactCommon/turbomodule/core (= 0.64.1) 275 | - React-RCTImage (0.64.1): 276 | - FBReactNativeSpec (= 0.64.1) 277 | - RCT-Folly (= 2020.01.13.00) 278 | - RCTTypeSafety (= 0.64.1) 279 | - React-Core/RCTImageHeaders (= 0.64.1) 280 | - React-jsi (= 0.64.1) 281 | - React-RCTNetwork (= 0.64.1) 282 | - ReactCommon/turbomodule/core (= 0.64.1) 283 | - React-RCTLinking (0.64.1): 284 | - FBReactNativeSpec (= 0.64.1) 285 | - React-Core/RCTLinkingHeaders (= 0.64.1) 286 | - React-jsi (= 0.64.1) 287 | - ReactCommon/turbomodule/core (= 0.64.1) 288 | - React-RCTNetwork (0.64.1): 289 | - FBReactNativeSpec (= 0.64.1) 290 | - RCT-Folly (= 2020.01.13.00) 291 | - RCTTypeSafety (= 0.64.1) 292 | - React-Core/RCTNetworkHeaders (= 0.64.1) 293 | - React-jsi (= 0.64.1) 294 | - ReactCommon/turbomodule/core (= 0.64.1) 295 | - React-RCTSettings (0.64.1): 296 | - FBReactNativeSpec (= 0.64.1) 297 | - RCT-Folly (= 2020.01.13.00) 298 | - RCTTypeSafety (= 0.64.1) 299 | - React-Core/RCTSettingsHeaders (= 0.64.1) 300 | - React-jsi (= 0.64.1) 301 | - ReactCommon/turbomodule/core (= 0.64.1) 302 | - React-RCTText (0.64.1): 303 | - React-Core/RCTTextHeaders (= 0.64.1) 304 | - React-RCTVibration (0.64.1): 305 | - FBReactNativeSpec (= 0.64.1) 306 | - RCT-Folly (= 2020.01.13.00) 307 | - React-Core/RCTVibrationHeaders (= 0.64.1) 308 | - React-jsi (= 0.64.1) 309 | - ReactCommon/turbomodule/core (= 0.64.1) 310 | - React-runtimeexecutor (0.64.1): 311 | - React-jsi (= 0.64.1) 312 | - ReactCommon/turbomodule/core (0.64.1): 313 | - DoubleConversion 314 | - glog 315 | - RCT-Folly (= 2020.01.13.00) 316 | - React-callinvoker (= 0.64.1) 317 | - React-Core (= 0.64.1) 318 | - React-cxxreact (= 0.64.1) 319 | - React-jsi (= 0.64.1) 320 | - React-perflogger (= 0.64.1) 321 | - RNCMaskedView (0.1.11): 322 | - React 323 | - RNGestureHandler (1.10.3): 324 | - React-Core 325 | - RNReanimated (2.2.0): 326 | - DoubleConversion 327 | - FBLazyVector 328 | - FBReactNativeSpec 329 | - glog 330 | - RCT-Folly 331 | - RCTRequired 332 | - RCTTypeSafety 333 | - React 334 | - React-callinvoker 335 | - React-Core 336 | - React-Core/DevSupport 337 | - React-Core/RCTWebSocket 338 | - React-CoreModules 339 | - React-cxxreact 340 | - React-jsi 341 | - React-jsiexecutor 342 | - React-jsinspector 343 | - React-RCTActionSheet 344 | - React-RCTAnimation 345 | - React-RCTBlob 346 | - React-RCTImage 347 | - React-RCTLinking 348 | - React-RCTNetwork 349 | - React-RCTSettings 350 | - React-RCTText 351 | - React-RCTVibration 352 | - ReactCommon/turbomodule/core 353 | - Yoga 354 | - RNScreens (3.3.0): 355 | - React-Core 356 | - React-RCTImage 357 | - RNVectorIcons (8.1.0): 358 | - React-Core 359 | - Yoga (1.14.0) 360 | - YogaKit (1.18.1): 361 | - Yoga (~> 1.14) 362 | 363 | DEPENDENCIES: 364 | - DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) 365 | - FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`) 366 | - FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`) 367 | - Flipper (~> 0.75.1) 368 | - Flipper-DoubleConversion (= 1.1.7) 369 | - Flipper-Folly (~> 2.5.3) 370 | - Flipper-Glog (= 0.3.6) 371 | - Flipper-PeerTalk (~> 0.0.4) 372 | - Flipper-RSocket (~> 1.3) 373 | - FlipperKit (~> 0.75.1) 374 | - FlipperKit/Core (~> 0.75.1) 375 | - FlipperKit/CppBridge (~> 0.75.1) 376 | - FlipperKit/FBCxxFollyDynamicConvert (~> 0.75.1) 377 | - FlipperKit/FBDefines (~> 0.75.1) 378 | - FlipperKit/FKPortForwarding (~> 0.75.1) 379 | - FlipperKit/FlipperKitHighlightOverlay (~> 0.75.1) 380 | - FlipperKit/FlipperKitLayoutPlugin (~> 0.75.1) 381 | - FlipperKit/FlipperKitLayoutTextSearchable (~> 0.75.1) 382 | - FlipperKit/FlipperKitNetworkPlugin (~> 0.75.1) 383 | - FlipperKit/FlipperKitReactPlugin (~> 0.75.1) 384 | - FlipperKit/FlipperKitUserDefaultsPlugin (~> 0.75.1) 385 | - FlipperKit/SKIOSNetworkPlugin (~> 0.75.1) 386 | - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) 387 | - RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) 388 | - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired`) 389 | - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety`) 390 | - React (from `../node_modules/react-native/`) 391 | - React-callinvoker (from `../node_modules/react-native/ReactCommon/callinvoker`) 392 | - React-Core (from `../node_modules/react-native/`) 393 | - React-Core/DevSupport (from `../node_modules/react-native/`) 394 | - React-Core/RCTWebSocket (from `../node_modules/react-native/`) 395 | - React-CoreModules (from `../node_modules/react-native/React/CoreModules`) 396 | - React-cxxreact (from `../node_modules/react-native/ReactCommon/cxxreact`) 397 | - React-jsi (from `../node_modules/react-native/ReactCommon/jsi`) 398 | - React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`) 399 | - React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`) 400 | - react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`) 401 | - React-perflogger (from `../node_modules/react-native/ReactCommon/reactperflogger`) 402 | - React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`) 403 | - React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`) 404 | - React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`) 405 | - React-RCTImage (from `../node_modules/react-native/Libraries/Image`) 406 | - React-RCTLinking (from `../node_modules/react-native/Libraries/LinkingIOS`) 407 | - React-RCTNetwork (from `../node_modules/react-native/Libraries/Network`) 408 | - React-RCTSettings (from `../node_modules/react-native/Libraries/Settings`) 409 | - React-RCTText (from `../node_modules/react-native/Libraries/Text`) 410 | - React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`) 411 | - React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`) 412 | - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) 413 | - "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)" 414 | - RNGestureHandler (from `../node_modules/react-native-gesture-handler`) 415 | - RNReanimated (from `../node_modules/react-native-reanimated`) 416 | - RNScreens (from `../node_modules/react-native-screens`) 417 | - RNVectorIcons (from `../node_modules/react-native-vector-icons`) 418 | - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) 419 | 420 | SPEC REPOS: 421 | trunk: 422 | - boost-for-react-native 423 | - CocoaAsyncSocket 424 | - Flipper 425 | - Flipper-DoubleConversion 426 | - Flipper-Folly 427 | - Flipper-Glog 428 | - Flipper-PeerTalk 429 | - Flipper-RSocket 430 | - FlipperKit 431 | - libevent 432 | - OpenSSL-Universal 433 | - YogaKit 434 | 435 | EXTERNAL SOURCES: 436 | DoubleConversion: 437 | :podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" 438 | FBLazyVector: 439 | :path: "../node_modules/react-native/Libraries/FBLazyVector" 440 | FBReactNativeSpec: 441 | :path: "../node_modules/react-native/React/FBReactNativeSpec" 442 | glog: 443 | :podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec" 444 | RCT-Folly: 445 | :podspec: "../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" 446 | RCTRequired: 447 | :path: "../node_modules/react-native/Libraries/RCTRequired" 448 | RCTTypeSafety: 449 | :path: "../node_modules/react-native/Libraries/TypeSafety" 450 | React: 451 | :path: "../node_modules/react-native/" 452 | React-callinvoker: 453 | :path: "../node_modules/react-native/ReactCommon/callinvoker" 454 | React-Core: 455 | :path: "../node_modules/react-native/" 456 | React-CoreModules: 457 | :path: "../node_modules/react-native/React/CoreModules" 458 | React-cxxreact: 459 | :path: "../node_modules/react-native/ReactCommon/cxxreact" 460 | React-jsi: 461 | :path: "../node_modules/react-native/ReactCommon/jsi" 462 | React-jsiexecutor: 463 | :path: "../node_modules/react-native/ReactCommon/jsiexecutor" 464 | React-jsinspector: 465 | :path: "../node_modules/react-native/ReactCommon/jsinspector" 466 | react-native-safe-area-context: 467 | :path: "../node_modules/react-native-safe-area-context" 468 | React-perflogger: 469 | :path: "../node_modules/react-native/ReactCommon/reactperflogger" 470 | React-RCTActionSheet: 471 | :path: "../node_modules/react-native/Libraries/ActionSheetIOS" 472 | React-RCTAnimation: 473 | :path: "../node_modules/react-native/Libraries/NativeAnimation" 474 | React-RCTBlob: 475 | :path: "../node_modules/react-native/Libraries/Blob" 476 | React-RCTImage: 477 | :path: "../node_modules/react-native/Libraries/Image" 478 | React-RCTLinking: 479 | :path: "../node_modules/react-native/Libraries/LinkingIOS" 480 | React-RCTNetwork: 481 | :path: "../node_modules/react-native/Libraries/Network" 482 | React-RCTSettings: 483 | :path: "../node_modules/react-native/Libraries/Settings" 484 | React-RCTText: 485 | :path: "../node_modules/react-native/Libraries/Text" 486 | React-RCTVibration: 487 | :path: "../node_modules/react-native/Libraries/Vibration" 488 | React-runtimeexecutor: 489 | :path: "../node_modules/react-native/ReactCommon/runtimeexecutor" 490 | ReactCommon: 491 | :path: "../node_modules/react-native/ReactCommon" 492 | RNCMaskedView: 493 | :path: "../node_modules/@react-native-community/masked-view" 494 | RNGestureHandler: 495 | :path: "../node_modules/react-native-gesture-handler" 496 | RNReanimated: 497 | :path: "../node_modules/react-native-reanimated" 498 | RNScreens: 499 | :path: "../node_modules/react-native-screens" 500 | RNVectorIcons: 501 | :path: "../node_modules/react-native-vector-icons" 502 | Yoga: 503 | :path: "../node_modules/react-native/ReactCommon/yoga" 504 | 505 | SPEC CHECKSUMS: 506 | boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c 507 | CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99 508 | DoubleConversion: cf9b38bf0b2d048436d9a82ad2abe1404f11e7de 509 | FBLazyVector: 7b423f9e248eae65987838148c36eec1dbfe0b53 510 | FBReactNativeSpec: f23dad2c4029d8ee47e83337d387c1405c964a22 511 | Flipper: d3da1aa199aad94455ae725e9f3aa43f3ec17021 512 | Flipper-DoubleConversion: 38631e41ef4f9b12861c67d17cb5518d06badc41 513 | Flipper-Folly: 755929a4f851b2fb2c347d533a23f191b008554c 514 | Flipper-Glog: 1dfd6abf1e922806c52ceb8701a3599a79a200a6 515 | Flipper-PeerTalk: 116d8f857dc6ef55c7a5a75ea3ceaafe878aadc9 516 | Flipper-RSocket: 127954abe8b162fcaf68d2134d34dc2bd7076154 517 | FlipperKit: 8a20b5c5fcf9436cac58551dc049867247f64b00 518 | glog: 73c2498ac6884b13ede40eda8228cb1eee9d9d62 519 | libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 520 | OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b 521 | RCT-Folly: ec7a233ccc97cc556cf7237f0db1ff65b986f27c 522 | RCTRequired: ec2ebc96b7bfba3ca5c32740f5a0c6a014a274d2 523 | RCTTypeSafety: 22567f31e67c3e088c7ac23ea46ab6d4779c0ea5 524 | React: a241e3dbb1e91d06332f1dbd2b3ab26e1a4c4b9d 525 | React-callinvoker: da4d1c6141696a00163960906bc8a55b985e4ce4 526 | React-Core: 46ba164c437d7dac607b470c83c8308b05799748 527 | React-CoreModules: 217bd14904491c7b9940ff8b34a3fe08013c2f14 528 | React-cxxreact: 0090588ae6660c4615d3629fdd5c768d0983add4 529 | React-jsi: 5de8204706bd872b78ea646aee5d2561ca1214b6 530 | React-jsiexecutor: 124e8f99992490d0d13e0649d950d3e1aae06fe9 531 | React-jsinspector: 500a59626037be5b3b3d89c5151bc3baa9abf1a9 532 | react-native-safe-area-context: f0906bf8bc9835ac9a9d3f97e8bde2a997d8da79 533 | React-perflogger: aad6d4b4a267936b3667260d1f649b6f6069a675 534 | React-RCTActionSheet: fc376be462c9c8d6ad82c0905442fd77f82a9d2a 535 | React-RCTAnimation: ba0a1c3a2738be224a08092fa7f1b444ab77d309 536 | React-RCTBlob: f758d4403fc5828a326dc69e27b41e1a92f34947 537 | React-RCTImage: ce57088705f4a8d03f6594b066a59c29143ba73e 538 | React-RCTLinking: 852a3a95c65fa63f657a4b4e2d3d83a815e00a7c 539 | React-RCTNetwork: 9d7ccb8a08d522d71700b4fb677d9fa28cccd118 540 | React-RCTSettings: d8aaf4389ff06114dee8c42ef5f0f2915946011e 541 | React-RCTText: 809c12ed6b261796ba056c04fcd20d8b90bcc81d 542 | React-RCTVibration: 4b99a7f5c6c0abbc5256410cc5425fb8531986e1 543 | React-runtimeexecutor: ff951a0c241bfaefc4940a3f1f1a229e7cb32fa6 544 | ReactCommon: bedc99ed4dae329c4fcf128d0c31b9115e5365ca 545 | RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489 546 | RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211 547 | RNReanimated: 9c13c86454bfd54dab7505c1a054470bfecd2563 548 | RNScreens: bf59f17fbf001f1025243eeed5f19419d3c11ef2 549 | RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4 550 | Yoga: a7de31c64fe738607e7a3803e3f591a4b1df7393 551 | YogaKit: f782866e155069a2cca2517aafea43200b01fd5a 552 | 553 | PODFILE CHECKSUM: 544a51789156f9c5a460836a3ab6e13d07795f82 554 | 555 | COCOAPODS: 1.11.3 556 | -------------------------------------------------------------------------------- /example/ios/example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 54; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 00E356F31AD99517003FC87E /* exampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* exampleTests.m */; }; 11 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; 12 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13 | 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; 14 | 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; 15 | 9CFA9B40F286FD263840A77A /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F004716CAD1DEE3F79EC5E36 /* libPods-example.a */; }; 16 | CDA38E0FD1AEE84CBA9221D4 /* libPods-example-exampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4995FA7DDC69E5B9A90CB78E /* libPods-example-exampleTests.a */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = 13B07F861A680F5B00A75B9A; 25 | remoteInfo = example; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | 00E356EE1AD99517003FC87E /* exampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = exampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 31 | 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 32 | 00E356F21AD99517003FC87E /* exampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = exampleTests.m; sourceTree = ""; }; 33 | 0AFB333580ED283D54F32DD1 /* Pods-example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.debug.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.debug.xcconfig"; sourceTree = ""; }; 34 | 13B07F961A680F5B00A75B9A /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = example/AppDelegate.h; sourceTree = ""; }; 36 | 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = example/AppDelegate.m; sourceTree = ""; }; 37 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = example/Images.xcassets; sourceTree = ""; }; 38 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = example/Info.plist; sourceTree = ""; }; 39 | 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = example/main.m; sourceTree = ""; }; 40 | 27905FF8CC9DDD9ADC6B8DAB /* Pods-example-exampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example-exampleTests.debug.xcconfig"; path = "Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests.debug.xcconfig"; sourceTree = ""; }; 41 | 4995FA7DDC69E5B9A90CB78E /* libPods-example-exampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example-exampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = example/LaunchScreen.storyboard; sourceTree = ""; }; 43 | 9FCC11FF61BB656938A6351F /* Pods-example-exampleTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example-exampleTests.release.xcconfig"; path = "Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests.release.xcconfig"; sourceTree = ""; }; 44 | D9BDDFAF4C799D00EBD50F11 /* Pods-example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-example.release.xcconfig"; path = "Target Support Files/Pods-example/Pods-example.release.xcconfig"; sourceTree = ""; }; 45 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; 46 | F004716CAD1DEE3F79EC5E36 /* libPods-example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | /* End PBXFileReference section */ 48 | 49 | /* Begin PBXFrameworksBuildPhase section */ 50 | 00E356EB1AD99517003FC87E /* Frameworks */ = { 51 | isa = PBXFrameworksBuildPhase; 52 | buildActionMask = 2147483647; 53 | files = ( 54 | CDA38E0FD1AEE84CBA9221D4 /* libPods-example-exampleTests.a in Frameworks */, 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | 9CFA9B40F286FD263840A77A /* libPods-example.a in Frameworks */, 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | 00E356EF1AD99517003FC87E /* exampleTests */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 00E356F21AD99517003FC87E /* exampleTests.m */, 73 | 00E356F01AD99517003FC87E /* Supporting Files */, 74 | ); 75 | path = exampleTests; 76 | sourceTree = ""; 77 | }; 78 | 00E356F01AD99517003FC87E /* Supporting Files */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 00E356F11AD99517003FC87E /* Info.plist */, 82 | ); 83 | name = "Supporting Files"; 84 | sourceTree = ""; 85 | }; 86 | 13B07FAE1A68108700A75B9A /* example */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 90 | 13B07FB01A68108700A75B9A /* AppDelegate.m */, 91 | 13B07FB51A68108700A75B9A /* Images.xcassets */, 92 | 13B07FB61A68108700A75B9A /* Info.plist */, 93 | 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */, 94 | 13B07FB71A68108700A75B9A /* main.m */, 95 | ); 96 | name = example; 97 | sourceTree = ""; 98 | }; 99 | 2D16E6871FA4F8E400B85C8A /* Frameworks */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */, 103 | F004716CAD1DEE3F79EC5E36 /* libPods-example.a */, 104 | 4995FA7DDC69E5B9A90CB78E /* libPods-example-exampleTests.a */, 105 | ); 106 | name = Frameworks; 107 | sourceTree = ""; 108 | }; 109 | 4A978F6D4DD37002E83D94DD /* Pods */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | 0AFB333580ED283D54F32DD1 /* Pods-example.debug.xcconfig */, 113 | D9BDDFAF4C799D00EBD50F11 /* Pods-example.release.xcconfig */, 114 | 27905FF8CC9DDD9ADC6B8DAB /* Pods-example-exampleTests.debug.xcconfig */, 115 | 9FCC11FF61BB656938A6351F /* Pods-example-exampleTests.release.xcconfig */, 116 | ); 117 | name = Pods; 118 | path = Pods; 119 | sourceTree = ""; 120 | }; 121 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | ); 125 | name = Libraries; 126 | sourceTree = ""; 127 | }; 128 | 83CBB9F61A601CBA00E9B192 = { 129 | isa = PBXGroup; 130 | children = ( 131 | 13B07FAE1A68108700A75B9A /* example */, 132 | 832341AE1AAA6A7D00B99B32 /* Libraries */, 133 | 00E356EF1AD99517003FC87E /* exampleTests */, 134 | 83CBBA001A601CBA00E9B192 /* Products */, 135 | 2D16E6871FA4F8E400B85C8A /* Frameworks */, 136 | 4A978F6D4DD37002E83D94DD /* Pods */, 137 | ); 138 | indentWidth = 2; 139 | sourceTree = ""; 140 | tabWidth = 2; 141 | usesTabs = 0; 142 | }; 143 | 83CBBA001A601CBA00E9B192 /* Products */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | 13B07F961A680F5B00A75B9A /* example.app */, 147 | 00E356EE1AD99517003FC87E /* exampleTests.xctest */, 148 | ); 149 | name = Products; 150 | sourceTree = ""; 151 | }; 152 | /* End PBXGroup section */ 153 | 154 | /* Begin PBXNativeTarget section */ 155 | 00E356ED1AD99517003FC87E /* exampleTests */ = { 156 | isa = PBXNativeTarget; 157 | buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "exampleTests" */; 158 | buildPhases = ( 159 | 944F9278EB9446A8409A3F50 /* [CP] Check Pods Manifest.lock */, 160 | 00E356EA1AD99517003FC87E /* Sources */, 161 | 00E356EB1AD99517003FC87E /* Frameworks */, 162 | 00E356EC1AD99517003FC87E /* Resources */, 163 | 4A8F0FAE7B2C03C07DDFDBC5 /* [CP] Embed Pods Frameworks */, 164 | F55DEAEAFF47A12C509EC6C8 /* [CP] Copy Pods Resources */, 165 | ); 166 | buildRules = ( 167 | ); 168 | dependencies = ( 169 | 00E356F51AD99517003FC87E /* PBXTargetDependency */, 170 | ); 171 | name = exampleTests; 172 | productName = exampleTests; 173 | productReference = 00E356EE1AD99517003FC87E /* exampleTests.xctest */; 174 | productType = "com.apple.product-type.bundle.unit-test"; 175 | }; 176 | 13B07F861A680F5B00A75B9A /* example */ = { 177 | isa = PBXNativeTarget; 178 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "example" */; 179 | buildPhases = ( 180 | 99FC9228678A20409F678EB4 /* [CP] Check Pods Manifest.lock */, 181 | FD10A7F022414F080027D42C /* Start Packager */, 182 | 13B07F871A680F5B00A75B9A /* Sources */, 183 | 13B07F8C1A680F5B00A75B9A /* Frameworks */, 184 | 13B07F8E1A680F5B00A75B9A /* Resources */, 185 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, 186 | 9058A475C7709709AA7C5851 /* [CP] Embed Pods Frameworks */, 187 | BA1BE5AC2BB5FDB85A38BACC /* [CP] Copy Pods Resources */, 188 | ); 189 | buildRules = ( 190 | ); 191 | dependencies = ( 192 | ); 193 | name = example; 194 | productName = example; 195 | productReference = 13B07F961A680F5B00A75B9A /* example.app */; 196 | productType = "com.apple.product-type.application"; 197 | }; 198 | /* End PBXNativeTarget section */ 199 | 200 | /* Begin PBXProject section */ 201 | 83CBB9F71A601CBA00E9B192 /* Project object */ = { 202 | isa = PBXProject; 203 | attributes = { 204 | LastUpgradeCheck = 1210; 205 | TargetAttributes = { 206 | 00E356ED1AD99517003FC87E = { 207 | CreatedOnToolsVersion = 6.2; 208 | TestTargetID = 13B07F861A680F5B00A75B9A; 209 | }; 210 | 13B07F861A680F5B00A75B9A = { 211 | LastSwiftMigration = 1120; 212 | }; 213 | }; 214 | }; 215 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "example" */; 216 | compatibilityVersion = "Xcode 12.0"; 217 | developmentRegion = en; 218 | hasScannedForEncodings = 0; 219 | knownRegions = ( 220 | en, 221 | Base, 222 | ); 223 | mainGroup = 83CBB9F61A601CBA00E9B192; 224 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; 225 | projectDirPath = ""; 226 | projectRoot = ""; 227 | targets = ( 228 | 13B07F861A680F5B00A75B9A /* example */, 229 | 00E356ED1AD99517003FC87E /* exampleTests */, 230 | ); 231 | }; 232 | /* End PBXProject section */ 233 | 234 | /* Begin PBXResourcesBuildPhase section */ 235 | 00E356EC1AD99517003FC87E /* Resources */ = { 236 | isa = PBXResourcesBuildPhase; 237 | buildActionMask = 2147483647; 238 | files = ( 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | 13B07F8E1A680F5B00A75B9A /* Resources */ = { 243 | isa = PBXResourcesBuildPhase; 244 | buildActionMask = 2147483647; 245 | files = ( 246 | 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, 247 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | /* End PBXResourcesBuildPhase section */ 252 | 253 | /* Begin PBXShellScriptBuildPhase section */ 254 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { 255 | isa = PBXShellScriptBuildPhase; 256 | buildActionMask = 2147483647; 257 | files = ( 258 | ); 259 | inputPaths = ( 260 | ); 261 | name = "Bundle React Native code and images"; 262 | outputPaths = ( 263 | ); 264 | runOnlyForDeploymentPostprocessing = 0; 265 | shellPath = /bin/sh; 266 | shellScript = "set -e\n\nexport NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n"; 267 | }; 268 | 4A8F0FAE7B2C03C07DDFDBC5 /* [CP] Embed Pods Frameworks */ = { 269 | isa = PBXShellScriptBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | ); 273 | inputFileListPaths = ( 274 | "${PODS_ROOT}/Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests-frameworks-${CONFIGURATION}-input-files.xcfilelist", 275 | ); 276 | name = "[CP] Embed Pods Frameworks"; 277 | outputFileListPaths = ( 278 | "${PODS_ROOT}/Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests-frameworks-${CONFIGURATION}-output-files.xcfilelist", 279 | ); 280 | runOnlyForDeploymentPostprocessing = 0; 281 | shellPath = /bin/sh; 282 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests-frameworks.sh\"\n"; 283 | showEnvVarsInLog = 0; 284 | }; 285 | 9058A475C7709709AA7C5851 /* [CP] Embed Pods Frameworks */ = { 286 | isa = PBXShellScriptBuildPhase; 287 | buildActionMask = 2147483647; 288 | files = ( 289 | ); 290 | inputFileListPaths = ( 291 | "${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks-${CONFIGURATION}-input-files.xcfilelist", 292 | ); 293 | name = "[CP] Embed Pods Frameworks"; 294 | outputFileListPaths = ( 295 | "${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks-${CONFIGURATION}-output-files.xcfilelist", 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | shellPath = /bin/sh; 299 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks.sh\"\n"; 300 | showEnvVarsInLog = 0; 301 | }; 302 | 944F9278EB9446A8409A3F50 /* [CP] Check Pods Manifest.lock */ = { 303 | isa = PBXShellScriptBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | ); 307 | inputFileListPaths = ( 308 | ); 309 | inputPaths = ( 310 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 311 | "${PODS_ROOT}/Manifest.lock", 312 | ); 313 | name = "[CP] Check Pods Manifest.lock"; 314 | outputFileListPaths = ( 315 | ); 316 | outputPaths = ( 317 | "$(DERIVED_FILE_DIR)/Pods-example-exampleTests-checkManifestLockResult.txt", 318 | ); 319 | runOnlyForDeploymentPostprocessing = 0; 320 | shellPath = /bin/sh; 321 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 322 | showEnvVarsInLog = 0; 323 | }; 324 | 99FC9228678A20409F678EB4 /* [CP] Check Pods Manifest.lock */ = { 325 | isa = PBXShellScriptBuildPhase; 326 | buildActionMask = 2147483647; 327 | files = ( 328 | ); 329 | inputFileListPaths = ( 330 | ); 331 | inputPaths = ( 332 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 333 | "${PODS_ROOT}/Manifest.lock", 334 | ); 335 | name = "[CP] Check Pods Manifest.lock"; 336 | outputFileListPaths = ( 337 | ); 338 | outputPaths = ( 339 | "$(DERIVED_FILE_DIR)/Pods-example-checkManifestLockResult.txt", 340 | ); 341 | runOnlyForDeploymentPostprocessing = 0; 342 | shellPath = /bin/sh; 343 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 344 | showEnvVarsInLog = 0; 345 | }; 346 | BA1BE5AC2BB5FDB85A38BACC /* [CP] Copy Pods Resources */ = { 347 | isa = PBXShellScriptBuildPhase; 348 | buildActionMask = 2147483647; 349 | files = ( 350 | ); 351 | inputFileListPaths = ( 352 | "${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-resources-${CONFIGURATION}-input-files.xcfilelist", 353 | ); 354 | name = "[CP] Copy Pods Resources"; 355 | outputFileListPaths = ( 356 | "${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-resources-${CONFIGURATION}-output-files.xcfilelist", 357 | ); 358 | runOnlyForDeploymentPostprocessing = 0; 359 | shellPath = /bin/sh; 360 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-resources.sh\"\n"; 361 | showEnvVarsInLog = 0; 362 | }; 363 | F55DEAEAFF47A12C509EC6C8 /* [CP] Copy Pods Resources */ = { 364 | isa = PBXShellScriptBuildPhase; 365 | buildActionMask = 2147483647; 366 | files = ( 367 | ); 368 | inputFileListPaths = ( 369 | "${PODS_ROOT}/Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests-resources-${CONFIGURATION}-input-files.xcfilelist", 370 | ); 371 | name = "[CP] Copy Pods Resources"; 372 | outputFileListPaths = ( 373 | "${PODS_ROOT}/Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests-resources-${CONFIGURATION}-output-files.xcfilelist", 374 | ); 375 | runOnlyForDeploymentPostprocessing = 0; 376 | shellPath = /bin/sh; 377 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-example-exampleTests/Pods-example-exampleTests-resources.sh\"\n"; 378 | showEnvVarsInLog = 0; 379 | }; 380 | FD10A7F022414F080027D42C /* Start Packager */ = { 381 | isa = PBXShellScriptBuildPhase; 382 | buildActionMask = 2147483647; 383 | files = ( 384 | ); 385 | inputFileListPaths = ( 386 | ); 387 | inputPaths = ( 388 | ); 389 | name = "Start Packager"; 390 | outputFileListPaths = ( 391 | ); 392 | outputPaths = ( 393 | ); 394 | runOnlyForDeploymentPostprocessing = 0; 395 | shellPath = /bin/sh; 396 | shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n"; 397 | showEnvVarsInLog = 0; 398 | }; 399 | /* End PBXShellScriptBuildPhase section */ 400 | 401 | /* Begin PBXSourcesBuildPhase section */ 402 | 00E356EA1AD99517003FC87E /* Sources */ = { 403 | isa = PBXSourcesBuildPhase; 404 | buildActionMask = 2147483647; 405 | files = ( 406 | 00E356F31AD99517003FC87E /* exampleTests.m in Sources */, 407 | ); 408 | runOnlyForDeploymentPostprocessing = 0; 409 | }; 410 | 13B07F871A680F5B00A75B9A /* Sources */ = { 411 | isa = PBXSourcesBuildPhase; 412 | buildActionMask = 2147483647; 413 | files = ( 414 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, 415 | 13B07FC11A68108700A75B9A /* main.m in Sources */, 416 | ); 417 | runOnlyForDeploymentPostprocessing = 0; 418 | }; 419 | /* End PBXSourcesBuildPhase section */ 420 | 421 | /* Begin PBXTargetDependency section */ 422 | 00E356F51AD99517003FC87E /* PBXTargetDependency */ = { 423 | isa = PBXTargetDependency; 424 | target = 13B07F861A680F5B00A75B9A /* example */; 425 | targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; 426 | }; 427 | /* End PBXTargetDependency section */ 428 | 429 | /* Begin XCBuildConfiguration section */ 430 | 00E356F61AD99517003FC87E /* Debug */ = { 431 | isa = XCBuildConfiguration; 432 | baseConfigurationReference = 27905FF8CC9DDD9ADC6B8DAB /* Pods-example-exampleTests.debug.xcconfig */; 433 | buildSettings = { 434 | BUNDLE_LOADER = "$(TEST_HOST)"; 435 | GCC_PREPROCESSOR_DEFINITIONS = ( 436 | "DEBUG=1", 437 | "$(inherited)", 438 | ); 439 | INFOPLIST_FILE = exampleTests/Info.plist; 440 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 441 | LD_RUNPATH_SEARCH_PATHS = ( 442 | "$(inherited)", 443 | "@executable_path/Frameworks", 444 | "@loader_path/Frameworks", 445 | ); 446 | OTHER_LDFLAGS = ( 447 | "-ObjC", 448 | "-lc++", 449 | "$(inherited)", 450 | ); 451 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 452 | PRODUCT_NAME = "$(TARGET_NAME)"; 453 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/example.app/example"; 454 | }; 455 | name = Debug; 456 | }; 457 | 00E356F71AD99517003FC87E /* Release */ = { 458 | isa = XCBuildConfiguration; 459 | baseConfigurationReference = 9FCC11FF61BB656938A6351F /* Pods-example-exampleTests.release.xcconfig */; 460 | buildSettings = { 461 | BUNDLE_LOADER = "$(TEST_HOST)"; 462 | COPY_PHASE_STRIP = NO; 463 | INFOPLIST_FILE = exampleTests/Info.plist; 464 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 465 | LD_RUNPATH_SEARCH_PATHS = ( 466 | "$(inherited)", 467 | "@executable_path/Frameworks", 468 | "@loader_path/Frameworks", 469 | ); 470 | OTHER_LDFLAGS = ( 471 | "-ObjC", 472 | "-lc++", 473 | "$(inherited)", 474 | ); 475 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 476 | PRODUCT_NAME = "$(TARGET_NAME)"; 477 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/example.app/example"; 478 | }; 479 | name = Release; 480 | }; 481 | 13B07F941A680F5B00A75B9A /* Debug */ = { 482 | isa = XCBuildConfiguration; 483 | baseConfigurationReference = 0AFB333580ED283D54F32DD1 /* Pods-example.debug.xcconfig */; 484 | buildSettings = { 485 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 486 | CLANG_ENABLE_MODULES = YES; 487 | CURRENT_PROJECT_VERSION = 1; 488 | ENABLE_BITCODE = NO; 489 | INFOPLIST_FILE = example/Info.plist; 490 | LD_RUNPATH_SEARCH_PATHS = ( 491 | "$(inherited)", 492 | "@executable_path/Frameworks", 493 | ); 494 | OTHER_LDFLAGS = ( 495 | "$(inherited)", 496 | "-ObjC", 497 | "-lc++", 498 | ); 499 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 500 | PRODUCT_NAME = example; 501 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 502 | SWIFT_VERSION = 5.0; 503 | VERSIONING_SYSTEM = "apple-generic"; 504 | }; 505 | name = Debug; 506 | }; 507 | 13B07F951A680F5B00A75B9A /* Release */ = { 508 | isa = XCBuildConfiguration; 509 | baseConfigurationReference = D9BDDFAF4C799D00EBD50F11 /* Pods-example.release.xcconfig */; 510 | buildSettings = { 511 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 512 | CLANG_ENABLE_MODULES = YES; 513 | CURRENT_PROJECT_VERSION = 1; 514 | INFOPLIST_FILE = example/Info.plist; 515 | LD_RUNPATH_SEARCH_PATHS = ( 516 | "$(inherited)", 517 | "@executable_path/Frameworks", 518 | ); 519 | OTHER_LDFLAGS = ( 520 | "$(inherited)", 521 | "-ObjC", 522 | "-lc++", 523 | ); 524 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)"; 525 | PRODUCT_NAME = example; 526 | SWIFT_VERSION = 5.0; 527 | VERSIONING_SYSTEM = "apple-generic"; 528 | }; 529 | name = Release; 530 | }; 531 | 83CBBA201A601CBA00E9B192 /* Debug */ = { 532 | isa = XCBuildConfiguration; 533 | buildSettings = { 534 | ALWAYS_SEARCH_USER_PATHS = NO; 535 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 536 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 537 | CLANG_CXX_LIBRARY = "libc++"; 538 | CLANG_ENABLE_MODULES = YES; 539 | CLANG_ENABLE_OBJC_ARC = YES; 540 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 541 | CLANG_WARN_BOOL_CONVERSION = YES; 542 | CLANG_WARN_COMMA = YES; 543 | CLANG_WARN_CONSTANT_CONVERSION = YES; 544 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 545 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 546 | CLANG_WARN_EMPTY_BODY = YES; 547 | CLANG_WARN_ENUM_CONVERSION = YES; 548 | CLANG_WARN_INFINITE_RECURSION = YES; 549 | CLANG_WARN_INT_CONVERSION = YES; 550 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 551 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 552 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 553 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 554 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 555 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 556 | CLANG_WARN_STRICT_PROTOTYPES = YES; 557 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 558 | CLANG_WARN_UNREACHABLE_CODE = YES; 559 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 560 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 561 | COPY_PHASE_STRIP = NO; 562 | ENABLE_STRICT_OBJC_MSGSEND = YES; 563 | ENABLE_TESTABILITY = YES; 564 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; 565 | GCC_C_LANGUAGE_STANDARD = gnu99; 566 | GCC_DYNAMIC_NO_PIC = NO; 567 | GCC_NO_COMMON_BLOCKS = YES; 568 | GCC_OPTIMIZATION_LEVEL = 0; 569 | GCC_PREPROCESSOR_DEFINITIONS = ( 570 | "DEBUG=1", 571 | "$(inherited)", 572 | ); 573 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 574 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 575 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 576 | GCC_WARN_UNDECLARED_SELECTOR = YES; 577 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 578 | GCC_WARN_UNUSED_FUNCTION = YES; 579 | GCC_WARN_UNUSED_VARIABLE = YES; 580 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 581 | LD_RUNPATH_SEARCH_PATHS = ( 582 | /usr/lib/swift, 583 | "$(inherited)", 584 | ); 585 | LIBRARY_SEARCH_PATHS = ( 586 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", 587 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"", 588 | "\"$(inherited)\"", 589 | ); 590 | MTL_ENABLE_DEBUG_INFO = YES; 591 | ONLY_ACTIVE_ARCH = YES; 592 | SDKROOT = iphoneos; 593 | }; 594 | name = Debug; 595 | }; 596 | 83CBBA211A601CBA00E9B192 /* Release */ = { 597 | isa = XCBuildConfiguration; 598 | buildSettings = { 599 | ALWAYS_SEARCH_USER_PATHS = NO; 600 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 601 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 602 | CLANG_CXX_LIBRARY = "libc++"; 603 | CLANG_ENABLE_MODULES = YES; 604 | CLANG_ENABLE_OBJC_ARC = YES; 605 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 606 | CLANG_WARN_BOOL_CONVERSION = YES; 607 | CLANG_WARN_COMMA = YES; 608 | CLANG_WARN_CONSTANT_CONVERSION = YES; 609 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 610 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 611 | CLANG_WARN_EMPTY_BODY = YES; 612 | CLANG_WARN_ENUM_CONVERSION = YES; 613 | CLANG_WARN_INFINITE_RECURSION = YES; 614 | CLANG_WARN_INT_CONVERSION = YES; 615 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 616 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 617 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 618 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 619 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 620 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 621 | CLANG_WARN_STRICT_PROTOTYPES = YES; 622 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 623 | CLANG_WARN_UNREACHABLE_CODE = YES; 624 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 625 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 626 | COPY_PHASE_STRIP = YES; 627 | ENABLE_NS_ASSERTIONS = NO; 628 | ENABLE_STRICT_OBJC_MSGSEND = YES; 629 | "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = ""; 630 | GCC_C_LANGUAGE_STANDARD = gnu99; 631 | GCC_NO_COMMON_BLOCKS = YES; 632 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 633 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 634 | GCC_WARN_UNDECLARED_SELECTOR = YES; 635 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 636 | GCC_WARN_UNUSED_FUNCTION = YES; 637 | GCC_WARN_UNUSED_VARIABLE = YES; 638 | IPHONEOS_DEPLOYMENT_TARGET = 10.0; 639 | LD_RUNPATH_SEARCH_PATHS = ( 640 | /usr/lib/swift, 641 | "$(inherited)", 642 | ); 643 | LIBRARY_SEARCH_PATHS = ( 644 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", 645 | "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"", 646 | "\"$(inherited)\"", 647 | ); 648 | MTL_ENABLE_DEBUG_INFO = NO; 649 | SDKROOT = iphoneos; 650 | VALIDATE_PRODUCT = YES; 651 | }; 652 | name = Release; 653 | }; 654 | /* End XCBuildConfiguration section */ 655 | 656 | /* Begin XCConfigurationList section */ 657 | 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "exampleTests" */ = { 658 | isa = XCConfigurationList; 659 | buildConfigurations = ( 660 | 00E356F61AD99517003FC87E /* Debug */, 661 | 00E356F71AD99517003FC87E /* Release */, 662 | ); 663 | defaultConfigurationIsVisible = 0; 664 | defaultConfigurationName = Release; 665 | }; 666 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "example" */ = { 667 | isa = XCConfigurationList; 668 | buildConfigurations = ( 669 | 13B07F941A680F5B00A75B9A /* Debug */, 670 | 13B07F951A680F5B00A75B9A /* Release */, 671 | ); 672 | defaultConfigurationIsVisible = 0; 673 | defaultConfigurationName = Release; 674 | }; 675 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "example" */ = { 676 | isa = XCConfigurationList; 677 | buildConfigurations = ( 678 | 83CBBA201A601CBA00E9B192 /* Debug */, 679 | 83CBBA211A601CBA00E9B192 /* Release */, 680 | ); 681 | defaultConfigurationIsVisible = 0; 682 | defaultConfigurationName = Release; 683 | }; 684 | /* End XCConfigurationList section */ 685 | }; 686 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; 687 | } 688 | --------------------------------------------------------------------------------