diff --git a/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers.xcodeproj/project.pbxproj b/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers.xcodeproj/project.pbxproj index a3c80b1..36f326a 100644 --- a/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers.xcodeproj/project.pbxproj +++ b/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 9A102CEE1CDAA6080026CC43 /* ActionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A102CED1CDAA6080026CC43 /* ActionCell.swift */; }; + 9A102CF01CDB7C0F0026CC43 /* OrdersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A102CEF1CDB7C0F0026CC43 /* OrdersViewController.swift */; }; 9A9C03071CD8F9AC00AE79BD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A9C03061CD8F9AC00AE79BD /* AppDelegate.swift */; }; 9A9C03091CD8F9AC00AE79BD /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A9C03081CD8F9AC00AE79BD /* LoginViewController.swift */; }; 9A9C030C1CD8F9AC00AE79BD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9A9C030A1CD8F9AC00AE79BD /* Main.storyboard */; }; @@ -66,6 +67,7 @@ /* Begin PBXFileReference section */ 9A102CED1CDAA6080026CC43 /* ActionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionCell.swift; sourceTree = "<group>"; }; + 9A102CEF1CDB7C0F0026CC43 /* OrdersViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrdersViewController.swift; sourceTree = "<group>"; }; 9A9C03031CD8F9AC00AE79BD /* Sample App Customers.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Sample App Customers.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 9A9C03061CD8F9AC00AE79BD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 9A9C03081CD8F9AC00AE79BD /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = "<group>"; }; @@ -146,6 +148,7 @@ 9A9C031B1CD8FC6A00AE79BD /* AccountViewController.swift */, 9A9C03081CD8F9AC00AE79BD /* LoginViewController.swift */, 9A9C031D1CD8FD2300AE79BD /* SignupViewController.swift */, + 9A102CEF1CDB7C0F0026CC43 /* OrdersViewController.swift */, ); name = "View Controllers"; sourceTree = "<group>"; @@ -282,6 +285,7 @@ 9A9C03091CD8F9AC00AE79BD /* LoginViewController.swift in Sources */, 9A9C03071CD8F9AC00AE79BD /* AppDelegate.swift in Sources */, 9A9C033B1CD921D700AE79BD /* BUYClient+Extensions.swift in Sources */, + 9A102CF01CDB7C0F0026CC43 /* OrdersViewController.swift in Sources */, 9A102CEE1CDAA6080026CC43 /* ActionCell.swift in Sources */, 9A9C031C1CD8FC6A00AE79BD /* AccountViewController.swift in Sources */, 9A9C031E1CD8FD2300AE79BD /* SignupViewController.swift in Sources */, diff --git a/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers/ActionCell.swift b/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers/ActionCell.swift index a5c0d95..97a79bd 100644 --- a/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers/ActionCell.swift +++ b/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers/ActionCell.swift @@ -2,8 +2,26 @@ // ActionCell.swift // Sample App Customers // -// Created by Dima Bart on 2016-05-04. -// Copyright © 2016 Shopify Inc. All rights reserved. +// Created by Shopify. +// Copyright (c) 2016 Shopify Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. // import UIKit diff --git a/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers/Base.lproj/Main.storyboard b/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers/Base.lproj/Main.storyboard index 4494d0d..1af496b 100644 --- a/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers/Base.lproj/Main.storyboard +++ b/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers/Base.lproj/Main.storyboard @@ -78,6 +78,7 @@ <connections> <outlet property="loginContainerView" destination="KZD-y5-2e3" id="g1r-NW-TfQ"/> <outlet property="signupContainerView" destination="ZAC-pf-9Yj" id="GGw-ff-lV9"/> + <segue destination="gsn-tk-U20" kind="show" id="cw5-XQ-PCc"/> </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="twZ-kb-vHr" userLabel="First Responder" sceneMemberID="firstResponder"/> @@ -215,6 +216,46 @@ </objects> <point key="canvasLocation" x="1227" y="2046"/> </scene> + <!--Orders--> + <scene sceneID="Kny-Kh-xPd"> + <objects> + <viewController id="gsn-tk-U20" customClass="OrdersViewController" customModule="Sample_App_Customers" customModuleProvider="target" sceneMemberID="viewController"> + <layoutGuides> + <viewControllerLayoutGuide type="top" id="A7z-xl-YN2"/> + <viewControllerLayoutGuide type="bottom" id="61m-HD-4Dc"/> + </layoutGuides> + <view key="view" contentMode="scaleToFill" id="nv0-Ew-4s3"> + <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <subviews> + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="0Fn-mj-l5t"> + <rect key="frame" x="0.0" y="0.0" width="600" height="600"/> + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <connections> + <outlet property="dataSource" destination="gsn-tk-U20" id="I04-cV-mh5"/> + <outlet property="delegate" destination="gsn-tk-U20" id="nwo-WG-rYn"/> + </connections> + </tableView> + </subviews> + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> + <constraints> + <constraint firstItem="0Fn-mj-l5t" firstAttribute="top" secondItem="nv0-Ew-4s3" secondAttribute="top" id="Iad-q1-O8p"/> + <constraint firstItem="0Fn-mj-l5t" firstAttribute="leading" secondItem="nv0-Ew-4s3" secondAttribute="leading" id="jEu-Qy-BFt"/> + <constraint firstAttribute="trailing" secondItem="0Fn-mj-l5t" secondAttribute="trailing" id="q11-1O-evS"/> + <constraint firstItem="61m-HD-4Dc" firstAttribute="top" secondItem="0Fn-mj-l5t" secondAttribute="bottom" id="qka-hB-mCa"/> + </constraints> + </view> + <navigationItem key="navigationItem" title="Orders" id="QJf-qx-qvw"> + <barButtonItem key="leftBarButtonItem" title="Logout" id="Iio-Wf-I5q"/> + </navigationItem> + <connections> + <outlet property="tableView" destination="0Fn-mj-l5t" id="ZFj-eI-hKE"/> + </connections> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="lWE-gv-HEA" userLabel="First Responder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="2262" y="1317"/> + </scene> <!--Signup View Controller--> <scene sceneID="Uio-b8-HRq"> <objects> diff --git a/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers/OrdersViewController.swift b/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers/OrdersViewController.swift new file mode 100644 index 0000000..b48eeef --- /dev/null +++ b/Mobile Buy SDK Sample Apps/Sample App Customers/Sample App Customers/OrdersViewController.swift @@ -0,0 +1,55 @@ +// +// OrdersViewController.swift +// Sample App Customers +// +// Created by Shopify. +// Copyright (c) 2016 Shopify Inc. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import UIKit +import Buy + +class OrdersViewController: UIViewController { + + @IBOutlet private weak var tableView: UITableView! + + private var orders = [BUYOrder]() + + // ---------------------------------- + // MARK: - View Loading - + // + override func viewDidLoad() { + super.viewDidLoad() + + self.loadOrders() + } + + private func loadOrders() { + BUYClient.sharedClient.getOrdersForCustomerWithCallback { (orders, error) in + if let orders = orders { + self.orders = orders + self.tableView.reloadData() + } else { + print("Could not fetch orders: \(error)") + } + } + } +}