Post

Replies

Boosts

Views

Activity

NavigationSplitView
Hello everyone, I am currently trying to implement and test the latest SwiftUI changes with Xcode 16 Beta 3. Now I wanted to create, like in FreeForm, that I have a grid in the detail column with tiles in a NavigationSplitView. If you now press on the tile, a DetailView (in my code its an EmptyView) should open with the zoom effect and in fullscreen so that the NavigationSplitView disappears and the NavigationBar is no longer there. In FreeForm the desired effect is when you create a new board. any tips or hints? struct CanvasGrid: View { @Namespace var namespace; var body: some View { if let project = project { if viewMode == .grid { ScrollView{ LazyVGrid(columns: columns, spacing: 10) { ForEach(sortedCanvases) { canvas in NavigationLink { EmptyView() .navigationTransition( .zoom(sourceID: canvas.id, in: namespace) ) } label: { CanvasTile(canvas: canvas) } .matchedTransitionSource(id: canvas.id, in: namespace) } } .searchable(text: $searchText) .navigationTitle(project.name) } } #Preview { NavigationStack{ CanvasGrid(project: SampleData.shared.project) } } ...... struct ContentView: View { var body: some View { NavigationSplitView { List(selection: $selectedProject) { ForEach(projects, id: \.self) { project in HStack { NavigationLink(project.name, value: project) Spacer() Button(action: { showingEditSheet.toggle() }) { Image(systemName: "pencil") .foregroundColor(.blue) } .buttonStyle(BorderlessButtonStyle()) } } } } detail: { NavigationStack(path: $path) { CanvasGrid(project:selectedProject).padding(.leading, 10) } } .navigationSplitViewStyle(.balanced) .onAppear() { selectedProject = projects.first } } ...... } #Preview { ContentView() .modelContainer(SampleData.shared.modelContainer) }
0
0
292
Jul ’24
TextEditor automatically adjusts the height
Good day together, I am currently trying to adjust the height of my TextEditor automatically. The whole thing should not increase further once 3 lines are reached. The whole thing is modeled after the text field in the iMessage app. Now to my problem: I'm trying to recreate the whole thing in SwiftUI and so far it works quite well, but I currently have the problem that the height of the control is not automatically adjusted and I unfortunately do not know how to do it best. Does anyone have a suggestion or even a solution for this? SwiftUI Snippet: VStack{           List{           }.listStyle(.plain)           HStack(alignment: .center){             Button{                             }label:{               Image(systemName: "plus.circle")                 .resizable()                 .frame(width: 25, height: 25, alignment: .center)             }             HStack{               TextEditor(text: $message)                 .focused($focusedField, equals: .messageView_TextEditor)                 .foregroundColor(self.message == "Message" ? .gray : .primary)                 .frame(height:35.0)                 .onTapGesture {                   if self.message == "Message"{                     self.message = ""                   }                 }                 .padding(.leading,10)                               Button{                                 }label:{                 Image(systemName: "arrow.up.circle.fill")                   .resizable()                   .frame(width: 25, height: 25, alignment: .center)                   .padding(.trailing,5)                   .foregroundColor(.green)               }             }.overlay(               RoundedRectangle(cornerRadius: 8)                 .stroke(Color.gray, lineWidth: 1)             )           }           .padding(.bottom)                                 }
1
0
1.7k
Mar ’22
Add controls to large title in navigation bar
Good day together, I am already in despair, I would like to insert a button in the NavigationBar next to the NavigationBarTitle which also automatically shrinks or enlarges. The whole thing can be seen in the App Store under the menu item "search". There, when the user scrolls down, the search bar and the title is given as .inline but not the user button. I am currently trying to implement the whole thing in SwiftUI and can't find a solution. Is there already a solution for this or if someone has the exact documentation for this case I would be very grateful for it :). thank you very much!
2
0
1.5k
Mar ’21