Ferrite-backup/Ferrite/Views/MainView.swift
kingbri 44e4f74258 Searching: Cleanup existing searches
If a user searched after cancelling the search the first time,
the first search would still continue.

Assign the search task to navigation view and automatically cancel
it and dismiss the searchbar when the user switches to a different
tab.

Also add a ProgressView to show which source is being parsed.

Signed-off-by: kingbri <bdashore3@gmail.com>
2022-08-09 12:29:18 -04:00

63 lines
1.8 KiB
Swift

//
// MainView.swift
// Ferrite
//
// Created by Brian Dashore on 7/11/22.
//
import SwiftUI
struct MainView: View {
@EnvironmentObject var navModel: NavigationViewModel
@EnvironmentObject var toastModel: ToastViewModel
var body: some View {
TabView(selection: $navModel.selectedTab) {
ContentView()
.tabItem {
Label("Search", systemImage: "magnifyingglass")
}
.tag(ViewTab.search)
SourcesView()
.tabItem {
Label("Sources", systemImage: "doc.text")
}
.tag(ViewTab.sources)
SettingsView()
.tabItem {
Label("Settings", systemImage: "gear")
}
.tag(ViewTab.settings)
}
.overlay {
VStack {
Spacer()
if toastModel.showToast {
GroupBox {
switch toastModel.toastType {
case .info:
Text(toastModel.toastDescription ?? "This shouldn't be showing up... Contact the dev!")
case .error:
Text("Error: \(toastModel.toastDescription ?? "This shouldn't be showing up... Contact the dev!")")
}
}
.groupBoxStyle(ErrorGroupBoxStyle())
Rectangle()
.foregroundColor(.clear)
.frame(height: 60)
}
}
.font(.caption)
.animation(.easeInOut(duration: 0.3), value: toastModel.showToast)
}
}
}
struct MainView_Previews: PreviewProvider {
static var previews: some View {
MainView()
}
}