Procházet zdrojové kódy

Add unregisterForPreviewingWithContext (#2239)

* Preview API

* Added preview actions and fail-guard wrappers

* Remove old setters

* Moved from passProps to actionParams

* Move findNodeHandle to internal method

* Removing findNodeHandle

* Added height and option to dont 'pop' the view controller

* Documentation update for peek and pop

* Document how to access button press events

* Commit by default in example. Because it's cool

* Docs and if elses ifs then

* Unregister previous ViewController on attempt to preview.

* Merge conflict fail
Birkir Rafn Guðjónsson před 7 roky
rodič
revize
36ed3b0af5
2 změnil soubory, kde provedl 4 přidání a 1 odebrání
  1. 3
    1
      ios/RCCNavigationController.m
  2. 1
    0
      ios/RCCViewController.h

+ 3
- 1
ios/RCCNavigationController.m Zobrazit soubor

@@ -172,6 +172,8 @@ NSString const *CALLBACK_ASSOCIATED_ID = @"RCCNavigationController.CALLBACK_ASSO
172 172
       if ([self.topViewController isKindOfClass:[RCCViewController class]])
173 173
       {
174 174
         RCCViewController *topViewController = ((RCCViewController*)self.topViewController);
175
+        topViewController.previewController = nil;
176
+        [topViewController.navigationController unregisterForPreviewingWithContext:topViewController.previewContext];
175 177
         viewController.previewActions = previewActions;
176 178
         viewController.previewCommit = actionParams[@"previewCommit"] ? [actionParams[@"previewCommit"] boolValue] : YES;
177 179
         NSNumber *previewHeight = actionParams[@"previewHeight"];
@@ -184,7 +186,7 @@ NSString const *CALLBACK_ASSOCIATED_ID = @"RCCNavigationController.CALLBACK_ASSO
184 186
             [bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
185 187
               UIView *view = viewRegistry[previewViewID];
186 188
               topViewController.previewView = view;
187
-              [topViewController registerForPreviewingWithDelegate:(id)topViewController sourceView:view];
189
+              topViewController.previewContext = [topViewController registerForPreviewingWithDelegate:(id)topViewController sourceView:view];
188 190
             }];
189 191
           });
190 192
           topViewController.previewController = viewController;

+ 1
- 0
ios/RCCViewController.h Zobrazit soubor

@@ -22,6 +22,7 @@ extern NSString* const RCCViewControllerCancelReactTouchesNotification;
22 22
 @property (nonatomic) UIView *previewView;
23 23
 @property (nonatomic) NSArray *previewActions;
24 24
 @property (nonatomic) BOOL previewCommit;
25
+@property (nonatomic) id previewContext;
25 26
 
26 27
 + (UIViewController*)controllerWithLayout:(NSDictionary *)layout globalProps:(NSDictionary *)globalProps bridge:(RCTBridge *)bridge;
27 28