Skip to content

Commit

Permalink
Adding renderers for WebView and UIFrame/Layout for iOS and Android. …
Browse files Browse the repository at this point in the history
…Adding helper for getting Contacts.
  • Loading branch information
Alvaro Vargas committed May 14, 2019
1 parent d284f6c commit 1f9e64f
Show file tree
Hide file tree
Showing 16 changed files with 9,882 additions and 25 deletions.
186 changes: 186 additions & 0 deletions src/Trestle.Android/Archetypical.Software.Trestle.Android.csproj

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/Trestle.Android/Bridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ public void WireWebView<T>(T webView)
_webView.ClearCache(true);
_webView.Settings.JavaScriptEnabled = true;
_webView.Settings.DomStorageEnabled = true;
_webView.LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);

_webViewClient = new BridgeWebViewClient();

_webView.SetBackgroundColor(Android.Graphics.Color.Pink);
_view.AddView(_webView, new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent));
_view.AddView(_webView);
_webView.SetWebViewClient(_webViewClient);

var button = new Button(_view.Context);
button.Text = "My Dynamic Button";
button.SetBackgroundColor(Android.Graphics.Color.Brown);
button.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
_view.AddView(button);
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/Trestle.Android/BridgeWebViewClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public override WebResourceResponse ShouldInterceptRequest(WebView view, IWebRes
var urlToCheck = $"{request.Url.Scheme}:{request.Url.SchemeSpecificPart}";
if (!_urls.Contains(urlToCheck))
return base.ShouldInterceptRequest(view, request);

try
{
var action = _urlActions[urlToCheck];
Expand All @@ -41,12 +40,12 @@ public override WebResourceResponse ShouldInterceptRequest(WebView view, IWebRes
var content = response.Content.ReadAsStreamAsync().Result;
var contentType = "*/*";
var headers = new Dictionary<string, string>();
headers.Add("Access-Control-Allow-Origin", "*"); // SUPER FLIPIN' IMPORTANT!
headers.Add("Access-Control-Allow-Origin", "*");

return new WebResourceResponse(contentType, "UTF-8", 200, "OK", headers, content);
}
}
catch (AggregateException e)
catch (AggregateException)
{
return base.ShouldInterceptRequest(view, request);
}
Expand Down
Loading

0 comments on commit 1f9e64f

Please sign in to comment.