Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3 #37

Merged
merged 69 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
35e9f97
update .gitignore
marc-medley Sep 18, 2019
a6494ae
cleanup: removed .DS_Store
marc-medley Sep 18, 2019
7d65aae
Core DailyDozen updated for Swift 5. Dropped UICheckbox (~3yr out-of-…
marc-medley Sep 21, 2019
8ea29ee
Delete .DS_Store
marc-medley Sep 25, 2019
a1b7e90
Delete .DS_Store
marc-medley Sep 25, 2019
1ce4d7f
Delete .DS_Store
marc-medley Sep 26, 2019
7486583
Delete .DS_Store
marc-medley Sep 26, 2019
79cb0fe
Delete .DS_Store
marc-medley Sep 26, 2019
4ecd632
Delete .DS_Store
marc-medley Sep 26, 2019
98d6990
Delete .DS_Store
marc-medley Sep 26, 2019
d643ab9
Delete .DS_Store
marc-medley Sep 26, 2019
6739afd
basic native checkbox button in place. now compiles & runs with Xcode…
marc-medley Sep 26, 2019
47d1847
Merge branch 'version_3' of github.com:nutritionfactsorg/daily-dozen-…
marc-medley Sep 26, 2019
a720e4f
Delete .DS_Store
marc-medley Sep 26, 2019
f805704
v2.1 update.
marc-medley Oct 18, 2019
58e7286
toggled imperial/metric is now saved. solves GH issue #25
marc-medley Oct 22, 2019
4ea1c38
DB schema refactor snapshot. replaces random key with derived non-ran…
marc-medley Nov 20, 2019
8a8916c
DailyTracker passes basic write/read unit test.
marc-medley Nov 21, 2019
48bfa5b
Passes unit test: legacy DB CSV export > CSV import > CSV export > CS…
marc-medley Nov 24, 2019
d8852c0
added code coverage target. set legacy func names for clarity.
marc-medley Nov 26, 2019
1873277
updated Servings image assets.
marc-medley Nov 27, 2019
0594aae
initial integration of new database with UI.
marc-medley Nov 28, 2019
206c077
layout checkpoint
marc-medley Dec 6, 2019
2ff0964
small image assets.
marc-medley Dec 6, 2019
1040114
Test Daily Dozen + 21 Tweets
marc-medley Dec 6, 2019
88ae783
Test version.
marc-medley Dec 7, 2019
53edc33
opt out of dark mode via info.plist
marc-medley Dec 8, 2019
30393f6
weight
marc-medley Dec 8, 2019
0ff0ed2
Weight History Chart baseline.
marc-medley Dec 9, 2019
38497d4
health manager
marc-medley Dec 9, 2019
4669627
test snapshot 3.0.0 (2)
marc-medley Dec 9, 2019
8fa344f
fix app icon filenames
marc-medley Dec 9, 2019
8b8ff92
added assets for 21 Tweaks
marc-medley Dec 10, 2019
a60f99e
weight: database read write
marc-medley Dec 10, 2019
61db7c1
clear weight fields
marc-medley Dec 10, 2019
fee3e0a
realm delete weight entry
marc-medley Dec 10, 2019
f46c8bd
DataWeightRecord timeAmPm datetime
marc-medley Dec 10, 2019
09236df
fix initial picker registration
marc-medley Dec 10, 2019
d26f99c
first launch. weight plot update.
marc-medley Dec 10, 2019
61e8d30
weight plot scale
marc-medley Dec 10, 2019
35d3f3f
weight chart x-axis range
marc-medley Dec 10, 2019
7c84162
weight plot reporting completed for date navigation
marc-medley Dec 11, 2019
8740ef6
healthkit read connection for data from scales.
marc-medley Dec 11, 2019
88c3378
minor comment cleanup
marc-medley Dec 11, 2019
c52d92b
build 4
marc-medley Dec 11, 2019
252205e
21 Tweaks show/hide prelim snapshot.
marc-medley Dec 15, 2019
0ebc633
21 Tweaks show/hide prelim snapshot (checkpoint)
marc-medley Dec 15, 2019
3dce526
21 Tweaks show/hide merge snapshot (checkpoint)
marc-medley Dec 15, 2019
d91522d
21 Tweaks show/hide merge snapshot (checkpoint #2)
marc-medley Dec 15, 2019
486b4df
3.1.0-test-01
marc-medley Dec 15, 2019
f6f5321
set build version v3.1.0 (1)
marc-medley Dec 15, 2019
72ae388
fixes About presentation. Fixes Settings background highlights.
marc-medley Dec 15, 2019
a2723b0
verision 3.1.0 (4)
marc-medley Dec 16, 2019
dff82f8
fix "Sizes" section header "Units:" alignment
marc-medley Dec 16, 2019
66f611b
corrected nav title color. added brand color.
marc-medley Dec 16, 2019
dd4abca
settings color
marc-medley Dec 17, 2019
449c888
tweaks history chart now shows tweaks instead of history.
marc-medley Dec 17, 2019
160f1ca
updated data export.
marc-medley Dec 17, 2019
d04c290
build 3.1.0 (5)
marc-medley Dec 17, 2019
d658d40
(1) fixed lookup of data for weight chart now properly sorted (2) fix…
marc-medley Dec 20, 2019
0c91afc
v3.1.1(1)
marc-medley Dec 20, 2019
af30904
restructured to support international language localization. layout s…
marc-medley Feb 14, 2020
d05e317
README update
marc-medley Feb 14, 2020
4cc4c09
separted UI and associated cose for Tweaks Details and Doze Details
marc-medley Feb 28, 2020
f3881aa
imperial vs. metric toggle header updated layout & application logic.
marc-medley Mar 8, 2020
df7d3d1
language transition checkpoint. normalized Doze & Tweak naming.
marc-medley Mar 17, 2020
9c4f5fa
3.2.0 (1) Spanish beta version
marc-medley Mar 26, 2020
2af566f
build 3.2.0 (3)
marc-medley Apr 8, 2020
c9fa035
v3.2.1 (5) Reworked data sync with HealthKit. Fixed some UI updates. …
marc-medley Jun 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix initial picker registration
  • Loading branch information
marc-medley committed Dec 10, 2019
commit 09236df524e909a5fd192a9232d6106a9f611af3
24 changes: 24 additions & 0 deletions DailyDozen/DailyDozen/Database/RealmProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,30 @@ class RealmProvider {
return (amWeightRecord, pmWeightRecord)
}

func getDailyWeights(fromDate: Date, toDate: Date) -> (am: [DataWeightRecord], pm: [DataWeightRecord]) {
var amRecords = [DataWeightRecord]()
var pmRecords = [DataWeightRecord]()
let weightResults = realm.objects(DataWeightRecord.self)
let weightResultsById = weightResults.sorted(byKeyPath: "pid")

let fromDateKey = fromDate.datestampKey
let toDateKey = toDate.datestampKey

for dataWeightRecord in weightResultsById {
let pidKeys = dataWeightRecord.pidKeys
if pidKeys.datestampKey >= fromDateKey &&
pidKeys.datestampKey <= toDateKey {
if pidKeys.typeKey == "am" {
amRecords.append(dataWeightRecord)
} else {
pmRecords.append(dataWeightRecord)
}
}
}

return (amRecords, pmRecords)
}

/// :REPLACES: getDozeLegacy(Date)
func getDailyTracker(date: Date) -> DailyTracker {
let datestampKey = date.datestampKey
Expand Down
22 changes: 21 additions & 1 deletion DailyDozen/DailyDozen/Weight/WeightViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,19 @@ class WeightViewController: UIViewController {
// MARK: - UIViewController
override func viewDidLoad() {
super.viewDidLoad()

weightPM.delegate = self
weightAM.delegate = self
setViewModel(viewDate: Date())
timeAMInput.delegate = self
timePMInput.delegate = self

guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return
}
appDelegate.realmDelegate = self

// AM Morning
// :===: timePickerAM = UIDatePicker() // may need contraints?
timePickerAM = UIDatePicker(frame: CGRect())
timePickerAM?.datePickerMode = .time
timePickerAM?.addTarget(self, action: #selector(WeightViewController.timeChangedAM(timePicker:)), for: .valueChanged)
Expand All @@ -169,6 +172,8 @@ class WeightViewController: UIViewController {
timePickerPM?.addTarget(self, action: #selector(WeightViewController.timeChangedPM(timePicker:)), for: .valueChanged)
timePMInput.inputView = timePickerPM

setViewModel(viewDate: Date())

// Unit Type
if isImperial() {
weightAMLabel.text = "lbs."
Expand All @@ -185,6 +190,7 @@ class WeightViewController: UIViewController {
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Update stored values
saveWeightAM()
saveWeightPM()
Expand Down Expand Up @@ -252,6 +258,7 @@ class WeightViewController: UIViewController {
} else {
timeAMInput.text = ""
weightAM.text = ""
timePickerAM?.setDate(Date(), animated: false)
}

if let pmRecord = records.pm {
Expand All @@ -267,6 +274,7 @@ class WeightViewController: UIViewController {
} else {
timePMInput.text = ""
weightPM.text = ""
timePickerPM?.setDate(Date(), animated: false)
}
}

Expand Down Expand Up @@ -312,6 +320,18 @@ extension WeightViewController: UITextFieldDelegate {
// :1:
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
print("textFieldShouldBeginEditing")

// :===: should solve initial picker registration
if textField.text == nil || textField.text!.isEmpty {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "hh:mm a"
if textField == timeAMInput {
timeAMInput.text = dateFormatter.string(from: Date())
}
if textField == timePMInput {
timePMInput.text = dateFormatter.string(from: Date())
}
}
return true // return NO to disallow editing.
}
// :2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ class WeightHistoryViewController: UIViewController {
// MARK: - Properties
private var weightViewModel: WeightHistoryViewModel! // :???:
private var currentTimeScale = TimeScale.day
private let realm = RealmProvider()

private var chartSettings: (year: Int, month: Int)! {
didSet {
lineChartView.clear()

if currentTimeScale == .day {
controlPanel.isHidden = false
controlPanel.superview?.isHidden = false
Expand Down Expand Up @@ -144,20 +145,53 @@ class WeightHistoryViewController: UIViewController {
}

func updateChart(from: Date, to: Date) {
var dataEntriesAM = [
ChartDataEntry(x: 1.0, y: 144.3),
ChartDataEntry(x: 3.0, y: 143.5),
]
dataEntriesAM.append(ChartDataEntry(x: 4.0, y: 144.5))
//var dataEntriesAM = [
// ChartDataEntry(x: 1.0, y: 144.3),
// ChartDataEntry(x: 3.0, y: 143.5),
//]
//dataEntriesAM.append(ChartDataEntry(x: 4.0, y: 144.5))
var dataEntriesAM = [ChartDataEntry]()

//let dataEntriesPM = [
// ChartDataEntry(x: 2.0, y: 144.9),
// ChartDataEntry(x: 3.0, y: 144.0),
// ChartDataEntry(x: 5.0, y: 144.0)
//]
var dataEntriesPM = [ChartDataEntry]()

let records = realm.getDailyWeights(fromDate: from, toDate: to)

for item in records.am {
guard let datetime = item.datetime else { continue }
let x: TimeInterval = datetime.timeIntervalSince1970
var y = item.kg
if isImperial() {
y = item.lbs
}
let chartDataEntry = ChartDataEntry(x: x, y: y)
if item.pidKeys.typeKey == "am" {
dataEntriesAM.append(chartDataEntry)
} else {
dataEntriesPM.append(chartDataEntry)
}
}

let dataEntriesPM = [
ChartDataEntry(x: 2.0, y: 144.9),
ChartDataEntry(x: 3.0, y: 144.0),
ChartDataEntry(x: 5.0, y: 144.0)
]
updateChartWithData(am: dataEntriesAM, pm: dataEntriesPM)
}

private func isImperial() -> Bool {
guard
let unitsTypePrefStr = UserDefaults.standard.string(forKey: SettingsKeys.unitsTypePref),
let currentUnitsType = UnitsType(rawValue: unitsTypePrefStr)
else {
return true
}
if currentUnitsType == .imperial {
return true
}
return false
}

// -------------------------

private func setViewModel() {
Expand Down