Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add net6.0-maccatalyst support #99

Merged
merged 5 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions BTProgressHUD.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{CCCB766D
build.cake = build.cake
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTProgressHUDDemo2", "BTProgressHUDDemo2\BTProgressHUDDemo2.csproj", "{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|iPhone = Ad-Hoc|iPhone
Expand Down Expand Up @@ -63,6 +65,22 @@ Global
{620134FD-4E54-4459-8E18-8B6E1C8A2274}.Release|iPhone.ActiveCfg = Release|iPhone
{620134FD-4E54-4459-8E18-8B6E1C8A2274}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{620134FD-4E54-4459-8E18-8B6E1C8A2274}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.AppStore|iPhone.Build.0 = Release|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Debug|iPhone.Build.0 = Debug|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Release|iPhone.ActiveCfg = Release|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Release|iPhone.Build.0 = Release|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{D1D4590A-FCFE-4D4B-AA36-ABF3C48284BA}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 2 additions & 1 deletion BTProgressHUD/BTProgressHUD.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project Sdk="Xamarin.Legacy.Sdk">
<PropertyGroup>
<TargetFrameworks>xamarin.ios10;net6.0-ios</TargetFrameworks>
<TargetFrameworks>xamarin.ios10;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<AssemblyName>BTProgressHUD</AssemblyName>
<RootNamespace>BigTed</RootNamespace>
<PackageId>BTProgressHUD</PackageId>
<Description>BTProgressHUD is a clean and easy-to-use HUD meant to display the progress of an ongoing task.</Description>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">14.2</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<NoNFloatUsing>true</NoNFloatUsing>
</PropertyGroup>
Expand Down
5 changes: 5 additions & 0 deletions BTProgressHUD/ProgressHUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,10 @@ private static float GetActiveHeight(bool ignoreOrientation, UIInterfaceOrientat
return (float)activeHeight;
}

#if MACCATALYST
private float GetKeyboardHeightFromNotification(NSNotification? notification, bool ignoreOrientation,
UIInterfaceOrientation orientation, ref double animationDuration) => 0;
#else
private float GetKeyboardHeightFromNotification(NSNotification? notification, bool ignoreOrientation,
UIInterfaceOrientation orientation, ref double animationDuration)
{
Expand All @@ -927,6 +931,7 @@ private float GetKeyboardHeightFromNotification(NSNotification? notification, bo

return keyboardHeight;
}
#endif

private void SetFadeoutTimer(NSTimer? newTimer)
{
Expand Down
15 changes: 15 additions & 0 deletions BTProgressHUDDemo2/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:BTProgressHUDDemo2"
x:Class="BTProgressHUDDemo2.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

11 changes: 11 additions & 0 deletions BTProgressHUDDemo2/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace BTProgressHUDDemo2;

public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new MainPage());
}
}

27 changes: 27 additions & 0 deletions BTProgressHUDDemo2/BTProgressHUDDemo2.App.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31611.283
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BTProgressHUDDemo2", "BTProgressHUDDemo2.csproj", "{5CEEEB7D-D5E7-4FAF-8124-F961F82AB6BA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5CEEEB7D-D5E7-4FAF-8124-F961F82AB6BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CEEEB7D-D5E7-4FAF-8124-F961F82AB6BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CEEEB7D-D5E7-4FAF-8124-F961F82AB6BA}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{5CEEEB7D-D5E7-4FAF-8124-F961F82AB6BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CEEEB7D-D5E7-4FAF-8124-F961F82AB6BA}.Release|Any CPU.Build.0 = Release|Any CPU
{5CEEEB7D-D5E7-4FAF-8124-F961F82AB6BA}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
EndGlobalSection
EndGlobal
33 changes: 33 additions & 0 deletions BTProgressHUDDemo2/BTProgressHUDDemo2.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>BTProgressHUDDemo2</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<ApplicationTitle>BTProgressHUDDemo2</ApplicationTitle>
<ApplicationId>com.companyname.btprogresshuddemo2</ApplicationId>
<ApplicationIdGuid>245E06E9-855A-48E2-9C3A-F09A9E298C8D</ApplicationIdGuid>

<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<MauiImage Include="Resources\Images\*" />
<MauiFont Include="Resources\Fonts\*" />
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BTProgressHUD\BTProgressHUD.csproj" />
</ItemGroup>
</Project>
27 changes: 27 additions & 0 deletions BTProgressHUDDemo2/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:bth="clr-namespace:BTProgressHUDDemo2"
x:Class="BTProgressHUDDemo2.MainPage"
Title="BTProgressHUD">

<ContentPage.BindingContext>
<bth:MainViewModel />
</ContentPage.BindingContext>

<CollectionView ItemsSource="{Binding Items}">
<CollectionView.ItemTemplate>
<DataTemplate>
<VerticalStackLayout>
<Button Text="{Binding Text}"
Command="{Binding Command}" />
<BoxView HeightRequest="1"
HorizontalOptions="FillAndExpand"
Background="Black" />
</VerticalStackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>

</ContentPage>

11 changes: 11 additions & 0 deletions BTProgressHUDDemo2/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace BTProgressHUDDemo2;

public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}


