<commit_before>import EurofurenceKit
import SwiftUI

struct ScheduleView: View {
    
    @SectionedFetchRequest(
        entity: Event.entity(),
        sectionIdentifier: \EurofurenceKit.Event.day.name,
        sortDescriptors: [
            NSSortDescriptor(key: "day.date", ascending: true)
        ],
        animation: .spring()
    )
    private var searchResults: SectionedFetchResults<String, Event>
    
    @State private var searchQuery: String = ""
    @State private var selectedDay: Day?
    @State private var selectedTrack: Track?
    
    var body: some View {
        List {
            if searchQuery.isEmpty {
                NavigationLink {
                    Text("Favourite Events")
                } label: {
                    Label {
                        Text("Favourite Events")
                    } icon: {
                        Image(systemName: "heart")
                            .foregroundColor(.red)
                    }
                }
                
                Section {
                    EventConferenceDaysView(selectedDay: $selectedDay)
                } header: {
                    Text("Days")
                }
                .headerProminence(.increased)
                
                Section {
                    EventConferenceTracksView(selectedTrack: $selectedTrack)
                } header: {
                    Text("Tracks")
                }
                .headerProminence(.increased)
            } else {
                ForEach(searchResults) { group in
                    Section {
                        ForEach(group) { event in
                            NavigationLink {
                                Text(event.title)
                            } label: {
                                Text(event.title)
                            }
                        }
                    } header: {
                        Text(group.id)
                    }
                }
            }
        }
        .listStyle(.insetGrouped)
        .navigationTitle("Schedule")
        .onChange(of: searchQuery) { newValue in
            searchResults.nsPredicate = Event.predicateForTextualSearch(query: newValue)
        }
        .searchable(text: $searchQuery)
    }
    
}

struct ScheduleView_Previews: PreviewProvider {
    
    static var previews: some View {
        EurofurenceModel.preview { _ in
            NavigationView {
                ScheduleView()
            }
        }
    }
    
}<commit_msg>Enable pull-to-refresh in tabbed schedule view<commit_after>import EurofurenceKit
import SwiftUI

struct ScheduleView: View {
    
    @SectionedFetchRequest(
        entity: Event.entity(),
        sectionIdentifier: \EurofurenceKit.Event.day.name,
        sortDescriptors: [
            NSSortDescriptor(key: "day.date", ascending: true)
        ],
        animation: .spring()
    )
    private var searchResults: SectionedFetchResults<String, Event>
    
    @State private var searchQuery: String = ""
    @State private var selectedDay: Day?
    @State private var selectedTrack: Track?
    
    var body: some View {
        List {
            if searchQuery.isEmpty {
                NavigationLink {
                    Text("Favourite Events")
                } label: {
                    Label {
                        Text("Favourite Events")
                    } icon: {
                        Image(systemName: "heart")
                            .foregroundColor(.red)
                    }
                }
                
                Section {
                    EventConferenceDaysView(selectedDay: $selectedDay)
                } header: {
                    Text("Days")
                }
                .headerProminence(.increased)
                
                Section {
                    EventConferenceTracksView(selectedTrack: $selectedTrack)
                } header: {
                    Text("Tracks")
                }
                .headerProminence(.increased)
            } else {
                ForEach(searchResults) { group in
                    Section {
                        ForEach(group) { event in
                            NavigationLink {
                                Text(event.title)
                            } label: {
                                Text(event.title)
                            }
                        }
                    } header: {
                        Text(group.id)
                    }
                }
            }
        }
        .refreshesModel()
        .listStyle(.insetGrouped)
        .navigationTitle("Schedule")
        .onChange(of: searchQuery) { newValue in
            searchResults.nsPredicate = Event.predicateForTextualSearch(query: newValue)
        }
        .searchable(text: $searchQuery)
    }
    
}

struct ScheduleView_Previews: PreviewProvider {
    
    static var previews: some View {
        EurofurenceModel.preview { _ in
            NavigationView {
                ScheduleView()
            }
        }
    }
    
}
{'fraction_non_alphanumeric': 0.07507389162561576, 'fraction_numerical': 0.0, 'mean_word_length': 1.0533980582524272, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5008275', 'n_tokens_mistral': 1251, 'n_tokens_neox': 1143, 'n_words': 218}