Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import SwiftUI
- struct ScreenerFilterView: View {
- @State private var searchText = ""
- let filters: Filters
- var body: some View {
- #if DEBUG
- let _ = Self._printChanges()
- #endif
- ScrollView {
- LazyVStack(alignment: .leading, spacing: 20) {
- TextField("Search filter...", text: $searchText)
- .disableAutocorrection(true)
- .textFieldStyle(.plain)
- .padding(8)
- .foregroundStyle(.black)
- .autocorrectionDisabled(true)
- .background(
- RoundedRectangle(cornerRadius: 5)
- .stroke(Color.gray.opacity(0.6), lineWidth: 1)
- .fill(Color.white)
- )
- .padding(.horizontal, 10)
- ForEach(filters.data, id: \.name) { (group: FilterGroup) in
- Section(header: Text(group.name)
- .font(.title2)
- .foregroundColor(.blue)
- .fontWeight(.medium)
- ) {
- FilterView(filters: group.data)
- }
- }
- }
- .padding(.vertical)
- .padding(.horizontal)
- }
- }
- }
- struct FilterView: View {
- let columns = [
- GridItem(.flexible(minimum: 250), alignment: .leading),
- GridItem(.flexible(minimum: 250), alignment: .leading),
- GridItem(.flexible(minimum: 250), alignment: .leading)
- ]
- let filters: [Filter]
- var body: some View {
- #if DEBUG
- let _ = Self._printChanges()
- #endif
- LazyVGrid(columns: columns, spacing: 10) {
- ForEach(filters, id: \.name) { (item: Filter) in
- FilterItemView(name: item.name, selected: item.selected)
- }
- }
- .frame(alignment: .leading)
- }
- }
- struct FilterItemView: View {
- let name: String
- @State var selected: Bool
- var body: some View {
- #if DEBUG
- let _ = Self._printChanges()
- #endif
- Toggle(name, isOn: $selected)
- .animation(nil, value: selected)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement