mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 23:24:32 +00:00
68 lines
1.9 KiB
Swift
68 lines
1.9 KiB
Swift
//
|
|
// ClipboardShared.swift
|
|
// DynamicIsland
|
|
//
|
|
// Created by GitHub Copilot on 12/08/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
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 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())
|
|
}
|
|
}
|