Mercurial > public > lazybear
changeset 266:cc260d53fcf8
Update SafariView on Settings
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sun, 14 Mar 2021 13:24:01 +0100 |
parents | 0500cacf0136 |
children | e8223540f3f3 |
files | LazyBear/Functions/Normalize.swift LazyBear/Tests/DemoChart.swift LazyBear/UI/Settings.swift |
diffstat | 3 files changed, 33 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear/Functions/Normalize.swift Sat Mar 13 15:35:00 2021 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -// -// Normalize.swift -// LazyBear -// -// Created by Dennis Concepción Martín on 20/2/21. -// - -import Foundation - -func normalize(_ data: [Double]) -> [Double] { - var normalData = [Double]() - let min = data.min()! - let max = data.max()! - - for value in data { - let normal = (value - min) / (max - min) - normalData.append(normal) - } - - return normalData -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LazyBear/Tests/DemoChart.swift Sun Mar 14 13:24:01 2021 +0100 @@ -0,0 +1,20 @@ +// +// DemoChart.swift +// LazyBear +// +// Created by Dennis Concepción Martín on 13/3/21. +// + +import SwiftUI + +struct DemoChart: View { + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +struct DemoChart_Previews: PreviewProvider { + static var previews: some View { + DemoChart() + } +}
--- a/LazyBear/UI/Settings.swift Sat Mar 13 15:35:00 2021 +0100 +++ b/LazyBear/UI/Settings.swift Sun Mar 14 13:24:01 2021 +0100 @@ -9,11 +9,11 @@ import CoreData struct Settings: View { - @FetchRequest(entity: UserSettings.entity(), - sortDescriptors: [NSSortDescriptor(keyPath: \UserSettings.changedAt, ascending: false)]) + let setting = SettingMetadata() + @FetchRequest(entity: UserSettings.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \UserSettings.changedAt, ascending: false)]) var userSettings: FetchedResults<UserSettings> - let setting = SettingMetadata() @Environment(\.colorScheme) var colorScheme // Detect dark mode + @State private var showingSafari = false var body: some View { NavigationView { @@ -26,13 +26,17 @@ Section(footer: IexAttribution(text: "Data provided by IEX Cloud").padding(.top)) { ForEach((0...3), id: \.self) { index in - Link(destination: URL(string: setting.links[index])!) { - HStack { - SettingRow(image: setting.images[index], text: setting.texts[index], colour: setting.colours[index]) - FakeLinkArrow() + Button(action: { self.showingSafari = true }) { + HStack { + SettingRow(image: setting.images[index], text: setting.texts[index], colour: setting.colours[index]) + FakeLinkArrow() + } } - } - .foregroundColor(colorScheme == .dark ? .white: .black) + .foregroundColor(colorScheme == .dark ? .white: .black) + .sheet(isPresented: $showingSafari) { + SafariView(url:URL(string: setting.links[index])!) + } + } } }