Swift Student Challenge

RSS for tag

Ask questions and connect with other challenge applicants.

Posts under Swift Student Challenge tag

42 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

NavigationSplitView how to disable the side bar, to make it like the reminder app in iPad?
I want to make it like this How to disable the button that open the side bar, I only need the content and the detail view. I don't need the sidebar view. Below is my code import SwiftUI @available(iOS 16.0, *) struct Screen: View { @ObservedObject var userData = UserData() @State private var isIntroShown = true @State var Itema: Bool = false @State private var showFoodDetail = false @State var rb: Bool = false @State var Setting: Bool = false @State var Recipe: Bool = false @Environment(\.defaultMinListRowHeight) var minRowHeight @Environment(\.colorScheme) var colorScheme @State private var searchText = "" private let adaptiveColumns = [ GridItem(.adaptive(minimum: 170)) ] var columns = Array(repeating: GridItem(.flexible(), spacing: 10), count: 2) var filteredRooms: [Room] { if searchText.isEmpty { return userData.rooms } else { return userData.rooms.filter { room in let foodNames = room.food.map { $0.name.lowercased() } return room.name.lowercased().contains(searchText.lowercased()) || foodNames.contains { $0.contains(searchText.lowercased()) } } } } @State private var columnVisibility = NavigationSplitViewVisibility.doubleColumn var body: some View { NavigationSplitView (columnVisibility: $columnVisibility){ } content: { ScrollView{ GridView() .padding(.horizontal) .padding(.bottom, 20) }.toolbar { ToolbarItem(placement: .bottomBar){ Button(action:{self.Itema = true}) { HStack { Image(systemName: "plus.circle.fill").resizable().frame(width: 20, height: 20).foregroundColor(.white) Text("New Item").foregroundColor(.white).bold() } } .sheet(isPresented: self.$Itema){ NewItem(userData: self.userData) } } ToolbarItem(placement: .bottomBar){ Button(action:{self.rb = true}) { HStack { Text("New Room").foregroundColor(.white) } } .sheet(isPresented: self.$rb){ NewRoom(userData: self.userData) } } ToolbarItem(placement: .navigationBarTrailing){ Button(action:{self.Setting = true}) { HStack { Image(systemName: "gear").foregroundColor(.white) } } .sheet(isPresented: self.$Setting){ NavigationView { NewItem( userData: userData) .navigationBarItems(trailing:Button(action: { self.Setting = false }){ Text("Done") } ) } } } } .background(Color(red: 203/255, green: 237/255, blue: 207/255)) } detail: { ZStack { Text("") } .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color(red: 220/255, green: 247/255, blue: 234/255)) } .searchable(text: $searchText) } }
1
1
1.1k
Jul ’23