Skip to content

Commit 1b605fe

Browse files
Merge branch 'dialogs' into 'main'
Dialogs See merge request react-native/react-native-material-components!13
2 parents a2adf52 + 80099d2 commit 1b605fe

File tree

21 files changed

+589
-26
lines changed

21 files changed

+589
-26
lines changed

README.md

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Computools react native material components package
1111
yarn add react-native-reanimated
1212
yarn add react-native-gesture-handler
1313
yarn add react-native-safe-area-context
14+
yarn add react-native-svg
1415
```
1516

1617
3. Add ```react-native-reanimated/plugin``` plugin to your babel.config.js.
@@ -171,6 +172,9 @@ export const AppBodyLargeText: React.FC<PropsWithChildren> = ({children}) => {
171172
}
172173
```
173174
</deatils>
175+
</details>
176+
<details><summary>Components</summary>
177+
<br />
174178
<details><summary>Activity Indicators</summary>
175179
<br />
176180
<details><summary>Circular Activity Indicator</summary>
@@ -333,6 +337,111 @@ Outlined card is touchable.
333337
</details>
334338
</details>
335339

340+
<details><summary>Dialogs</summary>
341+
<br />
342+
<details><summary>Dialog</summary>
343+
<br />
344+
345+
Wrapper component used in ```BasicDialog```. This library proides the opportunity to use ```Dialog``` to implement custom components.
346+
347+
**Methods**
348+
349+
| name | parameters | returns |
350+
| ------ | ------ | ------ |
351+
| show | none | void |
352+
| close | none | void |
353+
| isShowed | none | boolean |
354+
355+
_See the example how to use:_
356+
```
357+
import {Dialog, type DialogRef} from '@computools/react-native-material-components';
358+
359+
export const YourComponent = () => {
360+
const dialogRef = useRef<DialogRef>(null);
361+
362+
return (
363+
{/* Rest of your app code */}
364+
<Button onPress={() => dialogRef.current.show()} />
365+
<Dialog ref={dialogRef}>
366+
<YourDialogContent />
367+
</Dialog>
368+
{/* Rest of your app code */}
369+
);
370+
}
371+
```
372+
373+
**Properties**
374+
375+
| name | description | type | default |
376+
| ------ | ------ | ------ | ----|
377+
| animationDuration | appearance/disappearance animation duration | number | 220 |
378+
379+
</details>
380+
<details><summary>Basic Dialog</summary>
381+
<br />
382+
383+
**Properties**
384+
385+
| name | description | type | default |
386+
| ------ | ------ | ------ | ----|
387+
| title | - | string | - |
388+
| subtitle | - | string | - |
389+
| firstActionTitle | - | string | - |
390+
| secondActionTitle | - | string | - |
391+
| onFirstActionPress | - | () | () => void |
392+
| onSecondActionPress | - | () => void | - |
393+
| titleStyle | - | TextStyle | - |
394+
| subtitleStyle | - | TextStyle | - |
395+
| prepend | - | ReactNde | - |
396+
| append | - | ReactNde | - |
397+
398+
![basic dialog gif](https://ik.imagekit.io/Computools/rn-material-components/basic-dialog.gif?updatedAt=1729261989459)
399+
</details>
400+
<details><summary>Full screen Dialog</summary>
401+
<br />
402+
403+
**Properties**
404+
animationDuration?: number;
405+
animationType?: AnimationType;
406+
407+
| name | description | type | default |
408+
| ------ | ------ | ------ | ----|
409+
| animationType | - | AnimationType | AnimationType.SLIDE |
410+
| animationDuration | - | number | 330 |
411+
412+
![full screen dialog gif](https://ik.imagekit.io/Computools/rn-material-components/full-screen-dialog.gif?updatedAt=1729261989519)
413+
</details>
414+
415+
<details><summary>Troubleshooting</summary>
416+
<br />
417+
418+
## Modal unexpectedly reappear
419+
420+
In some cases, a modal may unexpectedly reappear after being closed, especially when certain actions like navigation functions are triggered during or immediately after the modal's closure. This happens because the UI thread can be busy handling other interactions (e.g., button presses, transitions), leading to a race condition where the modal is shown again.
421+
422+
To prevent this, you can use ```InteractionManager.runAfterInteractions```. This ensures that your actions (like navigation) are executed only after all ongoing interactions are finished, providing a smoother and more predictable user experience.
423+
424+
425+
_See the example how to use:_
426+
```
427+
const onSubmitPress = async () => {
428+
const isSuccessfullySignedOut = await signOut();
429+
430+
if (isSuccessfullySignedOut) {
431+
InteractionManager.runAfterInteractions(() => {
432+
navigation.dispatch(
433+
CommonActions.reset({
434+
index: 0,
435+
routes: [{name: MainStackRoutes.Welcome}],
436+
}),
437+
);
438+
});
439+
}
440+
441+
}
442+
```
443+
</details>
444+
</details>
336445
<details><summary>Divider</summary>
337446
<br />
338447

@@ -357,7 +466,7 @@ Outlined card is touchable.
357466
| modalHeightCoeff | - | number | 0.4 |
358467
| animationDuration | - | number | 300 |
359468
| headerStyle | - | ViewStyle | - |
360-
| overlayStyle | - | ViewStyle | - |
469+
| backdropStyle | - | ViewStyle | - |
361470
| dragHandleStyle | - | ViewStyle | - |
362471

363472
### Usage
@@ -403,7 +512,7 @@ export const MyScreen = () => {
403512
| stickySide | - | 'right' or 'left | 'right' |
404513
| modalWidthCoeff | up to 1 | number | 0.85 |
405514
| animationDuration | - | number | 300 |
406-
| overlayStyle | - | ViewStyle | - |
515+
| backdropStyle | - | ViewStyle | - |
407516

408517
### Usage
409518

@@ -463,6 +572,7 @@ export const MyScreen = () => {
463572
![snackbar with icon](https://ik.imagekit.io/Computools/rn-material-components/snackbar-with-icon.png?updatedAt=1704887400512)
464573
![snackbar gif](https://ik.imagekit.io/Computools/rn-material-components/snackbar-gif.gif?updatedAt=1704887530020)
465574
</details>
575+
</deatils>
466576

467577
## Contributing
468578

example/ios/Podfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ PODS:
462462
- React-RCTText
463463
- ReactCommon/turbomodule/core
464464
- Yoga
465+
- RNSVG (15.3.0):
466+
- React-Core
465467
- SocketRocket (0.6.1)
466468
- Yoga (1.14.0)
467469

@@ -510,6 +512,7 @@ DEPENDENCIES:
510512
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
511513
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
512514
- RNReanimated (from `../node_modules/react-native-reanimated`)
515+
- RNSVG (from `../node_modules/react-native-svg`)
513516
- Yoga (from `../node_modules/react-native/ReactCommon/yoga`)
514517

515518
SPEC REPOS:
@@ -604,6 +607,8 @@ EXTERNAL SOURCES:
604607
:path: "../node_modules/react-native-gesture-handler"
605608
RNReanimated:
606609
:path: "../node_modules/react-native-reanimated"
610+
RNSVG:
611+
:path: "../node_modules/react-native-svg"
607612
Yoga:
608613
:path: "../node_modules/react-native/ReactCommon/yoga"
609614

@@ -652,6 +657,7 @@ SPEC CHECKSUMS:
652657
ReactCommon: 4b2bdcb50a3543e1c2b2849ad44533686610826d
653658
RNGestureHandler: bbb8e17b10afdafc5cc5746e8f60772236e7e2ca
654659
RNReanimated: 99aa8c96151abbc2d7e737a56ec62aca709f0c92
660+
RNSVG: 7c3f3fac9de6d67eee5525a8bafffafaaf022991
655661
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
656662
Yoga: 3efc43e0d48686ce2e8c60f99d4e6bd349aff981
657663

example/ios/ReactNativeMaterialComponentsExample.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,10 @@
485485
buildSettings = {
486486
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
487487
CLANG_ENABLE_MODULES = YES;
488+
CODE_SIGN_IDENTITY = "Apple Development";
489+
CODE_SIGN_STYLE = Automatic;
488490
CURRENT_PROJECT_VERSION = 1;
491+
DEVELOPMENT_TEAM = F3FM75P33H;
489492
ENABLE_BITCODE = NO;
490493
INFOPLIST_FILE = ReactNativeMaterialComponentsExample/Info.plist;
491494
LD_RUNPATH_SEARCH_PATHS = (
@@ -500,6 +503,7 @@
500503
);
501504
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
502505
PRODUCT_NAME = ReactNativeMaterialComponentsExample;
506+
PROVISIONING_PROFILE_SPECIFIER = "";
503507
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
504508
SWIFT_VERSION = 5.0;
505509
VERSIONING_SYSTEM = "apple-generic";
@@ -512,7 +516,10 @@
512516
buildSettings = {
513517
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
514518
CLANG_ENABLE_MODULES = YES;
519+
CODE_SIGN_IDENTITY = "Apple Development";
520+
CODE_SIGN_STYLE = Automatic;
515521
CURRENT_PROJECT_VERSION = 1;
522+
DEVELOPMENT_TEAM = F3FM75P33H;
516523
INFOPLIST_FILE = ReactNativeMaterialComponentsExample/Info.plist;
517524
LD_RUNPATH_SEARCH_PATHS = (
518525
"$(inherited)",
@@ -526,6 +533,7 @@
526533
);
527534
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
528535
PRODUCT_NAME = ReactNativeMaterialComponentsExample;
536+
PROVISIONING_PROFILE_SPECIFIER = "";
529537
SWIFT_VERSION = 5.0;
530538
VERSIONING_SYSTEM = "apple-generic";
531539
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

example/metro.config.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
1+
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
22
const path = require('path');
33
const escape = require('escape-string-regexp');
44
const exclusionList = require('metro-config/src/defaults/exclusionList');
55
const pak = require('../package.json');
66

77
const root = path.resolve(__dirname, '..');
8-
const modules = Object.keys({ ...pak.peerDependencies });
8+
const modules = Object.keys({...pak.peerDependencies});
99

1010
/**
1111
* Metro configuration
@@ -19,12 +19,7 @@ const config = {
1919
// We need to make sure that only one version is loaded for peerDependencies
2020
// So we block them at the root, and alias them to the versions in example's node_modules
2121
resolver: {
22-
blacklistRE: exclusionList(
23-
modules.map(
24-
(m) =>
25-
new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
26-
)
27-
),
22+
blacklistRE: exclusionList(modules.map((m) => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`))),
2823

2924
extraNodeModules: modules.reduce((acc, name) => {
3025
acc[name] = path.join(__dirname, 'node_modules', name);

example/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"react-native": "0.72.4",
1414
"react-native-gesture-handler": "2.17.1",
1515
"react-native-reanimated": "3.5.1",
16-
"react-native-safe-area-context": "4.10.7"
16+
"react-native-safe-area-context": "4.10.7",
17+
"react-native-svg": "15.3.0"
1718
},
1819
"devDependencies": {
1920
"@babel/core": "^7.20.0",

0 commit comments

Comments
 (0)