From 44a9d4ffad206a567c7aedf1b820f66c4deecdd5 Mon Sep 17 00:00:00 2001 From: Lukas Korba <62649321+lukaskorba-indiedev@users.noreply.github.com> Date: Fri, 18 Feb 2022 07:06:32 +0100 Subject: [PATCH] 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 --- secant.xcodeproj/project.pbxproj | 4 ---- secant/UIComponents/Chips/EnumeratedChip.swift | 2 +- secant/Util/Clamped.swift | 8 ++++---- secant/Util/SeedIndex.swift | 13 ------------- 4 files changed, 5 insertions(+), 22 deletions(-) delete mode 100644 secant/Util/SeedIndex.swift diff --git a/secant.xcodeproj/project.pbxproj b/secant.xcodeproj/project.pbxproj index 412d249..12df63f 100644 --- a/secant.xcodeproj/project.pbxproj +++ b/secant.xcodeproj/project.pbxproj @@ -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 = ""; }; 66D50667271D9B6100E51F0D /* NavigationButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationButtonStyle.swift; sourceTree = ""; }; 66DC733E271D88CC0053CBB6 /* StandardButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardButtonStyle.swift; sourceTree = ""; }; - 9E06EFEF27BE87BA001E3A08 /* SeedIndex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedIndex.swift; sourceTree = ""; }; F9322DBF273B555C00C105B5 /* NavigationLinks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationLinks.swift; sourceTree = ""; }; F93673D52742CB840099C6AF /* Previews.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Previews.swift; sourceTree = ""; }; F93874ED273C4DE200F0E875 /* HomeStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HomeStore.swift; sourceTree = ""; }; @@ -441,7 +439,6 @@ F9C165B3274031F600592F76 /* Bindings.swift */, F9EEB8152742C2210032EEB8 /* WithStateBinding.swift */, F93673D52742CB840099C6AF /* Previews.swift */, - 9E06EFEF27BE87BA001E3A08 /* SeedIndex.swift */, ); path = Util; sourceTree = ""; @@ -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 */, diff --git a/secant/UIComponents/Chips/EnumeratedChip.swift b/secant/UIComponents/Chips/EnumeratedChip.swift index 071a719..5252f01 100644 --- a/secant/UIComponents/Chips/EnumeratedChip.swift +++ b/secant/UIComponents/Chips/EnumeratedChip.swift @@ -8,7 +8,7 @@ import SwiftUI struct EnumeratedChip: View { - @SeedIndex + @Clamped(1...24) var index: Int = 1 var text: String diff --git a/secant/Util/Clamped.swift b/secant/Util/Clamped.swift index 2b19ef8..9bf8642 100644 --- a/secant/Util/Clamped.swift +++ b/secant/Util/Clamped.swift @@ -15,13 +15,13 @@ struct Clamped { var value: Value let range: ClosedRange 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) { diff --git a/secant/Util/SeedIndex.swift b/secant/Util/SeedIndex.swift deleted file mode 100644 index c2a2479..0000000 --- a/secant/Util/SeedIndex.swift +++ /dev/null @@ -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)) } - } -}