diff --git a/Social/IOs/AppDelegate.cs b/Social/IOs/AppDelegate.cs new file mode 100644 index 0000000..20196f5 --- /dev/null +++ b/Social/IOs/AppDelegate.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using MonoTouch.Foundation; +using MonoTouch.UIKit; + +using MonoTouch.FacebookConnect; + +namespace Social +{ + [Register ("AppDelegate")] + public partial class AppDelegate : UIApplicationDelegate + { + private UIWindow window; + private MainController _mainController; + + public override bool FinishedLaunching (UIApplication app, NSDictionary options) + { + window = new UIWindow (UIScreen.MainScreen.Bounds); + _mainController = new MainController (); + + window.RootViewController = _mainController; + window.MakeKeyAndVisible (); + + return true; + } + + public override bool OpenUrl (UIApplication application, NSUrl url, string sourceApplication, NSObject annotation) + { + return FBAppCall.HandleOpenURL (url, sourceApplication); + } + } +} + diff --git a/Social/IOs/Entitlements.plist b/Social/IOs/Entitlements.plist new file mode 100644 index 0000000..5ea1ec7 --- /dev/null +++ b/Social/IOs/Entitlements.plist @@ -0,0 +1,6 @@ + + + + + + diff --git a/Social/IOs/FrameContext.cs b/Social/IOs/FrameContext.cs new file mode 100644 index 0000000..3f27f54 --- /dev/null +++ b/Social/IOs/FrameContext.cs @@ -0,0 +1,214 @@ +using System; +using System.Drawing; +using MonoTouch.UIKit; + +namespace Touch.Common +{ + public class FrameContext + { + public UIView View; + public RectangleF Frame; + + public RectangleF? ParentBounds; + public RectangleF? RelativeFrame; + + public FrameContext(UIView view, UIView relativeView) + { + View = view; + + Frame = View.Frame; + ParentBounds = View.Superview != null ? View.Superview.Bounds : (RectangleF?)null; + RelativeFrame = relativeView != null ? relativeView.Frame : (RectangleF?)null; + } + + public void Commit() + { + View.Frame = Frame; + } + } + + public static class FrameHelper + { + /// + /// Get FrameContext + /// + public static FrameContext Begin(this UIView view, UIView relativeView = null) + { + FrameContext fc = new FrameContext(view, relativeView); + return fc; + } + + #region Coordinates and dimensions + public static FrameContext X(this FrameContext fc, float x) + { + fc.Frame.X = x; + return fc; + } + + public static FrameContext Y(this FrameContext fc, float y) + { + fc.Frame.Y = y; + return fc; + } + + public static FrameContext Width(this FrameContext fc, float width) + { + fc.Frame.Width = width; + return fc; + } + + public static FrameContext Height(this FrameContext fc, float height) + { + fc.Frame.Height = height; + return fc; + } + #endregion + + #region Alignment + public static FrameContext AlignLeft(this FrameContext fc, float dx = 0f) + { + fc.Frame.X = dx; + return fc; + } + + public static FrameContext AlignLeft(this FrameContext fc, UIView relativeView, float dx = 0f) + { + fc.Frame.X = relativeView.Frame.X + dx; + return fc; + } + + public static FrameContext AlignTop(this FrameContext fc, float topMargin = 0f) + { + fc.Frame.Y = topMargin; + return fc; + } + + public static FrameContext AlignTop(this FrameContext fc, UIView relativeView, float topMargin = 0f) + { + return fc.AlignTop(relativeView.Frame, topMargin); + } + + public static FrameContext AlignTop(this FrameContext fc, RectangleF relativeViewFrame, float topMargin = 0f) + { + fc.Frame.Y = relativeViewFrame.Y + topMargin; + return fc; + } + + public static FrameContext AlignRight(this FrameContext fc, float rightMargin = 0f) + { + fc.Frame.X = fc.ParentBounds.Value.Width - fc.Frame.Width - rightMargin; + return fc; + } + + public static FrameContext AlignRight(this FrameContext fc, UIView relativeView, float rightMargin = 0f) + { + fc.Frame.X = relativeView.Frame.Right - fc.Frame.Width - rightMargin; + return fc; + } + + public static FrameContext AlignBottom(this FrameContext fc) + { + return fc.BMargin(0f); + } + + public static FrameContext AlignBottom(this FrameContext fc, UIView relativeView, float bottomMargin = 0f) + { + fc.Frame.Y = relativeView.Frame.Bottom - fc.Frame.Height - bottomMargin; + return fc; + } + #endregion + + #region Margin + public static FrameContext BMargin(this FrameContext fc, float bottomMargin) + { + fc.Frame.Y = fc.ParentBounds.Value.Height - fc.Frame.Height - bottomMargin; + return fc; + } + + public static FrameContext LMargin(this FrameContext fc, float leftMargin) + { + fc.Frame.X = leftMargin; + return fc; + } + + public static FrameContext TMagrin(this FrameContext fc, float topMargin) + { + fc.Frame.Y = topMargin; + return fc; + } + #endregion + + #region Placement + public static FrameContext PlaceAbove(this FrameContext fc, UIView viewBelow, float dy = 0f) + { + fc.Frame.Y = viewBelow.Frame.Y - fc.Frame.Height + dy; + return fc; + } + + public static FrameContext PlaceBelow(this FrameContext fc, float dy = 0f) + { + fc.Frame.Y = fc.ParentBounds.Value.Height + dy; + return fc; + } + + public static FrameContext PlaceBelow(this FrameContext fc, UIView viewAbove, float dy = 0f) + { + fc.Frame.Y = viewAbove.Frame.Bottom + dy; + return fc; + } + + public static FrameContext PlaceRight(this FrameContext fc, UIView pivot, float dx = 0f) + { + fc.Frame.X = pivot.Frame.Right + dx; + return fc; + } + + public static FrameContext CenterH(this FrameContext fc) + { + fc.Frame.X = (fc.ParentBounds.Value.Width - fc.Frame.Width) / 2; + return fc; + } + + public static FrameContext CenterV(this FrameContext fc) + { + fc.Frame.Y = (fc.ParentBounds.Value.Height - fc.Frame.Height) / 2; + return fc; + } + + /// + /// Расплолагает view левее центра родителя. Есть возможность сдвига на dx + /// + public static FrameContext LeftOfCenter(this FrameContext fc, float dx = 0f) + { + fc.Frame.X = fc.ParentBounds.Value.Width / 2 + dx; + return fc; + } + #endregion + + #region Filling + public static FrameContext FillHorizontally(this FrameContext fc, float left = 0f, float right = 0f) + { + fc.Frame.X = left; + fc.Frame.Width = fc.ParentBounds.Value.Width - left - right; + return fc; + } + + public static FrameContext FillBelow(this FrameContext fc) + { + float height = fc.ParentBounds.Value.Height - fc.Frame.Top; + + fc.Frame.Height = height; + return fc; + } + #endregion + + #region Movement + public static FrameContext MoveY(this FrameContext fc, float dy) + { + fc.Frame.Y += dy; + return fc; + } + #endregion + } +} + diff --git a/Social/IOs/Info.plist b/Social/IOs/Info.plist new file mode 100644 index 0000000..e33ca71 --- /dev/null +++ b/Social/IOs/Info.plist @@ -0,0 +1,35 @@ + + + + + CFBundleDisplayName + Social + CFBundleIdentifier + com.touchin.social + UIDeviceFamily + + 1 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + MinimumOSVersion + 6.0 + FacebookAppID + 450576355025756 + FacebookDisplayName + rzaitov + CFBundleURLTypes + + + CFBundleURLSchemes + + fb450576355025756 + + + + + diff --git a/Social/IOs/Libs/MonoTouch.FacebookConnect.dll b/Social/IOs/Libs/MonoTouch.FacebookConnect.dll new file mode 100755 index 0000000..a17943a Binary files /dev/null and b/Social/IOs/Libs/MonoTouch.FacebookConnect.dll differ diff --git a/Social/IOs/Main.cs b/Social/IOs/Main.cs new file mode 100644 index 0000000..1e92370 --- /dev/null +++ b/Social/IOs/Main.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using MonoTouch.Foundation; +using MonoTouch.UIKit; + +namespace Social +{ + public class Application + { + // This is the main entry point of the application. + static void Main (string[] args) + { + // if you want to use a different Application Delegate class from "AppDelegate" + // you can specify it here. + UIApplication.Main (args, null, "AppDelegate"); + } + } +} diff --git a/Social/IOs/MainController.cs b/Social/IOs/MainController.cs new file mode 100644 index 0000000..f3bdd0d --- /dev/null +++ b/Social/IOs/MainController.cs @@ -0,0 +1,77 @@ +using System; + +using MonoTouch.UIKit; +using MonoTouch.Foundation; + +using MonoTouch.FacebookConnect; +using Touch.Common; + +namespace Social +{ + public class MainController : UIViewController + { + private UIButton _fbShare; + + public MainController () + { + + } + + public override void ViewDidLoad () + { + base.ViewDidLoad (); + + View.BackgroundColor = UIColor.White; + + _fbShare = new UIButton (); + _fbShare.TouchUpInside += OnLoginClicked; + _fbShare.SetTitle("Share in Facebook", UIControlState.Normal); + _fbShare.SetTitleColor (UIColor.White, UIControlState.Normal); + _fbShare.BackgroundColor = UIColor.Blue; + + _fbShare.SizeToFit (); + + + View.AddSubview (_fbShare); + _fbShare.Begin().MoveY(50).LMargin(20).Commit(); + } + + private void OnLoginClicked (object sender, EventArgs e) + { + FBShareDialogParams shareParams = new FBShareDialogParams () + { + Link = NSUrl.FromString("http://touchin.ru/"), + Name = "Touch instinct", + Caption = "Greatest mobile apps for you", + Description = "Touch instinct team work for you" + }; + + if (FBDialogs.CanPresentShareDialog (shareParams)) + PresentFacebookShareDialog (shareParams); + else + ; + } + + private void PresentFacebookShareDialog(FBShareDialogParams shareParams) + { + FBDialogs.PresentShareDialog(shareParams, null, FBDialogAppCallCompletion); + } + + private void FBDialogAppCallCompletion(FBAppCall call, NSDictionary results, NSError error) + { + // review results for fething additonal info such completed or canceled, post id etc. + // for more info https://developers.facebook.com/docs/ios/share#linkshare + + if (error == null) + return; + + Console.WriteLine (error.Code); + Console.WriteLine (error.DebugDescription); + Console.WriteLine (error.Description); + Console.WriteLine (error.Domain); + Console.WriteLine (error.UserInfo); + Console.WriteLine (error); + Console.WriteLine (call); + } + } +} \ No newline at end of file diff --git a/Social/IOs/Social.csproj b/Social/IOs/Social.csproj new file mode 100644 index 0000000..e4a13b8 --- /dev/null +++ b/Social/IOs/Social.csproj @@ -0,0 +1,112 @@ + + + + Debug + iPhoneSimulator + 10.0.0 + 2.0 + {CC0EE67C-0932-4C64-A5D7-6714994CA602} + {6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + Social + Resources + Social + + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG; + prompt + 4 + false + None + Entitlements.plist + true + + + full + true + bin\iPhoneSimulator\Release + prompt + 4 + None + false + Entitlements.plist + + + true + full + false + bin\iPhone\Debug + DEBUG; + prompt + 4 + false + Entitlements.plist + true + iPhone Developer + + + + + ARMv7 + + + full + true + bin\iPhone\Release + prompt + 4 + Entitlements.plist + false + iPhone Developer + + + full + true + bin\iPhone\Ad-Hoc + prompt + 4 + false + Entitlements.plist + true + Automatic:AdHoc + iPhone Distribution + + + full + true + bin\iPhone\AppStore + prompt + 4 + iPhone Distribution + Entitlements.plist + false + Automatic:AppStore + + + + + + + + Libs\MonoTouch.FacebookConnect.dll + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Social/Social.sln b/Social/Social.sln new file mode 100644 index 0000000..9d8ed25 --- /dev/null +++ b/Social/Social.sln @@ -0,0 +1,32 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Social", "IOs\Social.csproj", "{CC0EE67C-0932-4C64-A5D7-6714994CA602}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|iPhoneSimulator = Debug|iPhoneSimulator + Release|iPhoneSimulator = Release|iPhoneSimulator + Debug|iPhone = Debug|iPhone + Release|iPhone = Release|iPhone + Ad-Hoc|iPhone = Ad-Hoc|iPhone + AppStore|iPhone = AppStore|iPhone + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.AppStore|iPhone.ActiveCfg = AppStore|iPhone + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.AppStore|iPhone.Build.0 = AppStore|iPhone + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.Debug|iPhone.ActiveCfg = Debug|iPhone + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.Debug|iPhone.Build.0 = Debug|iPhone + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.Release|iPhone.ActiveCfg = Release|iPhone + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.Release|iPhone.Build.0 = Release|iPhone + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator + {CC0EE67C-0932-4C64-A5D7-6714994CA602}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = IOs\Social.csproj + EndGlobalSection +EndGlobal