mana-swift-ui/Sources/ManaComponentsUI/ManaSearchButton.swift
Till JS ae3135d06b ManaSearchButton: größeres Icon (46×46, 20pt)
Such-Icon der Bottom-Filter-Leisten flottenweit vergrößert
(40×40/17pt → 46×46/20pt). Wirkt in seepuls/comicello/zitare.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 02:10:01 +02:00

63 lines
2.3 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import ManaTokens
import SwiftUI
/// Rundes Such-Icon für die Bottom-Filter-Leiste — Einstieg in die
/// *native* Suche (`.searchable(text:isPresented:)`). Gedacht als fester
/// Anker **rechts** in einer Filter-Leiste (außerhalb des horizontalen
/// Pill-Scrollers), Platzierung wie die System-Suche in der Apple-
/// Podcasts-App. Referenz-Adoption: seepuls-Events/Orte-Tab.
///
/// Form & Größe sind hier zentral festgelegt (46×46, `.circle`), damit das
/// Icon über die Flotte gleich aussieht. Farbe kommt aus der aktiven
/// Theme-Variant via `@Environment(\.manaTheme)` — keine Farb-Parameter,
/// analog zu ``ManaPill``.
///
/// **iOS 26:** echtes Liquid-Glass (`glassEffect`). **iOS 18–25:**
/// Material-Kreis mit Hairline — konsistent mit den Filter-Leisten-Gläsern.
///
/// ```swift
/// // In der Filter-Leiste, rechts neben dem Pill-Scroller:
/// HStack {
/// ScrollView(.horizontal) { /* Filter-Pills */ }
/// ManaSearchButton { searchPresented = true }
/// }
/// // dazu am Screen: .searchable(text: $q, isPresented: $searchPresented)
/// ```
public struct ManaSearchButton: View {
@Environment(\.manaTheme) private var theme
private let action: () -> Void
/// - Parameter action: Tap-Handler — typischerweise `isPresented = true`,
/// das den `.searchable`-Modifier öffnet.
public init(action: @escaping () -> Void) {
self.action = action
}
public var body: some View {
Button(action: action) {
Image(systemName: "magnifyingglass")
.font(.system(size: 20, weight: .semibold))
.foregroundStyle(theme.colors.primary)
.frame(width: 46, height: 46)
.modifier(SearchButtonBackground(border: theme.colors.border))
}
.buttonStyle(.plain)
.accessibilityLabel("Suchen")
}
}
/// iOS 26: Liquid-Glass-Kreis. Fallback: Material-Kreis mit Hairline.
private struct SearchButtonBackground: ViewModifier {
let border: Color
func body(content: Content) -> some View {
if #available(iOS 26, macOS 26, *) {
content.glassEffect(.regular.interactive(), in: .circle)
} else {
content
.background(.ultraThinMaterial, in: .circle)
.overlay(Circle().stroke(border, lineWidth: 0.5))
}
}
}