Skip to content

Commit

Permalink
fix(android): Fix WebViewManager can no longer be customized (react-n…
Browse files Browse the repository at this point in the history
  • Loading branch information
deka0106 committed Feb 13, 2024
1 parent ae05226 commit 0068588
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public RNCWebViewWrapper createViewInstance(ThemedReactContext context) {
return mRNCWebViewManagerImpl.createViewInstance(context);
}

public RNCWebViewWrapper createViewInstance(ThemedReactContext context, RNCWebViewWrapper view) {
return mRNCWebViewManagerImpl.createViewInstance(context, view.getWebView());
public RNCWebViewWrapper createViewInstance(ThemedReactContext context, RNCWebView view) {
return mRNCWebViewManagerImpl.createViewInstance(context, view);
}

@ReactProp(name = "allowFileAccess")
Expand Down
10 changes: 5 additions & 5 deletions docs/Custom-Android.italian.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Prima di procedere, è consigliabile avere un'idea di base dei concetti legati
## Codice nativo
Per iniziare, dovrai creare una sottoclasse di `RNCWebViewManager`, `RNCWebView` e `RNCWebViewClient`. Poi, nel gestore della view, sovrascrivi i seguenti metodi:

- `createReactWebViewInstance`
- `createViewInstance`
- `getName`
- `addEventEmitters`

Expand Down Expand Up @@ -34,8 +34,8 @@ public class CustomWebViewManager extends RNCWebViewManager {
}

@Override
protected void addEventEmitters(ThemedReactContext reactContext, RNCWebView view) {
view.setWebViewClient(new CustomWebViewClient());
protected void addEventEmitters(ThemedReactContext reactContext, RNCWebViewWrapper view) {
view.getWebView().setWebViewClient(new CustomWebViewClient());
}
}
```
Expand Down Expand Up @@ -68,8 +68,8 @@ public class CustomWebViewManager extends RNCWebViewManager {
...

@ReactProp(name = "finalUrl")
public void setFinalUrl(WebView view, String url) {
((CustomWebView) view).setFinalUrl(url);
public void setFinalUrl(RNCWebViewWrapper view, String url) {
((CustomWebView) view.getWebView()).setFinalUrl(url);
}
}
```
Expand Down
10 changes: 5 additions & 5 deletions docs/Custom-Android.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Before you do this, you should be familiar with the concepts in [native UI compo

To get started, you'll need to create a subclass of `RNCWebViewManager`, `RNCWebView`, and `RNCWebViewClient`. In your view manager, you'll then need to override:

- `createReactWebViewInstance`
- `createViewInstance`
- `getName`
- `addEventEmitters`

Expand Down Expand Up @@ -35,8 +35,8 @@ public class CustomWebViewManager extends RNCWebViewManager {
}

@Override
protected void addEventEmitters(ThemedReactContext reactContext, RNCWebView view) {
view.setWebViewClient(new CustomWebViewClient());
protected void addEventEmitters(ThemedReactContext reactContext, RNCWebViewWrapper view) {
view.getWebView().setWebViewClient(new CustomWebViewClient());
}
}
```
Expand Down Expand Up @@ -70,8 +70,8 @@ public class CustomWebViewManager extends RNCWebViewManager {
...

@ReactProp(name = "finalUrl")
public void setFinalUrl(WebView view, String url) {
((CustomWebView) view).setFinalUrl(url);
public void setFinalUrl(RNCWebViewWrapper view, String url) {
((CustomWebView) view.getWebView()).setFinalUrl(url);
}
}
```
Expand Down
14 changes: 7 additions & 7 deletions docs/Custom-Android.portuguese.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Antes de fazer isso, você deve estar familiarizado com os conceitos de [compone

Para começar, você precisará criar uma subclasse de `RNCWebViewManager`, `RNCWebView` e `RNCWebViewClient`. Em seu gerenciador de visualizações, você precisará substituir:

- `createReactWebViewInstance`
- `createViewInstance`
- `getName`
- `addEventEmitters`

Expand All @@ -25,8 +25,8 @@ public class CustomWebViewManager extends RNCWebViewManager {
}

@Override
protected RNCWebView createRNCWebViewInstance(ThemedReactContext reactContext) {
return new CustomWebView(reactContext);
protected RNCWebView createViewInstance(ThemedReactContext reactContext) {
return super.createViewInstance(reactContext, new CustomWebView(reactContext));
}

@Override
Expand All @@ -35,8 +35,8 @@ public class CustomWebViewManager extends RNCWebViewManager {
}

@Override
protected void addEventEmitters(ThemedReactContext reactContext, WebView view) {
view.setWebViewClient(new CustomWebViewClient());
protected void addEventEmitters(ThemedReactContext reactContext, RNCWebViewWrapper view) {
view.getWebView().setWebViewClient(new CustomWebViewClient());
}
}
```
Expand Down Expand Up @@ -70,8 +70,8 @@ public class CustomWebViewManager extends RNCWebViewManager {
...

@ReactProp(name = "finalUrl")
public void setFinalUrl(WebView view, String url) {
((CustomWebView) view).setFinalUrl(url);
public void setFinalUrl(RNCWebViewWrapper view, String url) {
((CustomWebView) view.getWebView()).setFinalUrl(url);
}
}
```
Expand Down

0 comments on commit 0068588

Please sign in to comment.