WIP
parent
46289b3dc4
commit
471ea5e37a
@ -0,0 +1,71 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="quill.snow.css" />
|
||||
<style>
|
||||
.standalone-container {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
#bubble-container {
|
||||
width:100%;
|
||||
height: 100%;
|
||||
}
|
||||
#bubble-container div.ql-editor {
|
||||
margin-top:0;
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h1>Title</h1>
|
||||
<div class="standalone-container">
|
||||
<div id="bubble-container"><h1><strong>Hello Estimate!</strong></h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="quill.min.js"></script>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="showdown.js"></script>
|
||||
<script type="text/javascript" src="to-markdown.js"></script>
|
||||
<script type="text/javascript" src="md-helpers.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var toolbarOptions = [
|
||||
['bold', 'italic', 'underline', 'strike'], // toggled buttons
|
||||
['blockquote', 'code-block'],
|
||||
|
||||
[{ 'header': 1 }, { 'header': 2 }], // custom button values
|
||||
[{ 'list': 'ordered' }, { 'list': 'bullet' }],
|
||||
[{ 'indent': '-1' }, { 'indent': '+1' }], // outdent/indent
|
||||
|
||||
['clean'] // remove formatting button
|
||||
];
|
||||
|
||||
var quill = new Quill('#bubble-container', {
|
||||
modules: {
|
||||
toolbar: toolbarOptions
|
||||
},
|
||||
placeholder: 'Composez votre texte ...',
|
||||
theme: 'snow'
|
||||
});
|
||||
|
||||
function getMD() {
|
||||
return markdownize($('#bubble-container div.ql-editor').html())
|
||||
}
|
||||
quill.on('text-change', function (delta, oldDelta, source)
|
||||
{
|
||||
if (source === "user") {
|
||||
$.get("file:validate?md=" + encodeURIComponent(getMD()));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -0,0 +1,94 @@
|
||||
|
||||
using BookAStar.Views;
|
||||
using Android.Webkit;
|
||||
using Xamarin.Forms.Platform.Android;
|
||||
using BookAStar.Droid;
|
||||
using System;
|
||||
using Java.Interop;
|
||||
|
||||
[assembly: Xamarin.Forms.ExportRenderer(typeof(MarkdownView), typeof(MarkdownViewRenderer))]
|
||||
namespace BookAStar.Droid
|
||||
{
|
||||
public class JSBridge : Java.Lang.Object
|
||||
{
|
||||
readonly WeakReference<MarkdownViewRenderer> hybridWebViewRenderer;
|
||||
|
||||
public JSBridge(MarkdownViewRenderer hybridRenderer)
|
||||
{
|
||||
hybridWebViewRenderer = new WeakReference<MarkdownViewRenderer>(hybridRenderer);
|
||||
}
|
||||
|
||||
[JavascriptInterface]
|
||||
[Export("invokeAction")]
|
||||
public void InvokeAction(string data)
|
||||
{
|
||||
MarkdownViewRenderer hybridRenderer;
|
||||
|
||||
if (hybridWebViewRenderer != null && hybridWebViewRenderer.TryGetTarget(out hybridRenderer))
|
||||
{
|
||||
hybridRenderer.Element.Markdown=data;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class MarkdownViewRenderer : ViewRenderer<MarkdownView, WebView>
|
||||
{
|
||||
private WebView editorView;
|
||||
private MarkdownEditor editorTemplate = new MarkdownEditor();
|
||||
private MarkdownDeep.Markdown markdown = new MarkdownDeep.Markdown();
|
||||
const string JavaScriptFunction = "function invokeCSharpAction(data){jsBridge.invokeAction(data);}";
|
||||
|
||||
private void SetMDEditorText(string text)
|
||||
{
|
||||
editorTemplate.Model = (text == null) ? null : markdown.Transform(text);
|
||||
var html = editorTemplate.GenerateString();
|
||||
editorView.LoadDataWithBaseURL("file:///android_asset/",
|
||||
html, "text/html", "utf-8", null);
|
||||
}
|
||||
|
||||
protected override void OnElementChanged(ElementChangedEventArgs<MarkdownView> e)
|
||||
{
|
||||
base.OnElementChanged(e);
|
||||
if (Control == null)
|
||||
{
|
||||
editorView = new WebView(Context);
|
||||
editorView.Settings.BuiltInZoomControls = true;
|
||||
editorView.Settings.JavaScriptEnabled = true;
|
||||
editorView.Settings.LoadsImagesAutomatically = true;
|
||||
editorView.Settings.SetAppCacheEnabled(true);
|
||||
editorView.Settings.AllowContentAccess = true;
|
||||
editorView.Settings.AllowFileAccess = true;
|
||||
editorView.Settings.AllowFileAccessFromFileURLs = true;
|
||||
editorView.Settings.AllowUniversalAccessFromFileURLs = true;
|
||||
editorView.Settings.BlockNetworkImage = false;
|
||||
editorView.Settings.BlockNetworkLoads = false;
|
||||
editorView.Settings.DomStorageEnabled = true;
|
||||
// editorView.SetMinimumHeight(300);
|
||||
SetNativeControl(editorView);
|
||||
}
|
||||
if (e.OldElement != null)
|
||||
{
|
||||
// Unsubscribe
|
||||
}
|
||||
if (e.NewElement != null)
|
||||
{
|
||||
// Subscribe
|
||||
var viewclient = new MarkdownWebViewClient(
|
||||
md => { e.NewElement.Markdown = md; });
|
||||
editorView.SetWebViewClient(viewclient);
|
||||
Control.AddJavascriptInterface(new JSBridge(this), "jsBridge");
|
||||
SetMDEditorText(e.NewElement.Markdown);
|
||||
InjectJS(JavaScriptFunction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InjectJS(string script)
|
||||
{
|
||||
if (Control != null)
|
||||
{
|
||||
Control.LoadUrl(string.Format("javascript: {0}", script));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
@ -1,19 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
|
||||
xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps.dll"
|
||||
x:Class="BookAStar.Pages.BookQueryPage">
|
||||
x:Class="BookAStar.Pages.BookQueryPage"
|
||||
BackgroundColor="{x:Static local:Constants.BackgroundColor}"
|
||||
Padding="{x:Static local:Constants.PagePadding}"
|
||||
>
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
|
||||
<Style x:Key="labelStyle" TargetType="Label">
|
||||
<Setter Property="TextColor" Value="{DynamicResource EmphasisTextColor}" />
|
||||
<Setter Property="FontAttributes" Value="Bold" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource LargeFontSize}" />
|
||||
<Setter Property="VerticalOptions" Value="Start" />
|
||||
<Setter Property="LineBreakMode" Value="WordWrap" />
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
|
||||
<StackLayout x:Name="bookQueryLayout">
|
||||
|
||||
|
||||
<Label Text="{Binding Title}" VerticalOptions="Start" HorizontalOptions="Center" />
|
||||
<Label Text="{Binding Description}" VerticalOptions="FillAndExpand" HorizontalOptions="Center" />
|
||||
<Label Text="{Binding CommandId}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
<Label Text="{Binding Comment}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
<Label Text="{Binding StartDate}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
<Label Text="{Binding EndDate}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
<Label Text="{Binding Location}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
<Label Text="{Binding Client.UserName}" Style="{StaticResource labelStyle}"
|
||||
VerticalOptions="Start" HorizontalOptions="Center" />
|
||||
<Label Text="{Binding Location.Address}" VerticalOptions="FillAndExpand" HorizontalOptions="Center" />
|
||||
<Label Text="{Binding Previsional}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
|
||||
<Label Text="{Binding EventDate}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
<Label Text="{Binding Location.Address}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
<maps:Map x:Name="map"></maps:Map>
|
||||
<Button Text="Faire un devis" Clicked="MakeAnEstimate" VerticalOptions="Center" HorizontalOptions="End"/>
|
||||
</StackLayout>
|
||||
<Button Text="Faire un devis" Clicked="MakeAnEstimate" VerticalOptions="Center" HorizontalOptions="End"/>
|
||||
</StackLayout>
|
||||
</ContentPage>
|
||||
@ -0,0 +1,42 @@
|
||||
<?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="BookAStar.Pages.EditEstimatePage"
|
||||
xmlns:local="clr-namespace:BookAStar.Views;assembly=BookAStar"
|
||||
>
|
||||
<StackLayout Padding="10,10,10,10">
|
||||
|
||||
<StackLayout Orientation="Horizontal" Padding="10,10,10,10">
|
||||
<Label Text="{Binding Client.UserName}"
|
||||
LineBreakMode="WordWrap"></Label>
|
||||
<Label Text="{Binding Query.Location.Address}"
|
||||
LineBreakMode="WordWrap" ></Label>
|
||||
<Label Text="{Binding Query.EventDate, StringFormat='{0:dddd d MMMM yyyy à hh:mm}'}"
|
||||
LineBreakMode="WordWrap" ></Label>
|
||||
</StackLayout>
|
||||
|
||||
<local:MarkdownView x:Name="mdview" Markdown="{Binding Description}"
|
||||
Edited="OnDescriptionChanged" HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand">
|
||||
|
||||
</local:MarkdownView>
|
||||
|
||||
<!-- <ListView >
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ViewCell>
|
||||
<ViewCell.View>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Entry Placeholder="Ligne de facture"></Entry>
|
||||
<Entry Placeholder="Compte"></Entry>
|
||||
<Entry Placeholder="Prix unitaire" ></Entry>
|
||||
</StackLayout>
|
||||
</ViewCell.View>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView> -->
|
||||
<Label Text="Total TTC:"></Label>
|
||||
<Button Text="Valider ce devis"></Button>
|
||||
</StackLayout>
|
||||
</ContentPage>
|
||||
@ -1,10 +0,0 @@
|
||||
<?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="BookAStar.Pages.MakeAnEstimatePage"
|
||||
xmlns:local="clr-namespace:BookAStar.Views;assembly=BookAStar"
|
||||
>
|
||||
|
||||
<local:MarkdownView x:Name="mdview" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
|
||||
Markdown="hello estimate"></local:MarkdownView>
|
||||
</ContentPage>
|
||||
@ -1,6 +0,0 @@
|
||||
<?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="BookAStar.QueriesPage">
|
||||
<Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
|
||||
</ContentPage>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Loading…
Reference in New Issue