swiftui-list

Can’t pass data correctly to modal presentation using ForEach and CoreData in SwiftUI

*爱你&永不变心* 提交于 2020-04-16 05:48:15
问题 Im trying to pass data of some object from list of objects to modal sheet, fetching data from CoreData. The problem is that no matter what object I click on in the list, only the data form last added object appears in the details view. The same goes for deleting the object - no matter what object I'm trying to delete, the last one is deleted all the time. Problem disappears using NavigationLink, but it is not suitable for me. Here is my code: import SwiftUI struct CarScrollView: View {

SwiftUI reduce spacing of rows in a list to null

你说的曾经没有我的故事 提交于 2020-04-16 05:45:09
问题 I want to reduce the linespacing in a list to null. My tries with reducing the padding did not work. Setting ´.environment(.defaultMinListRowHeight, 0)´ helped a lot. struct ContentView: View { @State var data : [String] = ["first","second","3rd","4th","5th","6th"] var body: some View { VStack { List { ForEach(data, id: \.self) { item in Text("\(item)") .padding(0) //.frame(height: 60) .background(Color.yellow) } //.frame(height: 60) .padding(0) .background(Color.blue) } .environment(\

Swift UI Overlay a list to a background color

夙愿已清 提交于 2020-03-23 07:50:40
问题 I just want to set a Color as background color to my list. Can't find anything that work, It looks like is not possible, I don't want to change every single color of my row. Any tips how to do it? Looks like SwiftUI and List don't allow the background color, it allow only color per single raw. struct ContentView: View { var body: some View { ZStack { RadialGradient(gradient: Gradient(colors: [.orange, .red]), center: .center, startRadius: 100, endRadius: 470).edgesIgnoringSafeArea(.all)

Swiftui List Row Cells set padding after View appears

泪湿孤枕 提交于 2020-03-17 11:01:05
问题 I have a standard List only with one Text and on the right side the arrow for navigation. But after the list is loading and appeared at Screen, the list addapt the cells I think they add padding at the left and at the right. But this is not looking good, so it is looking like the list lags! List { ForEach(0..<book.chapters) { index in NavigationLink(destination: ReadingView(book: self.book, chapter: index)){ Text("Kapitel \(index + 1)") } } } .navigationBarTitle(Text(book.long_name),

NavigationLink freezes when trying to revisit previously clicked NavigationLink in SwiftUI

房东的猫 提交于 2020-03-17 08:44:20
问题 I am designing an app that includes the function of retrieving JSON data and displaying a list of retrieved items in a FileBrowser type view. In this view, a user should be able to click on a folder to dive deeper into the file tree or click on a file to view some metadata about said file. I've observed that while this is working, when I click on a file or folder then go back and click on it again, the NavigationLink is not triggered and I am stuck on the view until I click into a different

Refreshing a SwiftUI List

时光毁灭记忆、已成空白 提交于 2020-03-14 18:20:58
问题 Ím trying to refresh this List whenever I click on a NavLink NavigationView { List(feed.items.indices, id:\.self) { i in NavigationLink(destination: ListFeedItemDetail(idx: i).environmentObject(self.feed)) { ListFeedItem(item: self.$feed.items[i]) } } } The list is made out of an array inside an environment object. The problem: It does only refresh when I switch to another tab or close the app I had used a modal View before and it worked there. (I did it with .onAppear) Any Ideas? Example

Refreshing a SwiftUI List

本秂侑毒 提交于 2020-03-14 18:15:19
问题 Ím trying to refresh this List whenever I click on a NavLink NavigationView { List(feed.items.indices, id:\.self) { i in NavigationLink(destination: ListFeedItemDetail(idx: i).environmentObject(self.feed)) { ListFeedItem(item: self.$feed.items[i]) } } } The list is made out of an array inside an environment object. The problem: It does only refresh when I switch to another tab or close the app I had used a modal View before and it worked there. (I did it with .onAppear) Any Ideas? Example

Refreshing a SwiftUI List

家住魔仙堡 提交于 2020-03-14 18:14:59
问题 Ím trying to refresh this List whenever I click on a NavLink NavigationView { List(feed.items.indices, id:\.self) { i in NavigationLink(destination: ListFeedItemDetail(idx: i).environmentObject(self.feed)) { ListFeedItem(item: self.$feed.items[i]) } } } The list is made out of an array inside an environment object. The problem: It does only refresh when I switch to another tab or close the app I had used a modal View before and it worked there. (I did it with .onAppear) Any Ideas? Example

Horizontal scrollview is not working swiftUI

╄→尐↘猪︶ㄣ 提交于 2020-02-25 05:25:11
问题 i'm trying to show some horizontal view but it's not working. below are the code i'm using. @State var userDataList = [UserModel]() var body: some View{ VStack(spacing: 10){ VStack{ prefView() .padding(.bottom, 30) Text("Tap to start making friend") } ScrollView(.horizontal, content: { HStack(spacing: 10) { ForEach(userDataList) { user in NavigationLink(destination: ChatView(chatMember: self.chatmember, user: user)){ SearchUser() } } } .padding(.leading, 10) }) .frame(width: 300, height: 400)

Why is my SwiftUI List row not always updating internally

时间秒杀一切 提交于 2020-01-25 03:14:07
问题 I have a list of reminders grouped into sections by completion and date. With data coming from an ObservedObject DataStore called global. I pass a realmBinding to the cell. The cell can update this binding and it will trigger the data store to update. List { // Past Due if self.global.pastDueReminders.count > 0 { Section(header: SectionHeader {}){ ForEach(self.global.pastDueReminders) { reminder in NavigationLink(destination: ReminderDetail( reminder: reminder.realmBinding())) {