Przeglądaj źródła

Added modalAttemptedToDismiss event with tests and docs (#5832)

* Added modalAttemptedToDismiss event with tests and docs

* Typo on pageSheet modal button label

* Update ModalScreen.js

* Fixed button testID

* Revert label to fix test cases

Co-authored-by: Guy Carmeli <guyca@users.noreply.github.com>
Co-authored-by: Yogev Ben David <yogevbd@wix.com>
manicantic 5 lat temu
rodzic
commit
87af42a56b

+ 16
- 0
docs/docs/events.md Wyświetl plik

145
 modalDismissedListener.remove();
145
 modalDismissedListener.remove();
146
 ```
146
 ```
147
 
147
 
148
+## registerModalAttemptedToDismissListener(iOS 13+ only)
149
+Invoked only on iOS pageSheet modal when swipeToDismiss flag is set to true and modal swiped down to dismiss.
150
+
151
+```js
152
+// Subscribe
153
+const modalAttemptedToDismissListener = Navigation.events().registerModalAttemptedToDismissListener(({ componentId }) => {
154
+
155
+});
156
+...
157
+// Unsubscribe
158
+modalDismissedListener.remove();
159
+```
160
+|       Parameter         | Description |
161
+|:--------------------:|:-----|
162
+|**componentId** | Id of the modal tried to dismiss|
163
+
148
 ## registerScreenPoppedListener
164
 ## registerScreenPoppedListener
149
 Invoked when screen is popped.
165
 Invoked when screen is popped.
150
 
166
 

+ 4
- 0
lib/ios/RNNCommandsHandler.m Wyświetl plik

354
 	[_eventEmitter sendModalsDismissedEvent:viewController.layoutInfo.componentId numberOfModalsDismissed:@(1)];
354
 	[_eventEmitter sendModalsDismissedEvent:viewController.layoutInfo.componentId numberOfModalsDismissed:@(1)];
355
 }
355
 }
356
 
356
 
357
+- (void)attemptedToDismissModal:(UIViewController *)viewController {
358
+    [_eventEmitter sendModalAttemptedToDismissEvent:viewController.layoutInfo.componentId];
359
+}
360
+
357
 - (void)dismissedMultipleModals:(NSArray *)viewControllers {
361
 - (void)dismissedMultipleModals:(NSArray *)viewControllers {
358
 	if (viewControllers && viewControllers.count) {
362
 	if (viewControllers && viewControllers.count) {
359
 		[_eventEmitter sendModalsDismissedEvent:((UIViewController *)viewControllers.lastObject).layoutInfo.componentId numberOfModalsDismissed:@(viewControllers.count)];
363
 		[_eventEmitter sendModalsDismissedEvent:((UIViewController *)viewControllers.lastObject).layoutInfo.componentId numberOfModalsDismissed:@(viewControllers.count)];

+ 2
- 0
lib/ios/RNNEventEmitter.h Wyświetl plik

24
 
24
 
25
 - (void)sendModalsDismissedEvent:(NSString *)componentId numberOfModalsDismissed:(NSNumber *)modalsDismissed;
25
 - (void)sendModalsDismissedEvent:(NSString *)componentId numberOfModalsDismissed:(NSNumber *)modalsDismissed;
26
 
26
 
27
+- (void)sendModalAttemptedToDismissEvent:(NSString *)componentId;
28
+
27
 - (void)sendScreenPoppedEvent:(NSString *)componentId;
29
 - (void)sendScreenPoppedEvent:(NSString *)componentId;
28
 
30
 
29
 
31
 

+ 9
- 1
lib/ios/RNNEventEmitter.m Wyświetl plik

15
 static NSString* const ComponentDidDisappear	= @"RNN.ComponentDidDisappear";
15
 static NSString* const ComponentDidDisappear	= @"RNN.ComponentDidDisappear";
16
 static NSString* const NavigationButtonPressed	= @"RNN.NavigationButtonPressed";
16
 static NSString* const NavigationButtonPressed	= @"RNN.NavigationButtonPressed";
17
 static NSString* const ModalDismissed	        = @"RNN.ModalDismissed";
17
 static NSString* const ModalDismissed	        = @"RNN.ModalDismissed";
18
+static NSString* const ModalAttemptedToDismiss  = @"RNN.ModalAttemptedToDismiss";
18
 static NSString* const SearchBarUpdated 		= @"RNN.SearchBarUpdated";
19
 static NSString* const SearchBarUpdated 		= @"RNN.SearchBarUpdated";
19
 static NSString* const SearchBarCancelPressed 	= @"RNN.SearchBarCancelPressed";
20
 static NSString* const SearchBarCancelPressed 	= @"RNN.SearchBarCancelPressed";
20
 static NSString* const PreviewCompleted         = @"RNN.PreviewCompleted";
21
 static NSString* const PreviewCompleted         = @"RNN.PreviewCompleted";
31
              SearchBarUpdated,
32
              SearchBarUpdated,
32
              SearchBarCancelPressed,
33
              SearchBarCancelPressed,
33
              PreviewCompleted,
34
              PreviewCompleted,
34
-             ScreenPopped];
35
+             ScreenPopped,
36
+             ModalAttemptedToDismiss];
35
 }
37
 }
