[Features] Provides default toggle view for Bool @Options
This commit is contained in:
parent
6d95924145
commit
9f40223e6c
@ -196,6 +196,7 @@
|
|||||||
D5D7C20429E60F2000663793 /* Feature.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9BFFD29DDECF100A8D610 /* Feature.swift */; };
|
D5D7C20429E60F2000663793 /* Feature.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9BFFD29DDECF100A8D610 /* Feature.swift */; };
|
||||||
D5D7C20629E60F6100663793 /* OptionPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D592D6FE29E48FFB008D218A /* OptionPickerView.swift */; };
|
D5D7C20629E60F6100663793 /* OptionPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D592D6FE29E48FFB008D218A /* OptionPickerView.swift */; };
|
||||||
D5D7C20829E616CF00663793 /* FeatureContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5D7C20729E616CF00663793 /* FeatureContainer.swift */; };
|
D5D7C20829E616CF00663793 /* FeatureContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5D7C20729E616CF00663793 /* FeatureContainer.swift */; };
|
||||||
|
D5D7C20A29E61FA600663793 /* OptionToggleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5D7C20929E61FA600663793 /* OptionToggleView.swift */; };
|
||||||
D5F82FB82981D3AC00B229AF /* LegacySearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5F82FB72981D3AC00B229AF /* LegacySearchBar.swift */; };
|
D5F82FB82981D3AC00B229AF /* LegacySearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5F82FB72981D3AC00B229AF /* LegacySearchBar.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
@ -439,6 +440,7 @@
|
|||||||
D5D7C1E829E5FCDE00663793 /* LocalizedOptionValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedOptionValue.swift; sourceTree = "<group>"; };
|
D5D7C1E829E5FCDE00663793 /* LocalizedOptionValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedOptionValue.swift; sourceTree = "<group>"; };
|
||||||
D5D7C1F129E60DFF00663793 /* libDeltaFeatures.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDeltaFeatures.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
D5D7C1F129E60DFF00663793 /* libDeltaFeatures.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDeltaFeatures.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
D5D7C20729E616CF00663793 /* FeatureContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureContainer.swift; sourceTree = "<group>"; };
|
D5D7C20729E616CF00663793 /* FeatureContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureContainer.swift; sourceTree = "<group>"; };
|
||||||
|
D5D7C20929E61FA600663793 /* OptionToggleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OptionToggleView.swift; sourceTree = "<group>"; };
|
||||||
D5F82FB72981D3AC00B229AF /* LegacySearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacySearchBar.swift; sourceTree = "<group>"; };
|
D5F82FB72981D3AC00B229AF /* LegacySearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacySearchBar.swift; sourceTree = "<group>"; };
|
||||||
DC866E433B3BA9AE18ABA1EC /* libPods-Delta.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Delta.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
DC866E433B3BA9AE18ABA1EC /* libPods-Delta.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Delta.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
@ -1068,6 +1070,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
D592D6FE29E48FFB008D218A /* OptionPickerView.swift */,
|
D592D6FE29E48FFB008D218A /* OptionPickerView.swift */,
|
||||||
|
D5D7C20929E61FA600663793 /* OptionToggleView.swift */,
|
||||||
);
|
);
|
||||||
path = Views;
|
path = Views;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1555,6 +1558,7 @@
|
|||||||
D5D7C20429E60F2000663793 /* Feature.swift in Sources */,
|
D5D7C20429E60F2000663793 /* Feature.swift in Sources */,
|
||||||
D55C469129E7631000EA6DE9 /* AnyOption.swift in Sources */,
|
D55C469129E7631000EA6DE9 /* AnyOption.swift in Sources */,
|
||||||
D5D7C1FD29E60EEF00663793 /* OptionalProtocol.swift in Sources */,
|
D5D7C1FD29E60EEF00663793 /* OptionalProtocol.swift in Sources */,
|
||||||
|
D5D7C20A29E61FA600663793 /* OptionToggleView.swift in Sources */,
|
||||||
D55C468F29E761C000EA6DE9 /* AnyFeature.swift in Sources */,
|
D55C468F29E761C000EA6DE9 /* AnyFeature.swift in Sources */,
|
||||||
D5D7C20129E60F2000663793 /* LocalizedOptionValue.swift in Sources */,
|
D5D7C20129E60F2000663793 /* LocalizedOptionValue.swift in Sources */,
|
||||||
D54F710429E89DFC009C069A /* NotificationName+Settings.swift in Sources */,
|
D54F710429E89DFC009C069A /* NotificationName+Settings.swift in Sources */,
|
||||||
|
|||||||
@ -113,6 +113,21 @@ public extension Option where DetailView == EmptyView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "Toggle" Option (User-visible, Bool option with default toggle UI)
|
||||||
|
public extension Option where Value == Bool, DetailView == OptionToggleView
|
||||||
|
{
|
||||||
|
// Non-Optional
|
||||||
|
convenience init(wrappedValue: Value, name: LocalizedStringKey, description: LocalizedStringKey? = nil)
|
||||||
|
{
|
||||||
|
self.init(defaultValue: wrappedValue, name: name, description: description)
|
||||||
|
|
||||||
|
self.detailView = { [weak self] () -> DetailView? in
|
||||||
|
guard let self else { return nil }
|
||||||
|
return OptionToggleView(name: name, selectedValue: self.valueBinding)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// "Picker" Option (User-visible, pre-set options with default picker UI)
|
// "Picker" Option (User-visible, pre-set options with default picker UI)
|
||||||
public extension Option where Value: LocalizedOptionValue, DetailView == OptionPickerView<Value>
|
public extension Option where Value: LocalizedOptionValue, DetailView == OptionPickerView<Value>
|
||||||
{
|
{
|
||||||
|
|||||||
22
DeltaFeatures/Views/OptionToggleView.swift
Normal file
22
DeltaFeatures/Views/OptionToggleView.swift
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// OptionToggleView.swift
|
||||||
|
// DeltaFeatures
|
||||||
|
//
|
||||||
|
// Created by Riley Testut on 4/11/23.
|
||||||
|
// Copyright © 2023 Riley Testut. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
// Type must be public, but not its properties.
|
||||||
|
public struct OptionToggleView: View
|
||||||
|
{
|
||||||
|
var name: LocalizedStringKey
|
||||||
|
|
||||||
|
@Binding
|
||||||
|
var selectedValue: Bool
|
||||||
|
|
||||||
|
public var body: some View {
|
||||||
|
Toggle(name, isOn: $selectedValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user