This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftUI | |
struct PrimaryHeader: ViewModifier { | |
func body(content: Content) -> some View { | |
content | |
.font(Font.system(size: Matrix.headerPrimarySize, | |
weight: .bold, | |
design: .default)) | |
.foregroundColor(Color.textHeaderPrimary) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Toast.swift | |
// ThemingSwiftUI | |
// | |
// Created by Prafulla Singh on 6/6/20. | |
// Copyright © 2020 Prafulla Singh. All rights reserved. | |
// | |
//Picked: https://stackoverflow.com/questions/56550135/swiftui-global-overlay-that-can-be-triggered-from-any-view | |
import SwiftUI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
NavigationView { | |
NavigationLink(destination: DetailView()) { | |
Text("Simple Text Button") // set .primaryButton() to update | |
} | |
.navigationBarTitle("Welcome") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// GaugeViewDemo | |
// | |
// Created by Prafulla Singh on 7/6/20. | |
// Copyright © 2020 Prafulla Singh. All rights reserved. | |
// | |
import SwiftUI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct GaugeView: View { | |
func colorMix(percent: Int) -> Color { | |
let p = Double(percent) | |
let tempG = (100.0-p)/100 | |
let g: Double = tempG < 0 ? 0 : tempG | |
let tempR = 1+(p-100.0)/100.0 | |
let r: Double = tempR < 0 ? 0 : tempR | |
return Color.init(red: r, green: g, blue: 0) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct GaugeView: View { | |
func colorMix(percent: Int) -> Color { | |
let p = Double(percent) | |
let tempG = (100.0-p)/100 | |
let g: Double = tempG < 0 ? 0 : tempG | |
let tempR = 1+(p-100.0)/100.0 | |
let r: Double = tempR < 0 ? 0 : tempR | |
return Color.init(red: r, green: g, blue: 0) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Needle: Shape { | |
func path(in rect: CGRect) -> Path { | |
var path = Path() | |
path.move(to: CGPoint(x: 0, y: rect.height/2)) | |
path.addLine(to: CGPoint(x: rect.width, y: 0)) | |
path.addLine(to: CGPoint(x: rect.width, y: rect.height)) | |
return path | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
extension CGRect { | |
/// center of rect | |
var center: CGPoint { | |
return CGPoint(x: self.midX, y: self.midY) | |
} | |
/// if rect is not square take centered square to draw | |
var centeredSquare: CGRect { | |
let width = ceil(min(size.width, size.height)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct Heart: Shape { | |
func path(in rect: CGRect) -> Path { | |
let (x, y, width, height) = rect.centeredSquare.flatten() | |
let lowerPoint = CGPoint(x: x + width / 2, y: (y + height )) | |
let path = Path { p in | |
p.move(to: lowerPoint) |