36
 
38
 
37
 # pragma mark public
39
 # pragma mark public
113
     }];
115
     }];
114
 }
116
 }
115
 
117
 
118
+- (void)sendModalAttemptedToDismissEvent:(NSString *)componentId {
119
+    [self send:ModalAttemptedToDismiss body:@{
120
+        @"componentId": componentId,
121
+    }];
122
+}
123
+
116
 - (void)sendScreenPoppedEvent:(NSString *)componentId {
124
 - (void)sendScreenPoppedEvent:(NSString *)componentId {
117
     [self send:ScreenPopped body:@{
125
     [self send:ScreenPopped body:@{
118
         @"componentId": componentId
126
         @"componentId": componentId

+ 1
- 0
lib/ios/RNNModalManager.h Wyświetl plik

8
 @protocol RNNModalManagerDelegate <NSObject>
8
 @protocol RNNModalManagerDelegate <NSObject>
9
 
9
 
10
 - (void)dismissedModal:(UIViewController *)viewController;
10
 - (void)dismissedModal:(UIViewController *)viewController;
11
+- (void)attemptedToDismissModal:(UIViewController *)viewController;
11
 - (void)dismissedMultipleModals:(NSArray *)viewControllers;
12
 - (void)dismissedMultipleModals:(NSArray *)viewControllers;
12
 
13
 
13
 @end
14
 @end

+ 4
- 0
lib/ios/RNNModalManager.m Wyświetl plik

127
     [_delegate dismissedModal:presentationController.presentedViewController.presentedComponentViewController];
127
     [_delegate dismissedModal:presentationController.presentedViewController.presentedComponentViewController];
128
 }
128
 }
129
 
129
 
130
+- (void)presentationControllerDidAttemptToDismiss:(UIPresentationController *)presentationController {
131
+    [_delegate attemptedToDismissModal:presentationController.presentedViewController.presentedComponentViewController];
132
+}
133
+
130
 -(UIViewController*)topPresentedVC {
134
 -(UIViewController*)topPresentedVC {
131
 	UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
135
 	UIViewController *root = UIApplication.sharedApplication.delegate.window.rootViewController;
132
 	while(root.presentedViewController) {
136
 	while(root.presentedViewController) {

+ 6
- 1
lib/src/adapters/NativeEventsReceiver.ts Wyświetl plik

7
   SearchBarCancelPressedEvent,
7
   SearchBarCancelPressedEvent,
8
   PreviewCompletedEvent,
8
   PreviewCompletedEvent,
9
   ModalDismissedEvent,
9
   ModalDismissedEvent,
10
-  ScreenPoppedEvent
10
+  ScreenPoppedEvent,
11
+  ModalAttemptedToDismissEvent
11
 } from '../interfaces/ComponentEvents';
12
 } from '../interfaces/ComponentEvents';
12
 import { CommandCompletedEvent, BottomTabSelectedEvent } from '../interfaces/Events';
13
 import { CommandCompletedEvent, BottomTabSelectedEvent } from '../interfaces/Events';
13
 
14
 
49
     return this.emitter.addListener('RNN.ModalDismissed', callback);
50
     return this.emitter.addListener('RNN.ModalDismissed', callback);
50
   }
51
   }
51
 
52
 
53
+  public registerModalAttemptedToDismissListener(callback: (event: ModalAttemptedToDismissEvent) => void): EmitterSubscription {
54
+    return this.emitter.addListener('RNN.ModalAttemptedToDismiss', callback);
55
+  }
56
+
52
   public registerSearchBarUpdatedListener(callback: (event: SearchBarUpdatedEvent) => void): EmitterSubscription {
57
   public registerSearchBarUpdatedListener(callback: (event: SearchBarUpdatedEvent) => void): EmitterSubscription {
53
     return this.emitter.addListener('RNN.SearchBarUpdated', callback);
58
     return this.emitter.addListener('RNN.SearchBarUpdated', callback);
54
   }
59
   }

+ 16
- 3
lib/src/events/ComponentEventsObserver.test.tsx Wyświetl plik

18
   const searchBarCancelPressedFn = jest.fn();
18
   const searchBarCancelPressedFn = jest.fn();
19
   const previewCompletedFn = jest.fn();
19
   const previewCompletedFn = jest.fn();
20
   const modalDismissedFn = jest.fn();
20
   const modalDismissedFn = jest.fn();
21
+  const modalAttemptedToDismissFn = jest.fn();
21
   const screenPoppedFn = jest.fn();
22
   const screenPoppedFn = jest.fn();
22
   let subscription: EventSubscription;
23
   let subscription: EventSubscription;
23
   let uut: ComponentEventsObserver;
24
   let uut: ComponentEventsObserver;
57
       modalDismissedFn(event);
58
       modalDismissedFn(event);
58
     }
59
     }
59
 
60
 
61
+    modalAttemptedToDismiss(event: any) {
62
+      modalAttemptedToDismissFn(event);
63
+    }
64
+
60
     searchBarUpdated(event: any) {
65
     searchBarUpdated(event: any) {
61
       searchBarUpdatedFn(event);
66
       searchBarUpdatedFn(event);
62
     }
67
     }
108
       modalDismissedFn(event);
113
       modalDismissedFn(event);
109
     }
114
     }
