Skip to content
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
66 changes: 66 additions & 0 deletions .github/workflows/create-nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build nuget package

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: macos-latest
env:
SDK: 17.5
SRC_FOLDER: .
PROJ_NAME: MBProgressHUD.xcodeproj

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install .NET 9
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'

- name: Build MBProgressHUD for simulator
run: |
xcodebuild -project ${{ env.SRC_FOLDER }}/${{ env.PROJ_NAME }} \
-target "MBProgressHUD Static Library" \
-sdk iphonesimulator${{ env.SDK }} \
IPHONEOS_DEPLOYMENT_TARGET=12.0 \
EXCLUDED_ARCHS="arm64"

- name: Build MBProgressHUD for device
run: |
xcodebuild -project ${{ env.SRC_FOLDER }}/${{ env.PROJ_NAME }} \
-target "MBProgressHUD Static Library" \
-sdk iphoneos${{ env.SDK }} \
IPHONEOS_DEPLOYMENT_TARGET=12.0

- name: Create universal lib with lipo in dotnet-binding
run: |
lipo -create \
${{ env.SRC_FOLDER }}/build/Release-iphoneos/libMBProgressHUD.a \
${{ env.SRC_FOLDER }}/build/Release-iphonesimulator/libMBProgressHUD.a \
-output ./dotnet-binding/libMBProgressHUD.a
lipo -info ./dotnet-binding/libMBProgressHUD.a

- name: restore workload
working-directory: ./dotnet-binding
run: dotnet workload restore

- name: Build .NET binding project
working-directory: ./dotnet-binding
run: dotnet build -c Release MBProgressHUD-dotnet.csproj

- name: Pack NuGet
working-directory: ./dotnet-binding
run: dotnet pack -c Release MBProgressHUD-dotnet.csproj

- name: Upload .nupkg as artifact
uses: actions/[email protected]
with:
name: nuget-package
compression-level: '0'
path: /Users/runner/work/MBProgressHUD-dotnet/MBProgressHUD-dotnet/dotnet-binding/bin/Release/*.nupkg
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ profile

# Carthage
Carthage/Build


*/bin
*/obj
206 changes: 206 additions & 0 deletions dotnet-binding/ApiDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
using System;
using CoreGraphics;
using Foundation;
using ObjCRuntime;
using UIKit;

