2015-03-23 22:07:33 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
2015-03-14 17:52:40 +00:00
|
|
|
|
|
|
|
#import "RCTView.h"
|
|
|
|
|
2015-11-04 16:42:28 +00:00
|
|
|
@class RCTWebView;
|
|
|
|
|
2015-07-31 18:23:29 +00:00
|
|
|
/**
|
|
|
|
* Special scheme used to pass messages to the injectedJavaScript
|
|
|
|
* code without triggering a page load. Usage:
|
|
|
|
*
|
|
|
|
* window.location.href = RCTJSNavigationScheme + '://hello'
|
|
|
|
*/
|
2015-07-02 01:06:39 +00:00
|
|
|
extern NSString *const RCTJSNavigationScheme;
|
|
|
|
|
2015-11-04 16:42:28 +00:00
|
|
|
@protocol RCTWebViewDelegate <NSObject>
|
|
|
|
|
|
|
|
- (BOOL)webView:(RCTWebView *)webView
|
2015-11-14 18:25:00 +00:00
|
|
|
shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
2015-11-04 16:42:28 +00:00
|
|
|
withCallback:(RCTDirectEventBlock)callback;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2015-03-14 17:52:40 +00:00
|
|
|
@interface RCTWebView : RCTView
|
|
|
|
|
2015-11-04 16:42:28 +00:00
|
|
|
@property (nonatomic, weak) id<RCTWebViewDelegate> delegate;
|
|
|
|
|
2016-02-02 02:00:18 +00:00
|
|
|
@property (nonatomic, copy) NSDictionary *source;
|
2015-03-14 17:52:40 +00:00
|
|
|
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
|
|
|
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
|
2015-07-08 00:07:52 +00:00
|
|
|
@property (nonatomic, copy) NSString *injectedJavaScript;
|
2016-02-26 16:19:40 +00:00
|
|
|
@property (nonatomic, assign) BOOL scalesPageToFit;
|
2015-03-14 17:52:40 +00:00
|
|
|
|
|
|
|
- (void)goForward;
|
|
|
|
- (void)goBack;
|
|
|
|
- (void)reload;
|
Implemented stopLoading
Summary:**Motivation:** In my app, I'm using a WebView that loads content from my mobile site. What I want to do is when a user presses a link on the loaded page, I want to stop the WebView's request, hijack the URL and open the URL in a new WebView, pushed to the top of the navigator stack. To me, this gives the overall app a more native feel, instead of implementing a rudimentary navbar on the main WebView to go back.
**Attempted Workarounds:** I've attempted to get similar functionality by capturing the onNavigationStateChange event in the WebView, and then within calling goBack + pushing the new view to the navigator stack. From a functionality standpoint, this works. However, from a UI standpoint, the user can clearly see the webview change states to a new page + go back before having the new view pushed on top of their nav stack.
Closes https://github.com/facebook/react-native/pull/6886
Differential Revision: D3212447
Pulled By: mkonicek
fb-gh-sync-id: 05911e583d9ba54ddbd54a772153c80ed227731e
fbshipit-source-id: 05911e583d9ba54ddbd54a772153c80ed227731e
2016-04-22 15:14:53 +00:00
|
|
|
- (void)stopLoading;
|
2015-03-14 17:52:40 +00:00
|
|
|
|
|
|
|
@end
|