Skip to content
This repository was archived by the owner on Dec 27, 2020. It is now read-only.

Commit 86b5bed

Browse files
authored
Merge pull request #4 from spacenation/examples
Examples
2 parents 0e8c927 + 7cc090b commit 86b5bed

File tree

29 files changed

+1992
-4
lines changed

29 files changed

+1992
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import UIKit
2+
3+
@UIApplicationMain
4+
class AppDelegate: UIResponder, UIApplicationDelegate {
5+
6+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
7+
// Override point for customization after application launch.
8+
return true
9+
}
10+
11+
// MARK: UISceneSession Lifecycle
12+
13+
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
14+
// Called when a new scene session is being created.
15+
// Use this method to select a configuration to create the new scene with.
16+
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
17+
}
18+
19+
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
20+
// Called when the user discards a scene session.
21+
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
22+
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
23+
}
24+
25+
26+
}
27+
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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import SwiftUI
2+
3+
struct ContentView: View {
4+
@State private var selection = 0
5+
6+
var body: some View {
7+
TabView(selection: $selection) {
8+
OneColumnLayoutView()
9+
.tabItem {
10+
VStack {
11+
Image(systemName: "rectangle.grid.1x2.fill")
12+
Text("One Column")
13+
}
14+
}
15+
.tag(0)
16+
AutoColumnLayoutView()
17+
.tabItem {
18+
VStack {
19+
Image(systemName: "square.grid.3x2.fill")
20+
Text("Auto Column")
21+
}
22+
}
23+
.tag(1)
24+
PerformanceLayoutView()
25+
.tabItem {
26+
VStack {
27+
Image(systemName: "square.grid.4x3.fill")
28+
Text("Performance")
29+
}
30+
}
31+
.tag(2)
32+
}
33+
.accentColor(.purple)
34+
}
35+
}
36+
37+
#if DEBUG
38+
struct ContentView_Previews: PreviewProvider {
39+
static var previews: some View {
40+
ContentView()
41+
}
42+
}
43+
#endif

Examples/GridExamples iOS/Info.plist

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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>UIStatusBarTintParameters</key>
47+
<dict>
48+
<key>UINavigationBar</key>
49+
<dict>
50+
<key>Style</key>
51+
<string>UIBarStyleDefault</string>
52+
<key>Translucent</key>
53+
<false/>
54+
</dict>
55+
</dict>
56+
<key>UISupportedInterfaceOrientations</key>
57+
<array>
58+
<string>UIInterfaceOrientationPortrait</string>
59+
<string>UIInterfaceOrientationLandscapeLeft</string>
60+
<string>UIInterfaceOrientationLandscapeRight</string>
61+
</array>
62+
<key>UISupportedInterfaceOrientations~ipad</key>
63+
<array>
64+
<string>UIInterfaceOrientationPortrait</string>
65+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
66+
<string>UIInterfaceOrientationLandscapeLeft</string>
67+
<string>UIInterfaceOrientationLandscapeRight</string>
68+
</array>
69+
</dict>
70+
</plist>
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,52 @@
1+
import UIKit
2+
import SwiftUI
3+
4+
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
5+
6+
var window: UIWindow?
7+
8+
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
9+
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
10+
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
11+
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
12+
13+
// Use a UIHostingController as window root view controller
14+
if let windowScene = scene as? UIWindowScene {
15+
let window = UIWindow(windowScene: windowScene)
16+
window.rootViewController = UIHostingController(rootView: ContentView())
17+
self.window = window
18+
window.makeKeyAndVisible()
19+
}
20+
}
21+
22+
func sceneDidDisconnect(_ scene: UIScene) {
23+
// Called as the scene is being released by the system.
24+
// This occurs shortly after the scene enters the background, or when its session is discarded.
25+
// Release any resources associated with this scene that can be re-created the next time the scene connects.
26+
// The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
27+
}
28+
29+
func sceneDidBecomeActive(_ scene: UIScene) {
30+
// Called when the scene has moved from an inactive state to an active state.
31+
// Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
32+
}
33+
34+
func sceneWillResignActive(_ scene: UIScene) {
35+
// Called when the scene will move from an active state to an inactive state.
36+
// This may occur due to temporary interruptions (ex. an incoming phone call).
37+
}
38+
39+
func sceneWillEnterForeground(_ scene: UIScene) {
40+
// Called as the scene transitions from the background to the foreground.
41+
// Use this method to undo the changes made on entering the background.
42+
}
43+
44+
func sceneDidEnterBackground(_ scene: UIScene) {
45+
// Called as the scene transitions from the foreground to the background.
46+
// Use this method to save data, release shared resources, and store enough scene-specific state information
47+
// to restore the scene back to its current state.
48+
}
49+
50+
51+
}
52+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import Cocoa
2+
import SwiftUI
3+
4+
@NSApplicationMain
5+
class AppDelegate: NSObject, NSApplicationDelegate {
6+
7+
var window: NSWindow!
8+
9+
func applicationDidFinishLaunching(_ aNotification: Notification) {
10+
// Insert code here to initialize your application
11+
window = NSWindow(
12+
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
13+
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
14+
backing: .buffered, defer: false)
15+
window.center()
16+
window.setFrameAutosaveName("Main Window")
17+
18+
window.contentView = NSHostingView(rootView: ContentView())
19+
20+
window.makeKeyAndOrderFront(nil)
21+
}
22+
23+
func applicationWillTerminate(_ aNotification: Notification) {
24+
// Insert code here to tear down your application
25+
}
26+
27+
28+
}
29+

0 commit comments

Comments
 (0)