-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SidebarListStyle
#210
Conversation
I couldn't figure out how to add the label in order to pass the check-labels check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Can you also remove the dividers? |
Sure. Let me take a look. |
I added a check for usage of the SidebarListStyle. This isn't my favorite way of checking capabilities, but I was unsure if I should add some sort of private protocol for "showsDividers" or not. |
I think that's a good way for now and we can re-evaluate later on if needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates!
@@ -120,7 +120,7 @@ public struct _ListRow { | |||
public static func listRow<V: View>(_ view: V, _ style: ListStyle, isLast: Bool) -> some View { | |||
(style as? ListStyleDeferredToRenderer)?.listRow(view) ?? | |||
AnyView(view.padding([.trailing, .top, .bottom])) | |||
if !isLast { | |||
if !isLast && style as? SidebarListStyle == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably just add a var addDividers: Bool { get }
to the ListStyleDeferredToRenderer
protocol, then provide a default value of true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added "hasDividers" to the ListStyle. It wasn't clear how to add it to ListStyleDeferredToRenderer and have the code be clean.
Here is where the property is checked:
@ViewBuilder
public static func listRow<V: View>(_ view: V, _ style: ListStyle, isLast: Bool) -> some View {
(style as? ListStyleDeferredToRenderer)?.listRow(view) ??
AnyView(view.padding([.trailing, .top, .bottom]))
if !isLast && style.hasDividers {
Divider()
}
}
}
Thank you @Outcue! |
First pass at the SidebarListStyle.
For this to be truly complete, work needs to be completed on ButtonStyles. I can look at that next. NavigationLinks in a Sidebar are Text items that draw a blue background when clicked (and perhaps when item is active.)