public override Task <TEditorResponse> ShowTEditor(string html, ToolbarBuilder toolbarBuilder = null, EventHandler <ToolbarBuilderEventArgs> toolbarBuilderOnClick = null, bool autoFocusInput = false) { var result = new TaskCompletionSource <TEditorResponse>(); DecoreView.AddView(new TEditorView(MainActivity, html, autoFocusInput, toolbarBuilder, toolbarBuilderOnClick)); TEditorView.SetOutput = (res, resStr) => { TEditorView.SetOutput = null; if (res) { result.SetResult(new TEditorResponse() { IsSave = true, HTML = resStr }); } else { result.SetResult(new TEditorResponse() { IsSave = false, HTML = string.Empty }); } }; return(result.Task); }
private void InitializeComponent(string htmlStringvalue, bool autoFocusInputvalue) { _topToolBar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.TopToolbar); _topToolBar.Title = CrossTEditor.PageTitle; _topToolBar.SetNavigationIcon(Resource.Drawable.backbutton); _topToolBar.SetTitleTextColor(Android.Graphics.Color.White); _topToolBar.SetOnClickListener(new BackClicked(DecoreView, this)); _topToolBar.InflateMenu(Resource.Menu.TopToolbarMenu); _topToolBar.MenuItemClick += async(sender, e) => { if (SetOutput != null) { if (e.Item.TitleFormatted.ToString() == "Save") { string html = await _editorWebView.GetHTML(); SetOutput.Invoke(true, html); } else { SetOutput.Invoke(false, null); } } DecoreView.RemoveView(this); }; _rootLayout = FindViewById <LinearLayoutDetectsSoftKeyboard>(Resource.Id.RootRelativeLayout); _editorWebView = FindViewById <TEditorWebView>(Resource.Id.EditorWebView); _toolbarLayout = FindViewById <LinearLayout>(Resource.Id.ToolbarLayout); _rootLayout.onKeyboardShown += HandleSoftKeyboardShwon; _editorWebView.SetOnCreateContextMenuListener(this); BuildToolbar(); string htmlString = htmlStringvalue; _editorWebView.SetHTML(htmlString); bool autoFocusInput = autoFocusInputvalue; _editorWebView.SetAutoFocusInput(autoFocusInput); }
public void OnClick(View v) { TEditorView.SetOutput.Invoke(false, null); DecoreView.RemoveView(EditorView); }