6

I want to make changes to the listItem's background, rowInsets based on multiple conditions. How can I create a struct conforming to the ListStyle protocol?

I tried conforming to it and get the following code blocks. But I've no idea how to proceed from here.


struct CustomListStyle: ListStyle {
    
    static func _makeView<SelectionValue>(value: _GraphValue<_ListValue<CustomListStyle, SelectionValue>>, inputs: _ViewInputs) -> _ViewOutputs where SelectionValue : Hashable {
        
    }
    
    static func _makeViewList<SelectionValue>(value: _GraphValue<_ListValue<CustomListStyle, SelectionValue>>, inputs: _ViewListInputs) -> _ViewListOutputs where SelectionValue : Hashable {
        
    }
}

2
  • Create representable for UITableView or UICollectionView and anything you want inside. Commented Nov 1, 2020 at 8:55
  • But that will mean a lot of overhead in my particular case. Also, I'm using OutlineGroup inside the list. I can't find the equivalent for that in UIKit. Commented Nov 1, 2020 at 9:02

1 Answer 1

1

I was also facing this issue in these days. After some investigation, I eventually realized that SwiftUI does not really "allow" us to customize the list style by overriding the ListStyle protocol. And I found out that there is no any documentation related to this.

However, it is actually possible (not perfect, but doable) to customize it by using Introspect. Check here for more information: https://github.com/siteline/SwiftUI-Introspect#list

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.