Show numerical habits

This commit is contained in:
2019-04-02 20:16:00 -05:00
parent 082c575f82
commit 33bae657a3
10 changed files with 63 additions and 21 deletions

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2016-2019 Álinson Santos Xavier <isoron@gmail.com>
*
* This file is part of Loop Habit Tracker.
*
* Loop Habit Tracker is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Loop Habit Tracker is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import UIKit
class AboutScreenController : UITableViewController {
}

View File

@@ -33,7 +33,6 @@ class MainScreenCell : UITableViewCell {
let stack = UIStackView(frame: contentView.frame)
stack.autoresizingMask = [.flexibleWidth, .flexibleHeight]
stack.backgroundColor = .red
stack.axis = .horizontal
stack.distribution = .fill
stack.alignment = .center
@@ -48,7 +47,7 @@ class MainScreenCell : UITableViewCell {
label.heightAnchor.constraint(equalToConstant: size).isActive = true
stack.addArrangedSubview(label)
for _ in 1...3 {
for _ in 1...4 {
let btn = ComponentView(frame: frame, component: nil)
btn.backgroundColor = .white
btn.widthAnchor.constraint(equalToConstant: size).isActive = true
@@ -75,9 +74,17 @@ class MainScreenCell : UITableViewCell {
ring.setNeedsDisplay()
for i in 0..<buttons.count {
buttons[i].component = CheckmarkButton(value: Int32(truncating: values[i]),
color: color,
theme: theme)
if habit.type == .numerical {
buttons[i].component = NumberButton(color: color,
value: Double(truncating: values[i]) / 1000.0,
threshold: habit.target,
units: habit.unit,
theme: theme)
} else {
buttons[i].component = CheckmarkButton(value: Int32(truncating: values[i]),
color: color,
theme: theme)
}
buttons[i].setNeedsDisplay()
}
}
@@ -213,11 +220,13 @@ class MainScreenController: UITableViewController, MainScreenDataSourceListener
alert.addAction(UIAlertAction(title: strings.help, style: .default) {
(action: UIAlertAction) -> Void in
// TODO
if let link = URL(string: "http://loophabits.org/faq") {
UIApplication.shared.open(link)
}
})
alert.addAction(UIAlertAction(title: strings.about, style: .default) {
(action: UIAlertAction) -> Void in
// TODO
self.navigationController?.pushViewController(AboutScreenController(), animated: true)
})
alert.addAction(UIAlertAction(title: strings.cancel, style: .cancel) {
(action: UIAlertAction) -> Void in