Skip to content

Commit b8b586f

Browse files
authored
Remove the "delta text" UI section (#455)
The app previously showed a section of numbers below the graph, e.g. (+1 +1 +2). These were from a time when "lanes" and "road" were part of the beeminder vocabulary and were pretty hard to understand, especially for do less goals. We may wish to replace them with a table of what is due when, but for now just remove them. Testing Loaded the app and looked at a goal.
1 parent cf09914 commit b8b586f

File tree

3 files changed

+1
-88
lines changed

3 files changed

+1
-88
lines changed

BeeKit/Goal.swift

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class Goal {
2121
private let datapointValueEpsilon = 0.00000001
2222

2323
public var autodata: String = ""
24-
public var delta_text: String = ""
2524
public var graph_url: String?
2625
public var healthKitMetric: String?
2726
public var id: String = ""
@@ -31,10 +30,7 @@ public class Goal {
3130
public var thumb_url: String?
3231
public var title: String = ""
3332
public var won: NSNumber = 0
34-
public var yaw: NSNumber = 0
35-
public var safebump: NSNumber?
3633
public var safebuf: NSNumber = 0
37-
public var curval: NSNumber?
3834
public var limsum: String?
3935
public var safesum: String?
4036
public var initday: NSNumber?
@@ -80,15 +76,11 @@ public class Goal {
8076

8177
self.queued = json["queued"].bool!
8278
self.yaxis = json["yaxis"].string!
83-
self.delta_text = json["delta_text"].string ?? ""
8479
self.won = json["won"].number!
85-
self.yaw = json["yaw"].number!
8680
self.limsum = json["limsum"].string
8781
self.safesum = json["safesum"].string
8882
self.safebuf = json["safebuf"].number!
8983
self.use_defaults = json["use_defaults"].bool! as NSNumber
90-
self.safebump = json["safebump"].number
91-
self.curval = json["curval"].number
9284
self.pledge = json["pledge"].number!
9385
self.autodata = json["autodata"].string ?? ""
9486

@@ -134,58 +126,6 @@ public class Goal {
134126
if self.autodata.count > 0 { return self.autodata.capitalized }
135127
return nil
136128
}
137-
138-
public var attributedDeltaText :NSAttributedString {
139-
if self.delta_text.count == 0 { return NSAttributedString.init(string: "") }
140-
if self.delta_text.components(separatedBy: "").count == 4 {
141-
if (self.safebump!.doubleValue - self.curval!.doubleValue > 0) {
142-
let attString :NSMutableAttributedString = NSMutableAttributedString(string: String(format: "+ %.2f", self.safebump!.doubleValue - self.curval!.doubleValue))
143-
attString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.beeminder.green, range: NSRange(location: 0, length: attString.string.count))
144-
return attString
145-
}
146-
return NSMutableAttributedString(string: "")
147-
}
148-
var spaceIndices :Array<Int> = [0]
149-
150-
for i in 0...self.delta_text.count - 1 {
151-
if self.delta_text[delta_text.index(delta_text.startIndex, offsetBy: i)] == " " {
152-
spaceIndices.append(i)
153-
}
154-
}
155-
156-
spaceIndices.append(self.delta_text.count)
157-
158-
let attString :NSMutableAttributedString = NSMutableAttributedString(string: self.delta_text)
159-
160-
for i in 0..<spaceIndices.count {
161-
if i + 1 >= spaceIndices.count {
162-
continue
163-
}
164-
var color = self.deltaColors.first
165-
if i < self.deltaColors.count {
166-
color = self.deltaColors[i]
167-
}
168-
attString.addAttribute(NSAttributedString.Key.foregroundColor, value: color as Any, range: NSRange(location: spaceIndices[i], length: spaceIndices[i + 1] - spaceIndices[i]))
169-
}
170-
171-
attString.mutableString.replaceOccurrences(of: "", with: "", options: NSString.CompareOptions.literal, range: NSRange(location: 0, length: attString.string.count))
172-
173-
return attString
174-
}
175-
176-
public var deltaColors: [UIColor] {
177-
// yaw (number): Good side of the road (+1/-1 = above/below)
178-
179-
return self.yaw == 1 ? deltaColorsWhenAboveIsGoodSide : deltaColorsWhenBelowIsGoodSide
180-
}
181-
182-
public var deltaColorsWhenBelowIsGoodSide: [UIColor] {
183-
return [UIColor.beeminder.green, UIColor.beeminder.blue, UIColor.beeminder.orange]
184-
}
185-
186-
public var deltaColorsWhenAboveIsGoodSide: [UIColor] {
187-
return deltaColorsWhenBelowIsGoodSide.reversed()
188-
}
189129

190130
public func hideDataEntry() -> Bool {
191131
return self.isDataProvidedAutomatically || self.won.boolValue

BeeSwift/GoalViewController.swift

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl
3535
fileprivate var goalImageScrollView = UIScrollView()
3636
fileprivate var pollTimer : Timer?
3737
fileprivate var countdownLabel = BSLabel()
38-
fileprivate var deltasLabel = BSLabel()
3938
fileprivate var scrollView = UIScrollView()
4039
fileprivate var submitButton = BSButton()
4140
fileprivate let headerWidth = Double(1.0/3.0)
@@ -116,20 +115,11 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl
116115
}
117116
self.goalImageView.goal = self.goal
118117

119-
self.scrollView.addSubview(self.deltasLabel)
120-
self.deltasLabel.snp.makeConstraints { (make) in
121-
make.top.equalTo(self.goalImageScrollView.snp.bottom)
122-
make.left.right.equalTo(0)
123-
}
124-
self.deltasLabel.font = UIFont.beeminder.defaultBoldFont.withSize(Constants.defaultFontSize)
125-
self.deltasLabel.textAlignment = .center
126-
127-
128118
self.addChild(self.datapointTableController)
129119
self.scrollView.addSubview(self.datapointTableController.view)
130120
self.datapointTableController.delegate = self
131121
self.datapointTableController.view.snp.makeConstraints { (make) -> Void in
132-
make.top.equalTo(self.deltasLabel.snp.bottom).offset(elementSpacing)
122+
make.top.equalTo(self.goalImageScrollView.snp.bottom).offset(elementSpacing)
133123
make.left.equalTo(self.goalImageScrollView).offset(sideMargin)
134124
make.right.equalTo(self.goalImageScrollView).offset(-sideMargin)
135125
}
@@ -320,13 +310,6 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl
320310
updateInterfaceToMatchGoal()
321311
}
322312

323-
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
324-
if (!ServiceLocator.currentUserManager.signedIn()) { return }
325-
if keyPath == "delta_text" || keyPath == "safebump" || keyPath == "safesum" {
326-
self.refreshCountdown()
327-
}
328-
}
329-
330313
override func viewDidAppear(_ animated: Bool) {
331314
super.viewDidAppear(animated)
332315
Task { @MainActor in
@@ -535,7 +518,6 @@ class GoalViewController: UIViewController, UIScrollViewDelegate, DatapointTabl
535518
}
536519

537520
self.refreshCountdown()
538-
self.deltasLabel.attributedText = self.goal!.attributedDeltaText
539521
}
540522

541523
func viewForZooming(in scrollView: UIScrollView) -> UIView? {

BeeSwiftTests/GoalTests.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ final class GoalTests: XCTestCase {
2727
"use_defaults": true,
2828
"id": "737aaa34f0118a330852e4bd",
2929
"queued": false,
30-
"yaw": 1,
3130
"limsum": "100 in 200 days",
3231
"won": false,
33-
"delta_text": "✔ ✔ ✔",
34-
"safebump": 3828,
3532
"safesum": "safe for 200 days",
3633
"lasttouch": "2022-12-07T03:21:40.000Z",
3734
"safebuf": 3583,
@@ -40,7 +37,6 @@ final class GoalTests: XCTestCase {
4037
"hhmmformat": false,
4138
"yaxis": "cumulative total test-goal",
4239
"initday": 1668963600,
43-
"curval": 4000,
4440
"pledge": 0,
4541
"recent_data": [
4642
{
@@ -99,11 +95,8 @@ final class GoalTests: XCTestCase {
9995
XCTAssertEqual(goal.use_defaults, true)
10096
XCTAssertEqual(goal.id, "737aaa34f0118a330852e4bd")
10197
XCTAssertEqual(goal.queued, false)
102-
XCTAssertEqual(goal.yaw, 1)
10398
XCTAssertEqual(goal.limsum, "100 in 200 days")
10499
XCTAssertEqual(goal.won, false)
105-
XCTAssertEqual(goal.delta_text, "✔ ✔ ✔")
106-
XCTAssertEqual(goal.safebump, 3828)
107100
XCTAssertEqual(goal.safesum, "safe for 200 days")
108101
XCTAssertEqual(goal.lasttouch, 1670383300)
109102
XCTAssertEqual(goal.safebuf, 3583)
@@ -112,7 +105,6 @@ final class GoalTests: XCTestCase {
112105
XCTAssertEqual(goal.hhmmformat, false)
113106
XCTAssertEqual(goal.yaxis, "cumulative total test-goal")
114107
XCTAssertEqual(goal.initday, 1668963600)
115-
XCTAssertEqual(goal.curval, 4000)
116108
XCTAssertEqual(goal.pledge, 0)
117109
XCTAssertEqual(goal.recent_data!.count, 5)
118110

@@ -167,7 +159,6 @@ final class GoalTests: XCTestCase {
167159
"yaxis": "cumulative total test-goal",
168160
"won": false,
169161
"safebuf": 1,
170-
"yaw": 1,
171162
"use_defaults": true,
172163
"pledge": 0,
173164
"hhmmformat": false,

0 commit comments

Comments
 (0)