Skip to content

Commit

Permalink
SettingsScreen updates to pass in an added ViewBuilder's in-order to …
Browse files Browse the repository at this point in the history
…accomodate more settings options
  • Loading branch information
aravind-raveendran committed Oct 17, 2023
1 parent 23f3634 commit 207d874
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import SwiftUI
import DolbyIOUIKit

public struct SettingsScreen: View {
public struct SettingsScreen<Content: View>: View {

@Environment(\.presentationMode) var presentationMode
@StateObject private var viewModel: SettingsViewModel
Expand All @@ -14,8 +14,17 @@ public struct SettingsScreen: View {
@State private var isShowingStreamSortOrderScreen: Bool = false
@State private var isShowingAudioSelectionScreen: Bool = false

public init(mode: SettingsMode) {
@ViewBuilder private let moreSettings: Content

public init(mode: SettingsMode, @ViewBuilder moreSettings: () -> Content) {
_viewModel = StateObject(wrappedValue: SettingsViewModel(mode: mode))
self.moreSettings = moreSettings()
}

public init(mode: SettingsMode) where Content == EmptyView {
self.init(mode: mode) {
EmptyView()
}
}

public var body: some View {
Expand All @@ -42,6 +51,8 @@ public struct SettingsScreen: View {
.hidden()

List {
moreSettings

Toggle(isOn: Binding<Bool>(
get: { viewModel.showSourceLabels },
set: { viewModel.setShowSourceLabels($0) })
Expand All @@ -50,7 +61,7 @@ public struct SettingsScreen: View {
"settings.show-source-labels.label",
bundle: .module,
style: .titleMedium,
font: .custom("AvenirNext-Regular", size: CGFloat(14.0), relativeTo: .body)
font: .custom("AvenirNext-Regular", size: FontSize.body)
)
}

Expand Down Expand Up @@ -79,6 +90,7 @@ public struct SettingsScreen: View {
action: { isShowingAudioSelectionScreen = true }
)
}
.environment(\.defaultMinListRowHeight, Layout.spacing6x)
.navigationBarBackButtonHidden()
.navigationBarTitleDisplayMode(.inline)
.toolbar {
Expand Down
4 changes: 2 additions & 2 deletions Sources/DolbyIOUIKit/Views/Components/SettingsCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct SettingsCell: View {
Text(
text,
bundle: bundle,
font: .custom("AvenirNext-Regular", size: CGFloat(14.0), relativeTo: .body),
font: .custom("AvenirNext-Regular", size: FontSize.body),
textColor: textColor
)
}
Expand All @@ -51,7 +51,7 @@ public struct SettingsCell: View {
Text(
value,
bundle: bundle,
font: .custom("AvenirNext-Regular", size: CGFloat(14.0), relativeTo: .body),
font: .custom("AvenirNext-Regular", size: FontSize.body),
textColor: valueColor
)
}
Expand Down

0 comments on commit 207d874

Please sign in to comment.