Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Currently Toggles support only primitive types, but seemingly there is some need to add support for objects. I will be working for some time to add support for objects in Toggles. So, expect some more prs in upcomings days/weeks.
I have introduced the
Object
in #36. Now its time to actually using and add support object types in Toggles 馃殌Implementation
For the memory this is how the object based Toggle will be represented as json 馃憞
Object json
From now on
Object
andObjectSupportedType
both conformCodable
(instead ofDecodable
) andEquatable
. I had to conform to that sinceValue
enum isCodable & Equatable
.Added new case
object(Object)
inValue
which forced me to consider new case in multiple places:Toggle+Codable.swift
- Decodes json to one of the cases ofValue
.Value+Utilities.swift
- Provides utilities forToggle
e.g description, icon etc.description
inObject
which convertsmap
into pretty json string (Please see attached video)InputValidationHelper.swift
- Validates the input value for overrides. Considering now.object
as well. Created two extensions to fulfill my needs:String+ValidJSON.swift
- validates if input string can be decoded inObject
.String+Object.swift
- tries to convert input string toObject
.This is how it looks in Demo app:
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-02-13.at.14.06.17.mov