/TorchView

🔧 Hybrid App for Xamarin, Xamarin combined with Vue.js and more.

Primary LanguageC#Apache License 2.0Apache-2.0

TorchView

TorchView

Hybrid App for Xamarin, Xamarin combined with Vue.js and more.

repo size LICENSE

Introduction

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

Demo

  • TODO

Screenshots

  • TODO

Quick Start

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 to Assets/wwwroot (wwwroot needs to be created)

image-20210723093820791

Note

Snipaste_2021-08-17_12-19-01.png

4.Find Xamarin.Forms, add HybridWebView 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 in MainPage.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");
        }
    }
}

Support

TorchView TorchView.Android
Android 5.0 (+)

Note

Currently does not support iOS.

TorchView nuget downloads
TorchView.Android nuget downloads

Environment

  • Development: Visual Studio Community 2019, Xamarin Development Kit

Related Projects

Thanks

Donate

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:

Author

TorchView © yiyun, Released under the Apache-2.0 License.
Authored and maintained by yiyun with help from contributors (list).

GitHub @yiyungent Gitee @yiyungent