Hybrid App for Xamarin, Xamarin combined with Vue.js and more.
Hybrid App for Xamarin, Xamarin combined with Vue.js and more.
- Simple - enjoy 5 minutes installation, easy to get started.
- Interactive - Use JavaScript to call C#, use C# to call JavaScript
- TODO
- TODO
1.Install TorchView in your Xamarin.Forms
PM> Install-Package TorchView
2.Install TorchView.Android in your Xamarin.Android
PM> Install-Package TorchView.Android
Note
If the installation is not successful through nuget, please try to download in
Releases
and manually add a reference to the dll.
3.Find
Xamarin.Android
, add your web file toAssets/wwwroot
(wwwroot needs to be created)
Note
4.Find
Xamarin.Forms
, addHybridWebView
to the page you need,
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Demo.MainPage"
xmlns:com="clr-namespace:TorchView.Components;assembly=TorchView">
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
<Label HorizontalOptions="Center" VerticalOptions="Center" Text="Welcome to TorchView !" FontSize="16" BackgroundColor="LightBlue"></Label>
<Button Clicked="Button_Clicked" Text="Invoke JavaScript Code"></Button>
<com:HybridWebView x:Name="hybridWebView" Uri="http://torchview/index.html" WidthRequest="1000" HeightRequest="1000"></com:HybridWebView>
</StackLayout>
</ContentPage>
5.Finished, now you can start your app
Note
In fact, you can use
this.hybridWebView
inMainPage.xaml.cs
to complete more operations
namespace Demo
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
this.hybridWebView.RegisterAction(data => DisplayAlert("Alert", "RegisterAction " + data, "OK"));
this.hybridWebView.RegisterFunc(data => { return "RegisterFunc " + data; });
}
private async void Button_Clicked(object sender, EventArgs e)
{
string result = await this.hybridWebView.EvaluateJavaScriptAsync("document.getElementById('name').value");
await DisplayAlert("Alert", "Get name value: " + result, "OK");
}
}
}
TorchView | TorchView.Android | |
---|---|---|
Android 5.0 (+) | ||
Note
Currently does not support iOS.
TorchView | ||
---|---|---|
TorchView.Android |
- Development: Visual Studio Community 2019, Xamarin Development Kit
TorchView is an Apache-2.0 licensed open source project and completely free to use. However, the amount of effort needed to maintain and develop new features for the project is not sustainable without proper financial backing.
We accept donations through these channels:
TorchView © yiyun, Released under the Apache-2.0 License.
Authored and maintained by yiyun with help from contributors (list).
GitHub @yiyungent Gitee @yiyungent