Skip to content

Commit

Permalink
Remove old state
Browse files Browse the repository at this point in the history
  • Loading branch information
pauljohanneskraft committed Nov 12, 2024
1 parent 11aa4f3 commit 47b8841
Show file tree
Hide file tree
Showing 140 changed files with 41 additions and 5,120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import edu.stanford.spezi.core.logging.speziLogger
import edu.stanford.spezi.module.account.account.value.AccountKey
import edu.stanford.spezi.module.account.account.value.collections.AccountDetails
import edu.stanford.spezi.module.account.account.value.collections.AccountModifications
import edu.stanford.spezi.modules.storage.local.LocalStorage
import edu.stanford.spezi.modules.storage.local.LocalStorageSetting
import javax.inject.Inject

class AccountDetailsCache(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ import edu.stanford.spezi.core.utils.foundation.knowledgesource.DefaultProviding
import edu.stanford.spezi.core.utils.foundation.knowledgesource.KnowledgeSource
import edu.stanford.spezi.core.utils.foundation.knowledgesource.OptionalComputedKnowledgeSource

interface AccountServiceConfigurationKey<Value : Any> :
KnowledgeSource<AccountServiceConfigurationStorageAnchor, Value>
typealias AccountServiceConfigurationKey<Value> = KnowledgeSource<AccountServiceConfigurationStorageAnchor, Value>

interface DefaultProvidingAccountServiceConfigurationKey<Value : Any> :
AccountServiceConfigurationKey<Value>,
typealias DefaultProvidingAccountServiceConfigurationKey<Value> =
DefaultProvidingKnowledgeSource<AccountServiceConfigurationStorageAnchor, Value>

interface OptionalComputedAccountServiceConfigurationKey<Value : Any> :
AccountServiceConfigurationKey<Value>,
typealias OptionalComputedAccountServiceConfigurationKey<Value> =
OptionalComputedKnowledgeSource<AccountServiceConfigurationStorageAnchor, Value>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package edu.stanford.spezi.module.account.account.service.configuration
import edu.stanford.spezi.core.utils.foundation.RepositoryAnchor
import edu.stanford.spezi.core.utils.foundation.builtin.ValueRepository

enum class AccountServiceConfigurationStorageAnchor : RepositoryAnchor
object AccountServiceConfigurationStorageAnchor : RepositoryAnchor

typealias AccountServiceConfigurationStorage =
ValueRepository<AccountServiceConfigurationStorageAnchor>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import edu.stanford.spezi.core.design.views.validation.minimalPassword
import edu.stanford.spezi.core.design.views.validation.nonEmpty
import edu.stanford.spezi.core.utils.foundation.SharedRepository
import edu.stanford.spezi.core.utils.foundation.knowledgesource.ComputedKnowledgeSourceStoragePolicy
import edu.stanford.spezi.core.utils.foundation.knowledgesource.OptionalComputedKnowledgeSource
import edu.stanford.spezi.module.account.account.value.AccountKey
import edu.stanford.spezi.module.account.account.value.AccountKeys
import edu.stanford.spezi.module.account.account.value.keys.email
Expand All @@ -32,11 +31,7 @@ data class FieldValidationRules(

private data class FieldValidationRulesKey(
val key: AccountKey<String>,
) : OptionalComputedAccountServiceConfigurationKey<FieldValidationRules>,
OptionalComputedKnowledgeSource<
AccountServiceConfigurationStorageAnchor,
FieldValidationRules,
> {
) : OptionalComputedAccountServiceConfigurationKey<FieldValidationRules> {

override val storagePolicy: ComputedKnowledgeSourceStoragePolicy
get() = ComputedKnowledgeSourceStoragePolicy.AlwaysCompute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package edu.stanford.spezi.module.account.account.service.configuration

import edu.stanford.spezi.core.utils.UUID
import edu.stanford.spezi.module.account.account.value.AccountKey
import edu.stanford.spezi.module.account.account.value.AccountKeys
import edu.stanford.spezi.module.account.account.value.keys.userId
Expand All @@ -9,15 +8,12 @@ data class RequiredAccountKeys(
val keys: Collection<AccountKey<*>>,
) {
companion object {
val key: DefaultProvidingAccountServiceConfigurationKey<RequiredAccountKeys> = RequiredAccountKeysKey
val key = object : DefaultProvidingAccountServiceConfigurationKey<RequiredAccountKeys> {
override val defaultValue: RequiredAccountKeys
get() = RequiredAccountKeys(listOf(AccountKeys.userId))
}
}
}

private object RequiredAccountKeysKey : DefaultProvidingAccountServiceConfigurationKey<RequiredAccountKeys> {
override val uuid = UUID()
override val defaultValue: RequiredAccountKeys
get() = RequiredAccountKeys(listOf(AccountKeys.userId))
}

val AccountServiceConfiguration.requiredAccountKeys: Collection<AccountKey<*>>
get() = storage[RequiredAccountKeys.key].keys
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ sealed interface SupportedAccountKeys {
}

companion object {
val key: AccountServiceConfigurationKey<SupportedAccountKeys> = SupportedAccountKeysKey
val key = object : AccountServiceConfigurationKey<SupportedAccountKeys> {}
}
}

private object SupportedAccountKeysKey : AccountServiceConfigurationKey<SupportedAccountKeys>

var AccountServiceConfiguration.supportedAccountKeys: SupportedAccountKeys
get() = this.storage[SupportedAccountKeys.key] ?: error("Figure out how to translate preconditionFailure.")
set(value) { this.storage[SupportedAccountKeys.key] = value }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ internal fun <Value : Any> AccountKey<Value>.EntryComposableWithStoredOrInitialV
GeneralizedEntryComposable(this, initialValue = value)
}

@Composable
internal fun <Value : Any> AccountKey<Value>.DisplayComposableWithStored(details: AccountDetails): Boolean {
return details[this]?.let {
DisplayComposable(it)
true
} ?: false
}

@Composable
internal fun <Value : Any> AccountKey<Value>.SingleEntryComposable(
model: AccountOverviewFormViewModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package edu.stanford.spezi.module.account.account.value.collections

import edu.stanford.spezi.core.utils.foundation.RepositoryAnchor

enum class AccountAnchor : RepositoryAnchor
object AccountAnchor : RepositoryAnchor
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ data class AccountValueConfiguration internal constructor(
includeCollected: IncludeCollectedType = IncludeCollectedType.ONLY_REQUIRED,
ignore: List<AccountKey<*>> = emptyList(),
): List<AccountKey<*>> {
val keysPresent = Set(details.storage.map { it.key })
.union(ignore)
val keysPresent = details.storage.map { it.key } + ignore

val missingKeys = filter { entry ->
// generally, don't collect credentials!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,36 @@ import kotlin.reflect.KProperty0

// TODO: Possibly add the disfavoredOverload funs as well to make sure one doesn't create a non-required required AccountKey

data class ConfiguredAccountKey(
val configuration: AccountKeyConfiguration<*>,
data class ConfiguredAccountKey internal constructor(
internal val configuration: AccountKeyConfiguration<*>,
) {
companion object {
fun <Key : AccountKey<*>> requires(property: KProperty0<Key>): ConfiguredAccountKey {
return ConfiguredAccountKey(
AccountKeyConfigurationImpl(
property,
AccountKeyRequirement.REQUIRED
)
fun <Key : AccountKey<*>> requires(property: KProperty0<Key>) = ConfiguredAccountKey(
AccountKeyConfigurationImpl(
property,
AccountKeyRequirement.REQUIRED
)
}
)

fun <Key : AccountKey<*>> collects(property: KProperty0<Key>): ConfiguredAccountKey {
return ConfiguredAccountKey(
AccountKeyConfigurationImpl(
property,
AccountKeyRequirement.COLLECTED
)
fun <Key : AccountKey<*>> collects(property: KProperty0<Key>) = ConfiguredAccountKey(
AccountKeyConfigurationImpl(
property,
AccountKeyRequirement.COLLECTED
)
}
)

fun <Key : AccountKey<*>> supports(property: KProperty0<Key>): ConfiguredAccountKey {
return ConfiguredAccountKey(
AccountKeyConfigurationImpl(
property,
AccountKeyRequirement.SUPPORTED
)
fun <Key : AccountKey<*>> supports(property: KProperty0<Key>) = ConfiguredAccountKey(
AccountKeyConfigurationImpl(
property,
AccountKeyRequirement.SUPPORTED
)
}
)

fun <Key : AccountKey<*>> manual(property: KProperty0<Key>): ConfiguredAccountKey {
return ConfiguredAccountKey(
AccountKeyConfigurationImpl(
property,
AccountKeyRequirement.MANUAL
)
fun <Key : AccountKey<*>> manual(property: KProperty0<Key>) = ConfiguredAccountKey(
AccountKeyConfigurationImpl(
property,
AccountKeyRequirement.MANUAL
)
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.text.style.TextAlign
import edu.stanford.spezi.core.design.component.Button
import edu.stanford.spezi.core.design.component.StringResource
import edu.stanford.spezi.core.design.theme.Colors
import edu.stanford.spezi.core.design.theme.Spacings

@Composable
Expand All @@ -21,7 +22,7 @@ fun DocumentationInfoView(
Text(
infoText.text(),
textAlign = TextAlign.Center,
color = Color.Gray // TODO: Using .secondary color on iOS, is there an equivalent on Android?
color = Colors.secondary
)

val uriHandler = LocalUriHandler.current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import edu.stanford.spezi.core.design.views.validation.state.ReceiveValidation
import edu.stanford.spezi.core.design.views.validation.state.ValidationContext
import edu.stanford.spezi.core.design.views.views.model.ViewState
import edu.stanford.spezi.module.account.account.compositionLocal.LocalAccount
import edu.stanford.spezi.module.account.account.value.AccountKey
import edu.stanford.spezi.module.account.account.value.EntryComposableWithStoredOrInitialValue
import edu.stanford.spezi.module.account.account.value.collections.AccountDetails
import edu.stanford.spezi.module.account.views.validation.state.ReceiveValidation
import edu.stanford.spezi.module.account.views.validation.state.ValidationContext
import edu.stanford.spezi.module.account.views.views.ViewState

@Composable
internal fun <Value : Any> SingleEntryComposable(
Expand Down
2 changes: 0 additions & 2 deletions modules/main/AndroidManifest.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 47b8841

Please sign in to comment.