mirror of
https://github.com/yattee/yattee.git
synced 2025-11-12 21:28:42 +00:00
Improve search field layout and responsiveness
SearchTextField improvements: - Add flexible width constraints (minWidth: 250, maxWidth: .infinity) for macOS - Restructure iOS layout to use HStack instead of ZStack for better alignment - Add invisible spacer to maintain consistent width when clear button is hidden - Adjust padding for more balanced appearance - Remove fixed width from fieldBorder to support flexible sizing SearchView improvements: - Wrap in GeometryReader to calculate available width dynamically - Add searchFieldWidth() helper to compute optimal search field width - Account for navigation buttons and internal padding - Apply dynamic width to both FocusableSearchTextField and SearchTextField 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -41,29 +41,33 @@ struct SearchView: View {
|
||||
|
||||
#if os(iOS)
|
||||
var body: some View {
|
||||
VStack {
|
||||
GeometryReader { geometry in
|
||||
VStack {
|
||||
if accounts.app.supportsSearchSuggestions, state.query.query != state.queryText {
|
||||
SearchSuggestions()
|
||||
.opacity(state.queryText.isEmpty ? 0 : 1)
|
||||
} else {
|
||||
results
|
||||
VStack {
|
||||
if accounts.app.supportsSearchSuggestions, state.query.query != state.queryText {
|
||||
SearchSuggestions()
|
||||
.opacity(state.queryText.isEmpty ? 0 : 1)
|
||||
} else {
|
||||
results
|
||||
}
|
||||
}
|
||||
.backport
|
||||
.scrollDismissesKeyboardInteractively()
|
||||
}
|
||||
.backport
|
||||
.scrollDismissesKeyboardInteractively()
|
||||
}
|
||||
.environment(\.listingStyle, searchListingStyle)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .principal) {
|
||||
if #available(iOS 15, *) {
|
||||
FocusableSearchTextField()
|
||||
} else {
|
||||
SearchTextField()
|
||||
.environment(\.listingStyle, searchListingStyle)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .principal) {
|
||||
if #available(iOS 15, *) {
|
||||
FocusableSearchTextField()
|
||||
.frame(width: searchFieldWidth(geometry.size.width))
|
||||
} else {
|
||||
SearchTextField()
|
||||
.frame(width: searchFieldWidth(geometry.size.width))
|
||||
}
|
||||
}
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
searchMenu
|
||||
}
|
||||
}
|
||||
ToolbarItem(placement: .navigationBarTrailing) {
|
||||
searchMenu
|
||||
}
|
||||
}
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
@@ -645,6 +649,26 @@ struct SearchView: View {
|
||||
))
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
private func searchFieldWidth(_ viewWidth: CGFloat) -> CGFloat {
|
||||
// Base padding for internal SearchTextField padding (16pt each side = 32 total)
|
||||
var totalDeduction: CGFloat = 32
|
||||
|
||||
// Add space for trailing menu button
|
||||
totalDeduction += 44
|
||||
|
||||
// Add space for sidebar toggle button if in sidebar navigation style
|
||||
if navigationStyle == .sidebar {
|
||||
totalDeduction += 44
|
||||
}
|
||||
|
||||
// Minimum width to ensure usability
|
||||
let minWidth: CGFloat = 200
|
||||
|
||||
return max(minWidth, viewWidth - totalDeduction)
|
||||
}
|
||||
#endif
|
||||
|
||||
var shouldDisplayHeader: Bool {
|
||||
#if os(tvOS)
|
||||
!state.query.isEmpty
|
||||
|
||||
Reference in New Issue
Block a user