Fix List
This commit is contained in:
parent
ccd2035026
commit
208c260f81
|
@ -90,6 +90,7 @@ public struct List<SelectionValue, Content>: View
|
||||||
listStack
|
listStack
|
||||||
.environment(\._outlineGroupStyle, _ListOutlineGroupStyle())
|
.environment(\._outlineGroupStyle, _ListOutlineGroupStyle())
|
||||||
})
|
})
|
||||||
|
.frame(minHeight: 0, maxHeight: .infinity)
|
||||||
} else {
|
} else {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
HStack {
|
HStack {
|
||||||
|
|
|
@ -17,75 +17,164 @@ import TokamakCore
|
||||||
extension PlainListStyle: ListStyleDeferredToRenderer {
|
extension PlainListStyle: ListStyleDeferredToRenderer {
|
||||||
public func sectionHeader<Header>(_ header: Header) -> AnyView where Header: View {
|
public func sectionHeader<Header>(_ header: Header) -> AnyView where Header: View {
|
||||||
AnyView(header
|
AnyView(header
|
||||||
.padding(.vertical, 5)
|
.font(.system(size: 17, weight: .medium))
|
||||||
.background(Color(0xDDDDDD)))
|
.padding(.vertical, 4)
|
||||||
|
.padding(.leading)
|
||||||
|
.background(Color._withScheme {
|
||||||
|
switch $0 {
|
||||||
|
case .light: return Color(0xDDDDDD)
|
||||||
|
case .dark: return Color(0x323234)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func sectionFooter<Footer>(_ footer: Footer) -> AnyView where Footer: View {
|
public func sectionFooter<Footer>(_ footer: Footer) -> AnyView where Footer: View {
|
||||||
AnyView(VStack {
|
AnyView(VStack(alignment: .leading) {
|
||||||
Divider()
|
Divider()
|
||||||
_ListRow.listRow(footer, self, isLast: true)
|
_ListRow.listRow(footer, self, isLast: true)
|
||||||
})
|
}
|
||||||
|
.padding(.leading)
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity))
|
||||||
|
}
|
||||||
|
|
||||||
|
public func sectionBody<SectionBody>(_ section: SectionBody) -> AnyView where SectionBody: View {
|
||||||
|
AnyView(section.padding(.leading).frame(minWidth: 0, maxWidth: .infinity))
|
||||||
|
}
|
||||||
|
|
||||||
|
public func listRow<Row>(_ row: Row) -> AnyView where Row: View {
|
||||||
|
AnyView(row.padding(.vertical))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension InsetListStyle: ListStyleDeferredToRenderer {
|
||||||
|
public func sectionHeader<Header>(_ header: Header) -> AnyView where Header: View {
|
||||||
|
AnyView(header
|
||||||
|
.font(.system(size: 17, weight: .medium))
|
||||||
|
.padding(.vertical, 4)
|
||||||
|
.padding(.leading, 24)
|
||||||
|
.background(Color._withScheme {
|
||||||
|
switch $0 {
|
||||||
|
case .light: return Color(0xDDDDDD)
|
||||||
|
case .dark: return Color(0x323234)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func sectionFooter<Footer>(_ footer: Footer) -> AnyView where Footer: View {
|
||||||
|
AnyView(VStack(alignment: .leading) {
|
||||||
|
Divider()
|
||||||
|
_ListRow.listRow(footer, self, isLast: true)
|
||||||
|
}
|
||||||
|
.padding(.leading, 24)
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity))
|
||||||
|
}
|
||||||
|
|
||||||
|
public func sectionBody<SectionBody>(_ section: SectionBody) -> AnyView where SectionBody: View {
|
||||||
|
AnyView(section
|
||||||
|
.padding(.leading, 24)
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func listRow<Row>(_ row: Row) -> AnyView where Row: View {
|
||||||
|
AnyView(row.padding(.vertical))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension GroupedListStyle: ListStyleDeferredToRenderer {
|
extension GroupedListStyle: ListStyleDeferredToRenderer {
|
||||||
public func listBody<ListBody>(_ content: ListBody) -> AnyView where ListBody: View {
|
public func listBody<ListBody>(_ content: ListBody) -> AnyView where ListBody: View {
|
||||||
AnyView(content
|
AnyView(content
|
||||||
.padding(.top, 20)
|
.background(Color._withScheme {
|
||||||
.background(Color(0xEEEEEE))
|
switch $0 {
|
||||||
|
case .light: return Color(0xEEEEEE)
|
||||||
|
case .dark: return .clear
|
||||||
|
}
|
||||||
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func sectionHeader<Header>(_ header: Header) -> AnyView where Header: View {
|
public func sectionHeader<Header>(_ header: Header) -> AnyView where Header: View {
|
||||||
AnyView(header
|
AnyView(header
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.padding(.leading, 20))
|
.padding([.top, .leading])
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func sectionBody<SectionBody>(_ section: SectionBody) -> AnyView where SectionBody: View {
|
public func sectionBody<SectionBody>(_ section: SectionBody) -> AnyView where SectionBody: View {
|
||||||
AnyView(section
|
AnyView(section
|
||||||
.background(Color.white)
|
.padding(.leading)
|
||||||
.padding(.top))
|
.background(Color._withScheme {
|
||||||
|
switch $0 {
|
||||||
|
case .light: return .white
|
||||||
|
case .dark: return Color(0x444444)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.padding(.top)
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func sectionFooter<Footer>(_ footer: Footer) -> AnyView where Footer: View {
|
public func sectionFooter<Footer>(_ footer: Footer) -> AnyView where Footer: View {
|
||||||
AnyView(footer
|
AnyView(footer
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.padding(.leading, 20))
|
.padding([.top, .leading])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func listRow<Row>(_ row: Row) -> AnyView where Row: View {
|
||||||
|
AnyView(row.padding(.vertical))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension InsetGroupedListStyle: ListStyleDeferredToRenderer {
|
extension InsetGroupedListStyle: ListStyleDeferredToRenderer {
|
||||||
public func listBody<ListBody>(_ content: ListBody) -> AnyView where ListBody: View {
|
public func listBody<ListBody>(_ content: ListBody) -> AnyView where ListBody: View {
|
||||||
AnyView(content
|
AnyView(content
|
||||||
.padding(.top, 20)
|
.background(Color._withScheme {
|
||||||
.background(Color(0xEEEEEE))
|
switch $0 {
|
||||||
|
case .light: return Color(0xEEEEEE)
|
||||||
|
case .dark: return .clear
|
||||||
|
}
|
||||||
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func listRow<Row>(_ row: Row) -> AnyView where Row: View {
|
|
||||||
AnyView(row
|
|
||||||
.padding([.leading, .trailing, .top, .bottom]))
|
|
||||||
}
|
|
||||||
|
|
||||||
public func sectionHeader<Header>(_ header: Header) -> AnyView where Header: View {
|
public func sectionHeader<Header>(_ header: Header) -> AnyView where Header: View {
|
||||||
AnyView(header
|
AnyView(header
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.padding(.leading, 20))
|
.padding([.top, .leading])
|
||||||
|
.padding(.leading)
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func sectionBody<SectionBody>(_ section: SectionBody) -> AnyView where SectionBody: View {
|
public func sectionBody<SectionBody>(_ section: SectionBody) -> AnyView where SectionBody: View {
|
||||||
AnyView(section
|
AnyView(section
|
||||||
.background(Color.white)
|
.padding(.leading)
|
||||||
|
.background(Color._withScheme {
|
||||||
|
switch $0 {
|
||||||
|
case .light: return .white
|
||||||
|
case .dark: return Color(0x444444)
|
||||||
|
}
|
||||||
|
})
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.padding(.all))
|
.padding([.horizontal, .top])
|
||||||
|
.frame(minWidth: 0, maxWidth: .infinity))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func sectionFooter<Footer>(_ footer: Footer) -> AnyView where Footer: View {
|
public func sectionFooter<Footer>(_ footer: Footer) -> AnyView where Footer: View {
|
||||||
AnyView(footer
|
AnyView(footer
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.padding(.leading, 20))
|
.padding([.top, .leading])
|
||||||
|
.padding(.leading)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func listRow<Row>(_ row: Row) -> AnyView where Row: View {
|
||||||
|
AnyView(row.padding(.vertical))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue