swiftui-list

SwiftUI macOS Scroll a List With Arrow Keys While a TextField is Active

浪子不回头ぞ 提交于 2020-06-12 15:22:20
问题 I'd like to use a SwiftUI TextField and a SwiftUI List to render a "search box" above a list of items. Something roughly like the search box available in Safari's Help menu item...which provides a search box where you can always enter text while simultaneously browsing through the list of results using the up and down arrow keys. I've played with onMoveCommand, focusable, and adjustments to the "parent" NSWindow , but haven't found a clear and obvious way for the TextField to constantly

Change NavigationLink destination conditionally in SwiftUI

别说谁变了你拦得住时间么 提交于 2020-05-31 03:32:17
问题 I have a view with a List and depending on the item of the list I have clicked on, I need to open a different NavigationLink. I have a row model for one row of the List (I'm saying List even though I'm actually usually using a custom made element called Collection, which is a List with HStack and VStack together to emulate the UICollectionView ) In the row model view I can only specify one destination for the NavigationLink. A solution I can think of is getting the index of the item of the

Change NavigationLink destination conditionally in SwiftUI

China☆狼群 提交于 2020-05-31 03:30:45
问题 I have a view with a List and depending on the item of the list I have clicked on, I need to open a different NavigationLink. I have a row model for one row of the List (I'm saying List even though I'm actually usually using a custom made element called Collection, which is a List with HStack and VStack together to emulate the UICollectionView ) In the row model view I can only specify one destination for the NavigationLink. A solution I can think of is getting the index of the item of the

Change NavigationLink destination conditionally in SwiftUI

有些话、适合烂在心里 提交于 2020-05-31 03:30:25
问题 I have a view with a List and depending on the item of the list I have clicked on, I need to open a different NavigationLink. I have a row model for one row of the List (I'm saying List even though I'm actually usually using a custom made element called Collection, which is a List with HStack and VStack together to emulate the UICollectionView ) In the row model view I can only specify one destination for the NavigationLink. A solution I can think of is getting the index of the item of the

Swiftui [BUG] NavigationView and List not showing on iPad simulator only

时光怂恿深爱的人放手 提交于 2020-05-29 04:52:29
问题 Blank page on all kinds of iPad simulator Go to Apple developer website to download tutorials project below: https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation Run this on any iPad simulator, you will just get a blank page, but the code works fine on simulator of Mac/iPhone and my real iPhone device. This is definitely a bug, and I've reported to Apple, I am posting here just want ppl like me who said this issue, pls don't waste your time on reset simulator, checking

SwiftUI List Background color [duplicate]

喜欢而已 提交于 2020-05-16 04:04:57
问题 This question already has answers here : SwiftUI List color background (7 answers) Closed 7 months ago . I am trying on setting a view background color to black with the following code struct RuleList: View {[![enter image description here][1]][1] private var presenter: ConfigurationPresenter? @ObservedObject private var viewModel: RowListViewModel init(presenter: ConfigurationPresenter?, viewModel: RowListViewModel) { self.presenter = presenter self.viewModel = viewModel } var body: some

How to render multiline text in SwiftUI List with correct height?

我怕爱的太早我们不能终老 提交于 2020-05-14 18:42:07
问题 I would like to have a SwiftUI view that shows many lines of text, with the following requirements: Works on both macOS and iOS. Shows a large number of strings (each string is backed by a separate model object). I can do arbitrary styling to the multiline text. Each string of text can be of arbitrary length, possibly spanning multiple lines and paragraphs. The maximum width of each string of text is fixed to the width of the container. Height is variable according to the actual length of

SwiftUI: ForEach using Array/Index crashes when rows are deleted

我与影子孤独终老i 提交于 2020-05-09 05:59:49
问题 I've seen several posts about this, but so far none of the solutions seem to be working for me. I'm trying to create an array of Identifiable items using ForEach -- with both a Text() and Toggle() view inside. The array is stored in a @Published property of an @ObservableObject . I'm currently looping through the indices to create the toggle bindings (as suggested in other posts). Everything appears to be working, until I try to delete a row. (Specifically the last row - which triggers a

SwiftUI Toggle in a VStack is misaligned

陌路散爱 提交于 2020-04-30 10:31:09
问题 I have a simple List where each row is a Toggle with its Text and Text as a subtitle all in a VStack . All works fine until I start showing or hiding some rows. Somehow the switch of the Toggle view is misaligned and is placed over its title. This happens only on the device and not when running on the simulator. It happens with both XCode 13.3 and 13.4 beta on a device running iOS 13.3.1 The complete example is import SwiftUI struct ContentView: View { @State var showDetails = false @State

SwiftUI List how to identify what item is selected on macOS

巧了我就是萌 提交于 2020-04-30 09:25:07
问题 Here is what I have based on this answer. The code currently allows the user to select a cell but I cannot distinguish which cell is selected or execute any code in response to the selection. In summary, how can I execute code based on the selected cell's name and execute on click. The cell currently highlights in blue where clicked, but I want to identify it and act accordingly based on that selection. Note: I am not looking to select the cell in editing mode. Also, how can I