110
 
115
 
116
+    modalAttemptedToDismiss(event: any) {
117
+      modalAttemptedToDismissFn(event);
118
+    }
119
+
111
     searchBarUpdated(event: any) {
120
     searchBarUpdated(event: any) {
112
       searchBarUpdatedFn(event);
121
       searchBarUpdatedFn(event);
113
     }
122
     }
153
   });
162
   });
154
 
163
 
155
   it(`bindComponent should use optional componentId if component has a componentId in props`, () => {
164
   it(`bindComponent should use optional componentId if component has a componentId in props`, () => {
156
-    const tree = renderer.create(<UnboundScreen  componentId={'doNotUseThisId'} />);
165
+    const tree = renderer.create(<UnboundScreen componentId={'doNotUseThisId'} />);
157
     uut.bindComponent(tree.getInstance() as any, 'myCompId')
166
     uut.bindComponent(tree.getInstance() as any, 'myCompId')
158
 
167
 
159
     expect(tree.toJSON()).toBeDefined();
168
     expect(tree.toJSON()).toBeDefined();
160
-    
169
+
161
     uut.notifyComponentDidAppear({ componentId: 'dontUseThisId', componentName: 'doesnt matter', componentType: 'Component' });
170
     uut.notifyComponentDidAppear({ componentId: 'dontUseThisId', componentName: 'doesnt matter', componentType: 'Component' });
162
     expect(didAppearFn).not.toHaveBeenCalled();
171
     expect(didAppearFn).not.toHaveBeenCalled();
163
-    
172
+
164
 
173
 
165
     uut.notifyComponentDidAppear({ componentId: 'myCompId', componentName: 'doesnt matter', componentType: 'Component' });
174
     uut.notifyComponentDidAppear({ componentId: 'myCompId', componentName: 'doesnt matter', componentType: 'Component' });
166
     expect(didAppearFn).toHaveBeenCalledTimes(1);
175
     expect(didAppearFn).toHaveBeenCalledTimes(1);
188
     expect(modalDismissedFn).toHaveBeenCalledTimes(1);
197
     expect(modalDismissedFn).toHaveBeenCalledTimes(1);
189
     expect(modalDismissedFn).toHaveBeenLastCalledWith({ componentId: 'myCompId', modalsDismissed: 1 })
198
     expect(modalDismissedFn).toHaveBeenLastCalledWith({ componentId: 'myCompId', modalsDismissed: 1 })
190
 
199
 
200
+    uut.notifyModalAttemptedToDismiss({ componentId: 'myCompId' });
201
+    expect(modalAttemptedToDismissFn).toHaveBeenCalledTimes(1);
202
+    expect(modalAttemptedToDismissFn).toHaveBeenLastCalledWith({ componentId: 'myCompId' })
203
+
191
     uut.notifySearchBarUpdated({ componentId: 'myCompId', text: 'theText', isFocused: true });
204
     uut.notifySearchBarUpdated({ componentId: 'myCompId', text: 'theText', isFocused: true });
192
     expect(searchBarUpdatedFn).toHaveBeenCalledTimes(1);
205
     expect(searchBarUpdatedFn).toHaveBeenCalledTimes(1);
193
     expect(searchBarUpdatedFn).toHaveBeenCalledWith({ componentId: 'myCompId', text: 'theText', isFocused: true });
206
     expect(searchBarUpdatedFn).toHaveBeenCalledWith({ componentId: 'myCompId', text: 'theText', isFocused: true });

+ 8
- 1
lib/src/events/ComponentEventsObserver.ts Wyświetl plik

13
   ComponentEvent,
13
   ComponentEvent,
14
   PreviewCompletedEvent,
14
   PreviewCompletedEvent,
15
   ModalDismissedEvent,
15
   ModalDismissedEvent,
16
-  ScreenPoppedEvent
16
+  ScreenPoppedEvent,
17
+  ModalAttemptedToDismissEvent
17
 } from '../interfaces/ComponentEvents';
18
 } from '../interfaces/ComponentEvents';
18
 import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver';
19
 import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver';
19
 import { Store } from '../components/Store';
20
 import { Store } from '../components/Store';
32
     this.notifyComponentDidDisappear = this.notifyComponentDidDisappear.bind(this);
33
     this.notifyComponentDidDisappear = this.notifyComponentDidDisappear.bind(this);
33
     this.notifyNavigationButtonPressed = this.notifyNavigationButtonPressed.bind(this);
34
     this.notifyNavigationButtonPressed = this.notifyNavigationButtonPressed.bind(this);
34
     this.notifyModalDismissed = this.notifyModalDismissed.bind(this);
35
     this.notifyModalDismissed = this.notifyModalDismissed.bind(this);
36
+    this.notifyModalAttemptedToDismiss = this.notifyModalAttemptedToDismiss.bind(this);
35
     this.notifySearchBarUpdated = this.notifySearchBarUpdated.bind(this);
37
     this.notifySearchBarUpdated = this.notifySearchBarUpdated.bind(this);
36
     this.notifySearchBarCancelPressed = this.notifySearchBarCancelPressed.bind(this);
38
     this.notifySearchBarCancelPressed = this.notifySearchBarCancelPressed.bind(this);
37
     this.notifyPreviewCompleted = this.notifyPreviewCompleted.bind(this);
39
     this.notifyPreviewCompleted = this.notifyPreviewCompleted.bind(this);
45
     this.nativeEventsReceiver.registerComponentDidDisappearListener(this.notifyComponentDidDisappear);
47
     this.nativeEventsReceiver.registerComponentDidDisappearListener(this.notifyComponentDidDisappear);
46
     this.nativeEventsReceiver.registerNavigationButtonPressedListener(this.notifyNavigationButtonPressed);
48
     this.nativeEventsReceiver.registerNavigationButtonPressedListener(this.notifyNavigationButtonPressed);
47
     this.nativeEventsReceiver.registerModalDismissedListener(this.notifyModalDismissed);
49
     this.nativeEventsReceiver.registerModalDismissedListener(this.notifyModalDismissed);
50
+    this.nativeEventsReceiver.registerModalAttemptedToDismissListener(this.notifyModalAttemptedToDismiss);
48
     this.nativeEventsReceiver.registerSearchBarUpdatedListener(this.notifySearchBarUpdated);
51
     this.nativeEventsReceiver.registerSearchBarUpdatedListener(this.notifySearchBarUpdated);
49
     this.nativeEventsReceiver.registerSearchBarCancelPressedListener(this.notifySearchBarCancelPressed);
52
     this.nativeEventsReceiver.registerSearchBarCancelPressedListener(this.notifySearchBarCancelPressed);
50
     this.nativeEventsReceiver.registerPreviewCompletedListener(this.notifyPreviewCompleted);
53
     this.nativeEventsReceiver.registerPreviewCompletedListener(this.notifyPreviewCompleted);
87
     this.triggerOnAllListenersByComponentId(event, 'modalDismissed');
90
     this.triggerOnAllListenersByComponentId(event, 'modalDismissed');
88
   }
91
   }
