Modification of Clamped property
So it's no longer out of the bounds. This was the case when initialised property has never been modified = set was never called
This commit is contained in:
parent
c564215328
commit
44a9d4ffad
|
@ -71,7 +71,6 @@
|
|||
66A0807B271993C500118B79 /* OnboardingProgressIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66A0807A271993C500118B79 /* OnboardingProgressIndicator.swift */; };
|
||||
66D50668271D9B6100E51F0D /* NavigationButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66D50667271D9B6100E51F0D /* NavigationButtonStyle.swift */; };
|
||||
66DC733F271D88CC0053CBB6 /* StandardButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66DC733E271D88CC0053CBB6 /* StandardButtonStyle.swift */; };
|
||||
9E06EFF027BE87BA001E3A08 /* SeedIndex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E06EFEF27BE87BA001E3A08 /* SeedIndex.swift */; };
|
||||
F9322DC0273B555C00C105B5 /* NavigationLinks.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9322DBF273B555C00C105B5 /* NavigationLinks.swift */; };
|
||||
F93673D62742CB840099C6AF /* Previews.swift in Sources */ = {isa = PBXBuildFile; fileRef = F93673D52742CB840099C6AF /* Previews.swift */; };
|
||||
F93874F0273C4DE200F0E875 /* HomeStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F93874ED273C4DE200F0E875 /* HomeStore.swift */; };
|
||||
|
@ -189,7 +188,6 @@
|
|||
66A0807A271993C500118B79 /* OnboardingProgressIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingProgressIndicator.swift; sourceTree = "<group>"; };
|
||||
66D50667271D9B6100E51F0D /* NavigationButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationButtonStyle.swift; sourceTree = "<group>"; };
|
||||
66DC733E271D88CC0053CBB6 /* StandardButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardButtonStyle.swift; sourceTree = "<group>"; };
|
||||
9E06EFEF27BE87BA001E3A08 /* SeedIndex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedIndex.swift; sourceTree = "<group>"; };
|
||||
F9322DBF273B555C00C105B5 /* NavigationLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationLinks.swift; sourceTree = "<group>"; };
|
||||
F93673D52742CB840099C6AF /* Previews.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Previews.swift; sourceTree = "<group>"; };
|
||||
F93874ED273C4DE200F0E875 /* HomeStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeStore.swift; sourceTree = "<group>"; };
|
||||
|
@ -441,7 +439,6 @@
|
|||
F9C165B3274031F600592F76 /* Bindings.swift */,
|
||||
F9EEB8152742C2210032EEB8 /* WithStateBinding.swift */,
|
||||
F93673D52742CB840099C6AF /* Previews.swift */,
|
||||
9E06EFEF27BE87BA001E3A08 /* SeedIndex.swift */,
|
||||
);
|
||||
path = Util;
|
||||
sourceTree = "<group>";
|
||||
|
@ -981,7 +978,6 @@
|
|||
0D3D040A2728B3A10032ABC1 /* RecoveryPhraseDisplayStore.swift in Sources */,
|
||||
0D4E7A0B26B364170058B01E /* ContentView.swift in Sources */,
|
||||
0D354A0926D5A9D000315F45 /* Services.swift in Sources */,
|
||||
9E06EFF027BE87BA001E3A08 /* SeedIndex.swift in Sources */,
|
||||
660558F7270C862F009D6954 /* Fonts+Generated.swift in Sources */,
|
||||
F96B41E7273B501F0021B49A /* TransactionHistoryStore.swift in Sources */,
|
||||
F9971A5A27680DDE00A2DB75 /* RequestView.swift in Sources */,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import SwiftUI
|
||||
|
||||
struct EnumeratedChip: View {
|
||||
@SeedIndex
|
||||
@Clamped(1...24)
|
||||
var index: Int = 1
|
||||
|
||||
var text: String
|
||||
|
|
|
@ -15,13 +15,13 @@ struct Clamped<Value: Comparable> {
|
|||
var value: Value
|
||||
let range: ClosedRange<Value>
|
||||
var wrappedValue: Value {
|
||||
get { value }
|
||||
set {
|
||||
value = min(
|
||||
max(range.lowerBound, newValue),
|
||||
get {
|
||||
min(
|
||||
max(range.lowerBound, value),
|
||||
range.upperBound
|
||||
)
|
||||
}
|
||||
set { value = newValue }
|
||||
}
|
||||
|
||||
init(wrappedValue: Value, _ range: ClosedRange<Value>) {
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
//
|
||||
// SeedIndex.swift
|
||||
// secant-testnet
|
||||
//
|
||||
// Created by Lukáš Korba on 17.02.2022.
|
||||
//
|
||||
|
||||
@propertyWrapper
|
||||
struct SeedIndex {
|
||||
var wrappedValue: Int {
|
||||
didSet { wrappedValue = min(24, max(1, wrappedValue)) }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue