Skip to content

Commit fa73e4e

Browse files
Merge pull request #391 from woocommerce/issue/19-notifications-storyboard
Notifications: Standalone Storyboard
2 parents f896928 + 1783c20 commit fa73e4e

File tree

6 files changed

+124
-77
lines changed

6 files changed

+124
-77
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Foundation
2+
import Networking
3+
4+
5+
/// Extension: [Array of NoteBlock Elements]
6+
///
7+
extension Array where Element == Networking.NoteBlock {
8+
9+
/// Returns the first NoteBlock of the given kind.
10+
///
11+
func first(ofKind kind: NoteBlock.Kind) -> NoteBlock? {
12+
return first { $0.kind == kind }
13+
}
14+
}
Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="MVm-eA-hqC">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="MVm-eA-hqC">
33
<device id="retina4_7" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
7-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
8-
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1010
</dependencies>
1111
<scenes>
@@ -23,47 +23,22 @@
2323
<connections>
2424
<segue destination="jeN-XS-2qG" kind="relationship" relationship="viewControllers" id="SC7-CG-XND"/>
2525
<segue destination="eDI-91-edj" kind="relationship" relationship="viewControllers" id="71l-Q1-bEB"/>
26-
<segue destination="rba-5x-dGo" kind="relationship" relationship="viewControllers" id="BbB-sd-RmO"/>
26+
<segue destination="VMd-nd-2gL" kind="relationship" relationship="viewControllers" id="I5c-0D-HBd"/>
2727
</connections>
2828
</tabBarController>
2929
<placeholder placeholderIdentifier="IBFirstResponder" id="nhY-3q-fRh" userLabel="First Responder" sceneMemberID="firstResponder"/>
3030
</objects>
3131
<point key="canvasLocation" x="-724" y="134"/>
3232
</scene>
3333
<!--Notifications-->
34-
<scene sceneID="EJ6-1r-6MA">
34+
<scene sceneID="HkD-nF-E4c">
3535
<objects>
36-
<viewController id="U6u-1O-1OL" userLabel="Notifications" customClass="NotificationsViewController" customModule="WooCommerce" customModuleProvider="target" sceneMemberID="viewController">
37-
<view key="view" contentMode="scaleToFill" id="D1b-1l-L6F">
38-
<rect key="frame" x="0.0" y="0.0" width="375" height="618"/>
39-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
40-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
41-
<viewLayoutGuide key="safeArea" id="Ii7-x3-0Ts"/>
42-
</view>
43-
<navigationItem key="navigationItem" title="Notifications" id="DXK-kQ-5Wi"/>
44-
</viewController>
45-
<placeholder placeholderIdentifier="IBFirstResponder" id="BHQ-gQ-EAs" userLabel="First Responder" sceneMemberID="firstResponder"/>
46-
</objects>
47-
<point key="canvasLocation" x="1558" y="-507"/>
48-
</scene>
49-
<!--Notifications-->
50-
<scene sceneID="43x-Kq-Ktt">
51-
<objects>
52-
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="rba-5x-dGo" sceneMemberID="viewController">
53-
<tabBarItem key="tabBarItem" title="Notifications" id="ptG-a1-GOP"/>
54-
<toolbarItems/>
55-
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="M0j-pN-s2E">
56-
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
57-
<autoresizingMask key="autoresizingMask"/>
58-
</navigationBar>
59-
<nil name="viewControllers"/>
60-
<connections>
61-
<segue destination="U6u-1O-1OL" kind="relationship" relationship="rootViewController" id="Gx7-Me-gA3"/>
62-
</connections>
63-
</navigationController>
64-
<placeholder placeholderIdentifier="IBFirstResponder" id="IXB-cK-n9k" userLabel="First Responder" sceneMemberID="firstResponder"/>
36+
<viewControllerPlaceholder storyboardName="Notifications" id="VMd-nd-2gL" sceneMemberID="viewController">
37+
<tabBarItem key="tabBarItem" title="Item" id="8Hc-T2-dpT"/>
38+
</viewControllerPlaceholder>
39+
<placeholder placeholderIdentifier="IBFirstResponder" id="lNt-Bh-d2U" userLabel="First Responder" sceneMemberID="firstResponder"/>
6540
</objects>
66-
<point key="canvasLocation" x="524.79999999999995" y="-506.44677661169419"/>
41+
<point key="canvasLocation" x="-54" y="133"/>
6742
</scene>
6843
<!--Orders-->
6944
<scene sceneID="LpB-yt-3zf">
@@ -73,7 +48,7 @@
7348
</viewControllerPlaceholder>
7449
<placeholder placeholderIdentifier="IBFirstResponder" id="W3N-OO-li0" userLabel="First Responder" sceneMemberID="firstResponder"/>
7550
</objects>
76-
<point key="canvasLocation" x="109" y="133"/>
51+
<point key="canvasLocation" x="-83" y="-15"/>
7752
</scene>
7853
<!--Dashboard-->
7954
<scene sceneID="jh0-Br-aHk">
@@ -83,7 +58,7 @@
8358
</viewControllerPlaceholder>
8459
<placeholder placeholderIdentifier="IBFirstResponder" id="cFJ-6J-T54" userLabel="First Responder" sceneMemberID="firstResponder"/>
8560
</objects>
86-
<point key="canvasLocation" x="-725" y="630"/>
61+
<point key="canvasLocation" x="-64" y="-154"/>
8762
</scene>
8863
</scenes>
8964
</document>

WooCommerce/Classes/ViewRelated/MainTabBarController.swift

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Yosemite
55

66
/// Enum representing the individual tabs
77
///
8-
enum WooTab: Int, CustomStringConvertible {
8+
enum WooTab: Int {
99

1010
/// My Store Tab
1111
///
@@ -18,28 +18,6 @@ enum WooTab: Int, CustomStringConvertible {
1818
/// Notifications Tab
1919
///
2020
case notifications = 2
21-
22-
var description: String {
23-
switch self {
24-
case .myStore:
25-
return NSLocalizedString("My store", comment: "My store tab title")
26-
case .orders:
27-
return NSLocalizedString("Orders", comment: "Orders tab title")
28-
case .notifications:
29-
return NSLocalizedString("Notifications", comment: "Notifications tab title")
30-
}
31-
}
32-
33-
var tabIcon: UIImage {
34-
switch self {
35-
case .myStore:
36-
return Gridicon.iconOfType(.statsAlt)
37-
case .orders:
38-
return Gridicon.iconOfType(.pages)
39-
case .notifications:
40-
return Gridicon.iconOfType(.bell)
41-
}
42-
}
4321
}
4422

4523

@@ -62,24 +40,9 @@ class MainTabBarController: UITabBarController {
6240

6341
override func viewDidLoad() {
6442
super.viewDidLoad()
65-
setupTabBar()
6643
setNeedsStatusBarAppearanceUpdate() // call this to refresh status bar changes happening at runtime
6744
}
6845

69-
private func setupTabBar() {
70-
guard let items = tabBar.items else {
71-
fatalError()
72-
}
73-
74-
for (index, item) in items.enumerated() {
75-
guard let tab = WooTab(rawValue: index) else {
76-
fatalError()
77-
}
78-
item.title = tab.description
79-
item.image = tab.tabIcon
80-
}
81-
}
82-
8346
override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
8447
guard let currentlySelectedTab = WooTab(rawValue: selectedIndex),
8548
let userSelectedIndex = tabBar.items?.index(of: item),
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="611-pP-eI3">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
6+
<dependencies>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
9+
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
10+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
11+
</dependencies>
12+
<scenes>
13+
<!--Notifications-->
14+
<scene sceneID="47z-8R-JgL">
15+
<objects>
16+
<viewController id="twY-WG-a6J" userLabel="Notifications" customClass="NotificationsViewController" customModule="WooCommerce" customModuleProvider="target" sceneMemberID="viewController">
17+
<view key="view" contentMode="scaleToFill" id="FHu-UQ-IDk">
18+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
19+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
20+
<subviews>
21+
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="Xeu-Xa-kge">
22+
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
23+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
24+
</tableView>
25+
</subviews>
26+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
27+
<constraints>
28+
<constraint firstItem="Xeu-Xa-kge" firstAttribute="top" secondItem="mdw-WF-tPO" secondAttribute="top" id="B1t-gb-3Xh"/>
29+
<constraint firstItem="mdw-WF-tPO" firstAttribute="bottom" secondItem="Xeu-Xa-kge" secondAttribute="bottom" id="KfG-Zw-aVH"/>
30+
<constraint firstItem="Xeu-Xa-kge" firstAttribute="leading" secondItem="mdw-WF-tPO" secondAttribute="leading" id="ROB-ft-nxo"/>
31+
<constraint firstItem="mdw-WF-tPO" firstAttribute="trailing" secondItem="Xeu-Xa-kge" secondAttribute="trailing" id="YfA-Gf-FIr"/>
32+
</constraints>
33+
<viewLayoutGuide key="safeArea" id="mdw-WF-tPO"/>
34+
</view>
35+
<navigationItem key="navigationItem" title="Notifications" id="V9G-Sx-xMy"/>
36+
<connections>
37+
<outlet property="tableView" destination="Xeu-Xa-kge" id="Gy0-KZ-BM3"/>
38+
</connections>
39+
</viewController>
40+
<placeholder placeholderIdentifier="IBFirstResponder" id="lEp-4f-Ifi" userLabel="First Responder" sceneMemberID="firstResponder"/>
41+
</objects>
42+
<point key="canvasLocation" x="1558" y="-507"/>
43+
</scene>
44+
<!--Notifications-->
45+
<scene sceneID="wER-bJ-hJ2">
46+
<objects>
47+
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="611-pP-eI3" sceneMemberID="viewController">
48+
<tabBarItem key="tabBarItem" title="Notifications" id="lf4-mx-07a"/>
49+
<toolbarItems/>
50+
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Zqq-ZI-omZ">
51+
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
52+
<autoresizingMask key="autoresizingMask"/>
53+
</navigationBar>
54+
<nil name="viewControllers"/>
55+
<connections>
56+
<segue destination="twY-WG-a6J" kind="relationship" relationship="rootViewController" id="oac-UY-TmU"/>
57+
</connections>
58+
</navigationController>
59+
<placeholder placeholderIdentifier="IBFirstResponder" id="shI-NL-zqW" userLabel="First Responder" sceneMemberID="firstResponder"/>
60+
</objects>
61+
<point key="canvasLocation" x="524.79999999999995" y="-506.44677661169419"/>
62+
</scene>
63+
</scenes>
64+
</document>

WooCommerce/Classes/ViewRelated/NotificationsViewController.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
11
import UIKit
2+
import Gridicons
23

34

45
// MARK: - NotificationsViewController
56
//
67
class NotificationsViewController: UIViewController {
78

9+
/// Main TableView.
10+
///
11+
@IBOutlet private var tableView: UITableView!
12+
13+
814
// MARK: - View Lifecycle
915

16+
required init?(coder aDecoder: NSCoder) {
17+
super.init(coder: aDecoder)
18+
setupTabBarItem()
19+
}
20+
1021
override func viewDidLoad() {
1122
super.viewDidLoad()
1223
view.backgroundColor = StyleManager.tableViewBackgroundColor
1324

1425
displayPlaceholder()
1526
}
1627

17-
override func viewDidAppear(_ animated: Bool) {
18-
super.viewDidAppear(animated)
28+
29+
/// Setup: TabBar
30+
///
31+
func setupTabBarItem() {
32+
tabBarItem.title = NSLocalizedString("Notifications", comment: "Notifications tab title")
33+
tabBarItem.image = Gridicon.iconOfType(.statsAlt)
1934
}
2035

2136
/// Displays the Empty State Overlay.

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@
9696
B58B4AB62108F11C00076FDD /* Notice.swift in Sources */ = {isa = PBXBuildFile; fileRef = B58B4AB52108F11C00076FDD /* Notice.swift */; };
9797
B58B4AB82108F14700076FDD /* NoticeNotificationInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = B58B4AB72108F14700076FDD /* NoticeNotificationInfo.swift */; };
9898
B58B4AC02108FF6100076FDD /* Array+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = B58B4ABF2108FF6100076FDD /* Array+Helpers.swift */; };
99+
B59C09D92188CBB100AB41D6 /* Array+Notes.swift in Sources */ = {isa = PBXBuildFile; fileRef = B59C09D82188CBB100AB41D6 /* Array+Notes.swift */; };
100+
B59C09DC2188D70200AB41D6 /* Notifications.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B59C09DB2188D70200AB41D6 /* Notifications.storyboard */; };
99101
B5A0369B214C0E8500774E2C /* CocoaLumberjack.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5A0369A214C0E8500774E2C /* CocoaLumberjack.swift */; };
100102
B5A82EE221025C450053ADC8 /* FulfillViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5A82EE121025C450053ADC8 /* FulfillViewController.swift */; };
101103
B5A82EE521025E550053ADC8 /* FulfillViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B5A82EE421025E550053ADC8 /* FulfillViewController.xib */; };
@@ -309,6 +311,8 @@
309311
B58B4AB72108F14700076FDD /* NoticeNotificationInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeNotificationInfo.swift; sourceTree = "<group>"; };
310312
B58B4ABF2108FF6100076FDD /* Array+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+Helpers.swift"; sourceTree = "<group>"; };
311313
B597D0BE212476E100577E35 /* ARCHITECTURE.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = ARCHITECTURE.md; path = ../ARCHITECTURE.md; sourceTree = "<group>"; };
314+
B59C09D82188CBB100AB41D6 /* Array+Notes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Array+Notes.swift"; sourceTree = "<group>"; };
315+
B59C09DB2188D70200AB41D6 /* Notifications.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Notifications.storyboard; sourceTree = "<group>"; };
312316
B59F38E020D40A24008C1829 /* WooCommerce.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = WooCommerce.entitlements; sourceTree = "<group>"; };
313317
B5A0369A214C0E8500774E2C /* CocoaLumberjack.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CocoaLumberjack.swift; sourceTree = "<group>"; };
314318
B5A82EE121025C450053ADC8 /* FulfillViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FulfillViewController.swift; sourceTree = "<group>"; };
@@ -600,6 +604,7 @@
600604
CED6021A20B35FBF0032C639 /* ReusableViews */,
601605
CE85FD5120F677460080B73E /* Dashboard */,
602606
CE1CCB4920570B05000EE3AC /* Orders */,
607+
B59C09DA2188D6E800AB41D6 /* Notifications */,
603608
B56DB3CD2049BFAA00D4AA8E /* Main.storyboard */,
604609
CE263DE5206ACD220015A693 /* NotificationsViewController.swift */,
605610
CE263DE7206ACE3E0015A693 /* MainTabBarController.swift */,
@@ -671,6 +676,14 @@
671676
path = Notices;
672677
sourceTree = "<group>";
673678
};
679+
B59C09DA2188D6E800AB41D6 /* Notifications */ = {
680+
isa = PBXGroup;
681+
children = (
682+
B59C09DB2188D70200AB41D6 /* Notifications.storyboard */,
683+
);
684+
path = Notifications;
685+
sourceTree = "<group>";
686+
};
674687
B5A03699214C0E7000774E2C /* Logging */ = {
675688
isa = PBXGroup;
676689
children = (
@@ -765,6 +778,7 @@
765778
isa = PBXGroup;
766779
children = (
767780
B58B4ABF2108FF6100076FDD /* Array+Helpers.swift */,
781+
B59C09D82188CBB100AB41D6 /* Array+Notes.swift */,
768782
CE4296B820A5E9E400B2AFBD /* CNContact+Helpers.swift */,
769783
CE4DDB7A20DD312400D32EC8 /* Date+Helpers.swift */,
770784
748C7781211E294000814F2C /* Double+Woo.swift */,
@@ -1026,6 +1040,7 @@
10261040
CEE005F62076C4040079161F /* Orders.storyboard in Resources */,
10271041
CE85FD5C20F7A7740080B73E /* SettingsFooterView.xib in Resources */,
10281042
B57C744C20F564B400EEFC87 /* EmptyStoresTableViewCell.xib in Resources */,
1043+
B59C09DC2188D70200AB41D6 /* Notifications.storyboard in Resources */,
10291044
CE855367209BA6A700938BDC /* ShowHideSectionFooter.xib in Resources */,
10301045
CE1EC8F020B8A408009762BF /* OrderNoteTableViewCell.xib in Resources */,
10311046
B55D4BFD20B5CDE700D7A50F /* replace_secrets.rb in Resources */,
@@ -1249,6 +1264,7 @@
12491264
CE583A0421076C0100D73C1C /* AddANoteViewController.swift in Sources */,
12501265
B58B4AC02108FF6100076FDD /* Array+Helpers.swift in Sources */,
12511266
748C7780211E18A600814F2C /* OrderStats+Woo.swift in Sources */,
1267+
B59C09D92188CBB100AB41D6 /* Array+Notes.swift in Sources */,
12521268
CE4DDB7B20DD312400D32EC8 /* Date+Helpers.swift in Sources */,
12531269
B50911322049E27A007D25DC /* SettingsViewController.swift in Sources */,
12541270
B5E96B3821137AA100DF68D0 /* OrderStatus+Woo.swift in Sources */,

0 commit comments

Comments
 (0)