namespace MBProgressHUDMaui {

// typedef void (^MBProgressHUDCompletionBlock)();
delegate void MBProgressHUDCompletionBlock();

// @interface MBProgressHUD : UIView
[BaseType(typeof(UIView))]
interface MBProgressHUD
{
// +(instancetype _Nonnull)showHUDAddedTo:(UIView * _Nonnull)view animated:(BOOL)animated;
[Static]
[Export("showHUDAddedTo:animated:")]
MBProgressHUD ShowHUD(UIView view, bool animated);

// +(BOOL)hideHUDForView:(UIView * _Nonnull)view animated:(BOOL)animated;
[Static]
[Export("hideHUDForView:animated:")]
bool HideHUD(UIView view, bool animated);

// +(MBProgressHUD * _Nullable)HUDForView:(UIView * _Nonnull)view;
[Static]
[Export("HUDForView:")]
[return: NullAllowed]
MBProgressHUD HUDForView(UIView view);

// -(instancetype _Nonnull)initWithView:(UIView * _Nonnull)view;
[Export("initWithView:")]
IntPtr Constructor(UIView view);

// -(void)showAnimated:(BOOL)animated;
[Export("showAnimated:")]
void Show(bool animated);

// -(void)hideAnimated:(BOOL)animated;
[Export("hideAnimated:")]
void Hide(bool animated);

// -(void)hideAnimated:(BOOL)animated afterDelay:(NSTimeInterval)delay;
[Export("hideAnimated:afterDelay:")]
void Hide(bool animated, double delay);

[Wrap("WeakDelegate")]
[NullAllowed]
MBProgressHUDDelegate Delegate { get; set; }

// @property (nonatomic, weak) id<MBProgressHUDDelegate> _Nullable delegate;
[NullAllowed, Export("delegate", ArgumentSemantic.Weak)]
NSObject WeakDelegate { get; set; }

// @property (copy) MBProgressHUDCompletionBlock _Nullable completionBlock;
[NullAllowed, Export("completionBlock", ArgumentSemantic.Copy)]
MBProgressHUDCompletionBlock CompletionBlock { get; set; }

// @property (assign, nonatomic) NSTimeInterval graceTime;
[Export("graceTime")]
double GraceTime { get; set; }

// @property (assign, nonatomic) NSTimeInterval minShowTime;
[Export("minShowTime")]
double MinShowTime { get; set; }

// @property (assign, nonatomic) BOOL removeFromSuperViewOnHide;
[Export("removeFromSuperViewOnHide")]
bool RemoveFromSuperViewOnHide { get; set; }

// @property (assign, nonatomic) MBProgressHUDMode mode;
[Export("mode", ArgumentSemantic.Assign)]
MBProgressHUDMode Mode { get; set; }

// @property (nonatomic, strong) UIColor * _Nullable contentColor __attribute__((annotate("ui_appearance_selector")));
[NullAllowed, Export("contentColor", ArgumentSemantic.Strong)]
UIColor ContentColor { get; set; }

// @property (assign, nonatomic) MBProgressHUDAnimation animationType __attribute__((annotate("ui_appearance_selector")));
[Export("animationType", ArgumentSemantic.Assign)]
MBProgressHUDAnimation AnimationType { get; set; }

// @property (assign, nonatomic) CGPoint offset __attribute__((annotate("ui_appearance_selector")));
[Export("offset", ArgumentSemantic.Assign)]
CGPoint Offset { get; set; }

// @property (assign, nonatomic) CGFloat margin __attribute__((annotate("ui_appearance_selector")));
[Export("margin")]
nfloat Margin { get; set; }

// @property (assign, nonatomic) CGSize minSize __attribute__((annotate("ui_appearance_selector")));
[Export("minSize", ArgumentSemantic.Assign)]
CGSize MinSize { get; set; }

// @property (getter = isSquare, assign, nonatomic) BOOL square __attribute__((annotate("ui_appearance_selector")));
[Export("square")]
bool Square { [Bind("isSquare")] get; set; }

// @property (getter = areDefaultMotionEffectsEnabled, assign, nonatomic) BOOL defaultMotionEffectsEnabled __attribute__((annotate("ui_appearance_selector")));
[Export("defaultMotionEffectsEnabled")]
bool DefaultMotionEffectsEnabled { [Bind("areDefaultMotionEffectsEnabled")] get; set; }

// @property (assign, nonatomic) float progress;
[Export("progress")]
float Progress { get; set; }

// @property (nonatomic, strong) NSProgress * _Nullable progressObject;
[NullAllowed, Export("progressObject", ArgumentSemantic.Strong)]
NSProgress ProgressObject { get; set; }

// @property (readonly, nonatomic, strong) MBBackgroundView * _Nonnull bezelView;
[Export("bezelView", ArgumentSemantic.Strong)]
MBBackgroundView BezelView { get; }

// @property (readonly, nonatomic, strong) MBBackgroundView * _Nonnull backgroundView;
[Export("backgroundView", ArgumentSemantic.Strong)]
MBBackgroundView BackgroundView { get; }

// @property (nonatomic, strong) UIView * _Nullable customView;
[NullAllowed, Export("customView", ArgumentSemantic.Strong)]
UIView CustomView { get; set; }

// @property (readonly, nonatomic, strong) UILabel * _Nonnull label;
[Export("label", ArgumentSemantic.Strong)]
UILabel Label { get; }

// @property (readonly, nonatomic, strong) UILabel * _Nonnull detailsLabel;
[Export("detailsLabel", ArgumentSemantic.Strong)]
UILabel DetailsLabel { get; }

// @property (readonly, nonatomic, strong) UIButton * _Nonnull button;
[Export("button", ArgumentSemantic.Strong)]
UIButton Button { get; }
}

// @protocol MBProgressHUDDelegate <NSObject>
[Protocol, Model]
[BaseType(typeof(NSObject))]
interface MBProgressHUDDelegate
{
// @optional -(void)hudWasHidden:(MBProgressHUD * _Nonnull)hud;
[Export("hudWasHidden:")]
void HudWasHidden(MBProgressHUD hud);
}

// @interface MBRoundProgressView : UIView
[BaseType(typeof(UIView))]
interface MBRoundProgressView
{
// @property (assign, nonatomic) float progress;
[Export("progress")]
float Progress { get; set; }

// @property (nonatomic, strong) UIColor * _Nonnull progressTintColor;
[Export("progressTintColor", ArgumentSemantic.Strong)]
UIColor ProgressTintColor { get; set; }

// @property (nonatomic, strong) UIColor * _Nonnull backgroundTintColor;
[Export("backgroundTintColor", ArgumentSemantic.Strong)]
UIColor BackgroundTintColor { get; set; }

// @property (getter = isAnnular, assign, nonatomic) BOOL annular;
[Export("annular")]
bool Annular { [Bind("isAnnular")] get; set; }
}

// @interface MBBarProgressView : UIView
[BaseType(typeof(UIView))]
interface MBBarProgressView
{
// @property (assign, nonatomic) float progress;
[Export("progress")]
float Progress { get; set; }

// @property (nonatomic, strong) UIColor * _Nonnull lineColor;
[Export("lineColor", ArgumentSemantic.Strong)]
UIColor LineColor { get; set; }

// @property (nonatomic, strong) UIColor * _Nonnull progressRemainingColor;
[Export("progressRemainingColor", ArgumentSemantic.Strong)]
UIColor ProgressRemainingColor { get; set; }

// @property (nonatomic, strong) UIColor * _Nonnull progressColor;
[Export("progressColor", ArgumentSemantic.Strong)]
UIColor ProgressColor { get; set; }
}

// @interface MBBackgroundView : UIView
[BaseType(typeof(UIView))]
interface MBBackgroundView
{
// @property (nonatomic) MBProgressHUDBackgroundStyle style;
[Export("style", ArgumentSemantic.Assign)]
MBProgressHUDBackgroundStyle Style { get; set; }

// @property (nonatomic) UIBlurEffectStyle blurEffectStyle;
[Export("blurEffectStyle", ArgumentSemantic.Assign)]
UIBlurEffectStyle BlurEffectStyle { get; set; }

// @property (nonatomic, strong) UIColor * _Nonnull color;
[Export("color", ArgumentSemantic.Strong)]
UIColor Color { get; set; }
}

}
34 changes: 34 additions & 0 deletions dotnet-binding/MBProgressHUD-dotnet.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0-ios</TargetFramework>
<RootNamespace>MBProgressHUD</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<IsBindingProject>true</IsBindingProject>

