Skip to content

Commit 2aa979e

Browse files
author
Anton Poltoratskyi
committed
Implemented default example
1 parent a5cbd0d commit 2aa979e

File tree

5 files changed

+75
-18
lines changed

5 files changed

+75
-18
lines changed

Example/NativeUIExample/AppDelegate.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import UIKit
1111
@UIApplicationMain
1212
class AppDelegate: UIResponder, UIApplicationDelegate {
1313

14+
var window: UIWindow?
15+
1416
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1517
return true
1618
}
Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,53 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16096" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
3+
<device id="retina6_1" orientation="portrait" appearance="light"/>
34
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
5+
<deployment identifier="iOS"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16086"/>
57
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
68
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
79
</dependencies>
810
<scenes>
911
<!--View Controller-->
1012
<scene sceneID="tne-QT-ifu">
1113
<objects>
12-
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
14+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="NativeUIExample" customModuleProvider="target" sceneMemberID="viewController">
1315
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
14-
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
16+
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
1517
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
16-
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
18+
<subviews>
19+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ebP-Rj-pI3">
20+
<rect key="frame" x="169.5" y="433" width="75" height="30"/>
21+
<state key="normal" title="Show Alert"/>
22+
<connections>
23+
<action selector="showAlert" destination="BYZ-38-t0r" eventType="touchUpInside" id="uNp-2Y-5hB"/>
24+
</connections>
25+
</button>
26+
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="a8V-ju-ofH">
27+
<rect key="frame" x="24" y="94" width="366" height="32"/>
28+
<segments>
29+
<segment title="Default"/>
30+
<segment title="Custom Content"/>
31+
</segments>
32+
</segmentedControl>
33+
</subviews>
34+
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
35+
<constraints>
36+
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="a8V-ju-ofH" secondAttribute="trailing" constant="24" id="3kK-iL-GqD"/>
37+
<constraint firstItem="a8V-ju-ofH" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="50" id="CI3-gI-RbR"/>
38+
<constraint firstItem="ebP-Rj-pI3" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="h6u-16-ezP"/>
39+
<constraint firstItem="a8V-ju-ofH" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="24" id="qx7-Ep-2Nj"/>
40+
<constraint firstItem="ebP-Rj-pI3" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="zfF-6b-mHv"/>
41+
</constraints>
1742
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
1843
</view>
44+
<connections>
45+
<outlet property="segmentedControl" destination="a8V-ju-ofH" id="0pJ-nW-t1E"/>
46+
</connections>
1947
</viewController>
2048
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
2149
</objects>
50+
<point key="canvasLocation" x="139" y="138"/>
2251
</scene>
2352
</scenes>
2453
</document>

Example/NativeUIExample/ViewController.swift

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,34 @@
99
import UIKit
1010
import NativeUI
1111

12-
class ViewController: UIViewController {
13-
14-
override func viewDidLoad() {
15-
super.viewDidLoad()
16-
// Do any additional setup after loading the view.
12+
final class ViewController: UIViewController {
13+
14+
enum Appearance: Int {
15+
case `default` = 0
16+
case custom = 1
17+
}
18+
19+
@IBOutlet private var segmentedControl: UISegmentedControl!
20+
21+
@IBAction private func showAlert() {
22+
guard let appearance = Appearance(rawValue: segmentedControl.selectedSegmentIndex) else {
23+
return
24+
}
25+
switch appearance {
26+
case .default:
27+
let cancelAction = Alert.Action(title: "Cancel", style: .primary)
28+
let confirmAction = Alert.Action(title: "Confirm", style: .default)
29+
30+
let viewModel = Alert(
31+
title: "Your Title",
32+
message: "Your Message",
33+
actions: [cancelAction, confirmAction]
34+
)
35+
let alert = AlertViewController(viewModel: viewModel)
36+
present(alert, animated: true)
37+
38+
case .custom:
39+
break
40+
}
1741
}
1842
}

Example/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ platform :ios, '9.0'
33
target 'NativeUIExample' do
44
use_frameworks!
55

6-
pod 'NativeUI', :path => '../'
6+
pod 'NativeUI/Alert', '0.0.3'
77
end

Example/Podfile.lock

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
PODS:
2-
- NativeUI (0.0.1)
2+
- NativeUI/Alert (0.0.3):
3+
- NativeUI/Utils
4+
- NativeUI/Utils (0.0.3)
35

46
DEPENDENCIES:
5-
- NativeUI (from `../`)
7+
- NativeUI/Alert (= 0.0.3)
68

7-
EXTERNAL SOURCES:
8-
NativeUI:
9-
:path: "../"
9+
SPEC REPOS:
10+
trunk:
11+
- NativeUI
1012

1113
SPEC CHECKSUMS:
12-
NativeUI: 6eb610f100367634295be050ee96822db4ea235a
14+
NativeUI: d89eeb004dd445bb67bef1579be654edffdd7a2e
1315

14-
PODFILE CHECKSUM: bb46d7bf1ae3b119e00a9331a12cd0a4b5cac170
16+
PODFILE CHECKSUM: fbc3d68420579929484e8e2c80001a8e9fd72d90
1517

1618
COCOAPODS: 1.9.1

0 commit comments

Comments
 (0)