Skip to content
Browse files

Added a way to ignore swipes. Changed the sample name.

  • Loading branch information...
1 parent 0c73a2c commit 91a3f953a1ddd6c57440a6f2dcc6e2646fa59889 @Clancey committed Jan 8, 2013
View
6 FlyOutNavigation.sln
@@ -1,10 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlyOutNavigation", "FlyOutNavigation\FlyOutNavigation.csproj", "{E98F7600-6C2E-4586-A78C-D42BA89445B9}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlyOutNavigationSample", "Sample\FlyOutNavigationSample.csproj", "{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -41,6 +41,6 @@ Global
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
- StartupItem = Sample\Sample.csproj
+ StartupItem = FlyOutNavigation\FlyOutNavigation.csproj
EndGlobalSection
EndGlobal
View
7 FlyOutNavigation/FlyOutNavigation.csproj
@@ -36,16 +36,11 @@
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
+ <Reference Include="MonoTouch.Dialog-1" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="FlyOutNavigationController.cs" />
<Compile Include="OpenMenuGestureRecognizer.cs" />
</ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\MonoTouch.Dialog\MonoTouch.Dialog\MonoTouch.Dialog.csproj">
- <Project>{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}</Project>
- <Name>MonoTouch.Dialog</Name>
- </ProjectReference>
- </ItemGroup>
</Project>
View
62 FlyOutNavigation/FlyOutNavigationController.cs
@@ -83,9 +83,18 @@ public FlyOutNavigationController ()
};
AlwaysShowLandscapeMenu = true;
- this.View.AddGestureRecognizer(new OpenMenuGestureRecognizer(this,new Selector("swiperight")));
+ this.View.AddGestureRecognizer(new OpenMenuGestureRecognizer(this,new Selector("swiperight"),this));
+ //this.View.AddGestureRecognizer (new UIPanGestureRecognizer (DragContentView));
}
-
+
+ public event UITouchEventArgs ShouldReceiveTouch;
+ internal bool shouldReceiveTouch(UIGestureRecognizer gesture, UITouch touch)
+ {
+ if(ShouldReceiveTouch != null)
+ return ShouldReceiveTouch(gesture, touch);
+ return true;
+ }
+
public override void ViewDidLayoutSubviews ()
{
base.ViewDidLayoutSubviews ();
@@ -94,6 +103,41 @@ public override void ViewDidLayoutSubviews ()
if(navigation.View.Frame != navFrame)
navigation.View.Frame = navFrame;
}
+
+ public void DragContentView(UIPanGestureRecognizer panGesture)
+ {
+ var translation = panGesture.TranslationInView (View).X;
+// if (panGesture.State == UIGestureRecognizerState.Changed) {
+// if (IsOpen) {
+// if (translation > 0.0f) {
+// _contentView.frame = CGRectOffset(_contentView.bounds, kGHRevealSidebarWidth, 0.0f);
+// self.sidebarShowing = YES;
+// } else if (translation < -kGHRevealSidebarWidth) {
+// _contentView.frame = _contentView.bounds;
+// self.sidebarShowing = NO;
+// } else {
+// _contentView.frame = CGRectOffset(_contentView.bounds, (kGHRevealSidebarWidth + translation), 0.0f);
+// }
+// } else {
+// if (translation < 0.0f) {
+// _contentView.frame = _contentView.bounds;
+// self.sidebarShowing = NO;
+// } else if (translation > kGHRevealSidebarWidth) {
+// _contentView.frame = CGRectOffset(_contentView.bounds, kGHRevealSidebarWidth, 0.0f);
+// self.sidebarShowing = YES;
+// } else {
+// _contentView.frame = CGRectOffset(_contentView.bounds, translation, 0.0f);
+// }
+// }
+// } else if (panGesture.state == UIGestureRecognizerStateEnded) {
+// CGFloat velocity = [panGesture velocityInView:self.view].x;
+// BOOL show = (fabs(velocity) > kGHRevealSidebarFlickVelocity)
+// ? (velocity > 0)
+// : (translation > (kGHRevealSidebarWidth / 2));
+// [self toggleSidebar:show duration:kGHRevealSidebarDefaultAnimationDuration];
+//
+// }
+ }
[Export("swiperight")]
public void Swipped(UISwipeGestureRecognizer sender)
{
@@ -112,7 +156,10 @@ public override void ViewWillAppear (bool animated)
public RootElement NavigationRoot {
get{return navigation.Root;}
- set{EnsureInvokedOnMainThread(delegate{navigation.Root = value;});}
+ set{EnsureInvokedOnMainThread ( delegate {
+ navigation.Root = value;
+ });
+ }
}
public UITableView NavigationTableView {
get{return navigation.TableView;}
@@ -185,6 +232,7 @@ public void ShowMenu()
if(isOpen)
return;
EnsureInvokedOnMainThread(delegate{
+ navigation.ReloadData();
isOpen = true;
closeButton.Frame = mainView.Frame;
shadowView.Frame = mainView.Frame;
@@ -314,6 +362,8 @@ private int GetIndex(NSIndexPath indexPath)
}
private NSIndexPath GetIndexPath(int index)
{
+ if (navigation.Root == null)
+ return NSIndexPath.FromRowSection(0, 0);
int currentCount = 0;
int section = 0;
foreach(var element in navigation.Root)
@@ -331,7 +381,7 @@ private NSIndexPath GetIndexPath(int index)
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
if(DisableRotation)
- return false;
+ return toInterfaceOrientation == InterfaceOrientation;
var theReturn= CurrentViewController == null? true: CurrentViewController.ShouldAutorotateToInterfaceOrientation(toInterfaceOrientation);
return theReturn;
@@ -381,9 +431,7 @@ private void EnsureInvokedOnMainThread (Action action)
return NSThread.Current.IsMainThread;
//return Messaging.bool_objc_msgSend(GetClassHandle("NSThread"), new Selector("isMainThread").Handle);
}
- public static bool IsIos5 {
- get{ return new System.Version(UIDevice.CurrentDevice.SystemVersion).Major >= 5 ;}
- }
+
}
}
View
6 FlyOutNavigation/OpenMenuGestureRecognizer.cs
@@ -22,13 +22,15 @@ namespace FlyOutNavigation
{
public class OpenMenuGestureRecognizer : UISwipeGestureRecognizer
{
- public OpenMenuGestureRecognizer (NSObject target, Selector action) : base(target,action)
+ FlyOutNavigationController Parent;
+ public OpenMenuGestureRecognizer (NSObject target, Selector action,FlyOutNavigationController parent) : base(target,action)
{
+ Parent = parent;
this.Direction = UISwipeGestureRecognizerDirection.Right;
this.ShouldReceiveTouch += (sender,touch)=> {
if(touch.View is UISlider || touch.View is MPVolumeView)
return false;
- return true;
+ return Parent.shouldReceiveTouch(sender,touch);
};
}
}
View
0 Sample/Sample.csproj → Sample/FlyOutNavigationSample.csproj
File renamed without changes.

0 comments on commit 91a3f95

Please sign in to comment.
Something went wrong with that request. Please try again.