Skip to content

Commit

Permalink
Add RefreshViewHandler (dotnet#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
myroot committed Aug 25, 2022
1 parent 2b11ffe commit 8c7ebb8
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/RefreshView/IRefreshViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#elif WINDOWS
using PlatformView = Microsoft.UI.Xaml.Controls.RefreshContainer;
#elif TIZEN
using PlatformView = Tizen.NUI.BaseComponents.View;
using PlatformView = Microsoft.Maui.Platform.MauiRefreshLayout;
#elif (NETSTANDARD || !PLATFORM) || (NET6_0_OR_GREATER && !IOS && !ANDROID && !TIZEN)
using PlatformView = System.Object;
#endif
Expand Down
35 changes: 22 additions & 13 deletions src/Core/src/Handlers/RefreshView/RefreshViewHandler.Tizen.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Maui.Graphics;
using NView = Tizen.NUI.BaseComponents.View;

namespace Microsoft.Maui.Handlers
{
// TODO : Need to implement
public partial class RefreshViewHandler : ViewHandler<IRefreshView, NView>
public partial class RefreshViewHandler : ViewHandler<IRefreshView, MauiRefreshLayout>
{
protected override NView CreatePlatformView() => throw new NotImplementedException();

public static void MapIsRefreshing(IRefreshViewHandler handler, IRefreshView refreshView)
{
}
protected override MauiRefreshLayout CreatePlatformView() => new();

public static void MapContent(IRefreshViewHandler handler, IRefreshView refreshView)
protected override void ConnectHandler(MauiRefreshLayout platformView)
{
base.ConnectHandler(platformView);
platformView.Refreshing += OnRefreshing;
}

public static void MapRefreshColor(IRefreshViewHandler handler, IRefreshView refreshView)
void OnRefreshing(object? sender, EventArgs e)
{
VirtualView.IsRefreshing = true;
}

public static void MapRefreshViewBackground(IRefreshViewHandler handler, IView view)
protected override void DisconnectHandler(MauiRefreshLayout platformView)
{
platformView.Refreshing -= OnRefreshing;
platformView.Content = null;
base.DisconnectHandler(platformView);
}

public static void MapIsRefreshing(IRefreshViewHandler handler, IRefreshView refreshView) =>
handler.PlatformView.UpdateIsRefreshing(refreshView);

public static void MapContent(IRefreshViewHandler handler, IRefreshView refreshView) =>
handler.PlatformView.UpdateContent(handler.VirtualView.Content, handler.MauiContext);

public static void MapRefreshColor(IRefreshViewHandler handler, IRefreshView refreshView) =>
handler.PlatformView.UpdateRefreshColor(refreshView);

public static void MapBackground(IRefreshViewHandler handler, IRefreshView view)
=> handler.PlatformView.UpdateBackground(view);
}
}
2 changes: 1 addition & 1 deletion src/Core/src/Handlers/RefreshView/RefreshViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#elif WINDOWS
using PlatformView = Microsoft.UI.Xaml.Controls.RefreshContainer;
#elif TIZEN
using PlatformView = Tizen.NUI.BaseComponents.View;
using PlatformView = Microsoft.Maui.Platform.MauiRefreshLayout;
#elif (NETSTANDARD || !PLATFORM) || (NET6_0_OR_GREATER && !IOS && !ANDROID && !TIZEN)
using PlatformView = System.Object;
#endif
Expand Down
43 changes: 43 additions & 0 deletions src/Core/src/Platform/Tizen/MauiRefreshLayout.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.Maui.Graphics;
using Tizen.UIExtensions.NUI;
using TColor = Tizen.UIExtensions.Common.Color;

namespace Microsoft.Maui.Platform
{
public class MauiRefreshLayout : RefreshLayout
{
IPlatformViewHandler? _contentHandler;

public void UpdateContent(IView? content, IMauiContext? mauiContext)
{
Content = null;
_contentHandler?.Dispose();
_contentHandler = null;

if (content != null && mauiContext != null)
{
var contentView = content.ToPlatform(mauiContext);
if (content.Handler is IPlatformViewHandler thandler)
{
_contentHandler = thandler;
}
Content = contentView;
}
}

public void UpdateIsRefreshing(IRefreshView view)
{
IsRefreshing = view.IsRefreshing;
}

public void UpdateRefreshColor(IRefreshView view)
{
IconColor = view.RefreshColor?.ToPlatform() ?? TColor.Default;
}

public void UpdateBackground(IRefreshView view)
{
IconBackgroundColor = view.Background.ToColor()?.ToPlatform() ?? TColor.Default;
}
}
}
14 changes: 11 additions & 3 deletions src/Core/src/PublicAPI/net-tizen/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ Microsoft.Maui.Handlers.IRadioButtonHandler
Microsoft.Maui.Handlers.IRadioButtonHandler.PlatformView.get -> Microsoft.Maui.Platform.ContentViewGroup!
Microsoft.Maui.Handlers.IRadioButtonHandler.VirtualView.get -> Microsoft.Maui.IRadioButton!
Microsoft.Maui.Handlers.IRefreshViewHandler
Microsoft.Maui.Handlers.IRefreshViewHandler.PlatformView.get -> Tizen.NUI.BaseComponents.View!
Microsoft.Maui.Handlers.IRefreshViewHandler.PlatformView.get -> Microsoft.Maui.Platform.MauiRefreshLayout!
Microsoft.Maui.Handlers.IRefreshViewHandler.VirtualView.get -> Microsoft.Maui.IRefreshView!
Microsoft.Maui.Handlers.IScrollViewHandler
Microsoft.Maui.Handlers.IScrollViewHandler.PlatformView.get -> Tizen.UIExtensions.NUI.ScrollView!
Expand Down Expand Up @@ -582,6 +582,7 @@ Microsoft.Maui.Handlers.RadioButtonHandler.RadioButtonHandler(Microsoft.Maui.IPr
Microsoft.Maui.Handlers.RefreshViewHandler
Microsoft.Maui.Handlers.RefreshViewHandler.RefreshViewHandler() -> void
Microsoft.Maui.Handlers.RefreshViewHandler.RefreshViewHandler(Microsoft.Maui.IPropertyMapper? mapper = null) -> void
static Microsoft.Maui.Handlers.RefreshViewHandler.MapBackground(Microsoft.Maui.Handlers.IRefreshViewHandler! handler, Microsoft.Maui.IRefreshView! view) -> void
Microsoft.Maui.Handlers.ScrollViewHandler
Microsoft.Maui.Handlers.ScrollViewHandler.ScrollViewHandler() -> void
Microsoft.Maui.Handlers.ScrollViewHandler.ScrollViewHandler(Microsoft.Maui.IPropertyMapper? mapper = null) -> void
Expand Down Expand Up @@ -1503,6 +1504,12 @@ Microsoft.Maui.Platform.MauiPageControl.UpdatePosition() -> void
Microsoft.Maui.Platform.MauiScrollView
Microsoft.Maui.Platform.MauiScrollView.MauiScrollView(Microsoft.Maui.IScrollView! virtualView) -> void
Microsoft.Maui.Platform.MauiScrollView.Measure(double availableWidth, double availableHeight) -> Tizen.UIExtensions.Common.Size
Microsoft.Maui.Platform.MauiRefreshLayout
Microsoft.Maui.Platform.MauiRefreshLayout.MauiRefreshLayout() -> void
Microsoft.Maui.Platform.MauiRefreshLayout.UpdateBackground(Microsoft.Maui.IRefreshView! view) -> void
Microsoft.Maui.Platform.MauiRefreshLayout.UpdateContent(Microsoft.Maui.IView? content, Microsoft.Maui.IMauiContext? mauiContext) -> void
Microsoft.Maui.Platform.MauiRefreshLayout.UpdateIsRefreshing(Microsoft.Maui.IRefreshView! view) -> void
Microsoft.Maui.Platform.MauiRefreshLayout.UpdateRefreshColor(Microsoft.Maui.IRefreshView! view) -> void
Microsoft.Maui.Platform.MauiSearchBar
Microsoft.Maui.Platform.MauiSearchBar.Entry.get -> Tizen.UIExtensions.NUI.Entry!
Microsoft.Maui.Platform.MauiSearchBar.MauiSearchBar() -> void
Expand Down Expand Up @@ -1913,7 +1920,9 @@ override Microsoft.Maui.Handlers.ProgressBarHandler.CreatePlatformView() -> Tize
override Microsoft.Maui.Handlers.RadioButtonHandler.CreatePlatformView() -> Microsoft.Maui.Platform.ContentViewGroup!
override Microsoft.Maui.Handlers.RadioButtonHandler.ConnectHandler(Microsoft.Maui.Platform.ContentViewGroup! platformView) -> void
override Microsoft.Maui.Handlers.RadioButtonHandler.DisconnectHandler(Microsoft.Maui.Platform.ContentViewGroup! platformView) -> void
override Microsoft.Maui.Handlers.RefreshViewHandler.CreatePlatformView() -> Tizen.NUI.BaseComponents.View!
override Microsoft.Maui.Handlers.RefreshViewHandler.CreatePlatformView() -> Microsoft.Maui.Platform.MauiRefreshLayout!
override Microsoft.Maui.Handlers.RefreshViewHandler.ConnectHandler(Microsoft.Maui.Platform.MauiRefreshLayout! platformView) -> void
override Microsoft.Maui.Handlers.RefreshViewHandler.DisconnectHandler(Microsoft.Maui.Platform.MauiRefreshLayout! platformView) -> void
override Microsoft.Maui.Handlers.ScrollViewHandler.ConnectHandler(Tizen.UIExtensions.NUI.ScrollView! platformView) -> void
override Microsoft.Maui.Handlers.ScrollViewHandler.CreatePlatformView() -> Tizen.UIExtensions.NUI.ScrollView!
override Microsoft.Maui.Handlers.ScrollViewHandler.DisconnectHandler(Tizen.UIExtensions.NUI.ScrollView! platformView) -> void
Expand Down Expand Up @@ -2244,7 +2253,6 @@ static Microsoft.Maui.Handlers.RefreshViewHandler.MapContent(Microsoft.Maui.Hand
static Microsoft.Maui.Handlers.RefreshViewHandler.MapIsRefreshing(Microsoft.Maui.Handlers.IRefreshViewHandler! handler, Microsoft.Maui.IRefreshView! refreshView) -> void
static Microsoft.Maui.Handlers.RefreshViewHandler.Mapper -> Microsoft.Maui.IPropertyMapper<Microsoft.Maui.IRefreshView!, Microsoft.Maui.Handlers.IRefreshViewHandler!>!
static Microsoft.Maui.Handlers.RefreshViewHandler.MapRefreshColor(Microsoft.Maui.Handlers.IRefreshViewHandler! handler, Microsoft.Maui.IRefreshView! refreshView) -> void
static Microsoft.Maui.Handlers.RefreshViewHandler.MapRefreshViewBackground(Microsoft.Maui.Handlers.IRefreshViewHandler! handler, Microsoft.Maui.IView! view) -> void
static Microsoft.Maui.Handlers.ScrollViewHandler.CommandMapper -> Microsoft.Maui.CommandMapper<Microsoft.Maui.IScrollView!, Microsoft.Maui.Handlers.IScrollViewHandler!>!
static Microsoft.Maui.Handlers.ScrollViewHandler.MapContent(Microsoft.Maui.Handlers.IScrollViewHandler! handler, Microsoft.Maui.IScrollView! scrollView) -> void
static Microsoft.Maui.Handlers.ScrollViewHandler.MapHorizontalScrollBarVisibility(Microsoft.Maui.Handlers.IScrollViewHandler! handler, Microsoft.Maui.IScrollView! scrollView) -> void
Expand Down

0 comments on commit 8c7ebb8

Please sign in to comment.