89
 
92
 
93
+  notifyModalAttemptedToDismiss(event: ModalAttemptedToDismissEvent) {
94
+    this.triggerOnAllListenersByComponentId(event, 'modalAttemptedToDismiss');
95
+  }
96
+
90
   notifySearchBarUpdated(event: SearchBarUpdatedEvent) {
97
   notifySearchBarUpdated(event: SearchBarUpdatedEvent) {
91
     this.triggerOnAllListenersByComponentId(event, 'searchBarUpdated');
98
     this.triggerOnAllListenersByComponentId(event, 'searchBarUpdated');
92
   }
99
   }

+ 7
- 0
lib/src/events/EventsRegistry.test.tsx Wyświetl plik

68
     expect(mockNativeEventsReceiver.registerModalDismissedListener).toHaveBeenCalledWith(cb);
68
     expect(mockNativeEventsReceiver.registerModalDismissedListener).toHaveBeenCalledWith(cb);
69
   });
69
   });
70
 
70
 
71
+  it('delegates modalAttemptedToDimiss to nativeEventsReceiver', () => {
72
+    const cb = jest.fn();
73
+    uut.registerModalAttemptedToDismissListener(cb);
74
+    expect(mockNativeEventsReceiver.registerModalAttemptedToDismissListener).toHaveBeenCalledTimes(1);
75
+    expect(mockNativeEventsReceiver.registerModalAttemptedToDismissListener).toHaveBeenCalledWith(cb);
76
+  });
77
+
71
   it('delegates searchBarUpdated to nativeEventsReceiver', () => {
78
   it('delegates searchBarUpdated to nativeEventsReceiver', () => {
72
     const cb = jest.fn();
79
     const cb = jest.fn();
73
     uut.registerSearchBarUpdatedListener(cb);
80
     uut.registerSearchBarUpdatedListener(cb);

+ 6
- 1
lib/src/events/EventsRegistry.ts Wyświetl plik

12
   SearchBarCancelPressedEvent,
12
   SearchBarCancelPressedEvent,
13
   PreviewCompletedEvent,
13
   PreviewCompletedEvent,
14
   ModalDismissedEvent,
14
   ModalDismissedEvent,
15
-  ScreenPoppedEvent
15
+  ScreenPoppedEvent,
16
+  ModalAttemptedToDismissEvent
16
 } from '../interfaces/ComponentEvents';
17
 } from '../interfaces/ComponentEvents';
17
 import { CommandCompletedEvent, BottomTabSelectedEvent } from '../interfaces/Events';
18
 import { CommandCompletedEvent, BottomTabSelectedEvent } from '../interfaces/Events';
18
 
19
 
47
     return this.nativeEventsReceiver.registerModalDismissedListener(callback);
48
     return this.nativeEventsReceiver.registerModalDismissedListener(callback);
48
   }
49
   }
