Skip to content

Commit ad0b637

Browse files
committed
Removed: Cosmos and created custom star view
1 parent 7bcd56f commit ad0b637

File tree

9 files changed

+213
-74
lines changed

9 files changed

+213
-74
lines changed

Podfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ target 'WooCommerce' do
3636
pod 'XLPagerTabStrip', '~> 8.1'
3737
pod 'Charts', '~> 3.2'
3838
pod 'ZendeskSDK', '~> 2.2'
39-
pod 'Cosmos', '~> 17.0'
4039

4140
# Unit Tests
4241
# ==========

Podfile.lock

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ PODS:
1414
- CocoaLumberjack/Default (3.4.2)
1515
- CocoaLumberjack/Extensions (3.4.2):
1616
- CocoaLumberjack/Default
17-
- Cosmos (17.0.0)
1817
- Crashlytics (3.12.0):
1918
- Fabric (~> 1.9.0)
2019
- Fabric (1.9.0)
@@ -82,7 +81,6 @@ DEPENDENCIES:
8281
- Automattic-Tracks-iOS (from `https://github.com/Automattic/Automattic-Tracks-iOS.git`, tag `0.2.4-beta.1`)
8382
- Charts (~> 3.2)
8483
- CocoaLumberjack (~> 3.4)
85-
- Cosmos (~> 17.0)
8684
- Crashlytics (~> 3.10)
8785
- Gridicons (= 0.16)
8886
- KeychainAccess (~> 3.1)
@@ -98,7 +96,6 @@ SPEC REPOS:
9896
- Alamofire
9997
- Charts
10098
- CocoaLumberjack
101-
- Cosmos
10299
- Crashlytics
103100
- Fabric
104101
- FormatterKit
@@ -136,7 +133,6 @@ SPEC CHECKSUMS:
136133
Automattic-Tracks-iOS: 93f967b0ca5d7cba176366847e0f29debc339a04
137134
Charts: f122fb70b19847fa5817d018b77d6c5a2296ab25
138135
CocoaLumberjack: db7cc9e464771f12054c22ff6947c5a58d43a0fd
139-
Cosmos: 309e489f21ffc91a1eeecfebef7f817cd2fcfba6
140136
Crashlytics: 07fb167b1694128c1c9a5a5cc319b0e9c3ca0933
141137
Fabric: f988e33c97f08930a413e08123064d2e5f68d655
142138
FormatterKit: 4b8f29acc9b872d5d12a63efb560661e8f2e1b98
@@ -158,6 +154,6 @@ SPEC CHECKSUMS:
158154
XLPagerTabStrip: 22d4c58200d7c105e0e407ab6bfd01a5d85014be
159155
ZendeskSDK: af6509ad7968d367f95b2645713802712152f879
160156

161-
PODFILE CHECKSUM: d23723ee4dfdfe2f624d8f080d9a5268c03f7a60
157+
PODFILE CHECKSUM: 5e33e9ff7cd5d7ea4c1aad3108fe80ecdca66b38
162158

163159
COCOAPODS: 1.5.3

WooCommerce/Classes/Model/Note+Woo.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,3 @@ private extension Note {
4545
static let emptyStar = "\u{2606}" // Unicode White Star ☆
4646
}
4747
}
48-

WooCommerce/Classes/ViewRelated/Notifications/Cells/NoteDetailsCommentTableViewCell.swift

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Foundation
22
import UIKit
33
import WordPressUI
44
import Gridicons
5-
import Cosmos
65

76

