mirror of
https://github.com/exituser/Pearcleaner.git
synced 2026-09-17 08:29:07 +00:00
v3.5.4
This commit is contained in:
@@ -18,47 +18,44 @@ struct AppListItems: View {
|
||||
@AppStorage("displayMode") var displayMode: DisplayMode = .system
|
||||
@AppStorage("settings.general.miniview") private var miniView: Bool = true
|
||||
@AppStorage("settings.general.mini") private var mini: Bool = false
|
||||
@AppStorage("settings.general.glass") private var glass: Bool = true
|
||||
@AppStorage("settings.menubar.enabled") private var menubarEnabled: Bool = false
|
||||
@Binding var showPopover: Bool
|
||||
@EnvironmentObject var locations: Locations
|
||||
let itemId = UUID()
|
||||
let appInfo: AppInfo
|
||||
var isSelected: Bool {
|
||||
appState.appInfo.path == appInfo.path
|
||||
appState.appInfo.id == appInfo.id
|
||||
}
|
||||
@State private var hoveredItemPath: URL? = nil
|
||||
var body: some View {
|
||||
|
||||
HStack(alignment: .center) {
|
||||
ZStack() {
|
||||
|
||||
if (isHovered || isSelected) && mini {
|
||||
RoundedRectangle(cornerRadius: 50)
|
||||
.fill(isSelected ? Color("pear") : Color("mode").opacity(0.5))
|
||||
.frame(width: isSelected ? 4 : 2, height: 25)
|
||||
.padding(.trailing, 5)
|
||||
}
|
||||
HStack(alignment: .center) {
|
||||
|
||||
if let appIcon = appInfo.appIcon {
|
||||
ZStack {
|
||||
Image(nsImage: appIcon)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(width: 30, height: 30)
|
||||
.frame(width: (isHovered || isSelected) ? 32 : 30, height: (isHovered || isSelected) ? 32 : 30)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 8))
|
||||
.shadow(color: .black.opacity(0.5), radius: 2, y: 2)
|
||||
// .shadow(color: Color("pop").opacity(0.8), radius: isSelected ? 2 : 0)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
VStack(alignment: .leading, spacing: 5) {
|
||||
Text(appInfo.appName)
|
||||
.font(.system(size: 12))
|
||||
.font(.system(size: (isHovered || isSelected) ? 14 : 12))
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
.padding(.horizontal, 5)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Spacer()
|
||||
|
||||
if appInfo.webApp {
|
||||
@@ -83,75 +80,58 @@ struct AppListItems: View {
|
||||
}
|
||||
|
||||
Text(appInfo.appVersion)
|
||||
.font(.footnote)
|
||||
.font(.system(size: (isHovered || isSelected) ? 12 : 10))
|
||||
.foregroundStyle(Color("mode").opacity(0.5))
|
||||
|
||||
if (isHovered || isSelected) && !mini {
|
||||
Triangle()
|
||||
.fill(themeSettings.themeColor)
|
||||
.frame(width: isSelected ? 16 : 8, height: 30)
|
||||
.padding(.leading, 5)
|
||||
.offset(x: 22)
|
||||
.zIndex(5)
|
||||
// if (isHovered || isSelected) {
|
||||
// RoundedRectangle(cornerRadius: 50)
|
||||
// .fill(isSelected ? Color("pear") : Color("mode").opacity(0.5))
|
||||
// .frame(width: isSelected ? 4 : 2, height: 25)
|
||||
// .padding(.trailing, 5)
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
.frame(height: 35)
|
||||
.padding(.horizontal)
|
||||
.padding(.vertical, 5)
|
||||
.help(appInfo.appName)
|
||||
.onHover { hovering in
|
||||
withAnimation(Animation.easeIn(duration: 0.2)) {
|
||||
self.isHovered = hovering
|
||||
self.hoveredItemPath = isHovered ? appInfo.path : nil
|
||||
}
|
||||
}
|
||||
.onTapGesture {
|
||||
withAnimation(Animation.easeInOut(duration: 0.4)) {
|
||||
if isSelected {
|
||||
appState.appInfo = .empty
|
||||
appState.selectedItems = []
|
||||
appState.currentView = miniView ? .apps : .empty
|
||||
showPopover = false
|
||||
} else {
|
||||
showAppInFiles(appInfo: appInfo, appState: appState, locations: locations, showPopover: $showPopover)
|
||||
}
|
||||
}
|
||||
}
|
||||
.background{
|
||||
Rectangle()
|
||||
.fill(isSelected && !glass ? themeSettings.themeColor : .clear)
|
||||
}
|
||||
.overlay{
|
||||
if (isHovered || isSelected) {
|
||||
HStack {
|
||||
Spacer()
|
||||
RoundedRectangle(cornerRadius: 50)
|
||||
.fill(isSelected ? Color("pear") : Color("mode").opacity(0.5))
|
||||
.frame(width: isSelected ? 4 : 2, height: 25)
|
||||
.padding(.trailing, 5)
|
||||
}
|
||||
|
||||
}
|
||||
.padding(.horizontal, 5)
|
||||
.help(appInfo.appName)
|
||||
.onHover { hovering in
|
||||
withAnimation(Animation.easeIn(duration: 0.2)) {
|
||||
self.isHovered = hovering
|
||||
self.hoveredItemPath = isHovered ? appInfo.path : nil
|
||||
}
|
||||
}
|
||||
.onTapGesture {
|
||||
withAnimation(Animation.easeInOut(duration: 0.4)) {
|
||||
if isSelected {
|
||||
appState.appInfo = .empty
|
||||
appState.currentView = miniView ? .apps : .empty
|
||||
showPopover = false
|
||||
} else {
|
||||
showAppInFiles(appInfo: appInfo, appState: appState, locations: locations, showPopover: $showPopover)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func opacityForItem(_ path: URL) -> Double {
|
||||
// Check if any item is selected
|
||||
let isAnyItemSelected = appState.sortedApps.contains(where: { $0.path == appState.appInfo.path })
|
||||
|
||||
let isItemSelected = appState.appInfo.path == path
|
||||
let isItemHovered = hoveredItemPath == path
|
||||
|
||||
// Logic to determine grayscale level
|
||||
if isItemSelected || !isAnyItemSelected || isItemHovered {
|
||||
return 0 // No grayscale
|
||||
} else {
|
||||
return 1.0 // Full grayscale
|
||||
}
|
||||
|
||||
// return isAnyItemSelected ? (appState.appInfo.path == appInfo.path ? 0 : 1.0) : 0
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct Triangle: Shape {
|
||||
func path(in rect: CGRect) -> Path {
|
||||
var path = Path()
|
||||
|
||||
// Start at the top right
|
||||
path.move(to: CGPoint(x: rect.maxX, y: rect.minY))
|
||||
// Add line to the bottom right
|
||||
path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))
|
||||
// Add line to the left point
|
||||
path.addLine(to: CGPoint(x: rect.minX, y: rect.midY))
|
||||
// Close the path
|
||||
path.closeSubpath()
|
||||
|
||||
return path
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user