Skip to content

Commit

Permalink
More macos
Browse files Browse the repository at this point in the history
  • Loading branch information
xabre committed Aug 4, 2019
1 parent fa2231d commit b8a1fa9
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 14 deletions.
23 changes: 16 additions & 7 deletions Source/BLE.Client/BLE.Client.macOS/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
using AppKit;
using Foundation;
using MvvmCross.Core;
using MvvmCross.Forms.Platforms.Mac.Core;
using Xamarin.Forms;
using Xamarin.Forms.Platform.MacOS;

namespace BLE.Client.macOS
{
[Register("AppDelegate")]
public class AppDelegate : NSApplicationDelegate
public class AppDelegate : MvxFormsApplicationDelegate
{
public override NSWindow MainWindow { get; }

public AppDelegate()
{
}
var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;

public override void DidFinishLaunching(NSNotification notification)
{
// Insert code here to initialize your application
var rect = new CoreGraphics.CGRect(200, 1000, 500, 768);
MainWindow = new NSWindow(rect, style, NSBackingStore.Buffered, false)
{
Title = "Xamarin.Forms Badge Plugin on Mac!",
TitleVisibility = NSWindowTitleVisibility.Hidden
};
}

public override void WillTerminate(NSNotification notification)
protected override void RegisterSetup()
{
// Insert code here to tear down your application
this.RegisterSetupType<Setup>();
}
}
}
55 changes: 48 additions & 7 deletions Source/BLE.Client/BLE.Client.macOS/BLE.Client.macOS.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -27,15 +27,19 @@
<IncludeMonoRuntime>false</IncludeMonoRuntime>
<UseSGen>true</UseSGen>
<UseRefCounting>true</UseRefCounting>
<HttpClientHandler></HttpClientHandler>
<LinkMode></LinkMode>
<XamMacArch></XamMacArch>
<HttpClientHandler>
</HttpClientHandler>
<LinkMode>
</LinkMode>
<XamMacArch>
</XamMacArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<DefineConstants></DefineConstants>
<DefineConstants>
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<EnableCodeSigning>false</EnableCodeSigning>
Expand All @@ -45,8 +49,10 @@
<UseSGen>true</UseSGen>
<UseRefCounting>true</UseRefCounting>
<LinkMode>SdkOnly</LinkMode>
<HttpClientHandler></HttpClientHandler>
<XamMacArch></XamMacArch>
<HttpClientHandler>
</HttpClientHandler>
<XamMacArch>
</XamMacArch>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand Down Expand Up @@ -77,6 +83,7 @@
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="Setup.cs" />
<Compile Include="ViewController.cs" />
<Compile Include="ViewController.designer.cs">
<DependentUpon>ViewController.cs</DependentUpon>
Expand All @@ -85,5 +92,39 @@
<ItemGroup>
<InterfaceDefinition Include="Main.storyboard" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Acr.UserDialogs">
<Version>7.0.4</Version>
</PackageReference>
<PackageReference Include="MvvmCross">
<Version>6.3.1</Version>
</PackageReference>
<PackageReference Include="MvvmCross.Forms">
<Version>6.3.1</Version>
</PackageReference>
<PackageReference Include="Plugin.Permissions">
<Version>3.0.0.12</Version>
</PackageReference>
<PackageReference Include="Xam.Plugins.Settings">
<Version>3.1.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Forms">
<Version>4.1.0.581479</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Plugin.BLE.Abstractions\Plugin.BLE.Abstractions.csproj">
<Project>{56531910-6309-4f1d-a12b-f69e2914fae6}</Project>
<Name>Plugin.BLE.Abstractions</Name>
</ProjectReference>
<ProjectReference Include="..\..\Plugin.BLE.macOS\Plugin.BLE.macOS.csproj">
<Project>{239ad7ce-149f-4465-9baf-7d60373be5cb}</Project>
<Name>Plugin.BLE.macOS</Name>
</ProjectReference>
<ProjectReference Include="..\BLE.Client\BLE.Client.csproj">
<Project>{dfe97be0-070b-43ad-bf37-50fd42b542d1}</Project>
<Name>BLE.Client</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
</Project>
38 changes: 38 additions & 0 deletions Source/BLE.Client/BLE.Client.macOS/Setup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Acr.UserDialogs;
using MvvmCross;
using MvvmCross.Forms.Platforms.Mac.Core;
using MvvmCross.ViewModels;
using Plugin.Permissions;
using Plugin.Settings;

namespace BLE.Client.macOS
{
public class Setup : MvxFormsMacSetup
{
protected override IMvxApplication CreateApp()
{
return new BleMvxApplication();
}

protected override void InitializeIoC()
{
base.InitializeIoC();

Mvx.IoCProvider.RegisterSingleton(() => UserDialogs.Instance);
Mvx.IoCProvider.RegisterSingleton(() => CrossSettings.Current);
Mvx.IoCProvider.RegisterSingleton(() => CrossPermissions.Current);
}

protected override Xamarin.Forms.Application CreateFormsApplication()
{
return new BleMvxFormsApp();
}

/*
public override IEnumerable<Assembly> GetPluginAssemblies()
{
return new List<Assembly>(base.GetViewAssemblies().Union(new[] { typeof(MvvmCross.Plugins.BLE.iOS.Plugin).GetTypeInfo().Assembly }));
}
*/
}
}
1 change: 1 addition & 0 deletions Source/Plugin.BLE.macOS/Plugin.BLE.macOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.Mac" />
<Reference Include="netstandard" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down

0 comments on commit b8a1fa9

Please sign in to comment.