<!-- Nuget package -->
<PackageId>com.jonathanantoine.MBProgressHUD</PackageId>
<Version>1.0.0.0</Version>
<Authors>Jonathan Antoine</Authors>
<Title>MBProgressHUD for dotnet</Title>
<PackageProjectUrl>https://github.com/jonathanantoine/MBProgressHUD-dotnet</PackageProjectUrl>
<Description>MBProgressHUD binding for Net 9.0 iOS</Description>
<PackageReleaseNotes>MBProgressHUD binding for Net 9.0 iOS</PackageReleaseNotes>
<PackageTags>maui ios MBProgressHUD dotnet</PackageTags>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
<ObjcBindingCoreSource Include="StructsAndEnums.cs" />
<None Include="..\.github\workflows\create-nuget.yml" />
<None Include="README.md" Pack="true" PackagePath="\"/>
</ItemGroup>
<ItemGroup>
<NativeReference Include="libMBProgressHUD.a">
<Kind>Static</Kind>
<Frameworks>Foundation ImageIO CoreGraphics</Frameworks>
</NativeReference>
</ItemGroup>

</Project>
42 changes: 42 additions & 0 deletions dotnet-binding/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Maui iOS binding for MBProgressHUD

[![NuGet version](https://badge.fury.io/nu/com.jonathanantoine.MBProgressHUD.svg)](https://badge.fury.io/nu/com.jonathanantoine.MBProgressHUD)

- Native library: [MBProgressHUD](https://github.com/jdg/MBProgressHUD)

**Support Net 9.0 for iOS (works with Xcode 15 and iOS 17)**

## Nuget

* `Install-Package com.jonathanantoine.MBProgressHUD`
* <https://www.nuget.org/packages/com.jonathanantoine.MBProgressHUD>

## Build

* Run the GH action.

## Usage

```csharp
using MBProgressHUDMaui;

var hub = new MTMBProgressHUD(controller.View)
{
Mode = MBProgressHUDMode.Text,
Margin = 10f,
RemoveFromSuperViewOnHide = true,
UserInteractionEnabled = false

};

hub.Label.Text = "text to display";

controller.View.AddSubview(hub);
hub.Show(true);

hub.Hide(true, 2);
```

## Contribution
Contribution to [ApiDefinition.cs](ApiDefinition.cs) are welcome, just send PRs.

36 changes: 36 additions & 0 deletions dotnet-binding/StructsAndEnums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using CoreGraphics;
using Foundation;
using ObjCRuntime;
using UIKit;

namespace MBProgressHUDMaui {

[Native]
public enum MBProgressHUDMode : long
{
Indeterminate,
Determinate,
DeterminateHorizontalBar,
AnnularDeterminate,
CustomView,
Text
}

[Native]
public enum MBProgressHUDAnimation : long
{
Fade,
Zoom,
ZoomOut,
ZoomIn
}

[Native]
public enum MBProgressHUDBackgroundStyle : long
{
SolidColor,
Blur
}

}