This commit is contained in:
Alin
2024-02-12 18:09:49 -07:00
parent 18b9ceb564
commit 09b2785cd2
13 changed files with 230 additions and 107 deletions
+38 -24
View File
@@ -12,10 +12,13 @@ struct AppListItems: View {
@EnvironmentObject var appState: AppState
@Binding var search: String
@State private var isHovered = false
@State private var windowSettings = WindowSettings()
@Environment(\.colorScheme) var colorScheme
@AppStorage("settings.general.mini") private var mini: Bool = false
@AppStorage("settings.general.popover") private var popoverStay: Bool = true
@Binding var showPopover: Bool
@EnvironmentObject var locations: Locations
let itemId = UUID()
let appInfo: AppInfo
var isSelected: Bool {
appState.appInfo == appInfo
@@ -74,20 +77,6 @@ struct AppListItems: View {
}
// .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)
@@ -97,18 +86,43 @@ struct AppListItems: View {
}
}
.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
showPopover = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
updateOnMain {
appState.appInfo = .empty
appState.appInfo = appInfo
// appState.progressManager.resetProgress()
findPathsForApp(appState: appState, locations: locations)
withAnimation(Animation.easeIn(duration: 0.4)) {
if mini {
showPopover.toggle()
} else {
appState.currentView = .files
}
}
}
}
}
.popover(isPresented: Binding(
get: { showPopover && appState.appInfo.id == appInfo.id},
set: { _ in showPopover = false}
), attachmentAnchor: .rect(.rect(CGRect(x: windowSettings.loadWindowSettings().width - 17, y: 15, width: 0, height: 0))), arrowEdge: .trailing) {
// .popover(isPresented: $showPopover, arrowEdge: .trailing) {
VStack {
FilesView(showPopover: $showPopover, search: $search)
.id(appState.appInfo.id)
}
.interactiveDismissDisabled(popoverStay)
.background(
Rectangle()
.fill(Color("pop"))
.padding(-80)
)
.frame(minWidth: 650, minHeight: 500)
}
}
}