Adopt modern SwiftUI patterns now that the minimum target is iOS 18: NavigationStack, .toolbar, .tint, new Tab API with sidebarAdaptable style, and remove iOS 17 availability checks. Add Liquid Glass effect support for iOS 26 in TimerView and fix an optional interpolation warning in AppState. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
68 lines
2.2 KiB
Swift
68 lines
2.2 KiB
Swift
//
|
|
// ContentView.swift
|
|
// Nextcloud Cookbook iOS Client
|
|
//
|
|
// Created by Vincent Meilinger on 06.09.23.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct MainView: View {
|
|
@StateObject var appState = AppState()
|
|
@StateObject var groceryList = GroceryList()
|
|
|
|
// Tab ViewModels
|
|
@StateObject var recipeViewModel = RecipeTabView.ViewModel()
|
|
@StateObject var searchViewModel = SearchTabView.ViewModel()
|
|
|
|
@State private var selectedTab: Tab = .recipes
|
|
|
|
enum Tab {
|
|
case recipes, search, groceryList
|
|
}
|
|
|
|
var body: some View {
|
|
TabView(selection: $selectedTab) {
|
|
SwiftUI.Tab("Recipes", systemImage: "book.closed.fill", value: .recipes) {
|
|
RecipeTabView()
|
|
.environmentObject(recipeViewModel)
|
|
.environmentObject(appState)
|
|
.environmentObject(groceryList)
|
|
}
|
|
|
|
SwiftUI.Tab("Search", systemImage: "magnifyingglass", value: .search, role: .search) {
|
|
SearchTabView()
|
|
.environmentObject(searchViewModel)
|
|
.environmentObject(appState)
|
|
.environmentObject(groceryList)
|
|
}
|
|
|
|
SwiftUI.Tab("Grocery List", systemImage: "storefront", value: .groceryList) {
|
|
GroceryListTabView()
|
|
.environmentObject(groceryList)
|
|
}
|
|
}
|
|
.tabViewStyle(.sidebarAdaptable)
|
|
.modifier(TabBarMinimizeModifier())
|
|
.task {
|
|
recipeViewModel.presentLoadingIndicator = true
|
|
await appState.getCategories()
|
|
await appState.updateAllRecipeDetails()
|
|
|
|
// Open detail view for default category
|
|
if UserSettings.shared.defaultCategory != "" {
|
|
if let cat = appState.categories.first(where: { c in
|
|
if c.name == UserSettings.shared.defaultCategory {
|
|
return true
|
|
}
|
|
return false
|
|
}) {
|
|
recipeViewModel.selectedCategory = cat
|
|
}
|
|
}
|
|
await groceryList.load()
|
|
recipeViewModel.presentLoadingIndicator = false
|
|
}
|
|
}
|
|
}
|