Skip to content

Commit

Permalink
iOS Secondary Toolbars
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Rome committed Sep 3, 2015
1 parent ba981df commit 9d1a799
Show file tree
Hide file tree
Showing 33 changed files with 613 additions and 0 deletions.
43 changes: 43 additions & 0 deletions SecondaryToolbarDemo/SecondaryToolbarDemo.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecondaryToolbarDemo", "SecondaryToolbarDemo\SecondaryToolbarDemo.csproj", "{FB3076A6-A168-462C-AA14-256949871D72}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecondaryToolbarDemo.iOS", "iOS\SecondaryToolbarDemo.iOS.csproj", "{A8A773B3-9652-487E-90F5-06FAD0EF9D69}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhone = Release|iPhone
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Debug|iPhone.ActiveCfg = Debug|iPhone
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Debug|iPhone.Build.0 = Debug|iPhone
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Release|Any CPU.ActiveCfg = Release|iPhone
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Release|Any CPU.Build.0 = Release|iPhone
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Release|iPhone.ActiveCfg = Release|iPhone
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Release|iPhone.Build.0 = Release|iPhone
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{A8A773B3-9652-487E-90F5-06FAD0EF9D69}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{FB3076A6-A168-462C-AA14-256949871D72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB3076A6-A168-462C-AA14-256949871D72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB3076A6-A168-462C-AA14-256949871D72}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{FB3076A6-A168-462C-AA14-256949871D72}.Debug|iPhone.Build.0 = Debug|Any CPU
{FB3076A6-A168-462C-AA14-256949871D72}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{FB3076A6-A168-462C-AA14-256949871D72}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{FB3076A6-A168-462C-AA14-256949871D72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB3076A6-A168-462C-AA14-256949871D72}.Release|Any CPU.Build.0 = Release|Any CPU
{FB3076A6-A168-462C-AA14-256949871D72}.Release|iPhone.ActiveCfg = Release|Any CPU
{FB3076A6-A168-462C-AA14-256949871D72}.Release|iPhone.Build.0 = Release|Any CPU
{FB3076A6-A168-462C-AA14-256949871D72}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{FB3076A6-A168-462C-AA14-256949871D72}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
20 changes: 20 additions & 0 deletions SecondaryToolbarDemo/SecondaryToolbarDemo/MainAppPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SecondaryToolbarDemo.MainAppPage"
Title="Main">

<ContentPage.ToolbarItems>
<ToolbarItem
Text="Share"
Order="Secondary"
Name="Action"
Command="{Binding ShareCommand}"/>
</ContentPage.ToolbarItems>

<Image
Source="http://lorempixel.com/320/480/abstract"
Aspect="AspectFill"/>

</ContentPage>
16 changes: 16 additions & 0 deletions SecondaryToolbarDemo/SecondaryToolbarDemo/MainAppPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;

using Xamarin.Forms;

