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

View File

@@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
006EFE4C2252E9F3008464E0 /* IosLocaleTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006EFE4A2252E9D3008464E0 /* IosLocaleTest.swift */; };
006EFE4E2252EA2B008464E0 /* IosLocale.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006EFE4D2252EA2B008464E0 /* IosLocale.swift */; };
006EFE50225432B8008464E0 /* AboutScreenController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006EFE4F225432B8008464E0 /* AboutScreenController.swift */; };
00A5B42822009F590024E00C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00A5B42722009F590024E00C /* AppDelegate.swift */; };
00A5B42A22009F590024E00C /* MainScreenController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00A5B42922009F590024E00C /* MainScreenController.swift */; };
00A5B42F22009F5A0024E00C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 00A5B42E22009F5A0024E00C /* Assets.xcassets */; };
@@ -59,6 +60,7 @@
/* Begin PBXFileReference section */
006EFE4A2252E9D3008464E0 /* IosLocaleTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IosLocaleTest.swift; sourceTree = "<group>"; };
006EFE4D2252EA2B008464E0 /* IosLocale.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IosLocale.swift; sourceTree = "<group>"; };
006EFE4F225432B8008464E0 /* AboutScreenController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutScreenController.swift; sourceTree = "<group>"; };
00A5B42422009F590024E00C /* uhabits.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = uhabits.app; sourceTree = BUILT_PRODUCTS_DIR; };
00A5B42722009F590024E00C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
00A5B42922009F590024E00C /* MainScreenController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainScreenController.swift; sourceTree = "<group>"; };
@@ -108,9 +110,10 @@
006EFE49224FF41B008464E0 /* Frontend */ = {
isa = PBXGroup;
children = (
006EFE4F225432B8008464E0 /* AboutScreenController.swift */,
00C0C6DE224A35FC003D8AF0 /* DetailScreenController.swift */,
00D48BD22200AC1600CC4527 /* EditHabitController.swift */,
00A5B42922009F590024E00C /* MainScreenController.swift */,
00C0C6DE224A35FC003D8AF0 /* DetailScreenController.swift */,
);
path = Frontend;
sourceTree = "<group>";
@@ -338,6 +341,7 @@
00A5B42A22009F590024E00C /* MainScreenController.swift in Sources */,
00A5B42822009F590024E00C /* AppDelegate.swift in Sources */,
00D48BD32200AC1600CC4527 /* EditHabitController.swift in Sources */,
006EFE50225432B8008464E0 /* AboutScreenController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};