Skip to content

Commit

Permalink
Merge pull request #33 from MonoHelixLabs/linemode
Browse files Browse the repository at this point in the history
New feature: control how the lines between data points are drawn
  • Loading branch information
petcupaula authored Jul 24, 2017
2 parents d9bbbf1 + b2a3179 commit ba1a842
Show file tree
Hide file tree
Showing 14 changed files with 396 additions and 22 deletions.
23 changes: 23 additions & 0 deletions DataFeeds-iOS/Assets.xcassets/plotsettings.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "plotsettings40pt.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "plotsettings80pt.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "plotsettings120pt.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 118 additions & 5 deletions DataFeeds-iOS/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions DataFeeds-iOS/FeedDetailsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class FeedDetailsViewController: UIViewController, UITableViewDataSource, UITabl

var timer: Timer!

var lineMode: Int!

#if os(iOS)
@IBOutlet var lineChartView: LineChartView!
#else
Expand Down Expand Up @@ -80,6 +82,7 @@ class FeedDetailsViewController: UIViewController, UITableViewDataSource, UITabl
timer = Timer.scheduledTimer(timeInterval: refreshInterval, target: self, selector: #selector(FeedDetailsViewController.refreshHistFeedData(_:)), userInfo: nil, repeats: true)
}

lineMode = UserDefaultsManager.sharedInstance.getLineMode()
}


Expand Down Expand Up @@ -150,8 +153,20 @@ class FeedDetailsViewController: UIViewController, UITableViewDataSource, UITabl
ds1.drawValuesEnabled = false
ds1.drawFilledEnabled = true
ds1.fillColor = UIColor(red: 0.0/255.0, green: 204.0/255.0, blue: 204.0/255.0, alpha: 1.0)
ds1.mode = LineChartDataSet.Mode.horizontalBezier
ds1.cubicIntensity = 0.2

switch lineMode {
case 0:
ds1.mode = LineChartDataSet.Mode.horizontalBezier
ds1.cubicIntensity = 0.2
case 1:
ds1.mode = LineChartDataSet.Mode.linear
case 2:
ds1.mode = LineChartDataSet.Mode.stepped
default:
ds1.mode = LineChartDataSet.Mode.horizontalBezier
ds1.cubicIntensity = 0.2
}

ds1.setDrawHighlightIndicators(false)

data.addDataSet(ds1)
Expand Down
4 changes: 2 additions & 2 deletions DataFeeds-iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<string>1.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.1.1</string>
<string>1.2</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down
53 changes: 53 additions & 0 deletions DataFeeds-iOS/PlotSettingsViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// PlotSettingsViewController.swift
// DataFeeds
//
// Created by Paula on 21/07/2017.
// Copyright © 2017 monohelixlabs. All rights reserved.
//

import UIKit


class PlotSettingsViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate {

@IBOutlet weak var lineModePicker: UIPickerView!

var pickerData = [
["Horizontal Bezier","Linear","Stepped"]
]

override func viewDidLoad() {
super.viewDidLoad()

self.navigationController?.navigationBar.barTintColor = UIColor(red: 0.0/255.0, green: 204.0/255.0, blue: 204.0/255.0, alpha: 1.0)
self.navigationController?.navigationBar.isTranslucent = false
self.navigationController?.navigationBar.tintColor = UIColor.black
self.navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName : UIColor.white]

lineModePicker.delegate = self
lineModePicker.dataSource = self

}

override func viewDidAppear(_ animated: Bool) {
lineModePicker.selectRow(UserDefaultsManager.sharedInstance.getLineMode(), inComponent: 0, animated: false)
}

func numberOfComponents(in pickerView: UIPickerView) -> Int {
return pickerData.count
}

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return pickerData[component].count
}

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
return pickerData[component][row]
}

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)
{
UserDefaultsManager.sharedInstance.setLineMode(lineModePicker.selectedRow(inComponent: 0))
}
}
45 changes: 37 additions & 8 deletions DataFeeds-iOS/UserDefaultsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ class UserDefaultsManager: NSObject {
let mainfeedrefreshdefault = 0
let feeddetailsrefreshString = "feeddetailsrefresh"
let feeddetailsrefreshdefault = 0

let refreshRates = [0.0, 15.0, 30.0, 60.0, 120.0]

let linemodeString = "linemode"
let linemodedefault = 0

//
// Preferences that are synced with iCloud
//

// AIO key

func getAIOkey() -> String {

let iCloudKeyStore: NSUbiquitousKeyValueStore? = NSUbiquitousKeyValueStore()
Expand All @@ -52,6 +60,8 @@ class UserDefaultsManager: NSObject {

}

// Feed emojis

func getImagesPreferences() -> [String:String]{

let iCloudKeyStore: NSUbiquitousKeyValueStore? = NSUbiquitousKeyValueStore()
Expand Down Expand Up @@ -96,6 +106,8 @@ class UserDefaultsManager: NSObject {

}

// Helper functions

func syncWithiCloud() {

let iCloudKeyStore: NSUbiquitousKeyValueStore? = NSUbiquitousKeyValueStore()
Expand All @@ -115,7 +127,9 @@ class UserDefaultsManager: NSObject {
return String(Character(UnicodeScalar(Int(emoji,radix:16)!)!))
}

//
// Preferences that are not synced with iCloud follow
//

func getShownKeyScreen() -> Bool {
let prefs = UserDefaults.standard
Expand All @@ -129,12 +143,7 @@ class UserDefaultsManager: NSObject {
UserDefaults.standard.synchronize()
}

func getRefreshRateMainFeed() -> Int {
let prefs = UserDefaults.standard
var mainfeedrefresh = prefs.integer(forKey: mainfeedrefreshString)
if (mainfeedrefresh == 0) { mainfeedrefresh = mainfeedrefreshdefault }
return mainfeedrefresh
}
// Refresh Rate

func getRefreshRateMainFeedToInterval() -> Double {
return refreshRates[getRefreshRateMainFeed()]
Expand All @@ -144,6 +153,13 @@ class UserDefaultsManager: NSObject {
return refreshRates[getRefreshRateDetailsFeed()]
}

func getRefreshRateMainFeed() -> Int {
let prefs = UserDefaults.standard
var mainfeedrefresh = prefs.integer(forKey: mainfeedrefreshString)
if (mainfeedrefresh == 0) { mainfeedrefresh = mainfeedrefreshdefault }
return mainfeedrefresh
}

func setRefreshRateMainFeed(_ value: Int) {
let prefs = UserDefaults.standard
prefs.set(value, forKey: mainfeedrefreshString)
Expand All @@ -162,6 +178,19 @@ class UserDefaultsManager: NSObject {
prefs.set(value, forKey: feeddetailsrefreshString)
UserDefaults.standard.synchronize()
}


// Line Mode

func getLineMode() -> Int {
let prefs = UserDefaults.standard
let linemode = prefs.integer(forKey: linemodeString)
return linemode
}

func setLineMode(_ value: Int) {
let prefs = UserDefaults.standard
prefs.set(value, forKey: linemodeString)
UserDefaults.standard.synchronize()
}

}
Loading

0 comments on commit ba1a842

Please sign in to comment.