refactoring
This commit is contained in:
parent
f2de8d9db5
commit
9b215072e1
18 changed files with 49 additions and 50 deletions
49
BookAStar/BookAStar/Pages/BlogPages/BlogPage.cs
Normal file
49
BookAStar/BookAStar/Pages/BlogPages/BlogPage.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
using BookAStar.Model.Blog;
|
||||
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Pages.BlogPages
|
||||
{
|
||||
public class BlogPage : ContentPage
|
||||
{
|
||||
HtmlWebViewSource _source;
|
||||
HtmlWebViewSource _sourceTitle;
|
||||
MarkdownDeep.Markdown _md;
|
||||
WebView titleLabel;
|
||||
WebView contentView;
|
||||
|
||||
public BlogPage()
|
||||
{
|
||||
_source = new HtmlWebViewSource();
|
||||
_sourceTitle = new HtmlWebViewSource();
|
||||
_md = new MarkdownDeep.Markdown();
|
||||
_sourceTitle.BaseUrl = _source.BaseUrl = Constants.YavscHomeUrl;
|
||||
_sourceTitle.Html = "Hello";
|
||||
titleLabel = new WebView { Source = _sourceTitle };
|
||||
contentView = new WebView { Source = _source };
|
||||
|
||||
Content = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
titleLabel,
|
||||
contentView
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnBindingContextChanged()
|
||||
{
|
||||
base.OnBindingContextChanged();
|
||||
var blog = BindingContext as Blog;
|
||||
if (blog == null)
|
||||
{
|
||||
_sourceTitle.Html = _source.Html = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_sourceTitle.Html = _md.Transform(blog.bcontent);
|
||||
_source.Html = _md.Transform(blog.bcontent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue