Skip to content

Commit 015f7cf

Browse files
committed
Initial commit
0 parents  commit 015f7cf

File tree

19 files changed

+1138
-0
lines changed

19 files changed

+1138
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SwiftUI-SideMenuPopup
2+
Example of side menu popup in SwiftUI
3+
4+
![Example Gif](/SideMenu.gif)
5+
6+
Credit: [ProgrammingWithSwift.com](https://programmingwithswift.com/create-side-menu-with-swiftui/)

Side Menu Example.xcodeproj/project.pbxproj

+599
Large diffs are not rendered by default.

Side Menu Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata

+7
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,8 @@
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>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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>SchemeUserState</key>
6+
<dict>
7+
<key>Side Menu Example.xcscheme_^#shared#^_</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
</dict>
14+
</plist>

Side Menu Example/AppDelegate.swift

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// AppDelegate.swift
3+
// Side Menu Example
4+
//
5+
// Created by Josh Hubbard on 1/10/20.
6+
// Copyright © 2020 YeetBox. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
@UIApplicationMain
12+
class AppDelegate: UIResponder, UIApplicationDelegate {
13+
14+
15+
16+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
17+
// Override point for customization after application launch.
18+
return true
19+
}
20+
21+
// MARK: UISceneSession Lifecycle
22+
23+
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
24+
// Called when a new scene session is being created.
25+
// Use this method to select a configuration to create the new scene with.
26+
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
27+
}
28+
29+
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
30+
// Called when the user discards a scene session.
31+
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
32+
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
33+
}
34+
35+
36+
}
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"size" : "29x29",
16+
"scale" : "2x"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"size" : "29x29",
21+
"scale" : "3x"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"size" : "40x40",
26+
"scale" : "2x"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"size" : "40x40",
31+
"scale" : "3x"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"size" : "60x60",
36+
"scale" : "2x"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"size" : "60x60",
41+
"scale" : "3x"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"size" : "20x20",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"size" : "20x20",
51+
"scale" : "2x"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"size" : "29x29",
56+
"scale" : "1x"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"size" : "29x29",
61+
"scale" : "2x"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"size" : "40x40",
66+
"scale" : "1x"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"size" : "40x40",
71+
"scale" : "2x"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"size" : "76x76",
76+
"scale" : "1x"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"size" : "76x76",
81+
"scale" : "2x"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"size" : "83.5x83.5",
86+
"scale" : "2x"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"size" : "1024x1024",
91+
"scale" : "1x"
92+
}
93+
],
94+
"info" : {
95+
"version" : 1,
96+
"author" : "xcode"
97+
}
98+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<scenes>
9+
<!--View Controller-->
10+
<scene sceneID="EHf-IW-A2E">
11+
<objects>
12+
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
13+
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
14+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
15+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16+
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
17+
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
18+
</view>
19+
</viewController>
20+
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
21+
</objects>
22+
<point key="canvasLocation" x="53" y="375"/>
23+
</scene>
24+
</scenes>
25+
</document>

Side Menu Example/ContentView.swift

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
//
2+
// ContentView.swift
3+
// Side Menu Example
4+
//
5+
// Created by Josh Hubbard on 1/10/20.
6+
// Copyright © 2020 YeetBox. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
11+
struct MenuContent: View {
12+
var body: some View {
13+
List {
14+
Text("My Profile").onTapGesture {
15+
print("My Profile")
16+
}
17+
Text("Posts").onTapGesture {
18+
print("Posts")
19+
}
20+
Text("Logout").onTapGesture {
21+
print("Logout")
22+
}
23+
}
24+
}
25+
}
26+
27+
struct SideMenu: View {
28+
let width: CGFloat
29+
let isOpen: Bool
30+
let menuClose: () -> Void
31+
32+
var body: some View {
33+
ZStack {
34+
GeometryReader { _ in
35+
EmptyView()
36+
}
37+
.background(Color.gray.opacity(0.3))
38+
.opacity(self.isOpen ? 1.0 : 0.0)
39+
.animation(Animation.easeIn.delay(0.25))
40+
.onTapGesture {
41+
self.menuClose()
42+
}
43+
44+
HStack {
45+
MenuContent()
46+
.frame(width: self.width)
47+
.background(Color.white)
48+
.offset(x: self.isOpen ? 0 : -self.width)
49+
.animation(.default)
50+
51+
Spacer()
52+
}
53+
}
54+
}
55+
}
56+
57+
struct ContentView: View {
58+
@State var menuOpen: Bool = false
59+
60+
var body: some View {
61+
ZStack {
62+
if !self.menuOpen {
63+
Button(action: {
64+
self.openMenu()
65+
}, label: {
66+
Text("Open")
67+
})
68+
}
69+
70+
SideMenu(width: 270,
71+
isOpen: self.menuOpen,
72+
menuClose: self.openMenu)
73+
}
74+
}
75+
76+
func openMenu() {
77+
self.menuOpen.toggle()
78+
}
79+
}
80+
81+
struct ContentView_Previews: PreviewProvider {
82+
static var previews: some View {
83+
ContentView()
84+
}
85+
}

Side Menu Example/Info.plist

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
<key>LSRequiresIPhoneOS</key>
22+
<true/>
23+
<key>UIApplicationSceneManifest</key>
24+
<dict>
25+
<key>UIApplicationSupportsMultipleScenes</key>
26+
<false/>
27+
<key>UISceneConfigurations</key>
28+
<dict>
29+
<key>UIWindowSceneSessionRoleApplication</key>
30+
<array>
31+
<dict>
32+
<key>UISceneConfigurationName</key>
33+
<string>Default Configuration</string>
34+
<key>UISceneDelegateClassName</key>
35+
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
36+
</dict>
37+
</array>
38+
</dict>
39+
</dict>
40+
<key>UILaunchStoryboardName</key>
41+
<string>LaunchScreen</string>
42+
<key>UIRequiredDeviceCapabilities</key>
43+
<array>
44+
<string>armv7</string>
45+
</array>
46+
<key>UISupportedInterfaceOrientations</key>
47+
<array>
48+
<string>UIInterfaceOrientationPortrait</string>
49+
<string>UIInterfaceOrientationLandscapeLeft</string>
50+
<string>UIInterfaceOrientationLandscapeRight</string>
51+
</array>
52+
<key>UISupportedInterfaceOrientations~ipad</key>
53+
<array>
54+
<string>UIInterfaceOrientationPortrait</string>
55+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
56+
<string>UIInterfaceOrientationLandscapeLeft</string>
57+
<string>UIInterfaceOrientationLandscapeRight</string>
58+
</array>
59+
</dict>
60+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

0 commit comments

Comments
 (0)