Skip to content

Commit

Permalink
update 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
little-huang committed Sep 9, 2024
1 parent 4394576 commit 755cd03
Show file tree
Hide file tree
Showing 71 changed files with 2,708 additions and 1,249 deletions.
568 changes: 356 additions & 212 deletions FolderColor.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "swiftuiflux",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Dimillian/SwiftUIFlux",
"state" : {
"branch" : "master",
"revision" : "39b885558fdee277f7ca2a8c81900123e9bc436f"
}
}
],
"version" : 2
}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>Document.xcdatamodel</string>
</dict>
<dict />
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "F8131F91-EED3-4375-A8D9-1A2AA3111D02"
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "05EC100F2823DCF300982154"
BuildableName = "FolderColor.app"
BlueprintName = "FolderColor"
ReferencedContainer = "container:FolderColor.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "05EC100F2823DCF300982154"
BuildableName = "FolderColor.app"
BlueprintName = "FolderColor"
ReferencedContainer = "container:FolderColor.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>FolderColor.xcscheme_^#shared#^_</key>
<key>FolderColor.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
Expand Down
26 changes: 0 additions & 26 deletions FolderColor/AppDelegate.swift

This file was deleted.

18 changes: 18 additions & 0 deletions FolderColor/AppReducer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// AppReducer.swift
// FolderColor
//
// Created by 黄宝成 on 2022/5/8.
//

import Foundation
import SwiftUIFlux

func appStateReducer(state: AppState, action: Action) -> AppState {

var state = state

state.colorState = colorReducer(state: state.colorState, action: action)

return state
}
90 changes: 90 additions & 0 deletions FolderColor/AppState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// AppState.swift
// FolderColor
//
// Created by 黄宝成 on 2022/5/8.
//

import Foundation
import SwiftUI
import SwiftUIFlux

fileprivate var savePath: URL!
fileprivate let encoder = JSONEncoder()
fileprivate let decoder = JSONDecoder()

struct AppState: FluxState, Codable {
var colorState: ColorState

init() {
do {
let icloudDirectory = FileManager.default.url(forUbiquityContainerIdentifier: nil)
let documentDirectory = try FileManager.default.url(for: .documentDirectory,
in: .userDomainMask,
appropriateFor: nil,
create: false)
if let icloudDirectory = icloudDirectory {
try FileManager.default.startDownloadingUbiquitousItem(at: icloudDirectory)
}

savePath = (icloudDirectory ?? documentDirectory).appendingPathComponent("userData")
} catch let error {
fatalError("Couldn't create save state data with error: \(error)")
}

if let data = try? Data(contentsOf: savePath),
let savedState = try? decoder.decode(AppState.self, from: data) {
colorState = savedState.colorState
} else {
colorState = initColorState()
}
}

func archiveState() {
let colorState = self.colorState

DispatchQueue.global().async {
let savingState = self

guard let data = try? encoder.encode(savingState) else {
return
}

do {
try data.write(to: savePath)
} catch let error {
print("Error while saving app state :\(error)")
}
}
}

func sizeOfArchivedState() -> String {
do {
let resources = try savePath.resourceValues(forKeys: [.fileSizeKey])
let formatter = ByteCountFormatter()

formatter.allowedUnits = .useKB
formatter.countStyle = .file

return formatter.string(fromByteCount: Int64(resources.fileSize ?? 0))

} catch {
return "0"
}
}

func deleteArchivedState() {
do {
try FileManager.default.removeItem(at: savePath)
print("Successfully deleted saved state data.")
} catch let error {
print("Error while deleting app state: \(error)")
}
}

#if DEBUG
init(colorState: ColorState) {
self.colorState = colorState
}
#endif
}
11 changes: 11 additions & 0 deletions FolderColor/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 33 additions & 23 deletions FolderColor/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,68 @@
{
"images" : [
{
"filename" : "16@1x.png",
"idiom" : "mac",
"size" : "16x16",
"scale" : "1x"
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "16@2x.png",
"idiom" : "mac",
"size" : "16x16",
"scale" : "2x"
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "32@1x.png",
"idiom" : "mac",
"size" : "32x32",
"scale" : "1x"
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "32@2x.png",
"idiom" : "mac",
"size" : "32x32",
"scale" : "2x"
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "128@1x.png",
"idiom" : "mac",
"size" : "128x128",
"scale" : "1x"
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "128@2x.png",
"idiom" : "mac",
"size" : "128x128",
"scale" : "2x"
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "256@1x.png",
"idiom" : "mac",
"size" : "256x256",
"scale" : "1x"
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "256@2x.png",
"idiom" : "mac",
"size" : "256x256",
"scale" : "2x"
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "512@1x.png",
"idiom" : "mac",
"size" : "512x512",
"scale" : "1x"
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "512@2x.png",
"idiom" : "mac",
"size" : "512x512",
"scale" : "2x"
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
6 changes: 3 additions & 3 deletions FolderColor/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
"author" : "xcode",
"version" : 1
}
}
}
22 changes: 22 additions & 0 deletions FolderColor/Assets.xcassets/Folder.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "Folder.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Folder@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 755cd03

Please sign in to comment.