Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 6b921bf

Browse files
sidebar sample (#466)
1 parent 6c9139b commit 6b921bf

22 files changed

+758
-0
lines changed

nnyeah-samples/sidebar/AppDelegate.cs

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using Foundation;
2+
using UIKit;
3+
4+
namespace StoryboardSample
5+
{
6+
// The UIApplicationDelegate for the application. This class is responsible for launching the
7+
// User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
8+
[Register("AppDelegate")]
9+
public class AppDelegate : UIApplicationDelegate
10+
{
11+
// class-level declarations
12+
13+
public override UIWindow? Window {
14+
get;
15+
set;
16+
}
17+
18+
public RootViewController? RootViewController { get { return Window?.RootViewController as RootViewController; } }
19+
20+
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
21+
{
22+
// create a new window instance based on the screen size
23+
Window = new UIWindow(UIScreen.MainScreen.Bounds);
24+
25+
// If you have defined a root view controller, set it here:
26+
Window.RootViewController = new RootViewController ();
27+
28+
// make the window visible
29+
Window.MakeKeyAndVisible ();
30+
31+
return true;
32+
}
33+
34+
public override void OnResignActivation (UIApplication application)
35+
{
36+
// Invoked when the application is about to move from active to inactive state.
37+
// This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
38+
// or when the user quits the application and it begins the transition to the background state.
39+
// Games should use this method to pause the game.
40+
}
41+
42+
public override void DidEnterBackground (UIApplication application)
43+
{
44+
// Use this method to release shared resources, save user data, invalidate timers and store the application state.
45+
// If your application supports background exection this method is called instead of WillTerminate when the user quits.
46+
}
47+
48+
public override void WillEnterForeground (UIApplication application)
49+
{
50+
// Called as part of the transiton from background to active state.
51+
// Here you can undo many of the changes made on entering the background.
52+
}
53+
54+
public override void OnActivated (UIApplication application)
55+
{
56+
// Restart any tasks that were paused (or not yet started) while the application was inactive.
57+
// If the application was previously in the background, optionally refresh the user interface.
58+
}
59+
60+
public override void WillTerminate (UIApplication application)
61+
{
62+
// Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground.
63+
}
64+
}
65+
}
66+
67+
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using System.Drawing;
3+
using Foundation;
4+
using UIKit;
5+
using ObjCRuntime;
6+
7+
namespace StoryboardSample
8+
{
9+
public partial class BaseController : UIViewController
10+
{
11+
// provide access to the sidebar controller to all inheriting controllers
12+
protected SidebarNavigation.SidebarController? SidebarController {
13+
get {
14+
return (UIApplication.SharedApplication.Delegate as AppDelegate)?.RootViewController?.SidebarController;
15+
}
16+
}
17+
18+
// provide access to the navigation controller to all inheriting controllers
19+
protected NavController NavController {
20+
get {
21+
if (UIApplication.SharedApplication.Delegate is AppDelegate appDelegate && appDelegate.RootViewController is not null) {
22+
return appDelegate.RootViewController.NavController;
23+
} else {
24+
Console.WriteLine ("NavController failed");
25+
throw new NotSupportedException ("unable to get root view controller.");
26+
}
27+
}
28+
}
29+
30+
// provide access to the storyboard to all inheriting controllers
31+
public override UIStoryboard Storyboard {
32+
get {
33+
if (UIApplication.SharedApplication.Delegate is AppDelegate appDelegate && appDelegate.RootViewController is not null) {
34+
return appDelegate.RootViewController.Storyboard;
35+
} else {
36+
Console.WriteLine ("Storyboard failed.");
37+
throw new NotSupportedException ("unable to get storyboard.");
38+
}
39+
}
40+
}
41+
42+
public BaseController (NativeHandle handle) : base (handle)
43+
{
44+
}
45+
46+
47+
public override void ViewDidLoad ()
48+
{
49+
base.ViewDidLoad ();
50+
51+
NavigationItem.SetRightBarButtonItem (
52+
new UIBarButtonItem (UIImage.FromBundle ("threelines"),
53+
UIBarButtonItemStyle.Plain,
54+
ButtonHandler), true);
55+
}
56+
57+
void ButtonHandler (object? sender, EventArgs e) {
58+
if (SidebarController is not null) {
59+
SidebarController.ToggleMenu ();
60+
}
61+
}
62+
}
63+
}
64+

nnyeah-samples/sidebar/BaseController.designer.cs

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Foundation;
2+
using System;
3+
using System.CodeDom.Compiler;
4+
using UIKit;
5+
using ObjCRuntime;
6+
7+
namespace StoryboardSample
8+
{
9+
partial class ContentController : BaseController
10+
{
11+
public ContentController (NativeHandle handle) : base (handle)
12+
{
13+
}
14+
}
15+
}

nnyeah-samples/sidebar/ContentController.designer.cs

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
</dict>
6+
</plist>

nnyeah-samples/sidebar/Info.plist

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDisplayName</key>
6+
<string>StoryboardSample</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>com.wholestacksoftware.storyboardsample</string>
9+
<key>LSRequiresIPhoneOS</key>
10+
<true/>
11+
<key>MinimumOSVersion</key>
12+
<string>13.0</string>
13+
<key>UIDeviceFamily</key>
14+
<array>
15+
<integer>1</integer>
16+
</array>
17+
<key>UILaunchStoryboardName</key>
18+
<string>LaunchScreen</string>
19+
<key>UIRequiredDeviceCapabilities</key>
20+
<array>
21+
<string>armv7</string>
22+
</array>
23+
<key>UISupportedInterfaceOrientations</key>
24+
<array>
25+
<string>UIInterfaceOrientationPortrait</string>
26+
<string>UIInterfaceOrientationLandscapeLeft</string>
27+
<string>UIInterfaceOrientationLandscapeRight</string>
28+
</array>
29+
<key>XSAppIconAssets</key>
30+
<string>Resources/Images.xcassets/AppIcons.appiconset</string>
31+
<key>CFBundleShortVersionString</key>
32+
<string>0.1</string>
33+
<key>CFBundleVersion</key>
34+
<string>0.1</string>
35+
</dict>
36+
</plist>
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Foundation;
2+
using System;
3+
using System.CodeDom.Compiler;
4+
using UIKit;
5+
using ObjCRuntime;
6+
7+
namespace StoryboardSample
8+
{
9+
partial class IntroController : BaseController
10+
{
11+
public IntroController (NativeHandle handle) : base (handle)
12+
{
13+
}
14+
}
15+
}

nnyeah-samples/sidebar/IntroController.designer.cs

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nnyeah-samples/sidebar/Main.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using UIKit;
2+
3+
namespace StoryboardSample
4+
{
5+
public class Application
6+
{
7+
// This is the main entry point of the application.
8+
static void Main(string[] args)
9+
{
10+
// if you want to use a different Application Delegate class from "AppDelegate"
11+
// you can specify it here.
12+
UIApplication.Main(args, typeof (UIApplication), typeof (AppDelegate));
13+
}
14+
}
15+
}

nnyeah-samples/sidebar/Makefile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
ifndef MS_PLATFORM_DLL
3+
$(error MS_PLATFORM_DLL is not set. See the package README.md for more information.)
4+
endif
5+
6+
PACKAGE=sidebarnavigation
7+
VERSION=2.1.0
8+
FULLPACKAGE=$(PACKAGE).$(VERSION).nupkg
9+
NUGETAPI=http://api.nuget.org/v3-flatcontainer
10+
XAMARIN_PLATFORM_DLL=/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Xamarin.iOS.dll
11+
12+
all: prepare
13+
dotnet build
14+
15+
prepare: ./nuget nuget/$(FULLPACKAGE)
16+
dotnet nnyeah \
17+
--input nuget/lib/xamarinios10/SidebarNavigation.dll \
18+
--output nuget/SidebarNavigation.dll \
19+
--xamarin-assembly=$(XAMARIN_PLATFORM_DLL) \
20+
--microsoft-assembly=$(MS_PLATFORM_DLL) \
21+
--force-overwrite
22+
nuget:
23+
mkdir $@
24+
25+
nuget/$(FULLPACKAGE):
26+
wget $(NUGETAPI)/$(PACKAGE)/$(VERSION)/$(FULLPACKAGE) -O nuget/$(FULLPACKAGE)
27+
unzip nuget/$(FULLPACKAGE) -d nuget
28+
29+
clean:
30+
rm -rf ./nuget ./bin ./obj
31+
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Foundation;
2+
using System;
3+
using System.CodeDom.Compiler;
4+
using UIKit;
5+
using ObjCRuntime;
6+
7+
namespace StoryboardSample
8+
{
9+
partial class MenuController : BaseController
10+
{
11+
public MenuController (NativeHandle handle) : base (handle)
12+
{
13+
}
14+
15+
public override void ViewDidLoad ()
16+
{
17+
base.ViewDidLoad ();
18+
19+
var contentController = (ContentController)Storyboard.InstantiateViewController ("ContentController");
20+
21+
ContentButton.TouchUpInside += (o, e) => {
22+
if (NavController.TopViewController as ContentController is null)
23+
NavController.PushViewController (contentController, false);
24+
if (SidebarController is not null)
25+
SidebarController.CloseMenu ();
26+
};
27+
}
28+
}
29+
}

nnyeah-samples/sidebar/MenuController.designer.cs

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)