1
1
import Gridicons
2
+ import UIKit
2
3
3
4
class QuickStartChecklistCell : UITableViewCell {
4
5
@IBOutlet private var titleLabel : UILabel ! {
@@ -31,60 +32,20 @@ class QuickStartChecklistCell: UITableViewCell {
31
32
return WPDeviceIdentification . isiPhone ( ) ? contentView. trailingAnchor : contentView. readableContentGuide. trailingAnchor
32
33
}
33
34
34
- public var completed = false {
35
- didSet {
36
- if completed {
37
- guard let titleText = tour? . title else {
38
- return
39
- }
40
-
41
- titleLabel. attributedText = NSAttributedString ( string: titleText,
42
- attributes: [ . strikethroughStyle: 1 ,
43
- . foregroundColor: UIColor . neutral ( . shade30) ] )
44
- // Overrides the existing accessibility hint in the tour property observer,
45
- // because users don't need the hint repeated to them after a task is completed.
46
- accessibilityHint = nil
47
- accessibilityLabel = tour? . titleMarkedCompleted
48
- descriptionLabel. textColor = . neutral( . shade30)
49
- iconView? . tintColor = . neutral( . shade30)
50
- } else {
51
- titleLabel. textColor = . text
52
- descriptionLabel. textColor = . textSubtle
53
- iconView? . tintColor = . listIcon
54
- }
55
- }
56
- }
57
- public var tour : QuickStartTour ? {
58
- didSet {
59
- titleLabel. text = tour? . title
60
- descriptionLabel. text = tour? . description
61
- iconView? . image = tour? . icon. withRenderingMode ( . alwaysTemplate)
62
-
63
- if let hint = tour? . accessibilityHintText, !hint. isEmpty {
64
- accessibilityHint = hint
65
- }
66
- }
67
- }
68
-
69
- public var lastRow : Bool = false {
70
- didSet {
71
- bottomStrokeLeading? . isActive = !lastRow
72
- }
73
- }
74
-
75
- public var topSeparatorIsHidden : Bool = false {
76
- didSet {
77
- topSeparator? . isHidden = topSeparatorIsHidden
78
- }
79
- }
80
-
81
-
82
35
override func awakeFromNib( ) {
83
36
super. awakeFromNib ( )
84
37
contentView. backgroundColor = . listForeground
85
38
setupConstraints ( )
86
39
}
87
40
41
+ func configure( tour: QuickStartTour , completed: Bool , topSeparatorIsHidden: Bool , lastRow: Bool ) {
42
+ setupColors ( completed: completed)
43
+ setupTitle ( tour: tour, completed: completed)
44
+ setupContent ( tour: tour)
45
+ setupAccessibility ( tour: tour, completed: completed)
46
+ setupSeperators ( topSeparatorIsHidden: topSeparatorIsHidden, lastRow: lastRow)
47
+ }
48
+
88
49
static let reuseIdentifier = " QuickStartChecklistCell "
89
50
}
90
51
@@ -104,4 +65,46 @@ private extension QuickStartChecklistCell {
104
65
topSeparator. leadingAnchor. constraint ( equalTo: contentViewLeadingAnchor) . isActive = true
105
66
topSeparator. trailingAnchor. constraint ( equalTo: contentViewTrailingAnchor) . isActive = true
106
67
}
68
+
69
+ func setupTitle( tour: QuickStartTour , completed: Bool ) {
70
+ let strikeThroughStyle = completed ? 1 : 0
71
+ let titleColor : UIColor = completed ? . neutral( . shade30) : . text
72
+ titleLabel. attributedText = NSAttributedString ( string: tour. title,
73
+ attributes: [ . strikethroughStyle: strikeThroughStyle,
74
+ . foregroundColor: titleColor] )
75
+ }
76
+
77
+ func setupAccessibility( tour: QuickStartTour , completed: Bool ) {
78
+ if completed {
79
+ // Overrides the existing accessibility hint in the tour property observer,
80
+ // because users don't need the hint repeated to them after a task is completed.
81
+ accessibilityHint = nil
82
+ accessibilityLabel = tour. titleMarkedCompleted
83
+ } else {
84
+ let hint = tour. accessibilityHintText
85
+ if !hint. isEmpty {
86
+ accessibilityHint = hint
87
+ }
88
+ }
89
+ }
90
+
91
+ func setupColors( completed: Bool ) {
92
+ if completed {
93
+ descriptionLabel. textColor = . neutral( . shade30)
94
+ iconView? . tintColor = . neutral( . shade30)
95
+ } else {
96
+ descriptionLabel. textColor = . textSubtle
97
+ iconView? . tintColor = . listIcon
98
+ }
99
+ }
100
+
101
+ func setupContent( tour: QuickStartTour ) {
102
+ descriptionLabel. text = tour. description
103
+ iconView? . image = tour. icon. withRenderingMode ( . alwaysTemplate)
104
+ }
105
+
106
+ func setupSeperators( topSeparatorIsHidden: Bool , lastRow: Bool ) {
107
+ bottomStrokeLeading? . isActive = !lastRow
108
+ topSeparator? . isHidden = topSeparatorIsHidden
109
+ }
107
110
}
0 commit comments