49
 
50
 
51
+  public registerModalAttemptedToDismissListener(callback: (event: ModalAttemptedToDismissEvent) => void): EmitterSubscription {
52
+    return this.nativeEventsReceiver.registerModalAttemptedToDismissListener(callback);
53
+  }
54
+
50
   public registerSearchBarUpdatedListener(callback: (event: SearchBarUpdatedEvent) => void): EmitterSubscription {
55
   public registerSearchBarUpdatedListener(callback: (event: SearchBarUpdatedEvent) => void): EmitterSubscription {
51
     return this.nativeEventsReceiver.registerSearchBarUpdatedListener(callback);
56
     return this.nativeEventsReceiver.registerSearchBarUpdatedListener(callback);
52
   }
57
   }

+ 4
- 0
lib/src/interfaces/ComponentEvents.ts Wyświetl plik

24
   modalsDismissed: number;
24
   modalsDismissed: number;
25
 }
25
 }
26
 
26
 
27
+export interface ModalAttemptedToDismissEvent extends ComponentEvent {
28
+  componentId: string;
29
+}
30
+
27
 export interface SearchBarUpdatedEvent extends ComponentEvent {
31
 export interface SearchBarUpdatedEvent extends ComponentEvent {
28
   text: string;
32
   text: string;
29
   isFocused: boolean;
33
   isFocused: boolean;

+ 1
- 0
playground/ios/NavigationTests/RNNCommandsHandlerTest.m Wyświetl plik

103
 	[skipMethods addObject:@"readyToReceiveCommands"];
103
 	[skipMethods addObject:@"readyToReceiveCommands"];
104
 	[skipMethods addObject:@".cxx_destruct"];
104
 	[skipMethods addObject:@".cxx_destruct"];
105
 	[skipMethods addObject:@"dismissedModal:"];
105
 	[skipMethods addObject:@"dismissedModal:"];
106
+	[skipMethods addObject:@"attemptedToDismissModal:"];
106
 	[skipMethods addObject:@"dismissedMultipleModals:"];
107
 	[skipMethods addObject:@"dismissedMultipleModals:"];
107
 	
108
 	
108
 	NSMutableArray* result = [NSMutableArray new];
109
 	NSMutableArray* result = [NSMutableArray new];

+ 12
- 0
playground/src/screens/ModalScreen.js Wyświetl plik

34
     };
34
     };
