Fix Sidebar section headers to match macOS
This commit is contained in:
parent
aae1686bae
commit
ccd2035026
|
@ -81,7 +81,8 @@ extension Section: View, SectionView where Parent: View, Content: View, Footer:
|
||||||
headerView(style)
|
headerView(style)
|
||||||
sectionContent(style)
|
sectionContent(style)
|
||||||
footerView(style)
|
footerView(style)
|
||||||
})
|
}
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,10 @@ struct NavItem: View {
|
||||||
destination = nil
|
destination = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder var body: some View {
|
@ViewBuilder
|
||||||
|
var body: some View {
|
||||||
if let dest = destination {
|
if let dest = destination {
|
||||||
NavigationLink(id, destination: HStack {
|
NavigationLink(id, destination: dest)
|
||||||
Spacer(minLength: 0)
|
|
||||||
dest
|
|
||||||
Spacer(minLength: 0)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
#if os(WASI)
|
#if os(WASI)
|
||||||
Text(id)
|
Text(id)
|
||||||
|
@ -76,7 +73,8 @@ struct TokamakDemoView: View {
|
||||||
Counter(count: Count(value: 5), limit: 15)
|
Counter(count: Count(value: 5), limit: 15)
|
||||||
.padding()
|
.padding()
|
||||||
.background(Color(red: 0.9, green: 0.9, blue: 0.9, opacity: 1.0))
|
.background(Color(red: 0.9, green: 0.9, blue: 0.9, opacity: 1.0))
|
||||||
.border(Color.red, width: 3))
|
.border(Color.red, width: 3)
|
||||||
|
.foregroundColor(.black))
|
||||||
NavItem("ButtonStyle", destination: ButtonStyleDemo())
|
NavItem("ButtonStyle", destination: ButtonStyleDemo())
|
||||||
}
|
}
|
||||||
Section(header: Text("Containers")) {
|
Section(header: Text("Containers")) {
|
||||||
|
|
|
@ -89,7 +89,21 @@ extension InsetGroupedListStyle: ListStyleDeferredToRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Make sections collabsible (see Section.swift for more impl. details)
|
||||||
extension SidebarListStyle: ListStyleDeferredToRenderer {
|
extension SidebarListStyle: ListStyleDeferredToRenderer {
|
||||||
|
public func sectionHeader<Header>(_ header: Header) -> AnyView where Header: View {
|
||||||
|
AnyView(header
|
||||||
|
.font(.system(size: 11, weight: .medium))
|
||||||
|
.foregroundColor(Color._withScheme {
|
||||||
|
switch $0 {
|
||||||
|
case .light: return Color(.sRGB, white: 0, opacity: 0.4)
|
||||||
|
case .dark: return Color(.sRGB, white: 1, opacity: 0.4)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.padding(.vertical, 2)
|
||||||
|
.padding(.leading, 4))
|
||||||
|
}
|
||||||
|
|
||||||
public func listRow<Row>(_ row: Row) -> AnyView where Row: View {
|
public func listRow<Row>(_ row: Row) -> AnyView where Row: View {
|
||||||
AnyView(row.frame(minWidth: 0, maxWidth: .infinity))
|
AnyView(row.frame(minWidth: 0, maxWidth: .infinity))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue