Raise deployment target to iOS 18 and modernize SwiftUI APIs
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>
This commit is contained in:
@@ -10,46 +10,40 @@ 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 {
|
||||
RecipeTabView()
|
||||
.environmentObject(recipeViewModel)
|
||||
.environmentObject(appState)
|
||||
.environmentObject(groceryList)
|
||||
.tabItem {
|
||||
Label("Recipes", systemImage: "book.closed.fill")
|
||||
}
|
||||
.tag(Tab.recipes)
|
||||
|
||||
SearchTabView()
|
||||
.environmentObject(searchViewModel)
|
||||
.environmentObject(appState)
|
||||
.environmentObject(groceryList)
|
||||
.tabItem {
|
||||
Label("Search", systemImage: "magnifyingglass")
|
||||
}
|
||||
.tag(Tab.search)
|
||||
|
||||
GroceryListTabView()
|
||||
.environmentObject(groceryList)
|
||||
.tabItem {
|
||||
if #available(iOS 17.0, *) {
|
||||
Label("Grocery List", systemImage: "storefront")
|
||||
} else {
|
||||
Label("Grocery List", systemImage: "heart.text.square")
|
||||
}
|
||||
}
|
||||
.tag(Tab.groceryList)
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user