Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions XcodeCleaner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,12 @@
9DD3BABA24B4798E00EDA308 /* StatisticViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BAB624B4798E00EDA308 /* StatisticViewModelProtocol.swift */; };
9DD3BABD24B479BF00EDA308 /* BytesToStringFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BABC24B479BF00EDA308 /* BytesToStringFormatter.swift */; };
9DD3BAC024B479DF00EDA308 /* PieChartSliceFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BABF24B479DF00EDA308 /* PieChartSliceFactory.swift */; };
9DD3BAC524B479ED00EDA308 /* PieChartSubSliceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BAC224B479ED00EDA308 /* PieChartSubSliceView.swift */; };
9DD3BAC624B479ED00EDA308 /* PieChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BAC324B479ED00EDA308 /* PieChartView.swift */; };
9DD3BAC724B479ED00EDA308 /* PieChartSliceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BAC424B479ED00EDA308 /* PieChartSliceView.swift */; };
9DD3BACB24B47A0400EDA308 /* PieChartSubSliceShape.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BAC924B47A0400EDA308 /* PieChartSubSliceShape.swift */; };
9DD3BACC24B47A0400EDA308 /* PieChartSliceShape.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BACA24B47A0400EDA308 /* PieChartSliceShape.swift */; };
9DD3BAD224B47A1E00EDA308 /* PieChartSliceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BACE24B47A1D00EDA308 /* PieChartSliceModel.swift */; };
9DD3BAD324B47A1E00EDA308 /* PieChartObservableItemsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BACF24B47A1E00EDA308 /* PieChartObservableItemsModel.swift */; };
9DD3BAD424B47A1E00EDA308 /* PieChartItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BAD024B47A1E00EDA308 /* PieChartItemModel.swift */; };
9DD3BAD524B47A1E00EDA308 /* PieChartSubSliceModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BAD124B47A1E00EDA308 /* PieChartSubSliceModel.swift */; };
9DD3BAD824B47A4800EDA308 /* PieChartAnySliceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DD3BAD724B47A4800EDA308 /* PieChartAnySliceProtocol.swift */; };
9DDFA81D24B58F47008C2C2A /* DateManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DDFA81C24B58F47008C2C2A /* DateManager.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -88,16 +84,12 @@
9DD3BAB624B4798E00EDA308 /* StatisticViewModelProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatisticViewModelProtocol.swift; sourceTree = "<group>"; };
9DD3BABC24B479BF00EDA308 /* BytesToStringFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BytesToStringFormatter.swift; sourceTree = "<group>"; };
9DD3BABF24B479DF00EDA308 /* PieChartSliceFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PieChartSliceFactory.swift; sourceTree = "<group>"; };
9DD3BAC224B479ED00EDA308 /* PieChartSubSliceView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PieChartSubSliceView.swift; sourceTree = "<group>"; };
9DD3BAC324B479ED00EDA308 /* PieChartView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PieChartView.swift; sourceTree = "<group>"; };
9DD3BAC424B479ED00EDA308 /* PieChartSliceView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PieChartSliceView.swift; sourceTree = "<group>"; };
9DD3BAC924B47A0400EDA308 /* PieChartSubSliceShape.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PieChartSubSliceShape.swift; sourceTree = "<group>"; };
9DD3BACA24B47A0400EDA308 /* PieChartSliceShape.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PieChartSliceShape.swift; sourceTree = "<group>"; };
9DD3BACE24B47A1D00EDA308 /* PieChartSliceModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PieChartSliceModel.swift; sourceTree = "<group>"; };
9DD3BACF24B47A1E00EDA308 /* PieChartObservableItemsModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PieChartObservableItemsModel.swift; sourceTree = "<group>"; };
9DD3BAD024B47A1E00EDA308 /* PieChartItemModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PieChartItemModel.swift; sourceTree = "<group>"; };
9DD3BAD124B47A1E00EDA308 /* PieChartSubSliceModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PieChartSubSliceModel.swift; sourceTree = "<group>"; };
9DD3BAD724B47A4800EDA308 /* PieChartAnySliceProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PieChartAnySliceProtocol.swift; sourceTree = "<group>"; };
9DDFA81C24B58F47008C2C2A /* DateManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateManager.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -249,7 +241,6 @@
9DD3BAC124B479E500EDA308 /* Views */,
9DD3BAC824B479F300EDA308 /* Shapes */,
9DD3BACD24B47A1000EDA308 /* Models */,
9DD3BAD624B47A2300EDA308 /* Protocols */,
);
path = PieChart;
sourceTree = "<group>";
Expand All @@ -258,7 +249,6 @@
isa = PBXGroup;
children = (
9DD3BAC424B479ED00EDA308 /* PieChartSliceView.swift */,
9DD3BAC224B479ED00EDA308 /* PieChartSubSliceView.swift */,
9DD3BAC324B479ED00EDA308 /* PieChartView.swift */,
);
path = Views;
Expand All @@ -268,7 +258,6 @@
isa = PBXGroup;
children = (
9DD3BACA24B47A0400EDA308 /* PieChartSliceShape.swift */,
9DD3BAC924B47A0400EDA308 /* PieChartSubSliceShape.swift */,
);
path = Shapes;
sourceTree = "<group>";
Expand All @@ -279,19 +268,10 @@
9DD3BAD024B47A1E00EDA308 /* PieChartItemModel.swift */,
9DD3BACF24B47A1E00EDA308 /* PieChartObservableItemsModel.swift */,
9DD3BACE24B47A1D00EDA308 /* PieChartSliceModel.swift */,
9DD3BAD124B47A1E00EDA308 /* PieChartSubSliceModel.swift */,
);
path = Models;
sourceTree = "<group>";
};
9DD3BAD624B47A2300EDA308 /* Protocols */ = {
isa = PBXGroup;
children = (
9DD3BAD724B47A4800EDA308 /* PieChartAnySliceProtocol.swift */,
);
path = Protocols;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -373,7 +353,6 @@
9DD3BA9024B478B600EDA308 /* DirectoryType.swift in Sources */,
9DD3BACC24B47A0400EDA308 /* PieChartSliceShape.swift in Sources */,
9DD3BAA824B4794C00EDA308 /* ScanProgressView.swift in Sources */,
9DD3BAC524B479ED00EDA308 /* PieChartSubSliceView.swift in Sources */,
9DD3BA8E24B478AE00EDA308 /* DirectoryManager.swift in Sources */,
9DB4448224BAEFEE00165FB9 /* FileType.swift in Sources */,
9DD3BAB024B4796C00EDA308 /* ViewModel.swift in Sources */,
Expand All @@ -384,9 +363,7 @@
9DD3BABD24B479BF00EDA308 /* BytesToStringFormatter.swift in Sources */,
9DD3BABA24B4798E00EDA308 /* StatisticViewModelProtocol.swift in Sources */,
9DD3BAAE24B4796C00EDA308 /* StatisticViewModel.swift in Sources */,
9DD3BAD524B47A1E00EDA308 /* PieChartSubSliceModel.swift in Sources */,
9DD3BAB924B4798E00EDA308 /* ViewModelProtocol.swift in Sources */,
9DD3BACB24B47A0400EDA308 /* PieChartSubSliceShape.swift in Sources */,
9DD3BAA624B4794800EDA308 /* StatisticView.swift in Sources */,
9DD3BAA424B4794300EDA308 /* DividerButtonView.swift in Sources */,
9DD3BA7024B4639400EDA308 /* AppDelegate.swift in Sources */,
Expand All @@ -402,7 +379,6 @@
9DD3BA7524B4639400EDA308 /* XcodeCleaner.xcdatamodeld in Sources */,
9DD3BAB724B4798E00EDA308 /* DirectoryListViewModelProtocol.swift in Sources */,
9DCE1C0B24B582D200E49E6D /* CoreDataManager.swift in Sources */,
9DD3BAD824B47A4800EDA308 /* PieChartAnySliceProtocol.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
48 changes: 19 additions & 29 deletions XcodeCleaner/DirectoryManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ struct DirectoryManager {
completion()
return directorySize
}
func getPath(for type: DirectoryType) -> String {
var path: String

switch type {
case .derivedData:
path = getDerivedDataPath()
case .deviceSupport:
path = getDeviceSupportPath()
case .archives:
path = getArchivesPath()
case .iOSDeviceLogs:
path = getIOSDeviceLogsPath()
case .documentationCache:
path = getDocumentationCachePath()
}
return path
}
func normalizePathForDirectory(path: String) -> String {
var newPath = path

Expand All @@ -137,20 +154,7 @@ struct DirectoryManager {
}
func normalizePathForDisplay(directory: String, forType type: DirectoryType) -> String {
var result = directory
var prefix: String

switch type {
case .derivedData:
prefix = getDerivedDataPath()
case .deviceSupport:
prefix = getDeviceSupportPath()
case .archives:
prefix = getArchivesPath()
case .iOSDeviceLogs:
prefix = getIOSDeviceLogsPath()
case .documentationCache:
prefix = getDocumentationCachePath()
}
let prefix: String = getPath(for: type)

if directory.contains(prefix) {
result = directory.replacingOccurrences(of: prefix, with: "")
Expand All @@ -160,21 +164,7 @@ struct DirectoryManager {
}
func cleanDirectory(forType type: DirectoryType) {
let fileManager = FileManager.default

var directoryPath: String
switch type {
case .derivedData:
directoryPath = getDerivedDataPath()
case .deviceSupport:
directoryPath = getDeviceSupportPath()
case .archives:
directoryPath = getArchivesPath()
case .iOSDeviceLogs:
directoryPath = getIOSDeviceLogsPath()
case .documentationCache:
directoryPath = getDocumentationCachePath()
}

let directoryPath = getPath(for: type)
let directoryURL = URL(fileURLWithPath: normalizePathForDirectory(path: directoryPath))

do {
Expand Down
5 changes: 1 addition & 4 deletions XcodeCleaner/PieChart/Models/PieChartItemModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ import SwiftUI
public struct PieChartItemModel {
public var value: Double
public var color: Color
public var subItems: [PieChartItemModel]

public init(value: Double, color: Color, subItems: [PieChartItemModel] = []) {
public init(value: Double, color: Color) {
self.value = value
self.color = color

self.subItems = subItems
}
}
7 changes: 2 additions & 5 deletions XcodeCleaner/PieChart/Models/PieChartSliceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@

import SwiftUI

struct PieChartSliceModel: PieChartAnySliceProtocol {
struct PieChartSliceModel {
var value: Double
var color: Color

var startDegree: Double
var endDegree: Double

var subSlices: [PieChartSubSliceModel]

public init(value: Double, color: Color, startDegree: Double, endDegree: Double, subSlices: [PieChartSubSliceModel] = []) {
public init(value: Double, color: Color, startDegree: Double, endDegree: Double) {
self.value = value
self.color = color

self.startDegree = startDegree
self.endDegree = endDegree
self.subSlices = subSlices
}
}

26 changes: 0 additions & 26 deletions XcodeCleaner/PieChart/Models/PieChartSubSliceModel.swift

This file was deleted.

28 changes: 2 additions & 26 deletions XcodeCleaner/PieChart/PieChartSliceFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,11 @@ class PieChartSliceFactory {

let sliceEndDegree = sliceStartDegree + proportionalValue * maxShapeDegree

var subslices: [PieChartSubSliceModel] = []
if item.subItems.count > 0 {
let sliceIndex = itemIndex + 1
subslices = createPieChartSubSlicesFromItems(items: item.subItems, initialDegree: previousSliceEndDegree, maxShapeDegree: sliceEndDegree, withIndex: sliceIndex)
}
let slice = PieChartSliceModel(value: item.value, color: item.color, startDegree: sliceStartDegree, endDegree: sliceEndDegree, subSlices: subslices)
let slice = PieChartSliceModel(value: item.value, color: item.color, startDegree: sliceStartDegree, endDegree: sliceEndDegree)
slices.append(slice)
previousSliceEndDegree = sliceEndDegree
}
return slices
}
func createPieChartSubSlicesFromItems(items: [PieChartItemModel], initialDegree: Double, maxShapeDegree: Double, withIndex sliceIndex: Int = 1) -> [PieChartSubSliceModel] {
var subSlices: [PieChartSubSliceModel] = []
var previousSliceEndDegree = initialDegree

let maxSumSliceValue = items.reduce(0) { $0 + $1.value }

for itemIndex in 0 ..< items.count {
let item = items[itemIndex]

let sliceStartDegree = previousSliceEndDegree
let proportionalValue = item.value / maxSumSliceValue

let sliceEndDegree = sliceStartDegree + proportionalValue * maxShapeDegree / Double(sliceIndex)

let slice = PieChartSubSliceModel(value: item.value, color: item.color, startDegree: sliceStartDegree, endDegree: sliceEndDegree)
subSlices.append(slice)
previousSliceEndDegree = sliceEndDegree
}
return subSlices
return slices
}
}
18 changes: 0 additions & 18 deletions XcodeCleaner/PieChart/Protocols/PieChartAnySliceProtocol.swift

This file was deleted.

41 changes: 0 additions & 41 deletions XcodeCleaner/PieChart/Shapes/PieChartSubSliceShape.swift

This file was deleted.

13 changes: 2 additions & 11 deletions XcodeCleaner/PieChart/Views/PieChartSliceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,13 @@ struct PieChartSliceView: View {

let sliceShape = PieChartSliceShape(startAngle: startAngle, endAngle: endAngle)

return Group { sliceShape
return sliceShape
.fill()
.foregroundColor(slice.color)
.scaleEffect(isVisible ? 1: 0)
.scaleEffect(isVisible ? 1: 0.01)
.animation(Animation.easeIn)
.onAppear {
self.isVisible.toggle()
}
if self.slice.subSlices.count > 0 {
GeometryReader { geometryReader in
ForEach(0 ..< self.slice.subSlices.count, id: \.self) { subSliceIndex in
PieChartSubSliceView(rect: geometryReader.frame(in: .local), subSlice: self.slice.subSlices[subSliceIndex])
.padding(0 - min(geometryReader.size.width, geometryReader.size.height) / 2)
}
}
}
}
}
}
Expand Down
Loading