mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Clipboard Floating Panel
This commit is contained in:
parent
e29745f8f4
commit
e583069870
12 changed files with 549 additions and 226 deletions
|
|
@ -8,18 +8,6 @@
|
|||
import SwiftUI
|
||||
import Defaults
|
||||
|
||||
enum ClipboardTab: String, CaseIterable {
|
||||
case history = "History"
|
||||
case favorites = "Favorites"
|
||||
|
||||
var icon: String {
|
||||
switch self {
|
||||
case .history: return "clock"
|
||||
case .favorites: return "heart.fill"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ClipboardWindow: View {
|
||||
@ObservedObject var clipboardManager = ClipboardManager.shared
|
||||
@State private var selectedTab: ClipboardTab = .history
|
||||
|
|
@ -126,54 +114,6 @@ struct ClipboardWindowHeader: View {
|
|||
}
|
||||
}
|
||||
|
||||
struct ClipboardTabButton: View {
|
||||
let tab: ClipboardTab
|
||||
let isSelected: Bool
|
||||
let action: () -> Void
|
||||
@ObservedObject var clipboardManager = ClipboardManager.shared
|
||||
|
||||
var itemCount: Int {
|
||||
switch tab {
|
||||
case .history:
|
||||
return clipboardManager.regularHistory.count
|
||||
case .favorites:
|
||||
return clipboardManager.pinnedItems.count
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Button(action: action) {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: tab.icon)
|
||||
.font(.system(size: 11))
|
||||
|
||||
Text(tab.rawValue)
|
||||
.font(.system(size: 11, weight: .medium))
|
||||
|
||||
if itemCount > 0 {
|
||||
Text("\(itemCount)")
|
||||
.font(.system(size: 9, weight: .bold))
|
||||
.foregroundColor(isSelected ? .white : .secondary)
|
||||
.padding(.horizontal, 4)
|
||||
.padding(.vertical, 1)
|
||||
.background(
|
||||
Capsule()
|
||||
.fill(isSelected ? Color.white.opacity(0.3) : Color.gray.opacity(0.2))
|
||||
)
|
||||
}
|
||||
}
|
||||
.foregroundColor(isSelected ? .white : .secondary)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 6)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.fill(isSelected ? Color.blue : Color.clear)
|
||||
)
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
}
|
||||
|
||||
struct ClipboardWindowContent: View {
|
||||
let selectedTab: ClipboardTab
|
||||
let searchText: String
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue