Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Redth committed Jun 13, 2022
1 parent fbf64fb commit e6097f0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ public static MauiAppBuilder UsePlatformChannels(this MauiAppBuilder builder, Ch

return builder;
}

}
3 changes: 0 additions & 3 deletions Microsoft.Maui.PlatformChannels/PlatformChannelViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ public PlatformChannelViewHandler(PropertyMapper propertyMapper, CommandMapper c
}

public event ChannelMessageDelegate OnReceivedFromPlatform;


}

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Runtime.CompilerServices;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Handlers;
using Microsoft.PlatformChannels;
using AndroidViewChannel = Microsoft.PlatformChannels.Platform.ViewChannel;
using AViewGroup = Android.Widget.LinearLayout;
Expand Down Expand Up @@ -118,6 +116,3 @@ public PlatformObject OnChannelMessage(string id, PlatformObject[] parameters)
=> Callback?.Invoke(id, parameters.ToDotNetObjects()).ToPlatformObject();
}
}



50 changes: 25 additions & 25 deletions SamplePlatformChannels/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
using Microsoft.PlatformChannels;

namespace SamplePlatformChannels;

public partial class MainPage : ContentPage
{

public MainPage(IChannelService channelService)
{
ChannelService = channelService;
public MainPage(IChannelService channelService)
{
ChannelService = channelService;

InitializeComponent();
}
InitializeComponent();
}

public readonly IChannelService ChannelService;
public readonly IChannelService ChannelService;

void Button_Clicked(System.Object sender, System.EventArgs e)
{
void Button_Clicked(System.Object sender, System.EventArgs e)
{
labelViewChannel.SendToPlatform("setText", "Hello, From MAUI!");
labelViewChannel2.SendToPlatform("setText", "Hello again, From MAUI!");


if (string.IsNullOrEmpty(entryNumbers?.Text))
return;
return;

// Math service, use independently

var mathChannel = ChannelService.GetOrCreateChannel("math");

var entered = entryNumbers.Text.Split(' ', ',', ';');
var mathChannel = ChannelService.GetOrCreateChannel("math");

var entered = entryNumbers.Text.Split(' ', ',', ';');

var items = new List<object>();
var items = new List<object>();

foreach (var n in entered)
{
if (double.TryParse(n, out var ndbl))
items.Add(ndbl);
}
foreach (var n in entered)
{
if (double.TryParse(n, out var ndbl))
items.Add(ndbl);
}

var itemsArr = items.ToArray();
var result = mathChannel.SendToPlatform("add", itemsArr);
var itemsArr = items.ToArray();
var result = mathChannel.SendToPlatform("add", itemsArr);

if (result is double dbl)
labelResult.Text = dbl.ToString();
}
if (result is double dbl)
labelResult.Text = dbl.ToString();
}

private object PlatformChannelView_OnReceiveFromPlatform(string messageId, object parameters)
{
return null;
return null;
}
}
34 changes: 16 additions & 18 deletions SamplePlatformChannels/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,25 @@
namespace SamplePlatformChannels;

public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
{
public static MauiApp CreateMauiApp()
{
ChannelServiceConfiguration config = null;
#if ANDROID
config = new ChannelServiceConfiguration("com.microsoft.dotnet.platformchannels.sample", "SampleChannels", "init");
#elif IOS || MACCATALYST
config = new ChannelServiceConfiguration("", "");
config = new ChannelServiceConfiguration("", "");
#endif

var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiPlatformChannelViews(config)
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});

return builder.Build();
}

var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiPlatformChannelViews(config)
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});

return builder.Build();
}
}


0 comments on commit e6097f0

Please sign in to comment.