These sources will be converted to be more flexible with JavaScript in the future. The source catalog is populated by adding a source list in settings then installing a source from the catalog. Sources can be enabled or disabled when using Ferrite. Signed-off-by: kingbri <bdashore3@gmail.com>
70 lines
1.8 KiB
Swift
70 lines
1.8 KiB
Swift
//
|
|
// MainView.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 7/11/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
enum Tab {
|
|
case search
|
|
case sources
|
|
case settings
|
|
}
|
|
|
|
struct MainView: View {
|
|
@EnvironmentObject var toastModel: ToastViewModel
|
|
|
|
@State private var tabSelection: Tab = .search
|
|
|
|
var body: some View {
|
|
TabView(selection: $tabSelection) {
|
|
ContentView()
|
|
.tabItem {
|
|
Label("Search", systemImage: "magnifyingglass")
|
|
}
|
|
.tag(Tab.search)
|
|
|
|
SourceListView()
|
|
.tabItem {
|
|
Label("Sources", systemImage: "doc.text")
|
|
}
|
|
.tag(Tab.sources)
|
|
|
|
SettingsView()
|
|
.tabItem {
|
|
Label("Settings", systemImage: "gear")
|
|
}
|
|
.tag(Tab.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()
|
|
}
|
|
}
|