mirror of
https://github.com/exituser/Pearcleaner.git
synced 2026-09-17 08:29:07 +00:00
115 lines
4.1 KiB
Swift
115 lines
4.1 KiB
Swift
//
|
|
// AppListDetails.swift
|
|
// Pearcleaner
|
|
//
|
|
// Created by Alin Lupascu on 11/10/23.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftUI
|
|
|
|
struct AppListItems: View {
|
|
@EnvironmentObject var appState: AppState
|
|
@Binding var search: String
|
|
@State private var isHovered = false
|
|
@Environment(\.colorScheme) var colorScheme
|
|
@AppStorage("settings.general.mini") private var mini: Bool = false
|
|
@Binding var showPopover: Bool
|
|
|
|
let appInfo: AppInfo
|
|
var isSelected: Bool {
|
|
appState.appInfo == appInfo
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 5) {
|
|
HStack(alignment: .center) {
|
|
|
|
if let appIcon = appInfo.appIcon {
|
|
Image(nsImage: appIcon)
|
|
.resizable()
|
|
.aspectRatio(contentMode: .fit)
|
|
.frame(width: 30, height: 30)
|
|
.clipShape(RoundedRectangle(cornerRadius: 8))
|
|
}
|
|
VStack(alignment: .leading, spacing: 5) {
|
|
Text(appInfo.appName)
|
|
.font(.system(size: 12))
|
|
.lineLimit(1)
|
|
.truncationMode(.tail)
|
|
.padding(.horizontal, 5)
|
|
}
|
|
if appInfo.webApp {
|
|
Text("web")
|
|
.font(.footnote)
|
|
.foregroundStyle(Color("mode").opacity(0.5))
|
|
.frame(minWidth: 30, minHeight: 15)
|
|
.padding(2)
|
|
.background(Color("mode").opacity(0.1))
|
|
.clipShape(.capsule)
|
|
}
|
|
if appInfo.wrapped {
|
|
Text("iOS")
|
|
.font(.footnote)
|
|
.foregroundStyle(Color("mode").opacity(0.5))
|
|
.frame(minWidth: 30, minHeight: 15)
|
|
.padding(2)
|
|
.background(Color("mode").opacity(0.1))
|
|
.clipShape(.capsule)
|
|
}
|
|
|
|
|
|
Spacer()
|
|
Text(appInfo.appVersion)
|
|
.font(.footnote)
|
|
.foregroundStyle(Color("mode").opacity(0.5))
|
|
|
|
if isHovered || isSelected {
|
|
RoundedRectangle(cornerRadius: 50)
|
|
.fill(isSelected ? Color("AccentColor") : Color("mode").opacity(0.5))
|
|
.frame(width: isSelected ? 4 : 2, height: 30)
|
|
.padding(.leading, 5)
|
|
.offset(x: 20)
|
|
}
|
|
|
|
}
|
|
|
|
// .background(
|
|
// RoundedRectangle(cornerRadius: 6)
|
|
// .fill(isSelected ? Color("AccentColor").opacity(0.15) : (isHovered ? Color("AccentColor").opacity(0.1) : Color.white.opacity(colorScheme == .dark ? 0.05 : 0.8)))
|
|
// .shadow(color: .black.opacity(0.2), radius: 2, x: 0, y: 1)
|
|
// .overlay(
|
|
// RoundedRectangle(cornerRadius: 6)
|
|
// .strokeBorder(Color("AccentColor").opacity(isHovered ? 0.7 : 0.1), lineWidth: 1)
|
|
// )
|
|
// )
|
|
|
|
// Rectangle()
|
|
// .frame(maxWidth: isSelected ? .infinity : (isHovered ? .infinity : 30), maxHeight: 2)
|
|
// .foregroundStyle(Color("AccentColor"))
|
|
|
|
}
|
|
.padding(.horizontal, 5)
|
|
.help(appInfo.appName)
|
|
.onHover { hovering in
|
|
withAnimation(Animation.easeIn(duration: 0.2)) {
|
|
self.isHovered = hovering
|
|
}
|
|
}
|
|
.onTapGesture {
|
|
updateOnMain {
|
|
appState.appInfo = .empty
|
|
appState.appInfo = appInfo
|
|
findPathsForApp(appState: appState, appInfo: appState.appInfo)
|
|
withAnimation(Animation.easeIn(duration: 0.4)) {
|
|
if mini {
|
|
showPopover.toggle()
|
|
} else {
|
|
appState.currentView = .files
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|