| 1 |
// |
|
| 2 |
// SidebarListView.swift |
|
| 3 |
// USB Meter |
|
| 4 |
// |
|
| 5 | ||
| 6 |
import SwiftUI |
|
| 7 | ||
| 8 |
struct SidebarListView<USBMetersSection: View, HelpSection: View, DebugSection: View>: View {
|
|
| 9 |
let backgroundTint: Color |
|
| 10 |
let usbMetersSection: USBMetersSection |
|
| 11 |
let helpSection: HelpSection |
|
| 12 |
let debugSection: DebugSection |
|
| 13 | ||
| 14 |
init( |
|
| 15 |
backgroundTint: Color, |
|
| 16 |
@ViewBuilder usbMetersSection: () -> USBMetersSection, |
|
| 17 |
@ViewBuilder helpSection: () -> HelpSection, |
|
| 18 |
@ViewBuilder debugSection: () -> DebugSection |
|
| 19 |
) {
|
|
| 20 |
self.backgroundTint = backgroundTint |
|
| 21 |
self.usbMetersSection = usbMetersSection() |
|
| 22 |
self.helpSection = helpSection() |
|
| 23 |
self.debugSection = debugSection() |
|
| 24 |
} |
|
| 25 | ||
| 26 |
var body: some View {
|
|
| 27 |
if #available(iOS 16.0, *) {
|
|
| 28 |
listBody.scrollContentBackground(.hidden) |
|
| 29 |
} else {
|
|
| 30 |
listBody |
|
| 31 |
} |
|
| 32 |
} |
|
| 33 | ||
| 34 |
private var listBody: some View {
|
|
| 35 |
List {
|
|
| 36 |
usbMetersSection |
|
| 37 |
helpSection |
|
| 38 |
debugSection |
|
| 39 |
} |
|
| 40 |
.listStyle(SidebarListStyle()) |
|
| 41 |
.background( |
|
| 42 |
LinearGradient( |
|
| 43 |
colors: [ |
|
| 44 |
backgroundTint.opacity(0.18), |
|
| 45 |
Color.clear |
|
| 46 |
], |
|
| 47 |
startPoint: .topLeading, |
|
| 48 |
endPoint: .bottomTrailing |
|
| 49 |
) |
|
| 50 |
.ignoresSafeArea() |
|
| 51 |
) |
|
| 52 |
} |
|
| 53 |
} |