namespace SecondaryToolbarDemo
{
public partial class MainAppPage : ContentPage
{
public MainAppPage ()
{
InitializeComponent ();
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Reflection;
using System.Runtime.CompilerServices;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle ("SecondaryToolbarDemo")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("Wintellect, LLC")]
[assembly: AssemblyProduct ("")]
[assembly: AssemblyCopyright ("2015 Wintellect, LLC")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion ("1.0.*")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

21 changes: 21 additions & 0 deletions SecondaryToolbarDemo/SecondaryToolbarDemo/SecondaryToolbarDemo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Xamarin.Forms;

namespace SecondaryToolbarDemo
{
public class App : Application
{
public Command ShareCommand { get; private set; }

public App ()
{
ShareCommand = new Command (OnShare);
MainPage = new NavigationPage (new MainAppPage { BindingContext = this });
}

void OnShare()
{
MainPage.DisplayAlert ("Toolbar Demo", "Hello from the toolbar!", "WHATEV");
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?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>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>{FB3076A6-A168-462C-AA14-256949871D72}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>SecondaryToolbarDemo</RootNamespace>
<AssemblyName>SecondaryToolbarDemo</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile78</TargetFrameworkProfile>
</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>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Compile Include="SecondaryToolbarDemo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MainAppPage.xaml.cs">
<DependentUpon>MainAppPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<Import Project="..\packages\Xamarin.Forms.1.4.4.6392\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.1.4.4.6392\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
<ItemGroup>
<Reference Include="Xamarin.Forms.Core">
<HintPath>..\packages\Xamarin.Forms.1.4.4.6392\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Xaml">
<HintPath>..\packages\Xamarin.Forms.1.4.4.6392\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll</HintPath>
</Reference>
<Reference Include="Xamarin.Forms.Platform">
<HintPath>..\packages\Xamarin.Forms.1.4.4.6392\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MainAppPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions SecondaryToolbarDemo/SecondaryToolbarDemo/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Xamarin.Forms" version="1.4.4.6392" targetFramework="portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10" />
</packages>
28 changes: 28 additions & 0 deletions SecondaryToolbarDemo/iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit;

namespace SecondaryToolbarDemo.iOS
{
[Register ("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init ();

// Code for starting up the Xamarin Test Cloud Agent
#if ENABLE_TEST_CLOUD
Xamarin.Calabash.Start();
#endif

LoadApplication (new App ());

return base.FinishedLaunching (app, options);
}
}
}

7 changes: 7 additions & 0 deletions SecondaryToolbarDemo/iOS/Entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?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>
</dict>
</plist>

Binary file added SecondaryToolbarDemo/iOS/ITunesArtwork
Binary file not shown.
Binary file added SecondaryToolbarDemo/iOS/ITunesArtwork@2x
Binary file not shown.
64 changes: 64 additions & 0 deletions SecondaryToolbarDemo/iOS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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>CFBundleDisplayName</key>
<string>iOS Secondary Toolbar Demo</string>
<key>CFBundleIdentifier</key>
<string>com.wintellect.secondaryToolbar</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>7.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</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>
<key>CFBundleIconFiles</key>
<array>
<string>Icon-60@2x</string>
<string>Icon-60@3x</string>
<string>Icon-76</string>
<string>Icon-76@2x</string>
<string>Default</string>
<string>Default@2x</string>
<string>Default-568h</string>
<string>Default-568h@2x</string>
<string>Default-Landscape</string>
<string>Default-Landscape@2x</string>
<string>Default-Portrait</string>
<string>Default-Portrait@2x</string>
<string>Icon-Small-40</string>
<string>Icon-Small-40@2x</string>
<string>Icon-Small-40@3x</string>
<string>Icon-Small</string>
<string>Icon-Small@2x</string>
<string>Icon-Small@3x</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
</dict>
</plist>

21 changes: 21 additions & 0 deletions SecondaryToolbarDemo/iOS/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;

using Foundation;
using UIKit;

namespace SecondaryToolbarDemo.iOS
{
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");
}
}
}

56 changes: 56 additions & 0 deletions SecondaryToolbarDemo/iOS/PatchedNavigationRenderer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Xamarin.Forms.Platform.iOS;
using Xamarin.Forms;
using UIKit;
using System.Linq;
using CoreGraphics;
using System;

[assembly: ExportRenderer (typeof(NavigationPage), typeof(SecondaryToolbarDemo.iOS.PatchedNavigationRenderer))]

namespace SecondaryToolbarDemo.iOS
{
public class PatchedNavigationRenderer : NavigationRenderer
{
public override void ViewWillAppear (bool animated)
{
var badBar = View.Subviews.OfType<UIToolbar> ().FirstOrDefault (v => v.GetType () != typeof(UIToolbar));
if (badBar != null) {
badBar.RemoveFromSuperview ();
}
base.ViewWillAppear (animated);
}

public override void ViewDidLayoutSubviews ()
{
base.ViewDidLayoutSubviews ();

UIView[] subviews = View.Subviews.Where (v => v != NavigationBar).ToArray ();
var toolBarViews = subviews.Where (v => v is UIToolbar).ToArray ();
var otherViews = subviews.Where (v => !(v is UIToolbar)).ToArray ();

nfloat toolbarHeight = 0;

foreach (var uIView in toolBarViews) {
uIView.SizeToFit ();
uIView.Frame = new CGRect {
X = 0,
Y = View.Bounds.Height - uIView.Frame.Height,
Width = View.Bounds.Width,
Height = uIView.Frame.Height,
};
var thisToolbarHeight = uIView.Frame.Height;
if (toolbarHeight < thisToolbarHeight) {
toolbarHeight = thisToolbarHeight;
}
}

var othersHeight = View.Bounds.Height - toolbarHeight;
var othersFrame = new CGRect (View.Bounds.X, View.Bounds.Y, View.Bounds.Width, othersHeight);

foreach (var uIView in otherViews) {
uIView.Frame = othersFrame;
}
}
}

}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SecondaryToolbarDemo/iOS/Resources/Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SecondaryToolbarDemo/iOS/Resources/Icon-76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SecondaryToolbarDemo/iOS/Resources/Icon-Small-40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SecondaryToolbarDemo/iOS/Resources/Icon-Small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9d1a799

Please sign in to comment.