Skip to content

Commit

Permalink
feat: list show appicon and toggle use new sf font
Browse files Browse the repository at this point in the history
  • Loading branch information
wflixu committed Sep 23, 2024
1 parent 818a2ee commit c00c4e3
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 13 deletions.
Binary file modified FinderSyncer/Assets.xcassets/AppIcon.appiconset/icon_128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified FinderSyncer/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified FinderSyncer/Assets.xcassets/AppIcon.appiconset/icon_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified FinderSyncer/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified FinderSyncer/Assets.xcassets/AppIcon.appiconset/icon_256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified FinderSyncer/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified FinderSyncer/Assets.xcassets/AppIcon.appiconset/icon_32x32.png
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.
Binary file modified FinderSyncer/Assets.xcassets/AppIcon.appiconset/icon_512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified FinderSyncer/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 57 additions & 11 deletions FinderSyncer/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,42 @@

import SwiftUI


struct ContentView: View {
@AppLog(subsystem: "ContentView")
private var logger

@State private var extensionsList: [ExtensionInfo] = []

@State private var vibrateOnRing = false

var body: some View {
VStack {
List(extensionsList) { ext in

HStack {
Image(nsImage: NSWorkspace.shared.icon(forFile: ext.path))
.resizable()
.frame(width: 28, height: 28)
Text(ext.parentName)

Text(ext.bundle)
Text(ext.version)

Text(ext.status)

Spacer()
Button(ext.status == "+" ? "Disable" : "Enable") {
toggleExt(ext)
Image(systemName: ext.status == "+" ? "checkmark.square" : "square")
.font(.system(size: 24)) // Set the size of the SF Symbol
.foregroundColor(.blue)
}
.padding([.vertical], 6)
.onTapGesture {
toggleExt(ext)
}
.onHover { hovering in
if hovering {
NSCursor.pointingHand.push() // Change to hand cursor
} else {
NSCursor.pop() // Revert to the default cursor
}
}.padding([.vertical], 6)
}
}
.cornerRadius(4)
}
Expand Down Expand Up @@ -84,6 +101,8 @@ struct ContentView: View {
}

func parseExtensions(text: String) -> [ExtensionInfo] {
var extensionsDict: [String: ExtensionInfo] = [:]

var extensions: [ExtensionInfo] = []

// 使用正则表达式匹配扩展块
Expand Down Expand Up @@ -122,14 +141,43 @@ struct ContentView: View {
platform: String(text[platformRange])
)

extensions.append(extensionInfo)
// Compare the version if a bundle already exists in the dictionary
if let existingExt = extensionsDict[extensionInfo.bundle] {
if compareVersions(existingExt.version, extensionInfo.version) == .orderedAscending {
// Replace the existing extension if the new one has a higher version
extensionsDict[extensionInfo.bundle] = extensionInfo
}
} else {
// Add the new extension to the dictionary
extensionsDict[extensionInfo.bundle] = extensionInfo
}
}
}
}
print("------ \(extensions.count)")

extensions = Array(extensionsDict.values).sorted { $0.bundle < $1.bundle }

logger.info("\(extensions)")

return extensions
}

// Helper function to compare two version strings
func compareVersions(_ version1: String, _ version2: String) -> ComparisonResult {
let versionComponents1 = version1.split(separator: ".").map { Int($0) ?? 0 }
let versionComponents2 = version2.split(separator: ".").map { Int($0) ?? 0 }

for (v1, v2) in zip(versionComponents1, versionComponents2) {
if v1 < v2 {
return .orderedAscending
} else if v1 > v2 {
return .orderedDescending
}
}

return versionComponents1.count < versionComponents2.count ? .orderedAscending : .orderedSame
}

func runPluginkitCommand() -> String? {
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/pluginkit")
Expand All @@ -151,8 +199,6 @@ struct ContentView: View {
}
}



// 定义扩展的结构体
struct ExtensionInfo: Identifiable {
var status: String // +, -, !
Expand Down
4 changes: 2 additions & 2 deletions FinderSyncer/FinderSyncerApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ struct FinderSyncerApp: App {

var body: some Scene {
WindowGroup {
ContentView()
}.defaultSize(CGSize(width: 600, height: 450))
ContentView().frame(minWidth: 450, idealWidth: 700, minHeight: 450, idealHeight: 470)
}.defaultSize(CGSize(width: 900, height: 600))
}
}

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# FinderSyncer

[![Swift 5.9](https://img.shields.io/badge/Swift-5.9-ED523F.svg?style=flat)](https://swift.org/)
[![SwiftUI](https://img.shields.io/badge/SwiftUI-✓-orange)](https://developer.apple.com/xcode/swiftui/)
[![macOS 14](https://img.shields.io/badge/macOS14-Compatible-green)](https://www.apple.com/macos/monterey/)


![](./FinderSyncer/Assets.xcassets/AppIcon.appiconset/icon_256x256.png)

FinderSyncer is a macOS app that enable you finder sync extension for macOS 15. In macOS 15, Apple removed the Finder Sync extension configuration interface, which makes it difficult for users to manage their Finder Sync settings.
Expand Down
Binary file modified images/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c00c4e3

Please sign in to comment.