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 InnerCircle: Shape { | |
let ratio: CGFloat | |
func path(in rect: CGRect) -> Path { | |
let center = CGPoint.init(x: (rect.origin.x + rect.width)/2, y: (rect.origin.y + rect.height)/2) | |
let radii = min(center.x, center.y) * ratio | |
let path = Path { p in | |
p.addArc(center: center, | |
radius: radii, | |
startAngle: Angle(degrees: 0), | |
endAngle: Angle(degrees: 360), |
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 PieChart: View { | |
@State private var selectedCell: UUID = UUID() | |
let dataModel: ChartDataModel | |
let onTap: (ChartCellModel?) -> () | |
var body: some View { | |
ZStack { | |
ForEach(dataModel.chartCellModel) { dataSet in | |
PieChartCell(startAngle: self.dataModel.angle(for: dataSet.value), endAngle: self.dataModel.startingAngle) | |
.foregroundColor(dataSet.color) |
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
// | |
// PieChart.swift | |
// NokiaGame | |
// | |
// Created by Prafulla Singh on 13/9/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 ChartCellModel: Identifiable { | |
let id = UUID() | |
let color: Color | |
let value: CGFloat | |
let name: String | |
} | |
final class ChartDataModel: ObservableObject { | |
var chartCellModel: [ChartCellModel] | |
var startingAngle = Angle(degrees: 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 PieChartCell: Shape { | |
let startAngle: Angle | |
let endAngle: Angle | |
func path(in rect: CGRect) -> Path { | |
let center = CGPoint.init(x: (rect.origin.x + rect.width)/2, y: (rect.origin.y + rect.height)/2) | |
let radii = min(center.x, center.y) | |
let path = Path { p in | |
p.addArc(center: center, | |
radius: radii, | |
startAngle: startAngle, |
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 | |
enum StylesSet { | |
struct CustomToggle: ToggleStyle { | |
func makeBody(configuration: Configuration) -> some View { | |
HStack { | |
configuration.label | |
Spacer() | |
Rectangle() | |
.foregroundColor(configuration.isOn ? .red : .green) |
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 CustomBackOnNavigation: View { | |
var body: some View { | |
NavigationView { | |
NavigationLink(destination : DestinationView()) { | |
Text("Custom Back Nav") | |
} | |
.navigationBarTitle("Custom Back Nav") | |
} | |
} | |
} |