Fixed Android
This commit is contained in:
Родитель
ffba67529c
Коммит
9bb545d0cc
|
@ -26,23 +26,6 @@ namespace HotUI.Android
|
|||
return page.Activity;
|
||||
}*/
|
||||
|
||||
public static AView ToView(this HotPage hotPage, Activity activity)
|
||||
{
|
||||
if (hotPage == null)
|
||||
return null;
|
||||
|
||||
var handler = hotPage.ViewHandler;
|
||||
if (handler == null)
|
||||
{
|
||||
handler = Registrar.Pages.GetRenderer(hotPage.GetType()) as IViewContainer;
|
||||
hotPage.ViewHandler = handler;
|
||||
hotPage.ReBuildView();
|
||||
}
|
||||
|
||||
var page = handler as IViewContainer;
|
||||
return page.View;
|
||||
}
|
||||
|
||||
public static AView ToView(this View view)
|
||||
{
|
||||
if (view == null)
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
using AView = Android.Views.View;
|
||||
|
||||
namespace HotUI.Android
|
||||
{
|
||||
public class HotPageHandler : IViewContainer
|
||||
{
|
||||
HotPage hotpage;
|
||||
AView currentView;
|
||||
|
||||
public AView View => currentView;
|
||||
|
||||
public void Remove(View view)
|
||||
{
|
||||
// todo: implement this
|
||||
}
|
||||
|
||||
public void SetView(View view)
|
||||
{
|
||||
currentView = view.ToView();
|
||||
}
|
||||
|
||||
|
||||
public void SetViewBuilder(ViewBuilder builder)
|
||||
{
|
||||
hotpage = builder as HotPage;
|
||||
if (hotpage.View == null)
|
||||
hotpage.ReBuildView();
|
||||
|
||||
// todo: needs to be implemented
|
||||
}
|
||||
|
||||
public void UpdateValue(string property, object value)
|
||||
{
|
||||
// todo: needs to be implemented
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using AView = Android.Views.View;
|
||||
namespace HotUI.Android {
|
||||
public class ViewHandler : IView {
|
||||
AView currentView;
|
||||
|
||||
public AView View => currentView;
|
||||
|
||||
public void Remove (View view)
|
||||
{
|
||||
// todo: implement this
|
||||
}
|
||||
|
||||
public void SetView (View view)
|
||||
{
|
||||
currentView = view.ToView ();
|
||||
currentView?.UpdateProperties (view);
|
||||
}
|
||||
|
||||
public void UpdateValue (string property, object value)
|
||||
{
|
||||
View?.UpdateProperty (property, value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,15 +8,15 @@ namespace HotUI.Android
|
|||
{
|
||||
public abstract class HotActivity : AppCompatActivity
|
||||
{
|
||||
private HotPage _page;
|
||||
private View _page;
|
||||
|
||||
public HotPage Page
|
||||
public View Page
|
||||
{
|
||||
get => _page;
|
||||
set
|
||||
{
|
||||
_page = value;
|
||||
SetContentView(_page?.ToView(this));
|
||||
SetContentView(_page?.ToView());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,55 +32,5 @@ namespace HotUI.Android
|
|||
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
protected override void OnRestart()
|
||||
{
|
||||
base.OnRestart();
|
||||
_page?.OnAppearing();
|
||||
}
|
||||
|
||||
protected override void OnResume()
|
||||
{
|
||||
base.OnResume();
|
||||
_page?.OnAppearing();
|
||||
}
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
_page?.OnAppearing();
|
||||
}
|
||||
|
||||
protected override void OnStop()
|
||||
{
|
||||
base.OnStop();
|
||||
_page?.OnDisppearing();
|
||||
}
|
||||
|
||||
protected override void OnPause()
|
||||
{
|
||||
base.OnPause();
|
||||
_page?.OnDisppearing();
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class ControlExtensions
|
||||
{
|
||||
public static void UpdateProperties(this Activity view, HotPage hView)
|
||||
{
|
||||
view.Title = hView.Title;
|
||||
}
|
||||
|
||||
public static bool UpdateProperty(this Activity view, string property, object value)
|
||||
{
|
||||
switch (property)
|
||||
{
|
||||
case nameof(HotPage.Title):
|
||||
view.Title = (string) value;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -52,7 +52,6 @@
|
|||
<Compile Include="Extensions\AndroidExtensions.cs" />
|
||||
<Compile Include="Handlers\ButtonHandler.cs" />
|
||||
<Compile Include="Handlers\TextFieldHandler.cs" />
|
||||
<Compile Include="Handlers\HotPageHandler.cs" />
|
||||
<Compile Include="Handlers\ImageHandler.cs" />
|
||||
<Compile Include="Handlers\TextHandler.cs" />
|
||||
<Compile Include="Handlers\ScrollViewHandler.cs" />
|
||||
|
@ -63,6 +62,7 @@
|
|||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UI.cs" />
|
||||
<Compile Include="Handlers\ListViewHandler.cs" />
|
||||
<Compile Include="Handlers\ViewHandler.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\AboutResources.txt" />
|
||||
|
|
|
@ -6,9 +6,4 @@ namespace HotUI.Android
|
|||
{
|
||||
AView View { get; }
|
||||
}
|
||||
|
||||
public interface IViewContainer : IViewBuilderHandler
|
||||
{
|
||||
AView View { get; }
|
||||
}
|
||||
}
|
|
@ -17,8 +17,7 @@
|
|||
Registrar.Handlers.Register<ScrollView, ScrollViewHandler>();
|
||||
Registrar.Handlers.Register<Image, ImageHandler> ();
|
||||
Registrar.Handlers.Register<ListView, ListViewHandler> ();
|
||||
|
||||
Registrar.Pages.Register<HotPage, HotPageHandler>();
|
||||
Registrar.Handlers.Register<View, ViewHandler>();
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче