Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ca0ee45
WIP: Dashboard top performers UI
bummytime Sep 11, 2018
817e671
Top Perf: Added section label
bummytime Sep 11, 2018
b5c8cd9
Merge branch 'develop' of github.com:woocommerce/woocommerce-ios into…
bummytime Sep 11, 2018
6dc3cc5
Top Perf: Fixed a spacing issue
bummytime Sep 11, 2018
e7ebf1f
Top Perf: Layout adjustments
bummytime Sep 11, 2018
36c2546
Top Perf: Fixed some constraints
bummytime Sep 11, 2018
87bbb52
Top Perf: Added tab titles
bummytime Sep 11, 2018
80fe903
Merge branch 'develop' of github.com:woocommerce/woocommerce-ios into…
bummytime Sep 12, 2018
df1a40c
Removed superfluous VC from dash storyboard
bummytime Sep 12, 2018
02da5b2
Top Perf section headers
bummytime Sep 12, 2018
7f77f03
Top perf tweaks
bummytime Sep 12, 2018
03d4883
Added ProductTableViewCell
bummytime Sep 13, 2018
c5ef920
WIP: Loading data in top performers
bummytime Sep 13, 2018
49717af
Top Perf: UI updates
bummytime Sep 13, 2018
9bcb8a9
ProductTableViewCell updates
bummytime Sep 13, 2018
038c370
Top Perf: Wired up ResultsController
bummytime Sep 13, 2018
78e9cef
Top Perf: Added formatted price string to table
bummytime Sep 13, 2018
0e43031
Top Perf: Sorting
bummytime Sep 13, 2018
48e675a
Dashboard: resultsController.onDidResetContent imp'ed
bummytime Sep 13, 2018
758166f
Top Perf: Added no results view
bummytime Sep 14, 2018
eed1e62
Merge branch 'develop' of github.com:woocommerce/woocommerce-ios into…
bummytime Sep 14, 2018
b023664
Lint fixes!
bummytime Sep 14, 2018
a1bfc38
Top perf: leave section header in place if table is empty
bummytime Sep 17, 2018
62bc388
Top Perf: doc comment updates
bummytime Sep 17, 2018
d7f9513
Added IntrinsicTableView subclass
bummytime Sep 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Networking/Networking/Model/Stats/TopEarnerStatsItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ extension TopEarnerStatsItem: Comparable {
}

public static func < (lhs: TopEarnerStatsItem, rhs: TopEarnerStatsItem) -> Bool {
return lhs.quantity < rhs.quantity ||
(lhs.quantity == rhs.quantity && lhs.productName < rhs.productName)
return lhs.total < rhs.total ||
(lhs.total == rhs.total && lhs.quantity < rhs.quantity)
}

public static func > (lhs: TopEarnerStatsItem, rhs: TopEarnerStatsItem) -> Bool {
return lhs.total > rhs.total ||
(lhs.total == rhs.total && lhs.quantity > rhs.quantity)
}
}
1 change: 1 addition & 0 deletions WooCommerce/Classes/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ private extension AppDelegate {
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().tintColor = .white
UIApplication.shared.statusBarStyle = .lightContent
UILabel.appearance(whenContainedInInstancesOf: [UITableViewHeaderFooterView.self]).textColor = StyleManager.sectionTitleColor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


// Take advantage of a bug in UIAlertController
// to style all UIAlertControllers with WC color
Expand Down
9 changes: 9 additions & 0 deletions WooCommerce/Classes/Extensions/Array+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ extension Array {
return removeFirst()
}
}

extension Collection {

/// Returns the element at the specified index if it is within bounds, otherwise nil.
///
subscript (safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil
}
}
7 changes: 7 additions & 0 deletions WooCommerce/Classes/Extensions/UIImage+Woo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ extension UIImage {
return Gridicon.iconOfType(.chevronRight).imageWithTintColor(tintColor)!
}

/// Product Placeholder Image
///
static var productPlaceholderImage: UIImage {
let tintColor = StyleManager.wooGreyLight
return Gridicon.iconOfType(.product).imageWithTintColor(tintColor)!
}

/// Gravatar Placeholder Image
///
static var gravatarPlaceholderImage: UIImage {
Expand Down
6 changes: 6 additions & 0 deletions WooCommerce/Classes/Extensions/UILabel+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ extension UILabel {
textColor = StyleManager.defaultTextColor
}

func applySubheadlineStyle() {
adjustsFontForContentSizeCategory = true
font = .subheadline
textColor = StyleManager.defaultTextColor
}

func applyBodyStyle() {
adjustsFontForContentSizeCategory = true
font = .body
Expand Down
27 changes: 27 additions & 0 deletions WooCommerce/Classes/Model/TopEarnerStatsItem+Woo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Foundation
import Yosemite


// MARK: - TopEarnerStatsItem Helper Methods
//
extension TopEarnerStatsItem {

/// Returns the Currency Symbol associated with the current TopEarnerStatsItem.
///
var currencySymbol: String {
guard !currency.isEmpty else {
return ""
}
guard let identifier = Locale.availableIdentifiers.first(where: { Locale(identifier: $0).currencyCode == currency }) else {
return currency
}

return Locale(identifier: identifier).currencySymbol ?? currency
}

/// Returns a friendly-formatted total string including the currency symbol
///
var formattedTotalString: String {
return currencySymbol + total.friendlyString()
}
}
132 changes: 113 additions & 19 deletions WooCommerce/Classes/ViewRelated/Dashboard/Dashboard.storyboard

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class DashboardViewController: UIViewController {

private var storeStatsViewController: StoreStatsViewController!
private var newOrdersViewController: NewOrdersViewController!
private var topPerformersViewController: TopPerformersViewController!

private lazy var refreshControl: UIRefreshControl = {
let refreshControl = UIRefreshControl()
Expand All @@ -37,13 +38,16 @@ class DashboardViewController: UIViewController {
}

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let vc = segue.destination as? StoreStatsViewController, segue.identifier == Constants.storeStatsSegue {
if let vc = segue.destination as? StoreStatsViewController, segue.identifier == Segues.storeStatsSegue {
storeStatsViewController = vc
}
if let vc = segue.destination as? NewOrdersViewController, segue.identifier == Constants.newOrdersSegue {
if let vc = segue.destination as? NewOrdersViewController, segue.identifier == Segues.newOrdersSegue {
newOrdersViewController = vc
newOrdersViewController.delegate = self
}
if let vc = segue.destination as? TopPerformersViewController, segue.identifier == Segues.topPerformersSegue {
topPerformersViewController = vc
}
}
}

Expand Down Expand Up @@ -86,7 +90,7 @@ private extension DashboardViewController {
private extension DashboardViewController {

@objc func settingsTapped() {
performSegue(withIdentifier: Constants.settingsSegue, sender: nil)
performSegue(withIdentifier: Segues.settingsSegue, sender: nil)
}

@objc func pullToRefresh() {
Expand Down Expand Up @@ -116,6 +120,7 @@ private extension DashboardViewController {
DDLogInfo("♻️ Requesting dashboard data be reloaded...")
storeStatsViewController.syncAllStats()
newOrdersViewController.syncNewOrders()
topPerformersViewController.syncTopPerformers()
refreshControl.endRefreshing()
}

Expand Down Expand Up @@ -149,14 +154,18 @@ private extension DashboardViewController {
// MARK: - Constants
//
private extension DashboardViewController {

struct Segues {
static let settingsSegue = "ShowSettingsViewController"
static let storeStatsSegue = "StoreStatsEmbedSegue"
static let newOrdersSegue = "NewOrdersEmbedSegue"
static let topPerformersSegue = "TopPerformersEmbedSegue"
}

struct Constants {
static let settingsSegue = "ShowSettingsViewController"
static let storeStatsSegue = "StoreStatsEmbedSegue"
static let newOrdersSegue = "NewOrdersEmbedSegue"

static let hideAnimationDuration: TimeInterval = 0.25
static let showAnimationDuration: TimeInterval = 0.50
static let showSpringDamping: CGFloat = 0.7
static let showSpringVelocity: CGFloat = 0.0
static let hideAnimationDuration: TimeInterval = 0.25
static let showAnimationDuration: TimeInterval = 0.50
static let showSpringDamping: CGFloat = 0.7
static let showSpringVelocity: CGFloat = 0.0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Foundation
import UIKit


/// Displayed whenever there is no top performer data for a given period (granularity)
///
class NoPeriodDataTableViewCell: UITableViewCell {
@IBOutlet private weak var mainImageView: UIImageView!

/// LegendLabel: To be displayed below the ImageView.
///
@IBOutlet private var legendLabel: UILabel! {
didSet {
legendLabel.applySubheadlineStyle()
legendLabel.text = NSLocalizedString("No activity this period", comment: "Default text for Top Performers section when no data exists for a given period.")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="242" id="qMv-Pb-lgn" customClass="NoPeriodDataTableViewCell" customModule="WooCommerce" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="375" height="242"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="qMv-Pb-lgn" id="gcY-Gg-DvR">
<rect key="frame" x="0.0" y="0.0" width="375" height="241.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="woo-no-store" translatesAutoresizingMaskIntoConstraints="NO" id="uuh-xp-DA5">
<rect key="frame" x="0.0" y="0.0" width="375" height="180"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bPV-bJ-GBz">
<rect key="frame" x="26" y="200.5" width="323" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="bPV-bJ-GBz" firstAttribute="leading" secondItem="gcY-Gg-DvR" secondAttribute="leadingMargin" constant="10" id="02T-fd-amz"/>
<constraint firstAttribute="trailingMargin" secondItem="bPV-bJ-GBz" secondAttribute="trailing" constant="10" id="4v0-dU-uL0"/>
<constraint firstItem="uuh-xp-DA5" firstAttribute="top" secondItem="gcY-Gg-DvR" secondAttribute="top" id="AXH-sZ-i9m"/>
<constraint firstItem="uuh-xp-DA5" firstAttribute="leading" secondItem="gcY-Gg-DvR" secondAttribute="leading" id="QK4-JX-5Z1"/>
<constraint firstItem="bPV-bJ-GBz" firstAttribute="top" relation="greaterThanOrEqual" secondItem="uuh-xp-DA5" secondAttribute="bottom" constant="10" id="YHi-MJ-ZFK"/>
<constraint firstAttribute="bottomMargin" secondItem="bPV-bJ-GBz" secondAttribute="bottom" constant="10" id="Zyf-Uq-D8M"/>
<constraint firstAttribute="trailing" secondItem="uuh-xp-DA5" secondAttribute="trailing" id="egs-Ij-2lL"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="legendLabel" destination="bPV-bJ-GBz" id="VBf-2Q-gkI"/>
<outlet property="mainImageView" destination="uuh-xp-DA5" id="vq3-GZ-F81"/>
</connections>
<point key="canvasLocation" x="-162.5" y="-12"/>
</tableViewCell>
</objects>
<resources>
<image name="woo-no-store" width="320" height="180"/>
</resources>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import UIKit
import Yosemite
import WordPressUI
import Gridicons

class ProductTableViewCell: UITableViewCell {

// MARK: - Properties

@IBOutlet private weak var productImage: UIImageView!
@IBOutlet private var nameLabel: UILabel!
@IBOutlet private var detailLabel: UILabel!
@IBOutlet private var priceLabel: UILabel!

var nameText: String? {
get {
return nameLabel.text
}
set {
nameLabel.text = newValue
}
}

var detailText: String? {
get {
return detailLabel.text
}
set {
detailLabel.text = newValue
}
}

var priceText: String? {
get {
return priceLabel.text
}
set {
priceLabel.text = newValue
}
}

override func awakeFromNib() {
super.awakeFromNib()
nameLabel.applyBodyStyle()
priceLabel.applyBodyStyle()
detailLabel.applyFootnoteStyle()
productImage.contentMode = .scaleAspectFit
}
}

// MARK: - Public Methods
//
extension ProductTableViewCell {
func configure(_ statsItem: TopEarnerStatsItem?) {
nameText = statsItem?.productName
detailText = String.localizedStringWithFormat( NSLocalizedString("Total Product Order: %ld", comment: "Top performers — label for the total number of products ordered"), statsItem?.quantity ?? 0)
priceText = statsItem?.formattedTotalString

if let productURLString = statsItem?.imageUrl {
productImage.downloadImage(from: URL(string: productURLString), placeholderImage: UIImage.productPlaceholderImage)
} else {
productImage.image = .productPlaceholderImage
}
}
}
Loading