Skip to content

Commit

Permalink
Merge pull request #130 from commercetools/issues/#51-categories
Browse files Browse the repository at this point in the history
Closes #51 Add categories
  • Loading branch information
nikola-mladenovic authored Feb 17, 2017
2 parents 4d0cbc4 + 51008e1 commit 01ae58d
Show file tree
Hide file tree
Showing 47 changed files with 1,008 additions and 165 deletions.
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ platform :ios, '10.0'
use_frameworks!

def common_pods
pod 'Commercetools'
pod 'Commercetools', :git => 'http://github.com/commercetools/commercetools-ios-sdk.git', :branch => 'master'
pod 'ReactiveCocoa'
pod 'ReactiveObjC'
pod 'DZNEmptyDataSet'
Expand All @@ -23,7 +23,7 @@ end

target 'Sunrise Watch Extension' do
platform :watchos, '3.0'
pod 'Commercetools'
pod 'Commercetools', :git => 'http://github.com/commercetools/commercetools-ios-sdk.git', :branch => 'master'
pod 'ReactiveSwift'
pod 'SDWebImage', '4.0.0-beta2'
pod 'NKWatchActivityIndicator'
Expand Down
2 changes: 1 addition & 1 deletion ReservationNotification/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<key>CFBundleVersion</key>
<string>60</string>
<string>61</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
2 changes: 1 addition & 1 deletion Sunrise Watch Extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<key>CFBundleVersion</key>
<string>60</string>
<string>61</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
2 changes: 1 addition & 1 deletion Sunrise Watch/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<key>CFBundleVersion</key>
<string>60</string>
<string>61</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
264 changes: 172 additions & 92 deletions Sunrise.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions Sunrise/Assets.xcassets/Categories/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "category-separator.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "[email protected]",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "category_accessories.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "category_men.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "category_women.jpg",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions Sunrise/Cells/CategoryCell.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//
// Copyright (c) 2016 Commercetools. All rights reserved.
//

import UIKit

class CategoryCell: UITableViewCell {

@IBOutlet weak var categoryName: UILabel!
}
23 changes: 21 additions & 2 deletions Sunrise/Helpers/AppRouting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class AppRouting {
enum TabIndex: Int {
case homeTab = 0
case searchTab
case categoriesTab
case myAccountTab
case cartTab

Expand Down Expand Up @@ -37,6 +38,13 @@ class AppRouting {
return (tabBarController?.viewControllers?[TabIndex.homeTab.index] as? UINavigationController)?.viewControllers.first as? ProductOverviewViewController
}

static var categoryProductOverviewViewController: ProductOverviewViewController? {
if let categoriesNavigationController = tabBarController?.viewControllers?[TabIndex.categoriesTab.index] as? UINavigationController {
return categoriesNavigationController.viewControllers.count > 1 ? categoriesNavigationController.viewControllers[1] as? ProductOverviewViewController : nil
}
return nil
}

/**
In case the user is not logged in, this method presents login view controller from my account tab.
*/
Expand Down Expand Up @@ -136,6 +144,15 @@ class AppRouting {
homeNavigationController.popToRootViewController(animated: false)
}

/**
Pops category navigation controller to it's root view controller.
*/
static func popCategoryToRoot() {
guard let tabBarController = tabBarController, let categoryNavigationController = tabBarController.viewControllers?[TabIndex.categoriesTab.index] as? UINavigationController else { return }

categoryNavigationController.popToRootViewController(animated: false)
}

/**
Switches back to the my account tab, and navigates to the my store view controller.
*/
Expand All @@ -157,8 +174,10 @@ class AppRouting {
guard let tabBarController = tabBarController, let accountNavigationController = tabBarController.viewControllers?[TabIndex.myAccountTab.index] as? UINavigationController,
let accountViewController = accountNavigationController.viewControllers.first as? AccountViewController else { return }

tabBarController.selectedIndex = TabIndex.myAccountTab.index
accountNavigationController.popToRootViewController(animated: false)
accountViewController.viewModel?.presentConfirmationForReservationWithId(reservationId)
tabBarController.selectedIndex = TabIndex.myAccountTab.index
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
accountViewController.viewModel?.presentConfirmationForReservationWithId(reservationId)
}
}
}
2 changes: 1 addition & 1 deletion Sunrise/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>60</string>
<string>61</string>
<key>Displayable attributes</key>
<array>
<string>colorFreeDefinition</string>
Expand Down
6 changes: 3 additions & 3 deletions Sunrise/Models/Attribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ extension Attribute {
case ("money", let rawValue):
return Mapper<Money>().map(JSONObject: rawValue)?.description
case ("date", let rawValue):
if let date = ISO8601DateTransform().transformFromJSON(rawValue) {
if let date = Commercetools.ISO8601DateTransform().transformFromJSON(rawValue) {
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .none
return dateFormatter.string(from: date)
}
return nil
case ("time", let rawValue):
if let date = ISO8601DateTransform().transformFromJSON(rawValue) {
if let date = Commercetools.ISO8601DateTransform().transformFromJSON(rawValue) {
dateFormatter.dateStyle = .none
dateFormatter.timeStyle = .short
return dateFormatter.string(from: date)
}
return nil
case ("datetime", let rawValue):
if let date = ISO8601DateTransform().transformFromJSON(rawValue) {
if let date = Commercetools.ISO8601DateTransform().transformFromJSON(rawValue) {
dateFormatter.dateStyle = .medium
dateFormatter.timeStyle = .short
return dateFormatter.string(from: date)
Expand Down
Loading

0 comments on commit 01ae58d

Please sign in to comment.