Skip to content

Commit

Permalink
Added Xamarin Binding
Browse files Browse the repository at this point in the history
  • Loading branch information
kyurkchyan committed Jan 29, 2015
1 parent 3ac3f78 commit 8cb2140
Show file tree
Hide file tree
Showing 7 changed files with 355 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ profile

# AppCode noise
.idea/

#Xamarin
[Oo]bj
[Bb]in
*.userprefs
243 changes: 243 additions & 0 deletions Xamarin binding/ApiDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
using System;
using System.Drawing;

using ObjCRuntime;
using Foundation;
using UIKit;
using CoreFoundation;

namespace MBProgressHUD
{
// typedef void (^MBProgressHUDCompletionBlock)();
delegate void MBProgressHUDCompletionHandler();
delegate void NSDispatchHandlerT();

// @interface MBProgressHUD : UIView
[BaseType (typeof (UIView), Name="MBProgressHUD",
Delegates=new string [] {"WeakDelegate"},
Events=new Type [] { typeof (MBProgressHUDDelegate) })]
interface MTMBProgressHUD {

// + (MB_INSTANCETYPE)showHUDAddedTo:(UIView *)view animated:(BOOL)animated;
[Static]
[Export ("showHUDAddedTo:animated:")]
MTMBProgressHUD ShowHUD (UIView view, bool animated);

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

// + (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated;
[Static]
[Export ("hideAllHUDsForView:animated:")]
uint HideAllHUDs (UIView view, bool animated);

// + (MB_INSTANCETYPE)HUDForView:(UIView *)view;
[Static]
[Export ("HUDForView:")]
MTMBProgressHUD HUDForView (UIView view);

// + (NSArray *)allHUDsForView:(UIView *)view;
[Static]
[Export ("allHUDsForView:")]
MTMBProgressHUD [] AllHUDsForView (UIView view);

// - (id)initWithWindow:(UIWindow *)window;
[Export ("initWithWindow:")]
IntPtr Constructor (UIWindow window);

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

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

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

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

// - (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated;
[Export ("showWhileExecuting:onTarget:withObject:animated:")]
void Show (Selector method, NSObject target, [NullAllowed] NSObject aObject, bool animated);

// - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block;
[Export ("showAnimated:whileExecutingBlock:")]
void Show (bool animated, NSDispatchHandlerT whileExecutingHandler);

// - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(MBProgressHUDCompletionBlock)completion;
[Export ("showAnimated:whileExecutingBlock:completionBlock:")]
void Show (bool animated, NSDispatchHandlerT whileExecutingHandler, MBProgressHUDCompletionHandler completionHandler);

// - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue;
[Export ("showAnimated:whileExecutingBlock:onQueue:")]
void Show (bool animated, NSDispatchHandlerT whileExecutingHandler, DispatchQueue queue);

// - (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue completionBlock:(MBProgressHUDCompletionBlock)completion;
[Export ("showAnimated:whileExecutingBlock:onQueue:completionBlock:")]
void Show (bool animated, NSDispatchHandlerT whileExecutingHandler, DispatchQueue queue, MBProgressHUDCompletionHandler completionHandler);

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

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

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

// @property (MB_STRONG) UIView *customView;
[Export ("customView", ArgumentSemantic.Retain)]
UIView CustomView { get; set; }

// @property (MB_WEAK) id<MBProgressHUDDelegate> delegate;
[Wrap ("WeakDelegate")]
MBProgressHUDDelegate Delegate { get; set; }

[Export ("delegate", ArgumentSemantic.Assign)][NullAllowed]
NSObject WeakDelegate { get; set; }

// @property (copy) NSString *labelText;
[Export ("labelText", ArgumentSemantic.Copy)]
string LabelText { get; set; }

// @property (copy) NSString *detailsLabelText;
[Export ("detailsLabelText", ArgumentSemantic.Copy)]
string DetailsLabelText { get; set; }

// @property (assign) float opacity;
[Export ("opacity", ArgumentSemantic.Assign)]
float Opacity { get; set; }

// @property (MB_STRONG) UIColor *color;
[Export ("color", ArgumentSemantic.Retain)]
UIColor Color { get; set; }

// @property (assign) float xOffset;
[Export ("xOffset", ArgumentSemantic.Assign)]
float XOffset { get; set; }

// @property (assign) float yOffset;
[Export ("yOffset", ArgumentSemantic.Assign)]
float YOffset { get; set; }

// @property (assign) float margin;
[Export ("margin", ArgumentSemantic.Assign)]
float Margin { get; set; }

// @property (assign) float cornerRadius;
[Export ("cornerRadius", ArgumentSemantic.Assign)]
float CornerRadius { get; set; }

// @property (assign) BOOL dimBackground;
[Export ("dimBackground", ArgumentSemantic.Assign)]
bool DimBackground { get; set; }

// @property (assign) float graceTime;
[Export ("graceTime", ArgumentSemantic.Assign)]
float GraceTime { get; set; }

// @property (assign) float minShowTime;
[Export ("minShowTime", ArgumentSemantic.Assign)]
float MinShowTime { get; set; }

// @property (assign) BOOL taskInProgress;
[Export ("taskInProgress", ArgumentSemantic.Assign)]
bool TaskInProgress { get; set; }

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

// @property (MB_STRONG) UIFont* labelFont;
[Export ("labelFont", ArgumentSemantic.Retain)]
UIFont LabelFont { get; set; }

// @property (MB_STRONG) UIColor* labelColor;
[Export ("labelColor", ArgumentSemantic.Retain)]
UIColor LabelColor { get; set; }

// @property (MB_STRONG) UIFont* detailsLabelFont;
[Export ("detailsLabelFont", ArgumentSemantic.Retain)]
UIFont DetailsLabelFont { get; set; }

// @property (MB_STRONG) UIColor* detailsLabelColor;
[Export ("detailsLabelColor", ArgumentSemantic.Retain)]
UIColor DetailsLabelColor { get; set; }

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

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

// @property (assign, getter = isSquare) BOOL square;
[Export ("square", ArgumentSemantic.Assign)]
bool Square { [Bind ("isSquare")] get; set; }
}

// @protocol MBProgressHUDDelegate <NSObject>
[BaseType (typeof (NSObject))]
[Model]
[Protocol]
interface MBProgressHUDDelegate {

//- (void)hudWasHidden:(MBProgressHUD *)hud;
[Export ("hudWasHidden:"), EventArgs("MBProgressHUDS"), EventName("DidHide")]
void HudWasHidden (MTMBProgressHUD hud);

}

// @interface MBRoundProgressView : UIView
[BaseType (typeof (UIView))]
interface MBRoundProgressView {

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

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

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

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

// @interface MBBarProgressView : UIView
[BaseType (typeof (UIView))]
interface MBBarProgressView {

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

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

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

// @property (nonatomic, MB_STRONG) UIColor *progressColor;
[Export ("progressColor", ArgumentSemantic.Retain)]
UIColor ProgressColor { get; set; }
}
}
55 changes: 55 additions & 0 deletions Xamarin binding/MBProgressHUD.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectTypeGuids>{8FFB629D-F513-41CE-95D2-7ECE97B6EEEC};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>{473BB5C4-D6CD-4BAB-809D-09F6D05F09E7}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>MBProgressHUD</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>MBProgressHUD</AssemblyName>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.ObjCBinding.CSharp.targets" />
<ItemGroup>
<ObjcBindingNativeLibrary Include="libMBProgressHUD.a" />
</ItemGroup>
<ItemGroup>
<Compile Include="libMBProgressHUD.linkwith.cs" />
<Compile Include="libMBProgressHUD.linkwith.cs">
<DependentUpon>libMBProgressHUD.a</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingCoreSource Include="StructsAndEnums.cs" />
</ItemGroup>
</Project>
17 changes: 17 additions & 0 deletions Xamarin binding/MBProgressHUD.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MBProgressHUD", "MBProgressHUD.csproj", "{473BB5C4-D6CD-4BAB-809D-09F6D05F09E7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{473BB5C4-D6CD-4BAB-809D-09F6D05F09E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{473BB5C4-D6CD-4BAB-809D-09F6D05F09E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{473BB5C4-D6CD-4BAB-809D-09F6D05F09E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{473BB5C4-D6CD-4BAB-809D-09F6D05F09E7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
31 changes: 31 additions & 0 deletions Xamarin binding/StructsAndEnums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;

namespace MBProgressHUD
{
public enum MBProgressHUDMode
{
/** Progress is shown using an UIActivityIndicatorView. This is the default. */
Indeterminate,
/** Progress is shown using a round, pie-chart like, progress view. */
Determinate,
/** Progress is shown using a horizontal progress bar */
DeterminateHorizontalBar,
/** Progress is shown using a ring-shaped progress view. */
AnnularDeterminate,
/** Shows a custom view */
CustomView,
/** Shows only labels */
Text
}

public enum MBProgressHUDAnimation
{
/** Opacity animation */
Fade,
/** Opacity + scale animation */
Zoom,
ZoomOut = Zoom,
ZoomIn
}
}

Binary file added Xamarin binding/libMBProgressHUD.a
Binary file not shown.
4 changes: 4 additions & 0 deletions Xamarin binding/libMBProgressHUD.linkwith.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using System;
using ObjCRuntime;

[assembly: LinkWith ("libMBProgressHUD.a", LinkTarget.ArmV7 | LinkTarget.Arm64, SmartLink = true, ForceLoad = true)]

0 comments on commit 8cb2140

Please sign in to comment.