Created
June 10, 2019 14:17
-
-
Save ericlewis/cbf0be7080eaf0e650e0f32146a02460 to your computer and use it in GitHub Desktop.
This file contains 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
// | |
// CircularProgress.swift | |
// Time! | |
// | |
// Created by Eric Lewis on 6/9/19. | |
// Copyright © 2019 Eric Lewis, Inc. All rights reserved. | |
// | |
import SwiftUI | |
struct CakeView: View { | |
@Binding var percent: TimeInterval; | |
init(_ percent: Binding<TimeInterval>) { | |
$percent = percent | |
} | |
var body: some View { | |
ZStack { | |
Circle().stroke(Color.blue, lineWidth: 2) | |
GeometryReader { geometry in | |
Path { path in | |
let width: CGFloat = min(geometry.size.width, geometry.size.height) | |
let height = width | |
let middle = width / 2.0 | |
path.move( | |
to: CGPoint( | |
x: middle, | |
y: height * 0.5 | |
) | |
) | |
let middlePoint = CGPoint( | |
x: middle, | |
y: height * 0.5 | |
) | |
path.addArc(center: middlePoint, radius: width * 0.45, startAngle: .degrees(-90), endAngle: .degrees(-90 + (3.6 * self.percent)), clockwise: false) | |
path.addLine(to: middlePoint) | |
path.closeSubpath() | |
} | |
.fill(Color.blue) | |
.aspectRatio(1, contentMode: .fit) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment