search_top_bar #1

Merged
cheykrym merged 7 commits from search_top_bar into main 2025-10-07 04:47:37 +03:00
2 changed files with 45 additions and 10 deletions
Showing only changes of commit 6583ce38bb - Show all commits

View File

@ -12,6 +12,8 @@ struct TopBarView: View {
// Привязка для управления боковым меню
@Binding var isSideMenuPresented: Bool
@State private var searchText: String = ""
var isHomeTab: Bool {
return title == "Home"
@ -103,12 +105,45 @@ struct TopBarView: View {
.padding()
.frame(height: 50) // Стандартная высота для нав. бара
if isChatsTab {
searchBar
.padding(.horizontal)
.padding(.bottom, 8)
}
Divider()
}
.background(Color(UIColor.systemBackground))
}
}
private extension TopBarView {
var searchBar: some View {
HStack(spacing: 8) {
Image(systemName: "magnifyingglass")
.foregroundColor(.secondary)
TextField(NSLocalizedString("Поиск", comment: ""), text: $searchText)
.textFieldStyle(.plain)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
if !searchText.isEmpty {
Button(action: { searchText = "" }) {
Image(systemName: "xmark.circle.fill")
.foregroundColor(.secondary)
}
.buttonStyle(.plain)
}
}
.padding(.horizontal, 12)
.padding(.vertical, 6)
.frame(minHeight: 36)
.background(
RoundedRectangle(cornerRadius: 12, style: .continuous)
.fill(Color(UIColor.secondarySystemBackground))
)
}
}
struct TopBarView_Previews: PreviewProvider {
static var previews: some View {
/*@START_MENU_TOKEN@*/Text("Hello, World!")/*@END_MENU_TOKEN@*/

View File

@ -115,16 +115,16 @@ struct ChatsTab: View {
}
}
.listStyle(.plain)
.safeAreaInset(edge: .top) {
VStack(spacing: 0) {
searchBar
.padding(.horizontal, 16)
.padding(.top, 8)
.padding(.bottom, 8)
Divider()
}
.background(Color(UIColor.systemBackground))
}
// .safeAreaInset(edge: .top) {
// VStack(spacing: 0) {
// searchBar
// .padding(.horizontal, 16)
// .padding(.top, 8)
// .padding(.bottom, 8)
// Divider()
// }
// .background(Color(UIColor.systemBackground))
// }
}
private var searchBar: some View {