150 changes: 150 additions & 0 deletions BTProgressHUDDemo2/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
using System;
using System.Windows.Input;
using BigTed;
using Foundation;

namespace BTProgressHUDDemo2
{
public class MainViewModel
{
float progress = -1;
NSTimer timer;

public MainViewModel()
{
this.Items = new[]
{
Create("Show", () => BTProgressHUD.Show(), true),
Create("Cancel problem 3", () => BTProgressHUD.Show("Cancel", () => KillAfter(), "Cancel and text"), false),
Create("Cancel problem 2", () => BTProgressHUD.Show("Cancel", () => KillAfter()), false),
Create("Cancel problem", () => BTProgressHUD.Show("Cancel", () => KillAfter(), "This is a multilinetext\nSome more text\n more text\n and again more text"), false),
Create("Show Message", () => BTProgressHUD.Show("Processing your image", -1, MaskType.Black), false),
Create("Show Success", () =>
{
BTProgressHUD.ShowSuccessWithStatus("Great success!");
}, false),

Create("Show Fail", () =>
{
BTProgressHUD.ShowErrorWithStatus("Oh, thats bad");
}, false),

Create("Show Info", () =>
{
BTProgressHUD.ShowInfoWithStatus("Notice me!");
}, false),

Create("Show Success (Outlined)", () =>
{
BTProgressHUD.ShowSuccessWithStatus("Great success!", default, 1000, ImageStyle.Outline);
}, false),

Create("Show Fail (Outlined)", () =>
{
BTProgressHUD.ShowErrorWithStatus("Oh, thats bad", default, 1000, ImageStyle.Outline);
}, false),

Create("Show Info (Outlined)", () =>
{
BTProgressHUD.ShowInfoWithStatus("Notice me!", default, 1000, ImageStyle.Outline);
}, false),

Create("Show Success (Full Outlined)", () =>
{
BTProgressHUD.ShowSuccessWithStatus("Great success!", default, 1000, ImageStyle.OutlineFull);
}, false),

Create("Show Fail (Full Outlined)", () =>
{
BTProgressHUD.ShowErrorWithStatus("Oh, thats bad", default, 1000, ImageStyle.OutlineFull);
}, false),

Create("Show Info (Full Outlined)", () =>
{
BTProgressHUD.ShowInfoWithStatus("Notice me!", default, 1000, ImageStyle.OutlineFull);
}, false),

Create("Toast", () =>
{
BTProgressHUD.ShowToast("Hello from the toast", false, 1000);
}, false),

Create("Dismiss", () =>
{
BTProgressHUD.Dismiss();
}, false),

Create("Progress", () =>
{
progress = 0;
BTProgressHUD.Show("Hello!", progress);
if (timer != null)
{
timer.Invalidate();
}
timer = NSTimer.CreateRepeatingTimer(0.5f, delegate
{
progress += 0.1f;
if (progress > 1)
{
timer.Invalidate();
timer = null;
BTProgressHUD.Dismiss();
}
else
{
BTProgressHUD.Show("Hello!", progress);
}
});
NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Common);
}, false),

Create("Dismiss", () =>
{
BTProgressHUD.Dismiss();
}, false)
};
}


public CommandItem[] Items { get; }

CommandItem Create(string text, Action action, bool timedKill) => new CommandItem(
text,
new Command(() =>
{
try
{
action();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
if (timedKill)
{
KillAfter();
}
})
);

void KillAfter()
{
if (timer != null)
{
timer.Invalidate();
}
timer = NSTimer.CreateRepeatingTimer(5, delegate
{
BTProgressHUD.Dismiss();
});
NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Common);
}
}


public record CommandItem(
string Text,
ICommand Command
);
}
19 changes: 19 additions & 0 deletions BTProgressHUDDemo2/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace BTProgressHUDDemo2;

public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

return builder.Build();
}
}

10 changes: 10 additions & 0 deletions BTProgressHUDDemo2/Platforms/MacCatalyst/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Foundation;

namespace BTProgressHUDDemo2;

[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}

Loading