This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| appConfig { | |
| $0.config(environment: "FREE") {/*...*/} | |
| $0.config(environment: "PREMIUM") {/*...*/} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| appConfig { | |
| $0.config(environment: "FREE") { | |
| $0.switch { | |
| $0.key = "A" | |
| $0.description = "Set text visibility" | |
| $0.switchValue = true | |
| } | |
| $0.range { | |
| $0.key = "B" | |
| $0.description = "Set text size" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| appConfig { | |
| config("FREE") {/*...*/} | |
| config("PREMIUM") { | |
| switch { | |
| key = "A" | |
| description = "Set text visibility" | |
| switchValue = false | |
| } | |
| range { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Podfile | |
| use_frameworks! | |
| target 'YOUR_TARGET_NAME' do | |
| pod 'MultiConfig', '~> 1.0.59' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| implementation('com.juliuscanute.multiconfig:multiconfig:1.0.59@aar') { | |
| transitive = true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| actual class Settings(group: String) { | |
| private val defaults = NSUserDefaults(suiteName = group) | |
| /*..*/ | |
| actual fun getInt(key: String, defaultValue: Int): Int { | |
| val value = defaults.integerForKey(defaultName = key) | |
| return value.toInt() | |
| } | |
| /*..*/ | |
| actual fun putInt(key: String, value: Int) { | |
| defaults.setInteger(value = value.toLong(), forKey = key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| actual class Settings(context: Context, name: String = "multi-config") { | |
| private var sharedPreference: SharedPreferences = context.getSharedPreferences(name, MODE_PRIVATE) | |
| /*..*/ | |
| actual fun getInt(key: String, defaultValue: Int): Int = | |
| sharedPreference.getInt(key, defaultValue) | |
| /*..*/ | |
| actual fun putInt(key: String, value: Int) { | |
| sharedPreference.edit() | |
| .putInt(key, value) | |
| .apply() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| expect class Settings { | |
| /*..*/ | |
| fun getInt(key: String, defaultValue: Int): Int | |
| /*..*/ | |
| fun putInt(key: String, value: Int) | |
| /*..*/ | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*..*/ | |
| fun saveConfig(key: String, value: Int) { | |
| val userKey = getUserKey(key) | |
| store[userKey] = StoreValue.IntValue(value = value) | |
| settings.putInt(userKey, value) | |
| } | |
| /*..*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*..*/ | |
| override fun getConfigInt(userKey: String): Int { | |
| val key = environment + PREFIX + userKey | |
| val storeValue: StoreValue? = store[key] | |
| checkNotNull(storeValue, { "Unable to find the key" }) | |
| check(storeValue is StoreValue.IntValue) { "Store value must be Int" } | |
| return storeValue.value | |
| } | |
| /*..*/ |