This commit is contained in:
Clancey 2011-11-26 17:15:16 -09:00
Коммит c2c1f9e8ac
9 изменённых файлов: 518 добавлений и 0 удалений

53
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,53 @@
#ignore thumbnails created by windows
Thumbs.db
#Ignore files build by Visual Studio
*.obj
*.pdb
*.user
*.userprefs
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.pidb
.svn
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
obj/
tozip/
test-results/
Build/Output/
Build/output/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
Examples*/
SerializerTest*/
*.csproj.user
*.resharper*
*.rdl.data
#ignore files created by TortoiseGit when resolving conflicts
/ToZip
LOCAL.*/
REMOTE.*/
BASE.*/
LOCAL.*
REMOTE.*
BASE.*
/nunit-result.xml
/test-results
*.DS_Store
*.ipa

64
FlyOutNavigation.sln Normal file
Просмотреть файл

@ -0,0 +1,64 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlyOutNavigation", "FlyOutNavigation\FlyOutNavigation.csproj", "{E98F7600-6C2E-4586-A78C-D42BA89445B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoTouch.Dialog", "..\MonoTouch.Dialog\MonoTouch.Dialog\MonoTouch.Dialog.csproj", "{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
AdHoc|iPhoneSimulator = AdHoc|iPhoneSimulator
AppStore|iPhoneSimulator = AppStore|iPhoneSimulator
AdHoc|iPhone = AdHoc|iPhone
AppStore|iPhone = AppStore|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.AdHoc|iPhone.ActiveCfg = AdHoc|iPhone
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.AdHoc|iPhone.Build.0 = AdHoc|iPhone
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.AdHoc|iPhoneSimulator.ActiveCfg = AdHoc|iPhoneSimulator
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.AdHoc|iPhoneSimulator.Build.0 = AdHoc|iPhoneSimulator
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.AppStore|iPhone.Build.0 = AppStore|iPhone
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.AppStore|iPhoneSimulator.ActiveCfg = AppStore|iPhoneSimulator
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.AppStore|iPhoneSimulator.Build.0 = AppStore|iPhoneSimulator
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Debug|iPhone.ActiveCfg = Debug|iPhone
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Debug|iPhone.Build.0 = Debug|iPhone
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Release|iPhone.ActiveCfg = Release|iPhone
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Release|iPhone.Build.0 = Release|iPhone
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{E98F7600-6C2E-4586-A78C-D42BA89445B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E98F7600-6C2E-4586-A78C-D42BA89445B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E98F7600-6C2E-4586-A78C-D42BA89445B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E98F7600-6C2E-4586-A78C-D42BA89445B9}.Release|Any CPU.Build.0 = Release|Any CPU
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Debug|iPhone.ActiveCfg = Debug|iPhone
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Debug|iPhone.Build.0 = Debug|iPhone
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Release|iPhone.ActiveCfg = Release|iPhone
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Release|iPhone.Build.0 = Release|iPhone
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Sample\Sample.csproj
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,48 @@
<?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>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E98F7600-6C2E-4586-A78C-D42BA89445B9}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>FlyOutNavigation</RootNamespace>
<AssemblyName>FlyOutNavigation</AssemblyName>
</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>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="FlyOutNavigationController.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>

Просмотреть файл

@ -0,0 +1,148 @@
using System;
using MonoTouch.UIKit;
using MonoTouch.Dialog;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
namespace FlyOutNavigation
{
public class FlyOutNavigationController : UIViewController
{
UIColor tintColor;
public UIColor TintColor
{
get{return tintColor;}
set{
if(tintColor == value)
return;
navigation.SearchBarTintColor = value;
}
}
DialogViewController navigation;
UIView mainView;
UIView currentView;
const int menuWidth = 250;
public FlyOutNavigationController ()
{
navigation = new DialogViewController(UITableViewStyle.Plain,null);
navigation.EnableSearch = true;
navigation.OnSelection = NavigationItemSelected;
TintColor = UIColor.Black;
var navFrame = navigation.View.Frame;
navFrame.Width = menuWidth;
navigation.View.Frame = navFrame;
this.View.AddSubview(navigation.View);
var mainFrame = View.Bounds;
//mainFrame.X = menuWidth;
mainView = new UIView(mainFrame);
mainView.BackgroundColor = UIColor.Blue;
mainView.Layer.ShadowOffset = new System.Drawing.SizeF(-5,-1);
mainView.Layer.ShadowColor = UIColor.Black.CGColor;
mainView.Layer.ShadowOpacity = .75f;
this.View.AddSubview(mainView);
}
public RootElement NavigationRoot {
get{return navigation.Root;}
set{navigation.Root = value;}
}
UIViewController[] viewControllers;
public UIViewController[] ViewControllers {
get{return viewControllers;}
set{
viewControllers = value;
NavigationItemSelected(GetIndexPath(SelectedIndex));
}
}
private void NavigationItemSelected(NSIndexPath indexPath){
Console.WriteLine(indexPath);
SelectedIndex = GetIndex(indexPath);
Console.WriteLine(SelectedIndex);
if(currentView != null)
currentView.RemoveFromSuperview();
currentView = ViewControllers[SelectedIndex].View;
currentView.Frame = mainView.Bounds;
mainView.AddSubview(currentView);
HideMenu();
}
bool isOpen;
public bool IsOpen{
get{return isOpen;}
set{
if(isOpen == value)
return;
if(value)
HideMenu();
else
ShowMenu();
}
}
public void ShowMenu()
{
isOpen = true;
UIView.BeginAnimations("slideMenu");
//UIView.SetAnimationDuration(2);
var frame = mainView.Frame;
frame.X = menuWidth;
mainView.Frame = frame;
UIView.CommitAnimations();
}
public void HideMenu()
{
isOpen = false;
navigation.FinishSearch();
UIView.BeginAnimations("slideMenu");
var frame = mainView.Frame;
frame.X = 0;
mainView.Frame = frame;
UIView.CommitAnimations();
}
public void ToggleMenu()
{
if(isOpen)
HideMenu();
else
ShowMenu();
}
public int SelectedIndex
{
get;set;
}
private int GetIndex(NSIndexPath indexPath)
{
int section = 0;
int rowCount = 0;
while(section < indexPath.Section)
{
rowCount += navigation.Root[section].Count;
section ++;
}
return rowCount + indexPath.Row;
}
private NSIndexPath GetIndexPath(int index)
{
int currentCount = 0;
int section = 0;
foreach(var element in navigation.Root)
{
if(element.Count + currentCount > index)
break;
currentCount += element.Count;
section ++;
}
var row = index - currentCount;
return NSIndexPath.FromRowSection(row,section);
}
}
}

78
Sample/AppDelegate.cs Normal file
Просмотреть файл

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using FlyOutNavigation;
using MonoTouch.Dialog;
namespace Sample
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
// class-level declarations
UIWindow window;
FlyOutNavigationController viewController;
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
viewController = new FlyOutNavigationController ();
viewController.NavigationRoot = new RootElement ("")
{
new Section ("Section 1"){
new StringElement ("View 1"),
new ImageStringElement("View 2",UIImage.FromFile("jhill.jpeg")),
new StringElement ("View 3"),
},
new Section ("Section 2"){
new StringElement ("View 1"),
new StringElement ("View 2"),
}
};
viewController.ViewControllers = new UIViewController[]{
new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 1"){new Section (){new StringElement ("View 1")}}))
,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 1"){new Section (){new StringElement ("View 2")}}))
,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 1"){new Section (){new StringElement ("View 3")}}))
,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 2"){new Section (){new StringElement ("View 1")}}))
,new UINavigationController (new BaseDialogViewController (viewController, new RootElement ("Section 2"){new Section (){new StringElement ("View 2")}}))
};
window.RootViewController = viewController;
window.MakeKeyAndVisible ();
return true;
}
public class BaseDialogViewController : DialogViewController
{
FlyOutNavigationController navigation;
public BaseDialogViewController (FlyOutNavigationController navigation, RootElement root) : base(root)
{
this.navigation = navigation;
}
public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
this.NavigationItem.LeftBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Bookmarks, delegate {
navigation.ToggleMenu ();
});
}
}
}
}

