Skip to content

Commit

Permalink
Adds icon to SettingToggle
Browse files Browse the repository at this point in the history
  • Loading branch information
tvidenov committed Feb 16, 2024
1 parent 92e8e59 commit 93b7ac9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/Views/SettingToggle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ public struct SettingToggle: View, Setting {
public var id: AnyHashable?
public var title: String
@Binding public var isOn: Bool
public var icon: SettingIcon?
public var horizontalSpacing = CGFloat(12)
public var verticalPadding = CGFloat(14)
public var horizontalPadding: CGFloat? = nil

public init(
id: AnyHashable? = nil,
icon: SettingIcon?,
title: String,
isOn: Binding<Bool>,
horizontalSpacing: CGFloat = CGFloat(12),
verticalPadding: CGFloat = CGFloat(14),
horizontalPadding: CGFloat? = nil
) {
self.id = id
self.icon = icon
self.title = title
self._isOn = isOn
self.horizontalSpacing = horizontalSpacing
Expand All @@ -37,6 +40,7 @@ public struct SettingToggle: View, Setting {

public var body: some View {
SettingToggleView(
icon: icon,
title: title,
isOn: $isOn,
horizontalSpacing: horizontalSpacing,
Expand All @@ -49,6 +53,7 @@ public struct SettingToggle: View, Setting {
struct SettingToggleView: View {
@Environment(\.edgePadding) var edgePadding

let icon: SettingIcon?
let title: String
@Binding var isOn: Bool

Expand All @@ -58,6 +63,9 @@ struct SettingToggleView: View {

var body: some View {
HStack(spacing: horizontalSpacing) {
if let icon {
SettingIconView(icon: icon)
}
Text(title)
.fixedSize(horizontal: false, vertical: true)
.frame(maxWidth: .infinity, alignment: .leading)
Expand Down

0 comments on commit 93b7ac9

Please sign in to comment.