Skip to content

Commit 59e73de

Browse files
committed
Allow custom LoggerChannelsView labels
1 parent 5a7b29e commit 59e73de

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

Sources/LoggerUI/LoggerChannelsView.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@
99
import SwiftUI
1010

1111
/// SwiftUI section that exposes the logger manager's channels as toggles.
12-
public struct LoggerChannelsView: View {
12+
public struct LoggerChannelsView<Label: View>: View {
1313
/// Watcher that adapts logger channels for SwiftUI observation.
1414
private let watcher: ChannelWatcher
1515

1616
/// Section title shown above the channel toggles.
17-
private let label: LocalizedStringResource
18-
17+
@ViewBuilder private let label: () -> Label
18+
1919
/// Creates a new section backed by the specified logger manager.
20-
public init(label: LocalizedStringResource = "Log Channels", manager: Logger.Manager = .shared) {
20+
public init(label: @escaping () -> Label, manager: Logger.Manager = .shared) {
2121
self.label = label
2222
self.watcher = ChannelWatcher(manager: manager)
2323
}
2424

25+
/// Creates a new section backed by the specified logger manager.
26+
public init(manager: Logger.Manager = .shared) where Label == Text {
27+
self.label = { Text("All Channels") }
28+
self.watcher = ChannelWatcher(manager: manager)
29+
}
30+
2531
/// Renders the channel settings section and the master toggle.
2632
public var body: some View {
2733
Section(header: HStack {
28-
Text(label)
34+
label()
2935
Spacer()
3036
AllChannelsToggleView(watcher: watcher)
3137
.labelsHidden()

0 commit comments

Comments
 (0)