87
// MARK: - NoteDetailsCommentTableViewCell
@@ -37,13 +36,9 @@ class NoteDetailsCommentTableViewCell: UITableViewCell {
3736
///
3837
@IBOutlet private var approvalButton: UIButton!
3938

40-
/// UIView: container view for rating star view
39+
/// Custom UIView: Rating star view
4140
///
42-
@IBOutlet private var starViewContainer: UIView!
43-
44-
/// Star View for reviews
45-
///
46-
private var starView = CosmosView()
41+
@IBOutlet private var starRatingView: RatingView!
4742

4843
/// Closure to be executed whenever the Spam Button is pressed.
4944
///
@@ -146,12 +141,12 @@ class NoteDetailsCommentTableViewCell: UITableViewCell {
146141
var starRating: Int? {
147142
didSet {
148143
guard let starRating = starRating else {
149-
starViewContainer.isHidden = true
144+
starRatingView.isHidden = true
150145
return
151146
}
152147

153-
starView.rating = Double(starRating)
154-
starViewContainer.isHidden = false
148+
starRatingView.rating = CGFloat(starRating)
149+
starRatingView.isHidden = false
155150
}
156151
}
157152

@@ -171,10 +166,6 @@ class NoteDetailsCommentTableViewCell: UITableViewCell {
171166
configureStarView()
172167
configureDefaultAppearance()
173168
}
174-
175-
override public func prepareForReuse() {
176-
starView.prepareForReuse()
177-
}
178169
}
179170

180171

@@ -218,21 +209,9 @@ private extension NoteDetailsCommentTableViewCell {
218209
/// Setup: Star rating view
219210
///
220211
func configureStarView() {
221-
if starViewContainer.subviews.isEmpty {
222-
starView.translatesAutoresizingMaskIntoConstraints = false
223-
starViewContainer.addSubview(starView)
224-
starViewContainer.pinSubviewToAllEdges(starView)
225-
}
226-
227-
starView.accessibilityLabel = NSLocalizedString("Star rating", comment: "VoiceOver accessibility label for a product review star rating ")
228-
starView.settings.updateOnTouch = false
229-
starView.settings.totalStars = Star.totalStars
230-
starView.settings.fillMode = .full
231-
starView.settings.starSize = Star.size
232-
starView.settings.starMargin = Star.margin
233-
starView.settings.filledImage = Star.filledImage
234-
starView.settings.emptyImage = Star.emptyImage
235-
starViewContainer.isHidden = (starRating == nil)
212+
starRatingView.starImage = Star.filledImage
213+
starRatingView.emptyStarImage = Star.emptyImage
214+
starRatingView.isHidden = (starRating == nil)
236215
}
237216

238217
/// Setup: Button Appearance
@@ -315,9 +294,7 @@ private struct Approve {
315294
// MARK: - Star View: Defaults
316295
//
317296
private struct Star {
318-
static let totalStars = 5
319297
static let size = Double(18)
320-
static let margin = Double(2)
321298
static let filledImage = Gridicon.iconOfType(.star, withSize: CGSize(width: Star.size, height: Star.size)).imageWithTintColor(StyleManager.goldStarColor)
322299
static let emptyImage = Gridicon.iconOfType(.star, withSize: CGSize(width: Star.size, height: Star.size)).imageWithTintColor(StyleManager.wooGreyLight)
323300
}

WooCommerce/Classes/ViewRelated/Notifications/Cells/NoteDetailsCommentTableViewCell.xib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
<constraint firstAttribute="height" constant="10" id="qsU-jb-cDi"/>
7474
</constraints>
7575
</view>
76-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1Iy-55-tos">
76+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1Iy-55-tos" customClass="RatingView" customModule="WooCommerce" customModuleProvider="target">
7777
<rect key="frame" x="0.0" y="54" width="284" height="18"/>
7878
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
7979
<constraints>
@@ -150,7 +150,7 @@
150150
<outlet property="detailsLabel" destination="6d4-9R-dcK" id="pCn-M7-He8"/>
151151
<outlet property="gravatarImageView" destination="qcp-iw-3SL" id="e8j-K5-3V4"/>
152152
<outlet property="spamButton" destination="qUJ-uA-W4N" id="Gbe-6K-KhN"/>
153-
<outlet property="starViewContainer" destination="1Iy-55-tos" id="4bq-hc-Gxe"/>
153+
<outlet property="starRatingView" destination="1Iy-55-tos" id="bcq-5i-2Gp"/>
154154
<outlet property="textView" destination="FpQ-yp-a6e" id="qCC-ZC-o7p"/>
155155
<outlet property="titleLabel" destination="MB2-nk-Fuo" id="Rem-KB-lV9"/>
156156
<outlet property="trashButton" destination="6As-Iw-caM" id="x3j-WQ-47t"/>

WooCommerce/Classes/ViewRelated/Notifications/Cells/NoteTableViewCell.swift

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Foundation
22
import UIKit
33
import Gridicons
4-
import Cosmos
54

65

76
// MARK: - NoteTableViewCell
@@ -24,13 +23,9 @@ class NoteTableViewCell: UITableViewCell {
2423
///
2524
@IBOutlet private var snippetLabel: UILabel!
2625

27-
/// UIView: container view for rating star view
26+
/// Custom UIView: Rating star view
2827
///
29-
@IBOutlet private var starViewContainer: UIView!
30-
31-
/// Star View for reviews
32-
///
33-
private var starView = CosmosView()
28+
@IBOutlet private var starRatingView: RatingView!
3429

3530
/// Indicates if the Row should be marked as Read or not.
3631
///
@@ -78,12 +73,12 @@ class NoteTableViewCell: UITableViewCell {
7873
var starRating: Int? {
7974
didSet {
8075
guard let starRating = starRating else {
81-
starViewContainer.isHidden = true
76+
starRatingView.isHidden = true
8277
return
8378
}
8479

85-
starView.rating = Double(starRating)
86-
starViewContainer.isHidden = false
80+
starRatingView.rating = CGFloat(starRating)
81+
starRatingView.isHidden = false
8782
}
8883
}
8984

@@ -107,10 +102,6 @@ class NoteTableViewCell: UITableViewCell {
107102
super.setHighlighted(highlighted, animated: animated)
108103
refreshColors()
109104
}
110-
111-
override public func prepareForReuse() {
112-
starView.prepareForReuse()
113-
}
114105
}
115106

116107

@@ -126,21 +117,10 @@ private extension NoteTableViewCell {
126117
}
127118

128119
func configureStarView() {
129-
if starViewContainer.subviews.isEmpty {
130-
starView.translatesAutoresizingMaskIntoConstraints = false
131-
starViewContainer.addSubview(starView)
132-
starViewContainer.pinSubviewToAllEdges(starView)
133-
}
134-
135-
starView.accessibilityLabel = NSLocalizedString("Star rating", comment: "VoiceOver accessibility label for a product review star rating ")
136-
starView.settings.updateOnTouch = false
137-
starView.settings.fillMode = .full
138-
starView.settings.starSize = Star.size
139-
starView.settings.starMargin = Star.margin
140-
starView.settings.filledImage = Star.filledImage
141-
starView.settings.emptyImage = Star.emptyImage
142-
starViewContainer.isHidden = (starRating == nil)
143-
}
120+
starRatingView.starImage = Star.filledImage
121+
starRatingView.emptyStarImage = Star.emptyImage
122+
starRatingView.isHidden = (starRating == nil)
123+
}
144124
}
145125

146126

@@ -150,7 +130,6 @@ private extension NoteTableViewCell {
150130

151131
enum Star {
152132
static let size = Double(13)
153-
static let margin = Double(0)
154133
static let filledImage = Gridicon.iconOfType(.star, withSize: CGSize(width: Star.size, height: Star.size)).imageWithTintColor(StyleManager.defaultTextColor)
155134
static let emptyImage = Gridicon.iconOfType(.star, withSize: CGSize(width: Star.size, height: Star.size)).imageWithTintColor(.clear)
156135
}

WooCommerce/Classes/ViewRelated/Notifications/Cells/NoteTableViewCell.xib

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<nil key="textColor"/>
4444
<nil key="highlightedColor"/>
4545
</label>
46-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dNq-nY-Zo0">
46+
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dNq-nY-Zo0" customClass="RatingView" customModule="WooCommerce" customModuleProvider="target">
4747
<rect key="frame" x="0.0" y="42.5" width="304" height="14"/>
4848
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
4949
<constraints>
@@ -77,7 +77,7 @@
7777
<outlet property="noticonLabel" destination="MDO-G5-bNl" id="FLd-C3-3oN"/>
7878
<outlet property="sidebarView" destination="UhB-G7-KD0" id="hlK-xQ-KPR"/>
7979
<outlet property="snippetLabel" destination="JQs-0C-rb6" id="Ecy-tm-Fz2"/>
80-
<outlet property="starViewContainer" destination="dNq-nY-Zo0" id="iOP-48-y2e"/>
80+
<outlet property="starRatingView" destination="dNq-nY-Zo0" id="Bo9-lO-30X"/>
8181
<outlet property="subjectLabel" destination="Ow4-CR-HAI" id="AMO-Yd-fmE"/>
8282
</connections>
8383
<point key="canvasLocation" x="240.80000000000001" y="-62.068965517241381"/>

0 commit comments

Comments
 (0)