24
Sample/Info.plist Normal file
Просмотреть файл

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<string>1</string>
<string>2</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

19
Sample/Main.cs Normal file
Просмотреть файл

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace Sample
{
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");
}
}
}

84
Sample/Sample.csproj Normal file
Просмотреть файл

@ -0,0 +1,84 @@
<?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)' == '' ">iPhoneSimulator</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F7F9CC1F-0E0A-4E5D-A1B1-BB977A0CD36B}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>Sample</RootNamespace>
<AssemblyName>Sample</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchLink>None</MtouchLink>
<MtouchDebug>true</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchLink>None</MtouchLink>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchDebug>true</MtouchDebug>
<CodesignKey>iPhone Developer</CodesignKey>
<IpaPackageName />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<CodesignKey>iPhone Developer</CodesignKey>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\FlyOutNavigation\FlyOutNavigation.csproj">
<Project>{E98F7600-6C2E-4586-A78C-D42BA89445B9}</Project>
<Name>FlyOutNavigation</Name>
</ProjectReference>
<ProjectReference Include="..\..\MonoTouch.Dialog\MonoTouch.Dialog\MonoTouch.Dialog.csproj">
<Project>{3FFBFFF8-5560-4EDE-82E5-3FFDFBBA8A50}</Project>
<Name>MonoTouch.Dialog</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="jhill.jpeg" />
</ItemGroup>
</Project>

Двоичные данные
Sample/jhill.jpeg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 10 KiB