35
   }
35
   }
36
 
36
 
37
+  state = {
38
+    dimissCounter: 0,
39
+  }
40
+
41
+  componentDidMount() {
42
+    Navigation.events().bindComponent(this);
43
+  }
44
+
45
+  modalAttemptedToDismiss() {
46
+    return this.setState(state => ({ dimissCounter: state.dimissCounter + 1 }))
47
+  }
48
+
37
   render() {
49
   render() {
38
     return (
50
     return (
39
       <Root componentId={this.props.componentId} footer={`Modal Stack Position: ${this.getModalPosition()}`}>
51
       <Root componentId={this.props.componentId} footer={`Modal Stack Position: ${this.getModalPosition()}`}>

+ 13
- 3
playground/src/screens/NavigationScreen.js Wyświetl plik

2
 const Root = require('../components/Root');
2
 const Root = require('../components/Root');
3
 const Button = require('../components/Button')
3
 const Button = require('../components/Button')
4
 const Navigation = require('./../services/Navigation');
4
 const Navigation = require('./../services/Navigation');
5
+const { Platform } = require('react-native');
5
 const {
6
 const {
6
   NAVIGATION_TAB,
7
   NAVIGATION_TAB,
7
   MODAL_BTN,
8
   MODAL_BTN,
9
   EXTERNAL_COMP_BTN,
10
   EXTERNAL_COMP_BTN,
10
   SHOW_STATIC_EVENTS_SCREEN,
11
   SHOW_STATIC_EVENTS_SCREEN,
11
   SHOW_ORIENTATION_SCREEN,
12
   SHOW_ORIENTATION_SCREEN,
12
-  SET_ROOT_BTN
13
+  SET_ROOT_BTN,
14
+  PAGE_SHEET_MODAL_BTN
13
 } = require('../testIDs');
15
 } = require('../testIDs');
14
 const Screens = require('./Screens');
16
 const Screens = require('./Screens');
15
 
17
 
16
-class NavigationScreen  extends React.Component {
18
+class NavigationScreen extends React.Component {
17
   static options() {
19
   static options() {
18
     return {
20
     return {
19
       topBar: {
21
       topBar: {
34
       <Root componentId={this.props.componentId}>
36
       <Root componentId={this.props.componentId}>
35
         <Button label='Set Root' testID={SET_ROOT_BTN} onPress={this.setRoot} />
37
         <Button label='Set Root' testID={SET_ROOT_BTN} onPress={this.setRoot} />
36
         <Button label='Modal' testID={MODAL_BTN} onPress={this.showModal} />
38
         <Button label='Modal' testID={MODAL_BTN} onPress={this.showModal} />
39
+        {Platform.OS === 'ios' && <Button label='PageSheet modal' testID={PAGE_SHEET_MODAL_BTN} onPress={this.showPageSheetModal} />}
37
         <Button label='Overlay' testID={OVERLAY_BTN} onPress={this.showOverlay} />
40
         <Button label='Overlay' testID={OVERLAY_BTN} onPress={this.showOverlay} />
38
         <Button label='External Component' testID={EXTERNAL_COMP_BTN} onPress={this.externalComponent} />
41
         <Button label='External Component' testID={EXTERNAL_COMP_BTN} onPress={this.externalComponent} />
39
         <Button label='Static Events' testID={SHOW_STATIC_EVENTS_SCREEN} onPress={this.pushStaticEventsScreen} />
42
         <Button label='Static Events' testID={SHOW_STATIC_EVENTS_SCREEN} onPress={this.pushStaticEventsScreen} />
50
 
53
 
51
   setRoot = () => Navigation.showModal(Screens.SetRoot);
54
   setRoot = () => Navigation.showModal(Screens.SetRoot);
52
   showModal = () => Navigation.showModal(Screens.Modal);
55
   showModal = () => Navigation.showModal(Screens.Modal);
56
+
57
+  showPageSheetModal = () => Navigation.showModal(Screens.Modal, {
58
+    modalPresentationStyle: 'pageSheet',
59
+    modal: {
60
+      swipeToDismiss: false,
61
+    }
62
+  });
53
   showOverlay = () => Navigation.showModal(Screens.Overlay);
63
   showOverlay = () => Navigation.showModal(Screens.Overlay);
54
   externalComponent = () => Navigation.showModal(Screens.ExternalComponent);
64
   externalComponent = () => Navigation.showModal(Screens.ExternalComponent);
55
   pushStaticEventsScreen = () => Navigation.showModal(Screens.EventsScreen)
65
   pushStaticEventsScreen = () => Navigation.showModal(Screens.EventsScreen)
56
   orientation = () => Navigation.showModal(Screens.Orientation);
66
   orientation = () => Navigation.showModal(Screens.Orientation);
57
   pushContextScreen = () => Navigation.push(this, Screens.ContextScreen);
67
   pushContextScreen = () => Navigation.push(this, Screens.ContextScreen);
58
   sharedElement = () => Navigation.showModal(Screens.CocktailsListScreen)
68
   sharedElement = () => Navigation.showModal(Screens.CocktailsListScreen)
59
-  preview = ({reactTag}) => {
69
+  preview = ({ reactTag }) => {
60
     Navigation.push(this.props.componentId, {
70
     Navigation.push(this.props.componentId, {
61
       component: {
71
       component: {
62
         name: Screens.Pushed,
72
         name: Screens.Pushed,

+ 2
- 1
playground/src/testIDs.js Wyświetl plik

12
   OVERLAY_BTN: 'OVERLAY_BTN',
12
   OVERLAY_BTN: 'OVERLAY_BTN',
13
   SIDE_MENU_BTN: 'SIDE_MENU_BTN',
13
   SIDE_MENU_BTN: 'SIDE_MENU_BTN',
14
   MODAL_BTN: 'SHOW_MODAL_BUTTON',
14
   MODAL_BTN: 'SHOW_MODAL_BUTTON',
15
+  PAGE_SHEET_MODAL_BTN: 'SHOW_PAGE_SHEET_MODAL_BUTTON',
15
   DISMISS_MODAL_BTN: 'DISMISS_MODAL_BUTTON',
16
   DISMISS_MODAL_BTN: 'DISMISS_MODAL_BUTTON',
16
   MODAL_SCREEN_HEADER: 'MODAL_SCREEN_HEADER',
17
   MODAL_SCREEN_HEADER: 'MODAL_SCREEN_HEADER',
17
   ALERT_BUTTON: 'ALERT_BUTTON',
18
   ALERT_BUTTON: 'ALERT_BUTTON',
129
   SET_INTERCEPT_TOUCH: `SET_INTERCEPT_TOUCH`,
130
   SET_INTERCEPT_TOUCH: `SET_INTERCEPT_TOUCH`,
130
   PUSH_BOTTOM_TABS_BUTTON: `PUSH_BOTTOM_TABS_BUTTON`,
131
   PUSH_BOTTOM_TABS_BUTTON: `PUSH_BOTTOM_TABS_BUTTON`,
131
   SET_STACK_ROOT_BUTTON: `SET_STACK_ROOT_BUTTON`,
132
   SET_STACK_ROOT_BUTTON: `SET_STACK_ROOT_BUTTON`,
132
-  SET_ROOT:'SET_ROOT',
133
+  SET_ROOT: 'SET_ROOT',
133
   RESET_BUTTONS: 'RESET_BUTTONS',
134
   RESET_BUTTONS: 'RESET_BUTTONS',
134
   SHOW_LIFECYCLE_BTN: 'SHOW_LIFECYCLE_BTN',
135
   SHOW_LIFECYCLE_BTN: 'SHOW_LIFECYCLE_BTN',
135
   CHANGE_BUTTON_PROPS: 'CHANGE_BUTTON_PROPS',
136
   CHANGE_BUTTON_PROPS: 'CHANGE_BUTTON_PROPS',