Skip to content

Commit

Permalink
real final
Browse files Browse the repository at this point in the history
  • Loading branch information
jungchoib committed Feb 15, 2024
1 parent 05871b9 commit 17c784a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 49 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "5E2F1167-C34E-42B6-86EA-F3F3CC0A7F37"
type = "1"
version = "2.0">
</Bucket>
83 changes: 34 additions & 49 deletions AlwaysOnSize/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,66 +9,51 @@ import SwiftUI

struct ContentView: View {
@State private var fileInformations: [FileInformation] = []
@State var name : String = ""
@State var storage : String = getFreeSizeAsString()
var size : [String] = findFileSize()
@State private var storage: String = ""
@State private var size: [String] = []

private let timer = Timer.publish(every: 3, on: .main, in: .common).autoconnect()

var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text(storage)
Text(size[0])
}
.task {
let timer = Timer.scheduledTimer(withTimeInterval: 3, repeats: true) { (_) in
Text(storage)
}

timer.fire()
@State var size : [String] = findFileSize()

func updateFileInformations() {
fileInformations = findFileInformations()
}

var body: some View {
List(fileInformations.indices, id: \.self) { index in
// 각 파일 정보에 대한 Checkbox를 생성합니다.
Toggle(isOn: $fileInformations[index].isChecked) {
VStack(alignment: .leading) {
Text("Filename: \(fileInformations[index].fileName)")
Text("Filesize: \(getFormatedNumberString(size: fileInformations[index].fileSize))")
Text("Path: \(fileInformations[index].path)")
}
}
}
.onAppear {
self.fileInformations = findFileInformations()
}
.padding()
return HStack(){
Text(size.first ?? "")
List(fileInformations.indices, id: \.self) { index in
Toggle(isOn: $fileInformations[index].isChecked) {
VStack(alignment: .leading) {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text(storage)
Text(size[0])
Text("Filename: \(fileInformations[index].fileName)")
Text("Filesize: \(getFormatedNumberString(size: fileInformations[index].fileSize))")
Text("Path: \(fileInformations[index].path)")
}
Text("Total Checked File Size:\n \(totalCheckedFileSize(fileInformations: fileInformations)) bytes")
Button(action: {
deleteFiles(fileInformations: fileInformations)
updateFileInformations()
storage = getFreeSizeAsString()
size = findFileSize()
}, label: {
Text("Delete")
})
.padding()
}
.padding()
}
Text("Total Checked File Size:\n \(totalCheckedFileSize(fileInformations: fileInformations)) bytes")
Button(action: {
deleteFiles(fileInformations: fileInformations)
fileInformations = findFileInformations()
storage = getFreeSizeAsString()
size = findFileSize()
}, label: {
Text("Delete")
})
.padding()
}
// 초기 화면값
.onAppear {
fileInformations = findFileInformations()
storage = getFreeSizeAsString()
size = findFileSize()
}
// 3초마다 storage변화 확인
.onReceive(timer) { _ in
fileInformations = findFileInformations()
storage = getFreeSizeAsString()
size = findFileSize()
}
.padding()
}
}

Expand Down

0 comments on commit 17c784a

Please sign in to comment.