Skip to content

Commit 095c4bd

Browse files
Merge pull request #1 from jonathanantoine/create-nuget-from-sources
Add dotnet bindings for ios
2 parents 4a7c5f3 + 2570ca6 commit 095c4bd

6 files changed

Lines changed: 388 additions & 0 deletions

File tree

.github/workflows/create-nuget.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build nuget package
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
9+
jobs:
10+
build:
11+
runs-on: macos-latest
12+
env:
13+
SDK: 17.5
14+
SRC_FOLDER: .
15+
PROJ_NAME: MBProgressHUD.xcodeproj
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Install .NET 9
22+
uses: actions/setup-dotnet@v4
23+
with:
24+
dotnet-version: '9.x'
25+
26+
- name: Build MBProgressHUD for simulator
27+
run: |
28+
xcodebuild -project ${{ env.SRC_FOLDER }}/${{ env.PROJ_NAME }} \
29+
-target "MBProgressHUD Static Library" \
30+
-sdk iphonesimulator${{ env.SDK }} \
31+
IPHONEOS_DEPLOYMENT_TARGET=12.0 \
32+
EXCLUDED_ARCHS="arm64"
33+
34+
- name: Build MBProgressHUD for device
35+
run: |
36+
xcodebuild -project ${{ env.SRC_FOLDER }}/${{ env.PROJ_NAME }} \
37+
-target "MBProgressHUD Static Library" \
38+
-sdk iphoneos${{ env.SDK }} \
39+
IPHONEOS_DEPLOYMENT_TARGET=12.0
40+
41+
- name: Create universal lib with lipo in dotnet-binding
42+
run: |
43+
lipo -create \
44+
${{ env.SRC_FOLDER }}/build/Release-iphoneos/libMBProgressHUD.a \
45+
${{ env.SRC_FOLDER }}/build/Release-iphonesimulator/libMBProgressHUD.a \
46+
-output ./dotnet-binding/libMBProgressHUD.a
47+
lipo -info ./dotnet-binding/libMBProgressHUD.a
48+
49+
- name: restore workload
50+
working-directory: ./dotnet-binding
51+
run: dotnet workload restore
52+
53+
- name: Build .NET binding project
54+
working-directory: ./dotnet-binding
55+
run: dotnet build -c Release MBProgressHUD-dotnet.csproj
56+
57+
- name: Pack NuGet
58+
working-directory: ./dotnet-binding
59+
run: dotnet pack -c Release MBProgressHUD-dotnet.csproj
60+
61+
- name: Upload .nupkg as artifact
62+
uses: actions/upload-artifact@v4.6.2
63+
with:
64+
name: nuget-package
65+
compression-level: '0'
66+
path: /Users/runner/work/MBProgressHUD-dotnet/MBProgressHUD-dotnet/dotnet-binding/bin/Release/*.nupkg

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ profile
2626

2727
# Carthage
2828
Carthage/Build
29+
30+
31+
*/bin
32+
*/obj

dotnet-binding/ApiDefinition.cs

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
using System;
2+
using CoreGraphics;
3+
using Foundation;
4+
using ObjCRuntime;
5+
using UIKit;
6+
7+
namespace MBProgressHUDMaui {
8+
9+
// typedef void (^MBProgressHUDCompletionBlock)();
10+
delegate void MBProgressHUDCompletionBlock();
11+
12+
// @interface MBProgressHUD : UIView
13+
[BaseType(typeof(UIView))]
14+
interface MBProgressHUD
15+
{
16+
// +(instancetype _Nonnull)showHUDAddedTo:(UIView * _Nonnull)view animated:(BOOL)animated;
17+
[Static]
18+
[Export("showHUDAddedTo:animated:")]
19+
MBProgressHUD ShowHUD(UIView view, bool animated);
20+
21+
// +(BOOL)hideHUDForView:(UIView * _Nonnull)view animated:(BOOL)animated;
22+
[Static]
23+
[Export("hideHUDForView:animated:")]
24+
bool HideHUD(UIView view, bool animated);
25+
26+
// +(MBProgressHUD * _Nullable)HUDForView:(UIView * _Nonnull)view;
27+
[Static]
28+
[Export("HUDForView:")]
29+
[return: NullAllowed]
30+
MBProgressHUD HUDForView(UIView view);
31+
32+
// -(instancetype _Nonnull)initWithView:(UIView * _Nonnull)view;
33+
[Export("initWithView:")]
34+
IntPtr Constructor(UIView view);
35+
36+
// -(void)showAnimated:(BOOL)animated;
37+
[Export("showAnimated:")]
38+
void Show(bool animated);
39+
40+
// -(void)hideAnimated:(BOOL)animated;
41+
[Export("hideAnimated:")]
42+
void Hide(bool animated);
43+
44+
// -(void)hideAnimated:(BOOL)animated afterDelay:(NSTimeInterval)delay;
45+
[Export("hideAnimated:afterDelay:")]
46+
void Hide(bool animated, double delay);
47+
48+
[Wrap("WeakDelegate")]
49+
[NullAllowed]
50+
MBProgressHUDDelegate Delegate { get; set; }
51+
52+
// @property (nonatomic, weak) id<MBProgressHUDDelegate> _Nullable delegate;
53+
[NullAllowed, Export("delegate", ArgumentSemantic.Weak)]
54+
NSObject WeakDelegate { get; set; }
55+
56+
// @property (copy) MBProgressHUDCompletionBlock _Nullable completionBlock;
57+
[NullAllowed, Export("completionBlock", ArgumentSemantic.Copy)]
58+
MBProgressHUDCompletionBlock CompletionBlock { get; set; }
59+
60+
// @property (assign, nonatomic) NSTimeInterval graceTime;
61+
[Export("graceTime")]
62+
double GraceTime { get; set; }
63+
64+
// @property (assign, nonatomic) NSTimeInterval minShowTime;
65+
[Export("minShowTime")]
66+
double MinShowTime { get; set; }
67+
68+
// @property (assign, nonatomic) BOOL removeFromSuperViewOnHide;
69+
[Export("removeFromSuperViewOnHide")]
70+
bool RemoveFromSuperViewOnHide { get; set; }
71+
72+
// @property (assign, nonatomic) MBProgressHUDMode mode;
73+
[Export("mode", ArgumentSemantic.Assign)]
74+
MBProgressHUDMode Mode { get; set; }
75+
76+
// @property (nonatomic, strong) UIColor * _Nullable contentColor __attribute__((annotate("ui_appearance_selector")));
77+
[NullAllowed, Export("contentColor", ArgumentSemantic.Strong)]
78+
UIColor ContentColor { get; set; }
79+
80+
// @property (assign, nonatomic) MBProgressHUDAnimation animationType __attribute__((annotate("ui_appearance_selector")));
81+
[Export("animationType", ArgumentSemantic.Assign)]
82+
MBProgressHUDAnimation AnimationType { get; set; }
83+
84+
// @property (assign, nonatomic) CGPoint offset __attribute__((annotate("ui_appearance_selector")));
85+
[Export("offset", ArgumentSemantic.Assign)]
86+
CGPoint Offset { get; set; }
87+
88+
// @property (assign, nonatomic) CGFloat margin __attribute__((annotate("ui_appearance_selector")));
89+
[Export("margin")]
90+
nfloat Margin { get; set; }
91+
92+
// @property (assign, nonatomic) CGSize minSize __attribute__((annotate("ui_appearance_selector")));
93+
[Export("minSize", ArgumentSemantic.Assign)]
94+
CGSize MinSize { get; set; }
95+
96+
// @property (getter = isSquare, assign, nonatomic) BOOL square __attribute__((annotate("ui_appearance_selector")));
97+
[Export("square")]
98+
bool Square { [Bind("isSquare")] get; set; }
99+
100+
// @property (getter = areDefaultMotionEffectsEnabled, assign, nonatomic) BOOL defaultMotionEffectsEnabled __attribute__((annotate("ui_appearance_selector")));
101+
[Export("defaultMotionEffectsEnabled")]
102+
bool DefaultMotionEffectsEnabled { [Bind("areDefaultMotionEffectsEnabled")] get; set; }
103+
104+
// @property (assign, nonatomic) float progress;
105+
[Export("progress")]
106+
float Progress { get; set; }
107+
108+
// @property (nonatomic, strong) NSProgress * _Nullable progressObject;
109+
[NullAllowed, Export("progressObject", ArgumentSemantic.Strong)]
110+
NSProgress ProgressObject { get; set; }
111+
112+
// @property (readonly, nonatomic, strong) MBBackgroundView * _Nonnull bezelView;
113+
[Export("bezelView", ArgumentSemantic.Strong)]
114+
MBBackgroundView BezelView { get; }
115+
116+
// @property (readonly, nonatomic, strong) MBBackgroundView * _Nonnull backgroundView;
117+
[Export("backgroundView", ArgumentSemantic.Strong)]
118+
MBBackgroundView BackgroundView { get; }
119+
120+
// @property (nonatomic, strong) UIView * _Nullable customView;
121+
[NullAllowed, Export("customView", ArgumentSemantic.Strong)]
122+
UIView CustomView { get; set; }
123+
124+
// @property (readonly, nonatomic, strong) UILabel * _Nonnull label;
125+
[Export("label", ArgumentSemantic.Strong)]
126+
UILabel Label { get; }
127+
128+
// @property (readonly, nonatomic, strong) UILabel * _Nonnull detailsLabel;
129+
[Export("detailsLabel", ArgumentSemantic.Strong)]
130+
UILabel DetailsLabel { get; }
131+
132+
// @property (readonly, nonatomic, strong) UIButton * _Nonnull button;
133+
[Export("button", ArgumentSemantic.Strong)]
134+
UIButton Button { get; }
135+
}
136+
137+
// @protocol MBProgressHUDDelegate <NSObject>
138+
[Protocol, Model]
139+
[BaseType(typeof(NSObject))]
140+
interface MBProgressHUDDelegate
141+
{
142+
// @optional -(void)hudWasHidden:(MBProgressHUD * _Nonnull)hud;
143+
[Export("hudWasHidden:")]
144+
void HudWasHidden(MBProgressHUD hud);
145+
}
146+
147+
// @interface MBRoundProgressView : UIView
148+
[BaseType(typeof(UIView))]
149+
interface MBRoundProgressView
150+
{
151+
// @property (assign, nonatomic) float progress;
152+
[Export("progress")]
153+
float Progress { get; set; }
154+
155+
// @property (nonatomic, strong) UIColor * _Nonnull progressTintColor;
156+
[Export("progressTintColor", ArgumentSemantic.Strong)]
157+
UIColor ProgressTintColor { get; set; }
158+
159+
// @property (nonatomic, strong) UIColor * _Nonnull backgroundTintColor;
160+
[Export("backgroundTintColor", ArgumentSemantic.Strong)]
161+
UIColor BackgroundTintColor { get; set; }
162+
163+
// @property (getter = isAnnular, assign, nonatomic) BOOL annular;
164+
[Export("annular")]
165+
bool Annular { [Bind("isAnnular")] get; set; }
166+
}
167+
168+
// @interface MBBarProgressView : UIView
169+
[BaseType(typeof(UIView))]
170+
interface MBBarProgressView
171+
{
172+
// @property (assign, nonatomic) float progress;
173+
[Export("progress")]
174+
float Progress { get; set; }
175+
176+
// @property (nonatomic, strong) UIColor * _Nonnull lineColor;
177+
[Export("lineColor", ArgumentSemantic.Strong)]
178+
UIColor LineColor { get; set; }
179+
180+
// @property (nonatomic, strong) UIColor * _Nonnull progressRemainingColor;
181+
[Export("progressRemainingColor", ArgumentSemantic.Strong)]
182+
UIColor ProgressRemainingColor { get; set; }
183+
184+
// @property (nonatomic, strong) UIColor * _Nonnull progressColor;
185+
[Export("progressColor", ArgumentSemantic.Strong)]
186+
UIColor ProgressColor { get; set; }
187+
}
188+
189+
// @interface MBBackgroundView : UIView
190+
[BaseType(typeof(UIView))]
191+
interface MBBackgroundView
192+
{
193+
// @property (nonatomic) MBProgressHUDBackgroundStyle style;
194+
[Export("style", ArgumentSemantic.Assign)]
195+
MBProgressHUDBackgroundStyle Style { get; set; }
196+
197+
// @property (nonatomic) UIBlurEffectStyle blurEffectStyle;
198+
[Export("blurEffectStyle", ArgumentSemantic.Assign)]
199+
UIBlurEffectStyle BlurEffectStyle { get; set; }
200+
201+
// @property (nonatomic, strong) UIColor * _Nonnull color;
202+
[Export("color", ArgumentSemantic.Strong)]
203+
UIColor Color { get; set; }
204+
}
205+
206+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net9.0-ios</TargetFramework>
4+
<RootNamespace>MBProgressHUD</RootNamespace>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>true</ImplicitUsings>
7+
<IsBindingProject>true</IsBindingProject>
8+
9+
<!-- Nuget package -->
10+
<PackageId>com.jonathanantoine.MBProgressHUD</PackageId>
11+
<Version>1.0.0.0</Version>
12+
<Authors>Jonathan Antoine</Authors>
13+
<Title>MBProgressHUD for dotnet</Title>
14+
<PackageProjectUrl>https://github.com/jonathanantoine/MBProgressHUD-dotnet</PackageProjectUrl>
15+
<Description>MBProgressHUD binding for Net 9.0 iOS</Description>
16+
<PackageReleaseNotes>MBProgressHUD binding for Net 9.0 iOS</PackageReleaseNotes>
17+
<PackageTags>maui ios MBProgressHUD dotnet</PackageTags>
18+
<PackageReadmeFile>README.md</PackageReadmeFile>
19+
</PropertyGroup>
20+
21+
<ItemGroup>
22+
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
23+
<ObjcBindingCoreSource Include="StructsAndEnums.cs" />
24+
<None Include="..\.github\workflows\create-nuget.yml" />
25+
<None Include="README.md" Pack="true" PackagePath="\"/>
26+
</ItemGroup>
27+
<ItemGroup>
28+
<NativeReference Include="libMBProgressHUD.a">
29+
<Kind>Static</Kind>
30+
<Frameworks>Foundation ImageIO CoreGraphics</Frameworks>
31+
</NativeReference>
32+
</ItemGroup>
33+
34+
</Project>

dotnet-binding/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Maui iOS binding for MBProgressHUD
2+
3+
[![NuGet version](https://badge.fury.io/nu/com.jonathanantoine.MBProgressHUD.svg)](https://badge.fury.io/nu/com.jonathanantoine.MBProgressHUD)
4+
5+
- Native library: [MBProgressHUD](https://github.com/jdg/MBProgressHUD)
6+
7+
**Support Net 9.0 for iOS (works with Xcode 15 and iOS 17)**
8+
9+
## Nuget
10+
11+
* `Install-Package com.jonathanantoine.MBProgressHUD`
12+
* <https://www.nuget.org/packages/com.jonathanantoine.MBProgressHUD>
13+
14+
## Build
15+
16+
* Run the GH action.
17+
18+
## Usage
19+
20+
```csharp
21+
using MBProgressHUDMaui;
22+
23+
var hub = new MTMBProgressHUD(controller.View)
24+
{
25+
Mode = MBProgressHUDMode.Text,
26+
Margin = 10f,
27+
RemoveFromSuperViewOnHide = true,
28+
UserInteractionEnabled = false
29+
30+
};
31+
32+
hub.Label.Text = "text to display";
33+
34+
controller.View.AddSubview(hub);
35+
hub.Show(true);
36+
37+
hub.Hide(true, 2);
38+
```
39+
40+
## Contribution
41+
Contribution to [ApiDefinition.cs](ApiDefinition.cs) are welcome, just send PRs.
42+

dotnet-binding/StructsAndEnums.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using CoreGraphics;
3+
using Foundation;
4+
using ObjCRuntime;
5+
using UIKit;
6+
7+
namespace MBProgressHUDMaui {
8+
9+
[Native]
10+
public enum MBProgressHUDMode : long
11+
{
12+
Indeterminate,
13+
Determinate,
14+
DeterminateHorizontalBar,
15+
AnnularDeterminate,
16+
CustomView,
17+
Text
18+
}
19+
20+
[Native]
21+
public enum MBProgressHUDAnimation : long
22+
{
23+
Fade,
24+
Zoom,
25+
ZoomOut,
26+
ZoomIn
27+
}
28+
29+
[Native]
30+
public enum MBProgressHUDBackgroundStyle : long
31+
{
32+
SolidColor,
33+
Blur
34+
}
35+
36+
}

0 commit comments

Comments
 (0)