From 65dd54e5f5fbd02ca60dd0c4cbe503f1a76ab126 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Mon, 4 Dec 2023 08:49:17 -0500 Subject: [PATCH 01/11] running formatting --- .../com/kevinschildhorn/MainActivity.kt | 2 +- atomik/build.gradle.kts | 5 +- .../{+EditText.kt => EditTextExtensions.kt} | 5 +- .../{+TextView.kt => TextViewExtensions.kt} | 13 +- .../atoms/xml/{+View.kt => ViewExtensions.kt} | 5 +- ...raphy.kt => AtomikTypographyExtensions.kt} | 6 +- .../kevinschildhorn/atomik/DesignSystem.kt | 4 +- .../atomik/atomic/atoms/FigmaAtom.kt | 7 +- .../atomik/atomic/atoms/TextFieldAtom.kt | 6 - .../atomic/atoms/compose/+AtomikColorType.kt | 6 +- .../atomic/atoms/compose/+ConstrainedAtom.kt | 56 ++-- .../atomic/atoms/compose/+EnablableAtom.kt | 4 +- .../atomic/atoms/compose/+FixedSizeAtom.kt | 4 +- .../atomic/atoms/compose/+RoundedAtom.kt | 5 +- .../atomik/atomic/atoms/compose/+TextAtom.kt | 8 +- .../atomic/atoms/interfaces/AtomType.kt | 2 +- .../atomic/atoms/interfaces/BorderedAtom.kt | 1 - .../atoms/interfaces/ConstrainedAtom.kt | 4 +- .../atomic/atoms/interfaces/EnablableAtom.kt | 1 - .../atomic/atoms/interfaces/TextAtom.kt | 5 +- .../molecules/+OutlinedTextFieldMolecule.kt | 43 --- .../atomic/molecules/+TextFieldMolecule.kt | 35 --- .../atomik/atomic/molecules/BaseMolecule.kt | 3 - .../molecules/OutlinedTextFieldMolecule.kt | 49 +++- .../atomic/molecules/TextButtonMolecule.kt | 5 +- .../atomic/molecules/TextFieldMolecule.kt | 42 ++- .../atomik/atomic/organisms/BaseOrganism.kt | 2 +- .../atomik/atomic/organisms/FormOrganism.kt | 6 +- .../atomik/color/CustomColorSet.kt | 3 +- .../atomik/color/CustomColorSetTyped.kt | 3 +- .../atomik/color/base/AtomikColor.kt | 14 +- .../atomik/color/base/AtomikColorData.kt | 15 +- .../atomik/typography/+TypographyWeight.kt | 14 +- .../atomik/typography/CustomTypographySet.kt | 6 +- .../typography/CustomTypographySetTyped.kt | 3 +- .../typography/base/AtomikFontFamily.kt | 2 +- .../typography/base/AtomikTypography.kt | 2 +- .../typography/base/AtomikTypographyWeight.kt | 2 +- .../kevinschildhorn/atomik/AtomikColorTest.kt | 83 +++--- .../atomik/color/base/AtomikColor.kt | 3 +- .../atomik/atomic/atoms/+TextAtom.kt | 4 +- .../atomik/color/base/AtomikColor.kt | 2 +- .../atomik/typography/+TypographyWeight.kt | 13 +- .../typography/base/AtomikFontFamily.kt | 2 +- .../atomik/atomic/atoms/+Modifier.kt | 4 +- .../typography/base/AtomikFontFamily.kt | 1 - build.gradle.kts | 2 + desktopApp/build.gradle.kts | 2 +- .../desktopMain/kotlin/{main.kt => Main.kt} | 2 +- .../src/jvmMain/kotlin/{main.kt => Main.kt} | 3 +- shared/build.gradle.kts | 7 +- .../{main.android.kt => Main.android.kt} | 0 .../{koinAndroid.kt => KoinAndroid.kt} | 14 +- .../fotopresenter/ui/compose/Previews.kt | 7 +- .../fotopresenter/ui/viewmodel/ViewModel.kt | 2 +- shared/src/commonMain/kotlin/App.kt | 11 +- .../fotopresenter/{koin.kt => Koin.kt} | 29 +- .../fotopresenter/data/LoginCredentials.kt | 5 +- .../data/datasources/CredentialsDataSource.kt | 3 +- .../data/datasources/DirectoryDataSource.kt | 4 +- .../data/network/NetworkHandler.kt | 4 +- .../repositories/CredentialsRepository.kt | 5 +- .../domain/AutoConnectUseCase.kt | 3 +- .../domain/ConnectToServerUseCase.kt | 5 +- .../domain/SaveCredentialsUseCase.kt | 7 +- ...eFlow.kt => MutableStateFlowExtensions.kt} | 4 +- .../{+String.kt => StringExtensions.kt} | 2 +- .../fotopresenter/ui/atoms/FotoColors.kt | 2 +- .../fotopresenter/ui/atoms/FotoTypography.kt | 2 +- .../ui/atoms/LoginScreenAtoms.kt | 65 ++--- .../fotopresenter/ui/atoms/Padding.kt | 5 +- .../ui/compose/DirectoryScreen.kt | 5 +- .../fotopresenter/ui/compose/LoginScreen.kt | 14 +- .../ui/compose/NavigationState.kt | 4 +- .../ui/compose/common/ErrorView.kt | 12 +- .../ui/compose/common/FormColumn.kt | 6 +- .../ui/compose/common/PrimaryButton.kt | 28 +- .../ui/compose/common/TitleView.kt | 4 +- .../ui/compose/login/FotoCheckbox.kt | 8 +- .../ui/compose/login/FotoTextField.kt | 9 +- .../ui/compose/login/LoginScreenForm.kt | 9 +- .../fotopresenter/ui/state/LoginUiState.kt | 30 +- .../fotopresenter/ui/state/UiState.kt | 5 +- .../ui/viewmodel/LoginViewModel.kt | 13 +- .../fotopresenter/ui/viewmodel/ViewModel.kt | 3 +- .../kevinschildhorn/fotopresenter/KoinTest.kt | 6 +- .../datasources/CredentialsDataSourceTest.kt | 19 +- .../data/network/MockNetworkHandler.kt | 27 +- .../repositories/CredentialsRepositoryTest.kt | 9 +- .../domain/AutoConnectUseCaseTest.kt | 110 ++++--- .../domain/ConnectToServerUseCaseTest.kt | 84 +++--- .../domain/SaveCredentialsUseCaseTest.kt | 23 +- .../ui/viewmodel/LoginViewModelTest.kt | 268 +++++++++--------- shared/src/desktopMain/kotlin/Main.desktop.kt | 11 + .../{koinDesktop.kt => KoinDesktop.kt} | 2 +- .../fotopresenter/ui/viewmodel/ViewModel.kt | 4 +- shared/src/desktopMain/kotlin/main.desktop.kt | 16 -- .../kotlin/{main.ios.kt => Main.ios.kt} | 2 +- .../fotopresenter/{koiniOS.kt => KoiniOS.kt} | 4 +- .../fotopresenter/ui/viewmodel/ViewModel.kt | 4 +- .../fotopresenter/data/network/SMBJHandler.kt | 25 +- 101 files changed, 736 insertions(+), 733 deletions(-) rename atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/{+EditText.kt => EditTextExtensions.kt} (80%) rename atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/{+TextView.kt => TextViewExtensions.kt} (84%) rename atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/{+View.kt => ViewExtensions.kt} (83%) rename atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/typography/{+AtomikTypography.kt => AtomikTypographyExtensions.kt} (94%) delete mode 100644 atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/+OutlinedTextFieldMolecule.kt delete mode 100644 atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/+TextFieldMolecule.kt rename desktopApp/src/desktopMain/kotlin/{main.kt => Main.kt} (98%) rename desktopApp/src/jvmMain/kotlin/{main.kt => Main.kt} (77%) rename shared/src/androidMain/kotlin/{main.android.kt => Main.android.kt} (100%) rename shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/{koinAndroid.kt => KoinAndroid.kt} (94%) rename shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/{koin.kt => Koin.kt} (50%) rename shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/{+MutableStateFlow.kt => MutableStateFlowExtensions.kt} (70%) rename shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/{+String.kt => StringExtensions.kt} (87%) create mode 100644 shared/src/desktopMain/kotlin/Main.desktop.kt rename shared/src/desktopMain/kotlin/com/kevinschildhorn/fotopresenter/{koinDesktop.kt => KoinDesktop.kt} (99%) delete mode 100644 shared/src/desktopMain/kotlin/main.desktop.kt rename shared/src/iosMain/kotlin/{main.ios.kt => Main.ios.kt} (63%) rename shared/src/iosMain/kotlin/com/kevinschildhorn/fotopresenter/{koiniOS.kt => KoiniOS.kt} (98%) diff --git a/androidApp/src/androidMain/kotlin/com/kevinschildhorn/MainActivity.kt b/androidApp/src/androidMain/kotlin/com/kevinschildhorn/MainActivity.kt index 1067183e..6788335e 100644 --- a/androidApp/src/androidMain/kotlin/com/kevinschildhorn/MainActivity.kt +++ b/androidApp/src/androidMain/kotlin/com/kevinschildhorn/MainActivity.kt @@ -21,4 +21,4 @@ class MainActivity : AppCompatActivity(), KoinComponent { MainView(viewModel) } } -} \ No newline at end of file +} diff --git a/atomik/build.gradle.kts b/atomik/build.gradle.kts index 16915195..9d6b9b73 100644 --- a/atomik/build.gradle.kts +++ b/atomik/build.gradle.kts @@ -2,6 +2,7 @@ plugins { kotlin("multiplatform") id("com.android.library") id("org.jetbrains.compose") + id("org.jlleitschuh.gradle.ktlint") } /* // Exclude compose from iOS @@ -31,14 +32,14 @@ tasks.withType().configureEach kotlin { explicitApi() applyDefaultHierarchyTemplate() - androidTarget() { + androidTarget { publishLibraryVariants("debug", "release") } jvm("desktop") listOf( iosX64(), iosArm64(), - iosSimulatorArm64() + iosSimulatorArm64(), ).forEach { iosTarget -> iosTarget.binaries.framework { baseName = "atomik" diff --git a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/+EditText.kt b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/EditTextExtensions.kt similarity index 80% rename from atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/+EditText.kt rename to atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/EditTextExtensions.kt index 8d9e2e07..e175de86 100644 --- a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/+EditText.kt +++ b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/EditTextExtensions.kt @@ -5,9 +5,8 @@ import com.kevinschildhorn.atomik.atomic.molecules.TextFieldMolecule public fun EditText.applyMolecule(molecule: TextFieldMolecule) { setTextColor(molecule.textAtom.textColor.viewColor) - //setBackgroundColor(molecule.backgroundColorAtom.color.viewColor) TODO Add later + // setBackgroundColor(molecule.backgroundColorAtom.color.viewColor) TODO Add later molecule.hintTextAtom?.let { setHintTextColor(it.textColor.viewColor) } - -} \ No newline at end of file +} diff --git a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/+TextView.kt b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/TextViewExtensions.kt similarity index 84% rename from atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/+TextView.kt rename to atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/TextViewExtensions.kt index d70b39b6..48336f2f 100644 --- a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/+TextView.kt +++ b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/TextViewExtensions.kt @@ -1,4 +1,6 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.atomic.atoms.xml import android.widget.TextView @@ -27,7 +29,10 @@ public fun TextView.applyTextAtom(textAtom: TextAtom?) { */ public fun TextView.applyColorAtom(colorAtom: ColorAtom?, foreground: Boolean = true) { colorAtom?.let { - if (foreground) setTextColor(it.color.viewColor) - else setBackgroundColor(it.color.viewColor) + if (foreground) { + setTextColor(it.color.viewColor) + } else { + setBackgroundColor(it.color.viewColor) + } } -} \ No newline at end of file +} diff --git a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/+View.kt b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/ViewExtensions.kt similarity index 83% rename from atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/+View.kt rename to atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/ViewExtensions.kt index 923a63b4..869e2cf6 100644 --- a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/+View.kt +++ b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/ViewExtensions.kt @@ -1,10 +1,11 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.atomic.atoms.xml import android.view.View import android.widget.TextView import com.kevinschildhorn.atomik.atomic.atoms.interfaces.ColorAtom -import com.kevinschildhorn.atomik.atomic.atoms.interfaces.TextAtom /** * Applies a [ColorAtom] to a [TextView], setting the background color diff --git a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/typography/+AtomikTypography.kt b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/typography/AtomikTypographyExtensions.kt similarity index 94% rename from atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/typography/+AtomikTypography.kt rename to atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/typography/AtomikTypographyExtensions.kt index 3e76f0e0..f8766559 100644 --- a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/typography/+AtomikTypography.kt +++ b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/typography/AtomikTypographyExtensions.kt @@ -1,6 +1,7 @@ -// ktlint-disable filename -package com.kevinschildhorn.atomik.typography +@file:Suppress("ktlint:standard:filename") + +package com.kevinschildhorn.atomik.typography import android.graphics.Typeface import androidx.compose.ui.text.TextStyle @@ -16,7 +17,6 @@ public fun AtomikTypography.asComposeTextStyle(fontFamily: FontFamily): TextStyl fontSize = this.size.sp, ) - /* * Converting the Weight to a Typeface */ diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/DesignSystem.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/DesignSystem.kt index df77b817..3ea3e6c4 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/DesignSystem.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/DesignSystem.kt @@ -23,7 +23,7 @@ public open class DesignSystem( public open val colorSet: ColorSet, public open val typographySet: TypographySet, public open val components: Map, - public open var fontFamily: AtomikFontFamily? = null + public open var fontFamily: AtomikFontFamily? = null, ) /* @OptIn(ExperimentalAtomik::class) @@ -59,5 +59,5 @@ internal class CustomDesignSystem( override val colorSet: CustomColorSet, override val typographySet: CustomTypographySet, override val components: Map, - override var fontFamily: AtomikFontFamily? + override var fontFamily: AtomikFontFamily?, ) : DesignSystem(colorSet, typographySet, components, fontFamily) diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/FigmaAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/FigmaAtom.kt index 83307aee..04050e7f 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/FigmaAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/FigmaAtom.kt @@ -11,7 +11,6 @@ import com.kevinschildhorn.atomik.atomic.atoms.interfaces.TextAtom import com.kevinschildhorn.atomik.color.base.AtomikColor import com.kevinschildhorn.atomik.typography.base.AtomikFontFamily import com.kevinschildhorn.atomik.typography.base.AtomikTypography -import com.kevinschildhorn.atomik.typography.base.AtomikTypographyType /** * Represents an Atom with all of the properties found in a Figma atom @@ -30,7 +29,7 @@ public open class FigmaBaseAtom( override val width: Int?, override val height: Int?, override val constraintX: AtomikConstraintX, - override val constraintY: AtomikConstraintY + override val constraintY: AtomikConstraintY, ) : Atom(), FixedSizeAtom, ConstrainedAtom /** @@ -69,7 +68,7 @@ public class FigmaShapeAtom( override val paddingLeft: Int? = paddingHorizontal, override val paddingRight: Int? = paddingHorizontal, override val paddingTop: Int? = paddingVertical, - override val paddingBottom: Int? = paddingVertical + override val paddingBottom: Int? = paddingVertical, ) : FigmaBaseAtom(type, width, height, constraintX, constraintY), ColorAtom, PaddingAtom /** @@ -112,5 +111,5 @@ public class FigmaTextAtom( override val paddingLeft: Int? = paddingHorizontal, override val paddingRight: Int? = paddingHorizontal, override val paddingTop: Int? = paddingVertical, - override val paddingBottom: Int? = paddingVertical + override val paddingBottom: Int? = paddingVertical, ) : FigmaBaseAtom(type, width, height, constraintX, constraintY), TextAtom, PaddingAtom diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/TextFieldAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/TextFieldAtom.kt index 6348e711..9a67addd 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/TextFieldAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/TextFieldAtom.kt @@ -1,11 +1,5 @@ package com.kevinschildhorn.atomik.atomic.atoms -import com.kevinschildhorn.atomik.atomic.atoms.interfaces.AtomType -import com.kevinschildhorn.atomik.atomic.atoms.interfaces.BorderedAtom -import com.kevinschildhorn.atomik.atomic.atoms.interfaces.TextAtom -import com.kevinschildhorn.atomik.color.base.AtomikColor -import com.kevinschildhorn.atomik.typography.base.AtomikFontFamily -import com.kevinschildhorn.atomik.typography.base.AtomikTypography /* public class TextFieldAtom( override val textColor: AtomikColor, diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+AtomikColorType.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+AtomikColorType.kt index 6de079ff..474578e1 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+AtomikColorType.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+AtomikColorType.kt @@ -1,4 +1,6 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.atomic.atoms.compose /* import androidx.compose.ui.graphics.Color @@ -10,4 +12,4 @@ import com.kevinschildhorn.atomik.color.base.AtomikColorType */ internal val AtomikColorType.composeColor: Color get() = color.composeColor -*/ \ No newline at end of file +*/ diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+ConstrainedAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+ConstrainedAtom.kt index b436a57a..92124a96 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+ConstrainedAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+ConstrainedAtom.kt @@ -1,4 +1,6 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.atomic.atoms import androidx.compose.ui.Alignment @@ -11,23 +13,25 @@ import com.kevinschildhorn.atomik.atomic.atoms.interfaces.ConstrainedAtom * The Vertical compose Alignment, based on the [ConstrainedAtom] */ public val ConstrainedAtom.alignmentVertical: Alignment.Vertical - get() = when (this.constraintY) { - AtomikConstraintY.ALIGN_TOP -> Alignment.Top - AtomikConstraintY.ALIGN_BOTTOM -> Alignment.Bottom - AtomikConstraintY.CENTER -> Alignment.CenterVertically - AtomikConstraintY.SCALE -> Alignment.CenterVertically - } + get() = + when (this.constraintY) { + AtomikConstraintY.ALIGN_TOP -> Alignment.Top + AtomikConstraintY.ALIGN_BOTTOM -> Alignment.Bottom + AtomikConstraintY.CENTER -> Alignment.CenterVertically + AtomikConstraintY.SCALE -> Alignment.CenterVertically + } /** * The Horizontal compose Alignment, based on the [ConstrainedAtom] */ public val ConstrainedAtom.alignmentHorizontal: Alignment.Horizontal - get() = when (this.constraintX) { - AtomikConstraintX.ALIGN_LEFT -> Alignment.Start - AtomikConstraintX.ALIGN_RIGHT -> Alignment.End - AtomikConstraintX.CENTER -> Alignment.CenterHorizontally - AtomikConstraintX.SCALE -> Alignment.CenterHorizontally - } + get() = + when (this.constraintX) { + AtomikConstraintX.ALIGN_LEFT -> Alignment.Start + AtomikConstraintX.ALIGN_RIGHT -> Alignment.End + AtomikConstraintX.CENTER -> Alignment.CenterHorizontally + AtomikConstraintX.SCALE -> Alignment.CenterHorizontally + } /** * The compose Alignment, based on the [ConstrainedAtom]. Combines both vertical and horizontal @@ -36,17 +40,19 @@ public val ConstrainedAtom.alignment: Alignment get() = BiasAlignment(horizontalBias, verticalBias) private val ConstrainedAtom.verticalBias: Float - get() = when (this.constraintY) { - AtomikConstraintY.ALIGN_TOP -> -1f - AtomikConstraintY.ALIGN_BOTTOM -> 1f - AtomikConstraintY.CENTER -> 0f - AtomikConstraintY.SCALE -> 0f - } + get() = + when (this.constraintY) { + AtomikConstraintY.ALIGN_TOP -> -1f + AtomikConstraintY.ALIGN_BOTTOM -> 1f + AtomikConstraintY.CENTER -> 0f + AtomikConstraintY.SCALE -> 0f + } private val ConstrainedAtom.horizontalBias: Float - get() = when (this.constraintX) { - AtomikConstraintX.ALIGN_LEFT -> -1f - AtomikConstraintX.ALIGN_RIGHT -> 1f - AtomikConstraintX.CENTER -> 0f - AtomikConstraintX.SCALE -> 0f - } \ No newline at end of file + get() = + when (this.constraintX) { + AtomikConstraintX.ALIGN_LEFT -> -1f + AtomikConstraintX.ALIGN_RIGHT -> 1f + AtomikConstraintX.CENTER -> 0f + AtomikConstraintX.SCALE -> 0f + } diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+EnablableAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+EnablableAtom.kt index 540bffee..e0cfe9e0 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+EnablableAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+EnablableAtom.kt @@ -1,4 +1,6 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.atomic.atoms.compose /* diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+FixedSizeAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+FixedSizeAtom.kt index ed5cd741..e736fff1 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+FixedSizeAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+FixedSizeAtom.kt @@ -1,4 +1,6 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.atomic.atoms /* import androidx.compose.foundation.layout.height diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+RoundedAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+RoundedAtom.kt index 9d1b64d8..e2af884e 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+RoundedAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+RoundedAtom.kt @@ -1,4 +1,6 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.atomic.atoms import androidx.compose.foundation.shape.RoundedCornerShape @@ -8,4 +10,3 @@ import com.kevinschildhorn.atomik.atomic.atoms.interfaces.RoundedAtom public val RoundedAtom.shape: Shape get() = RoundedCornerShape(radius.dp) - diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+TextAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+TextAtom.kt index c700dd9d..1431ebfa 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+TextAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+TextAtom.kt @@ -1,4 +1,6 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.atomic.atoms import androidx.compose.runtime.Composable @@ -23,7 +25,7 @@ public val TextAtom.textStyle: TextStyle fontFamily = fontFamilyResource(this.typography.font), fontWeight = this.typography.weight.fontWeight, fontSize = this.typography.size.sp, - color = this.textColor.composeColor + color = this.textColor.composeColor, ) } @@ -38,5 +40,5 @@ public fun TextAtom.textStyle(fontFamily: FontFamily): TextStyle = fontFamily = fontFamily, fontWeight = this.typography.weight.fontWeight, fontSize = this.typography.size.sp, - color = this.textColor.composeColor + color = this.textColor.composeColor, ) diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/AtomType.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/AtomType.kt index b02264bb..31875a41 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/AtomType.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/AtomType.kt @@ -14,5 +14,5 @@ public enum class AtomType { TEXT, IMAGE, TEXTFIELD, - VIEW + VIEW, } diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/BorderedAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/BorderedAtom.kt index 430e641b..63ee44cc 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/BorderedAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/BorderedAtom.kt @@ -13,7 +13,6 @@ import com.kevinschildhorn.atomik.color.base.AtomikColor internal interface BorderedAtom : AtomInterface { public val focusedBorderColor: AtomikColor public val unFocusedBorderColor: AtomikColor - } /** diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/ConstrainedAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/ConstrainedAtom.kt index b7689523..a1621bc0 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/ConstrainedAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/ConstrainedAtom.kt @@ -20,7 +20,7 @@ public enum class AtomikConstraintX { CENTER, ALIGN_LEFT, ALIGN_RIGHT, - SCALE + SCALE, } /** @@ -30,7 +30,7 @@ public enum class AtomikConstraintY { CENTER, ALIGN_TOP, ALIGN_BOTTOM, - SCALE + SCALE, } /** diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/EnablableAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/EnablableAtom.kt index c7d6a11d..e4a38baf 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/EnablableAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/EnablableAtom.kt @@ -2,7 +2,6 @@ package com.kevinschildhorn.atomik.atomic.atoms.interfaces import com.kevinschildhorn.atomik.atomic.atoms.Atom import com.kevinschildhorn.atomik.color.base.AtomikColor -import com.kevinschildhorn.atomik.color.base.AtomikColorType /** * An atom that can be enabled / disabled. Contains the disabled color of the UI and inherits [ColorAtom] diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/TextAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/TextAtom.kt index 39d6280f..77d603c1 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/TextAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/interfaces/TextAtom.kt @@ -4,7 +4,6 @@ import com.kevinschildhorn.atomik.atomic.atoms.Atom import com.kevinschildhorn.atomik.color.base.AtomikColor import com.kevinschildhorn.atomik.typography.base.AtomikFontFamily import com.kevinschildhorn.atomik.typography.base.AtomikTypography -import com.kevinschildhorn.atomik.typography.base.AtomikTypographyType /** * An atom that has text @@ -31,7 +30,7 @@ public val Atom.textAtom: TextAtom? public class SimpleTextAtom( override val textColor: AtomikColor, override val typography: AtomikTypography, - override val fontFamily: AtomikFontFamily? + override val fontFamily: AtomikFontFamily?, ) : Atom(), TextAtom { override val type: AtomType = AtomType.TEXT -} \ No newline at end of file +} diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/+OutlinedTextFieldMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/+OutlinedTextFieldMolecule.kt deleted file mode 100644 index 75a967fc..00000000 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/+OutlinedTextFieldMolecule.kt +++ /dev/null @@ -1,43 +0,0 @@ -package com.kevinschildhorn.atomik.atomic.molecules - -import androidx.compose.material.ContentAlpha -import androidx.compose.material.TextFieldColors -import androidx.compose.material.TextFieldDefaults -import androidx.compose.runtime.Composable -import com.kevinschildhorn.atomik.color.base.composeColor - -@Composable -public fun OutlinedTextFieldMolecule.colors(): TextFieldColors { - val textColor = textAtom.textColor.composeColor - val backgroundColor = backgroundColorAtom.color.composeColor - val disabledBackgroundColor = backgroundColor.copy(alpha = ContentAlpha.disabled) - val errorTextColor = textAtom.textColor.composeColor - - return TextFieldDefaults.outlinedTextFieldColors( - textColor = textColor, - backgroundColor = backgroundColor, - placeholderColor = hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( - ContentAlpha.medium - ), - cursorColor = cursorColor?.composeColor ?: textColor, - focusedBorderColor = focusedBorderColor.composeColor, - unfocusedBorderColor = unFocusedBorderColor.composeColor, - - disabledTextColor = disabledColorAtom?.color?.composeColor - ?: textColor.copy(ContentAlpha.disabled), - disabledBorderColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, - disabledLabelColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, - disabledLeadingIconColor = disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, - disabledPlaceholderColor = disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, - disabledTrailingIconColor = disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, - - errorCursorColor = errorColor?.composeColor ?: errorTextColor, - errorBorderColor = errorColor?.composeColor ?: errorTextColor, - errorLabelColor = errorColor?.composeColor ?: errorTextColor, - errorLeadingIconColor = errorColor?.composeColor ?: errorTextColor, - errorTrailingIconColor = errorColor?.composeColor ?: errorTextColor, - ) -} \ No newline at end of file diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/+TextFieldMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/+TextFieldMolecule.kt deleted file mode 100644 index c21be960..00000000 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/+TextFieldMolecule.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.kevinschildhorn.atomik.atomic.molecules - -import androidx.compose.material.ContentAlpha -import androidx.compose.material.TextFieldColors -import androidx.compose.material.TextFieldDefaults.textFieldColors -import androidx.compose.runtime.Composable -import com.kevinschildhorn.atomik.color.base.composeColor - -@Composable -public fun TextFieldMolecule.colors(): TextFieldColors { - val textColor = textAtom.textColor.composeColor - val backgroundColor = backgroundColorAtom.color.composeColor - val disabledBackgroundColor = backgroundColor.copy(alpha = ContentAlpha.disabled) - val errorTextColor = textAtom.textColor.composeColor - - return textFieldColors( - textColor = textColor, - backgroundColor = backgroundColor, - placeholderColor = hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy(ContentAlpha.medium), - cursorColor = cursorColor?.composeColor ?: textColor, - - disabledTextColor = disabledColorAtom?.color?.composeColor ?: textColor.copy(ContentAlpha.disabled), - disabledIndicatorColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, - disabledLabelColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, - disabledLeadingIconColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, - disabledPlaceholderColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, - disabledTrailingIconColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, - - errorCursorColor = errorColor?.composeColor ?: errorTextColor, - errorIndicatorColor = errorColor?.composeColor ?: errorTextColor, - errorLabelColor = errorColor?.composeColor ?: errorTextColor, - errorLeadingIconColor = errorColor?.composeColor ?: errorTextColor, - errorTrailingIconColor = errorColor?.composeColor ?: errorTextColor, - ) -} \ No newline at end of file diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/BaseMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/BaseMolecule.kt index bc6b378e..e1af1b2c 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/BaseMolecule.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/BaseMolecule.kt @@ -1,8 +1,6 @@ package com.kevinschildhorn.atomik.atomic.molecules import com.kevinschildhorn.atomik.atomic.atoms.Atom -import com.kevinschildhorn.atomik.atomic.atoms.interfaces.ColorAtom -import com.kevinschildhorn.atomik.atomic.atoms.interfaces.TextAtom /** * Represents a Molecule from Atomic Design, as an interface @@ -15,4 +13,3 @@ import com.kevinschildhorn.atomik.atomic.atoms.interfaces.TextAtom public abstract class BaseMolecule { public abstract val atoms: List } - diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt index 1f296bba..a4edccee 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt @@ -1,10 +1,15 @@ package com.kevinschildhorn.atomik.atomic.molecules +import androidx.compose.material.ContentAlpha +import androidx.compose.material.TextFieldColors +import androidx.compose.material.TextFieldDefaults +import androidx.compose.runtime.Composable import com.kevinschildhorn.atomik.atomic.atoms.interfaces.BorderedAtom import com.kevinschildhorn.atomik.atomic.atoms.interfaces.ColorAtom import com.kevinschildhorn.atomik.atomic.atoms.interfaces.RoundedAtom import com.kevinschildhorn.atomik.atomic.atoms.interfaces.TextAtom import com.kevinschildhorn.atomik.color.base.AtomikColor +import com.kevinschildhorn.atomik.color.base.composeColor /** * A molecule that contains information about a TextField @@ -37,4 +42,46 @@ public open class OutlinedTextFieldMolecule( disabledColorAtom, cursorColor, errorColor, -), BorderedAtom, RoundedAtom \ No newline at end of file +), + BorderedAtom, + RoundedAtom { + + @Composable + public fun colors(): TextFieldColors { + val textColor = textAtom.textColor.composeColor + val backgroundColor = backgroundColorAtom.color.composeColor + val disabledBackgroundColor = backgroundColor.copy(alpha = ContentAlpha.disabled) + val errorTextColor = textAtom.textColor.composeColor + + return TextFieldDefaults.outlinedTextFieldColors( + textColor = textColor, + backgroundColor = backgroundColor, + placeholderColor = + hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( + ContentAlpha.medium, + ), + cursorColor = cursorColor?.composeColor ?: textColor, + focusedBorderColor = focusedBorderColor.composeColor, + unfocusedBorderColor = unFocusedBorderColor.composeColor, + disabledTextColor = + disabledColorAtom?.color?.composeColor + ?: textColor.copy(ContentAlpha.disabled), + disabledBorderColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, + disabledLabelColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, + disabledLeadingIconColor = + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, + disabledPlaceholderColor = + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, + disabledTrailingIconColor = + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, + errorCursorColor = errorColor?.composeColor ?: errorTextColor, + errorBorderColor = errorColor?.composeColor ?: errorTextColor, + errorLabelColor = errorColor?.composeColor ?: errorTextColor, + errorLeadingIconColor = errorColor?.composeColor ?: errorTextColor, + errorTrailingIconColor = errorColor?.composeColor ?: errorTextColor, + ) + } +} diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextButtonMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextButtonMolecule.kt index f359bb53..e102eb81 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextButtonMolecule.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextButtonMolecule.kt @@ -1,6 +1,5 @@ package com.kevinschildhorn.atomik.atomic.molecules - import com.kevinschildhorn.atomik.atomic.atoms.Atom import com.kevinschildhorn.atomik.atomic.atoms.interfaces.EnablableAtom import com.kevinschildhorn.atomik.atomic.atoms.interfaces.RoundedAtom @@ -11,9 +10,7 @@ public class TextButtonMolecule( override val color: AtomikColor, override val disabledColor: AtomikColor, override val radius: Int, - public val textAtom: TextAtom + public val textAtom: TextAtom, ) : BaseMolecule(), EnablableAtom, RoundedAtom { - override val atoms: List = listOf(textAtom as Atom) - } diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt index 15e14af8..62d5791e 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt @@ -1,9 +1,14 @@ package com.kevinschildhorn.atomik.atomic.molecules +import androidx.compose.material.ContentAlpha +import androidx.compose.material.TextFieldColors +import androidx.compose.material.TextFieldDefaults +import androidx.compose.runtime.Composable import com.kevinschildhorn.atomik.atomic.atoms.Atom import com.kevinschildhorn.atomik.atomic.atoms.interfaces.ColorAtom import com.kevinschildhorn.atomik.atomic.atoms.interfaces.TextAtom import com.kevinschildhorn.atomik.color.base.AtomikColor +import com.kevinschildhorn.atomik.color.base.composeColor /** * A molecule that contains information about a TextField @@ -25,8 +30,39 @@ public open class TextFieldMolecule( public val cursorColor: AtomikColor? = null, public val errorColor: AtomikColor? = errorTextAtom?.textColor, ) : BaseMolecule() { - override val atoms: List - get() = listOf(/*textAtom, hintTextAtom, errorTextAtom, cursorColor*/) -} + get() = listOf() + @Composable + public fun colors(): TextFieldColors { + val textColor = textAtom.textColor.composeColor + val backgroundColor = backgroundColorAtom.color.composeColor + val disabledBackgroundColor = backgroundColor.copy(alpha = ContentAlpha.disabled) + val errorTextColor = textAtom.textColor.composeColor + + return TextFieldDefaults.textFieldColors( + textColor = textColor, + backgroundColor = backgroundColor, + placeholderColor = hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( + ContentAlpha.medium, + ), + cursorColor = cursorColor?.composeColor ?: textColor, + disabledTextColor = disabledColorAtom?.color?.composeColor + ?: textColor.copy(ContentAlpha.disabled), + disabledIndicatorColor = disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, + disabledLabelColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, + disabledLeadingIconColor = disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, + disabledPlaceholderColor = disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, + disabledTrailingIconColor = disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, + errorCursorColor = errorColor?.composeColor ?: errorTextColor, + errorIndicatorColor = errorColor?.composeColor ?: errorTextColor, + errorLabelColor = errorColor?.composeColor ?: errorTextColor, + errorLeadingIconColor = errorColor?.composeColor ?: errorTextColor, + errorTrailingIconColor = errorColor?.composeColor ?: errorTextColor, + ) + } +} diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/organisms/BaseOrganism.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/organisms/BaseOrganism.kt index 6ccc7d09..29ea8d08 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/organisms/BaseOrganism.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/organisms/BaseOrganism.kt @@ -4,4 +4,4 @@ import com.kevinschildhorn.atomik.atomic.molecules.BaseMolecule public abstract class BaseOrganism { public abstract val molecules: List -} \ No newline at end of file +} diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/organisms/FormOrganism.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/organisms/FormOrganism.kt index 7e12cf2c..611b7fce 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/organisms/FormOrganism.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/organisms/FormOrganism.kt @@ -3,7 +3,5 @@ package com.kevinschildhorn.atomik.atomic.organisms import com.kevinschildhorn.atomik.atomic.molecules.BaseMolecule public class FormOrganism( - override val molecules: List -) : BaseOrganism() { - -} \ No newline at end of file + override val molecules: List, +) : BaseOrganism() diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/CustomColorSet.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/CustomColorSet.kt index 67d73979..59c71aae 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/CustomColorSet.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/CustomColorSet.kt @@ -15,9 +15,8 @@ import com.kevinschildhorn.atomik.color.base.ColorSet */ public class CustomColorSet( override val fallbackColor: AtomikColor, - private val colors: Map + private val colors: Map, ) : ColorSet { - /** * Gets the color based on a type. If none is found then the fallback is returned * @param name The name of color you want to get as a [String] diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/CustomColorSetTyped.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/CustomColorSetTyped.kt index 9a798a66..7db78e18 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/CustomColorSetTyped.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/CustomColorSetTyped.kt @@ -15,9 +15,8 @@ import com.kevinschildhorn.atomik.color.base.ColorSet */ internal class CustomColorSetTyped>( override val fallbackColor: AtomikColor, - private val colors: Map + private val colors: Map, ) : ColorSet { - /** * Gets the color based on an enum value. If none is found then the fallback is returned * @param type The enum associated with the typography you want to get as a [AtomikColor] diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt index 7a661970..4bc1361c 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt @@ -16,7 +16,6 @@ import androidx.compose.ui.graphics.Color */ @Suppress("SpellCheckingInspection") public expect class AtomikColor { - public val hexString: String public val r: Int public val g: Int @@ -44,9 +43,10 @@ public expect class AtomikColor { } public val AtomikColor.composeColor: Color - get() = Color( - red = r.toFloat() / 255, - green = g.toFloat() / 255, - blue = b.toFloat() / 255, - alpha = this.a - ) \ No newline at end of file + get() = + Color( + red = r.toFloat() / 255, + green = g.toFloat() / 255, + blue = b.toFloat() / 255, + alpha = this.a, + ) diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColorData.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColorData.kt index 72a7b1ed..29da7c78 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColorData.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColorData.kt @@ -22,9 +22,8 @@ internal data class AtomikColorData( val r: Int, val g: Int, val b: Int, - val a: Float + val a: Float, ) { - /** * @constructor constructor with hex value * @param hex hex value @@ -35,7 +34,7 @@ internal data class AtomikColorData( r = hex.red, g = hex.green, b = hex.blue, - a = hex.alpha + a = hex.alpha, ) /** @@ -51,7 +50,7 @@ internal data class AtomikColorData( r = r, g = g, b = b, - a = a ?: 1F + a = a ?: 1F, ) } @@ -75,7 +74,13 @@ private val Long.alpha: Float private val String.isLongFormHex: Boolean get() = this.length == 8 + 1 -private fun hexFromRGB(r: Int, g: Int, b: Int, a: Float?, alphaIsPrefix: Boolean): String { +private fun hexFromRGB( + r: Int, + g: Int, + b: Int, + a: Float?, + alphaIsPrefix: Boolean, +): String { val rgbString = (r.asHexString + g.asHexString + b.asHexString) return if (alphaIsPrefix) { "#${a.asAlphaString + rgbString}".uppercase() diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/+TypographyWeight.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/+TypographyWeight.kt index b5732420..404eaf59 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/+TypographyWeight.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/+TypographyWeight.kt @@ -1,7 +1,8 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.typography -import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import com.kevinschildhorn.atomik.typography.base.AtomikTypographyWeight @@ -9,7 +10,8 @@ import com.kevinschildhorn.atomik.typography.base.AtomikTypographyWeight * A composable [FontWeight] based on the [AtomikTypographyWeight] */ internal val AtomikTypographyWeight.fontWeight: FontWeight - get() = when (this) { - AtomikTypographyWeight.BOLD -> FontWeight.Bold - else -> FontWeight.Normal - } + get() = + when (this) { + AtomikTypographyWeight.BOLD -> FontWeight.Bold + else -> FontWeight.Normal + } diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/CustomTypographySet.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/CustomTypographySet.kt index bbf5918e..63a7047d 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/CustomTypographySet.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/CustomTypographySet.kt @@ -16,14 +16,12 @@ import com.kevinschildhorn.atomik.typography.base.TypographySet */ internal class CustomTypographySet( override val fallbackTypography: AtomikTypography, - private val typographies: Map + private val typographies: Map, ) : TypographySet { - /** * Gets the typography based on a type. If none is found then the fallback is returned * @param type The type of typography you want to get as a [AtomikTypographyType] * @return the [AtomikTypography] based on the type passed */ - override fun getTypography(type: AtomikTypographyType): AtomikTypography = - typographies[type] ?: fallbackTypography + override fun getTypography(type: AtomikTypographyType): AtomikTypography = typographies[type] ?: fallbackTypography } diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/CustomTypographySetTyped.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/CustomTypographySetTyped.kt index 8c20501e..be369a17 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/CustomTypographySetTyped.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/CustomTypographySetTyped.kt @@ -16,9 +16,8 @@ import com.kevinschildhorn.atomik.typography.base.TypographySet */ internal class CustomTypographySetTyped>( override val fallbackTypography: AtomikTypography, - private val typographies: Map + private val typographies: Map, ) : TypographySet { - /** * Gets the typography based on an enum value. If none is found then the fallback is returned * @param type The enum associated with the typography you want to get as a [AtomikTypographyType] diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt index 9e0f2ae1..13140ecf 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt @@ -11,4 +11,4 @@ import androidx.compose.ui.text.font.FontFamily @Suppress("SpellCheckingInspection") public expect class AtomikFontFamily { public val fontFamily: FontFamily -} \ No newline at end of file +} diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikTypography.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikTypography.kt index 4408d3e9..0b7f2640 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikTypography.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikTypography.kt @@ -13,5 +13,5 @@ import dev.icerock.moko.resources.FontResource public data class AtomikTypography( val weight: AtomikTypographyWeight = AtomikTypographyWeight.NORMAL, val size: Int, - val font: FontResource + val font: FontResource, ) diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikTypographyWeight.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikTypographyWeight.kt index ea081e7e..75f4b72f 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikTypographyWeight.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikTypographyWeight.kt @@ -14,5 +14,5 @@ public enum class AtomikTypographyWeight { SEMIBOLD, BOLD, EXTRABOLD, - BLACK + BLACK, } diff --git a/atomik/src/commonTest/kotlin/com/kevinschildhorn/atomik/AtomikColorTest.kt b/atomik/src/commonTest/kotlin/com/kevinschildhorn/atomik/AtomikColorTest.kt index d5e3da3b..393bb1f9 100644 --- a/atomik/src/commonTest/kotlin/com/kevinschildhorn/atomik/AtomikColorTest.kt +++ b/atomik/src/commonTest/kotlin/com/kevinschildhorn/atomik/AtomikColorTest.kt @@ -5,41 +5,43 @@ import kotlin.test.Test import kotlin.test.assertEquals class AtomikColorTest { - data class ColorTest( val hexColor: Long, val hexColorString: String, val r: Int, val g: Int, val b: Int, - val a: Float = 1F + val a: Float = 1F, ) - private val colorTestNoAlpha = ColorTest( - hexColor = 0xa63028, - hexColorString = "#A63028", - r = 166, - g = 48, - b = 40 - ) + private val colorTestNoAlpha = + ColorTest( + hexColor = 0xa63028, + hexColorString = "#A63028", + r = 166, + g = 48, + b = 40, + ) - private val colorTestAlpha = ColorTest( - hexColor = 0xa63028E6, - hexColorString = "#A63028E6", - r = 166, - g = 48, - b = 40, - a = 0.90F - ) + private val colorTestAlpha = + ColorTest( + hexColor = 0xa63028E6, + hexColorString = "#A63028E6", + r = 166, + g = 48, + b = 40, + a = 0.90F, + ) - private val colorWhite = ColorTest( - hexColor = 0xffffffff, - hexColorString = "#FFFFFFFF", - r = 255, - g = 255, - b = 255, - a = 1F - ) + private val colorWhite = + ColorTest( + hexColor = 0xffffffff, + hexColorString = "#FFFFFFFF", + r = 255, + g = 255, + b = 255, + a = 1F, + ) @Test fun testColorRGB() { @@ -54,23 +56,25 @@ class AtomikColorTest { @Test fun testColorRGBA() { - val color = AtomikColor( - colorTestAlpha.r, - colorTestAlpha.g, - colorTestAlpha.b, - colorTestAlpha.a - ) + val color = + AtomikColor( + colorTestAlpha.r, + colorTestAlpha.g, + colorTestAlpha.b, + colorTestAlpha.a, + ) assertAll(colorTestAlpha, color) } @Test fun testColorRGBAFull() { - val color = AtomikColor( - colorWhite.r, - colorWhite.g, - colorWhite.b, - colorWhite.a - ) + val color = + AtomikColor( + colorWhite.r, + colorWhite.g, + colorWhite.b, + colorWhite.a, + ) assertAll(colorWhite, color) } @@ -86,7 +90,10 @@ class AtomikColorTest { assertAll(colorTestAlpha, color) } - private fun assertAll(ColorTest: ColorTest, color: AtomikColor) { + private fun assertAll( + ColorTest: ColorTest, + color: AtomikColor, + ) { assertEquals(expected = ColorTest.a, actual = color.a) assertEquals(expected = ColorTest.r, actual = color.r) assertEquals(expected = ColorTest.g, actual = color.g) diff --git a/atomik/src/desktopMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt b/atomik/src/desktopMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt index 651d4338..24a0ba52 100644 --- a/atomik/src/desktopMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt +++ b/atomik/src/desktopMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt @@ -20,7 +20,6 @@ public actual class AtomikColor { public actual val b: Int public actual val a: Float - /** * Constructor with hex variable * @@ -53,4 +52,4 @@ public actual class AtomikColor { this.b = data.b this.a = data.a } -} \ No newline at end of file +} diff --git a/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/+TextAtom.kt b/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/+TextAtom.kt index e78fdf0a..df7a07d6 100644 --- a/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/+TextAtom.kt +++ b/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/+TextAtom.kt @@ -1,4 +1,6 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.atomic.atoms /* diff --git a/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt b/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt index 407994a8..fe822baf 100644 --- a/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt +++ b/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/color/base/AtomikColor.kt @@ -25,7 +25,7 @@ public actual class AtomikColor { red = r.toDouble() / 255, green = g.toDouble() / 255, blue = b.toDouble() / 255, - alpha = a.toDouble() + alpha = a.toDouble(), ) public actual constructor(hex: Long) { diff --git a/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/typography/+TypographyWeight.kt b/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/typography/+TypographyWeight.kt index 51a690ce..c8c4a00f 100644 --- a/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/typography/+TypographyWeight.kt +++ b/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/typography/+TypographyWeight.kt @@ -1,4 +1,6 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.typography import com.kevinschildhorn.atomik.typography.base.AtomikTypographyWeight @@ -19,10 +21,13 @@ internal val AtomikTypographyWeight.uiFontWeight: UIFontWeight AtomikTypographyWeight.NORMAL -> UIFontWeightRegular AtomikTypographyWeight.BOLD -> UIFontWeightBold AtomikTypographyWeight.BLACK, - AtomikTypographyWeight.EXTRABOLD -> UIFontWeightBlack + AtomikTypographyWeight.EXTRABOLD, + -> UIFontWeightBlack AtomikTypographyWeight.MEDIUM, - AtomikTypographyWeight.SEMIBOLD -> UIFontWeightMedium + AtomikTypographyWeight.SEMIBOLD, + -> UIFontWeightMedium AtomikTypographyWeight.THIN, - AtomikTypographyWeight.LIGHT -> UIFontWeightThin + AtomikTypographyWeight.LIGHT, + -> UIFontWeightThin AtomikTypographyWeight.EXTRALIGHT -> UIFontWeightUltraLight } diff --git a/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt b/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt index cc31d784..c7f81e99 100644 --- a/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt +++ b/atomik/src/iosMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt @@ -11,6 +11,6 @@ import platform.UIKit.UIFont * @property uiFonts a map of UIFonts reference by [AtomikTypographyWeight] */ @Suppress("SpellCheckingInspection") -public actual class AtomikFontFamily(private val uiFonts: Map){ +public actual class AtomikFontFamily(private val uiFonts: Map) { public actual val fontFamily: FontFamily = TODO() } diff --git a/atomik/src/jvmMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/+Modifier.kt b/atomik/src/jvmMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/+Modifier.kt index 34c5122b..f3bd164b 100644 --- a/atomik/src/jvmMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/+Modifier.kt +++ b/atomik/src/jvmMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/+Modifier.kt @@ -1,4 +1,6 @@ -// ktlint-disable filename + +@file:Suppress("ktlint:standard:filename") + package com.kevinschildhorn.atomik.atomic.atoms.compose import androidx.compose.foundation.background diff --git a/atomik/src/jvmMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt b/atomik/src/jvmMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt index dabe6fd8..70acf2bc 100644 --- a/atomik/src/jvmMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt +++ b/atomik/src/jvmMain/kotlin/com/kevinschildhorn/atomik/typography/base/AtomikFontFamily.kt @@ -1,6 +1,5 @@ package com.kevinschildhorn.atomik.typography.base -import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontFamily /** diff --git a/build.gradle.kts b/build.gradle.kts index b7e1d5d2..c46b66db 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,4 +5,6 @@ plugins { id("com.android.application").apply(false) id("com.android.library").apply(false) id("org.jetbrains.compose").apply(false) + id("org.jlleitschuh.gradle.ktlint").version("12.0.2").apply(false) + id("dev.icerock.mobile.multiplatform-resources").version("0.23.0").apply(false) } diff --git a/desktopApp/build.gradle.kts b/desktopApp/build.gradle.kts index 931f3467..89f3a578 100644 --- a/desktopApp/build.gradle.kts +++ b/desktopApp/build.gradle.kts @@ -8,7 +8,7 @@ plugins { kotlin { jvm() sourceSets { - val jvmMain by getting { + val jvmMain by getting { dependencies { implementation(compose.desktop.currentOs) implementation(project(":shared")) diff --git a/desktopApp/src/desktopMain/kotlin/main.kt b/desktopApp/src/desktopMain/kotlin/Main.kt similarity index 98% rename from desktopApp/src/desktopMain/kotlin/main.kt rename to desktopApp/src/desktopMain/kotlin/Main.kt index 5ffada98..0b3c250a 100644 --- a/desktopApp/src/desktopMain/kotlin/main.kt +++ b/desktopApp/src/desktopMain/kotlin/Main.kt @@ -5,4 +5,4 @@ fun main() = application { Window(onCloseRequest = ::exitApplication) { MainView() } -} \ No newline at end of file +} diff --git a/desktopApp/src/jvmMain/kotlin/main.kt b/desktopApp/src/jvmMain/kotlin/Main.kt similarity index 77% rename from desktopApp/src/jvmMain/kotlin/main.kt rename to desktopApp/src/jvmMain/kotlin/Main.kt index 5f10fa36..c814b116 100644 --- a/desktopApp/src/jvmMain/kotlin/main.kt +++ b/desktopApp/src/jvmMain/kotlin/Main.kt @@ -1,10 +1,9 @@ import androidx.compose.material.Text import androidx.compose.ui.window.Window import androidx.compose.ui.window.application -import com.kevinschildhorn.fotopresenter.ui.compose.LoginScreen fun main() = application { Window(onCloseRequest = ::exitApplication) { Text("") } -} \ No newline at end of file +} diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 5fd48758..f1c8943d 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -2,7 +2,8 @@ plugins { kotlin("multiplatform") id("com.android.library") id("org.jetbrains.compose") - id("dev.icerock.mobile.multiplatform-resources").version("0.23.0") + id("org.jlleitschuh.gradle.ktlint") + id("dev.icerock.mobile.multiplatform-resources") } kotlin { @@ -12,7 +13,7 @@ kotlin { listOf( iosX64(), iosArm64(), - iosSimulatorArm64() + iosSimulatorArm64(), ).forEach { iosTarget -> iosTarget.binaries.framework { baseName = "shared" @@ -111,4 +112,4 @@ android { multiplatformResources { multiplatformResourcesPackage = "com.kevinschildhorn.fotopresenter" // required -} \ No newline at end of file +} diff --git a/shared/src/androidMain/kotlin/main.android.kt b/shared/src/androidMain/kotlin/Main.android.kt similarity index 100% rename from shared/src/androidMain/kotlin/main.android.kt rename to shared/src/androidMain/kotlin/Main.android.kt diff --git a/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/koinAndroid.kt b/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/KoinAndroid.kt similarity index 94% rename from shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/koinAndroid.kt rename to shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/KoinAndroid.kt index 06bdc166..93761c51 100644 --- a/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/koinAndroid.kt +++ b/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/KoinAndroid.kt @@ -33,9 +33,9 @@ internal actual val platformModule: Module = module { .setKeyScheme(MasterKey.KeyScheme.AES256_GCM) .build(), EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, - EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM + EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM, ), - commit = false + commit = false, ) } single { @@ -53,18 +53,18 @@ fun KoinApplication.androidContext(androidContext: Context): KoinApplication { listOf( module { single { androidContext } binds arrayOf(Context::class, Application::class) - } - ) + }, + ), ) } else { koin.loadModules( listOf( module { single { androidContext } - } - ) + }, + ), ) } return this -} \ No newline at end of file +} diff --git a/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/Previews.kt b/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/Previews.kt index 893dd174..86aee48e 100644 --- a/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/Previews.kt +++ b/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/Previews.kt @@ -19,7 +19,6 @@ fun TitleViewPreview() { TitleView("Foto") } - @Preview @Composable fun ErrorViewPreview() { @@ -52,13 +51,13 @@ fun PrimaryButtonPreview() { fun LoginScreenFormPreview() { LoginScreenForm( LoginUiState( - state = State.ERROR("No Internet") + state = State.ERROR("No Internet"), ), {}, {}, {}, {}, {}, - {} + {}, ) -} \ No newline at end of file +} diff --git a/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt b/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt index 9731513a..b496efac 100644 --- a/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt +++ b/shared/src/androidMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt @@ -9,4 +9,4 @@ actual abstract class ViewModel actual constructor() : ViewModel() { actual override fun onCleared() { super.onCleared() } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/App.kt b/shared/src/commonMain/kotlin/App.kt index 21827933..c07b2bdd 100644 --- a/shared/src/commonMain/kotlin/App.kt +++ b/shared/src/commonMain/kotlin/App.kt @@ -9,19 +9,18 @@ import com.kevinschildhorn.fotopresenter.ui.viewmodel.LoginViewModel @Composable fun App(viewModel: LoginViewModel) { - val currentScreen = remember { mutableStateOf(Screen.LOGIN) } MaterialTheme { when (currentScreen.value) { - Screen.LOGIN -> LoginScreen(viewModel) { - currentScreen.value = Screen.DIRECTORY - } + Screen.LOGIN -> + LoginScreen(viewModel) { + currentScreen.value = Screen.DIRECTORY + } Screen.DIRECTORY -> DirectoryScreen() } - } } -expect fun getPlatformName(): String \ No newline at end of file +expect fun getPlatformName(): String diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/koin.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/Koin.kt similarity index 50% rename from shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/koin.kt rename to shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/Koin.kt index 445d8d0e..e1a0d746 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/koin.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/Koin.kt @@ -11,21 +11,22 @@ import com.kevinschildhorn.fotopresenter.ui.viewmodel.LoginViewModel import org.koin.core.module.Module import org.koin.dsl.module -val commonModule = module { - val baseLogger = Logger(LoggerConfig.default) +val commonModule = + module { + val baseLogger = Logger(LoggerConfig.default) - // Data - single { CredentialsDataSource(get()) } - single { CredentialsRepository(get()) } + // Data + single { CredentialsDataSource(get()) } + single { CredentialsRepository(get()) } - // Domain - factory { ConnectToServerUseCase(get()) } - factory { AutoConnectUseCase(get(), get()) } - factory { SaveCredentialsUseCase(get(), baseLogger.withTag("SaveCredentialsUseCase")) } - //factory { AutoConnectUseCase(get()) } + // Domain + factory { ConnectToServerUseCase(get()) } + factory { AutoConnectUseCase(get(), get()) } + factory { SaveCredentialsUseCase(get(), baseLogger.withTag("SaveCredentialsUseCase")) } + // factory { AutoConnectUseCase(get()) } - // UI - single { LoginViewModel(baseLogger.withTag("LoginViewModel"), get()) } -} + // UI + single { LoginViewModel(baseLogger.withTag("LoginViewModel"), get()) } + } -internal expect val platformModule: Module \ No newline at end of file +internal expect val platformModule: Module diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/LoginCredentials.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/LoginCredentials.kt index 957e75f4..1a9d4444 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/LoginCredentials.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/LoginCredentials.kt @@ -11,8 +11,9 @@ data class LoginCredentials( val shouldAutoConnect: Boolean = false, ) { val isComplete: Boolean - get() = hostname.isNotBlank() && + get() = + hostname.isNotBlank() && username.isNotBlank() && password.isNotBlank() && sharedFolder.isNotBlank() -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/CredentialsDataSource.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/CredentialsDataSource.kt index 395b1306..82e5f8f7 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/CredentialsDataSource.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/CredentialsDataSource.kt @@ -7,7 +7,6 @@ import com.russhwolf.settings.set Stores Sign in Credentials from Shared Preferences **/ class CredentialsDataSource(private val settings: Settings) { - var hostname: String get() = settings.getString(KEY_HOSTNAME, "") set(value) { @@ -47,4 +46,4 @@ class CredentialsDataSource(private val settings: Settings) { private const val KEY_PASSWORD = "password" private const val KEY_AUTOCONNECT = "autoConnect" } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/DirectoryDataSource.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/DirectoryDataSource.kt index 37988936..19f63a76 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/DirectoryDataSource.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/DirectoryDataSource.kt @@ -3,6 +3,4 @@ package com.kevinschildhorn.fotopresenter.data.datasources /** Fetches Directory info from a NAS **/ -class DirectoryDataSource { - -} \ No newline at end of file +class DirectoryDataSource diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/network/NetworkHandler.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/network/NetworkHandler.kt index b39a33f7..5a983950 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/network/NetworkHandler.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/network/NetworkHandler.kt @@ -6,6 +6,8 @@ import com.kevinschildhorn.fotopresenter.data.LoginCredentials interface NetworkHandler { @Throws(Exception::class) suspend fun connect(credentials: LoginCredentials): Boolean + fun openDirectory(directoryName: String) + fun openImage(imageName: String): ImageBitmap? -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/repositories/CredentialsRepository.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/repositories/CredentialsRepository.kt index 3ce59f40..83e9c95c 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/repositories/CredentialsRepository.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/repositories/CredentialsRepository.kt @@ -9,7 +9,6 @@ Fetches [LoginCredentials] from [CredentialsDataSource] to be used to sign into class CredentialsRepository( private val dataSource: CredentialsDataSource, ) { - fun fetchCredentials(): LoginCredentials = LoginCredentials( hostname = dataSource.hostname, @@ -24,7 +23,7 @@ class CredentialsRepository( username: String, password: String, sharedFolder: String, - shouldAutoConnect: Boolean + shouldAutoConnect: Boolean, ) { dataSource.hostname = hostname dataSource.username = username @@ -32,4 +31,4 @@ class CredentialsRepository( dataSource.sharedFolder = sharedFolder dataSource.shouldAutoConnect = shouldAutoConnect } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCase.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCase.kt index 95da6136..8e6c6441 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCase.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCase.kt @@ -10,7 +10,6 @@ class AutoConnectUseCase( private val client: NetworkHandler, private val repository: CredentialsRepository, ) { - suspend operator fun invoke(): Boolean = try { val credentials = repository.fetchCredentials() @@ -18,4 +17,4 @@ class AutoConnectUseCase( } catch (e: Exception) { false } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/ConnectToServerUseCase.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/ConnectToServerUseCase.kt index 9a6d76f8..2c364684 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/ConnectToServerUseCase.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/ConnectToServerUseCase.kt @@ -7,13 +7,12 @@ import com.kevinschildhorn.fotopresenter.data.network.NetworkHandler Connect to Server using FTPS **/ class ConnectToServerUseCase( - private val client: NetworkHandler + private val client: NetworkHandler, ) { - suspend operator fun invoke(credentials: LoginCredentials): Boolean = try { client.connect(credentials) } catch (e: Exception) { false } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/SaveCredentialsUseCase.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/SaveCredentialsUseCase.kt index 5f352925..4c37bf19 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/SaveCredentialsUseCase.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/domain/SaveCredentialsUseCase.kt @@ -11,10 +11,7 @@ class SaveCredentialsUseCase( private val repository: CredentialsRepository, private val logger: Logger, ) { - - operator fun invoke( - loginCredentials: LoginCredentials, - ): Boolean { + operator fun invoke(loginCredentials: LoginCredentials): Boolean { with(loginCredentials) { logger.i { "Saving Credentials" } repository.saveCredentials( @@ -27,4 +24,4 @@ class SaveCredentialsUseCase( } return true } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/+MutableStateFlow.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/MutableStateFlowExtensions.kt similarity index 70% rename from shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/+MutableStateFlow.kt rename to shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/MutableStateFlowExtensions.kt index 4c928712..daa86841 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/+MutableStateFlow.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/MutableStateFlowExtensions.kt @@ -2,6 +2,6 @@ package com.kevinschildhorn.fotopresenter.extension import kotlinx.coroutines.flow.MutableStateFlow -fun MutableStateFlow.update(block:(T) -> T){ +fun MutableStateFlow.update(block: (T) -> T) { this.value = block(this.value) -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/+String.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/StringExtensions.kt similarity index 87% rename from shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/+String.kt rename to shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/StringExtensions.kt index d6d0f773..aa205e80 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/+String.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/extension/StringExtensions.kt @@ -1,3 +1,3 @@ package com.kevinschildhorn.fotopresenter.extension -fun String.required(required: Boolean = true) = if (required) "$this*" else this \ No newline at end of file +fun String.required(required: Boolean = true) = if (required) "$this*" else this diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/FotoColors.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/FotoColors.kt index d09ffcf5..e5e25009 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/FotoColors.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/FotoColors.kt @@ -14,4 +14,4 @@ object FotoColors { val surfaceText = AtomikColor(0xFFA500) val errorText = AtomikColor(0x9E1F1F) val disabled = AtomikColor(0xE0E0E0) -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/FotoTypography.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/FotoTypography.kt index 38a5cbd1..f1a010f8 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/FotoTypography.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/FotoTypography.kt @@ -25,4 +25,4 @@ object FotoTypography { AtomikTypography(size = 16, weight = AtomikTypographyWeight.NORMAL, font = fontregularMoko) val caption = AtomikTypography(size = 14, weight = AtomikTypographyWeight.BOLD, font = fontBoldMoko) -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/LoginScreenAtoms.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/LoginScreenAtoms.kt index 49533d2d..b3b28f06 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/LoginScreenAtoms.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/LoginScreenAtoms.kt @@ -1,21 +1,14 @@ package com.kevinschildhorn.fotopresenter.ui.atoms -import androidx.compose.material.RadioButton -import com.kevinschildhorn.atomik.atomic.atoms.FigmaTextAtom import com.kevinschildhorn.atomik.atomic.atoms.TextViewAtom -import com.kevinschildhorn.atomik.atomic.atoms.interfaces.ConstrainedAtom import com.kevinschildhorn.atomik.atomic.atoms.interfaces.SimpleColorAtom import com.kevinschildhorn.atomik.atomic.atoms.interfaces.SimpleTextAtom -import com.kevinschildhorn.atomik.atomic.atoms.interfaces.TextAtom import com.kevinschildhorn.atomik.atomic.molecules.OutlinedTextFieldMolecule import com.kevinschildhorn.atomik.atomic.molecules.TextButtonMolecule import com.kevinschildhorn.atomik.color.base.AtomikColor -import com.kevinschildhorn.atomik.color.base.AtomikColorType -import com.kevinschildhorn.atomik.typography.base.AtomikFontFamily import com.kevinschildhorn.atomik.typography.base.AtomikTypography object LoginScreenAtoms { - fun title( textColor: AtomikColor = FotoColors.backgroundText, typography: AtomikTypography = FotoTypography.h1, @@ -25,38 +18,42 @@ object LoginScreenAtoms { fontFamily = null, ) - val errorView = TextViewAtom( - textColor = FotoColors.errorText, - typography = FotoTypography.body, - backgroundColor = FotoColors.error, - paddingHorizontal = Padding.MEDIUM.rawValue, - paddingVertical = Padding.MEDIUM.rawValue - ) + val errorView = + TextViewAtom( + textColor = FotoColors.errorText, + typography = FotoTypography.body, + backgroundColor = FotoColors.error, + paddingHorizontal = Padding.MEDIUM.rawValue, + paddingVertical = Padding.MEDIUM.rawValue, + ) - val primaryButton = TextButtonMolecule( - color = FotoColors.primary, - disabledColor = FotoColors.disabled, - radius = 15, - textAtom = SimpleTextAtom( - textColor = FotoColors.primaryText, - typography = FotoTypography.button, - fontFamily = null, + val primaryButton = + TextButtonMolecule( + color = FotoColors.primary, + disabledColor = FotoColors.disabled, + radius = 15, + textAtom = + SimpleTextAtom( + textColor = FotoColors.primaryText, + typography = FotoTypography.button, + fontFamily = null, + ), + ) + val textFieldMolecule = + OutlinedTextFieldMolecule( + textAtom = textAtom(FotoColors.primaryText), + backgroundColorAtom = SimpleColorAtom(FotoColors.surface), + hintTextAtom = textAtom(FotoColors.surfaceText), + errorTextAtom = textAtom(FotoColors.errorText), + disabledColorAtom = SimpleColorAtom(FotoColors.surface), + focusedBorderColor = FotoColors.backgroundText, + radius = 5, ) - ) - val textFieldMolecule = OutlinedTextFieldMolecule( - textAtom = textAtom(FotoColors.primaryText), - backgroundColorAtom = SimpleColorAtom(FotoColors.surface), - hintTextAtom = textAtom(FotoColors.surfaceText), - errorTextAtom = textAtom(FotoColors.errorText), - disabledColorAtom = SimpleColorAtom(FotoColors.surface), - focusedBorderColor = FotoColors.backgroundText, - radius = 5, - ) private fun textAtom(color: AtomikColor) = SimpleTextAtom( textColor = color, typography = FotoTypography.subtitle, - fontFamily = null + fontFamily = null, ) -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/Padding.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/Padding.kt index f34b643d..8705f8a6 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/Padding.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/Padding.kt @@ -8,8 +8,9 @@ enum class Padding(val rawValue: Int) { STANDARD(20), MEDIUM(12), SMALL(8), - NONE(0); + NONE(0), + ; val dp: Dp get() = this.rawValue.dp -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/DirectoryScreen.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/DirectoryScreen.kt index 1f088a5d..6ed1c568 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/DirectoryScreen.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/DirectoryScreen.kt @@ -10,9 +10,8 @@ fun DirectoryScreen() { Column { Text("You are Connected") OutlinedButton({ - - }){ + }) { Text("Logout") } } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt index d1c532ea..78896a9a 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt @@ -23,21 +23,21 @@ fun LoginScreen( viewModel: LoginViewModel, onLoginSuccess: () -> Unit, ) { - val uiState by viewModel.uiState.collectAsState() val uriHandler = LocalUriHandler.current - if(uiState.state == State.SUCCESS){ + if (uiState.state == State.SUCCESS) { onLoginSuccess() } Column { TitleView( "Foto", - modifier = Modifier.padding( + modifier = + Modifier.padding( top = Padding.SMALL.dp, start = Padding.STANDARD.dp, bottom = Padding.LARGE.dp, - ) + ), ) LoginScreenForm( uiState = uiState, @@ -46,16 +46,16 @@ fun LoginScreen( onPasswordChange = { viewModel.updatePassword(it) }, onSharedFolderChange = { viewModel.updateSharedFolder(it) }, onShouldAutoConnectChange = { viewModel.updateShouldAutoConnect(it) }, - loginButtonClicked = { viewModel.login() } + loginButtonClicked = { viewModel.login() }, ) ClickableText( buildAnnotatedString { append("Setting up a QNAP NAS") }, style = TextStyle(textAlign = TextAlign.Center), - modifier = Modifier.padding(top = Padding.STANDARD.dp).fillMaxWidth() + modifier = Modifier.padding(top = Padding.STANDARD.dp).fillMaxWidth(), ) { uriHandler.openUri("https://www.qnap.com/en/how-to/faq/article/how-to-map-network-drive-in-windows-os-by-qfinder") } } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/NavigationState.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/NavigationState.kt index 496dd04b..726f329e 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/NavigationState.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/NavigationState.kt @@ -1,10 +1,10 @@ package com.kevinschildhorn.fotopresenter.ui.compose class NavigationState { - val screen:Screen = Screen.LOGIN + val screen: Screen = Screen.LOGIN } enum class Screen { LOGIN, DIRECTORY, -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt index 7dfd4c70..9bbbf39f 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt @@ -14,7 +14,7 @@ import com.kevinschildhorn.fotopresenter.ui.atoms.LoginScreenAtoms.errorView @Composable fun ErrorView( message: String, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { val atom = errorView @@ -23,10 +23,11 @@ fun ErrorView( configuredModifier = configuredModifier.background(color = it.composeColor) } Box( - modifier = configuredModifier.padding( + modifier = + configuredModifier.padding( horizontal = atom.paddingHorizontal?.dp ?: 0.dp, - vertical = atom.paddingVertical?.dp ?: 0.dp - ) + vertical = atom.paddingVertical?.dp ?: 0.dp, + ), ) { Text( text = message, @@ -34,5 +35,4 @@ fun ErrorView( style = atom.textStyle, ) } - -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/FormColumn.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/FormColumn.kt index c4ac838f..62720192 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/FormColumn.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/FormColumn.kt @@ -14,9 +14,9 @@ import com.kevinschildhorn.fotopresenter.ui.atoms.Padding inline fun FormColumn( modifier: Modifier = Modifier, verticalPadding: Padding = Padding.STANDARD, - content: @Composable ColumnScope.() -> Unit + content: @Composable ColumnScope.() -> Unit, ) { - val halfPadding:Int = verticalPadding.rawValue / 2 + val halfPadding: Int = verticalPadding.rawValue / 2 Column( modifier .fillMaxWidth() @@ -24,4 +24,4 @@ inline fun FormColumn( verticalArrangement = Arrangement.spacedBy(verticalPadding.dp), content = content, ) -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt index cf17b36e..6adff0cd 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt @@ -1,31 +1,16 @@ package com.kevinschildhorn.fotopresenter.ui.compose.common -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.Button import androidx.compose.material.ButtonDefaults import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.MaterialTheme import androidx.compose.material.Text -import androidx.compose.material.TextButton import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.kevinschildhorn.atomik.atomic.atoms.textStyle import com.kevinschildhorn.atomik.color.base.composeColor -import com.kevinschildhorn.fotopresenter.ui.atoms.FotoColors -import com.kevinschildhorn.fotopresenter.ui.atoms.FotoTypography import com.kevinschildhorn.fotopresenter.ui.atoms.LoginScreenAtoms.primaryButton @Composable @@ -40,32 +25,35 @@ fun PrimaryButton( onClick = onClick, modifier = modifier.height(44.dp), enabled = buttonState.enabled, - colors = ButtonDefaults.buttonColors( + colors = + ButtonDefaults.buttonColors( backgroundColor = molecule.color.composeColor, disabledBackgroundColor = molecule.disabledColor.composeColor, ), ) { - if (buttonState.loading) + if (buttonState.loading) { CircularProgressIndicator( modifier = Modifier.width(30.dp), color = molecule.textAtom.textColor.composeColor, ) - else + } else { Text( title, style = molecule.textAtom.textStyle, ) + } } } enum class ButtonState { ENABLED, DISABLED, - LOADING; + LOADING, + ; val enabled: Boolean get() = this != DISABLED val loading: Boolean get() = this == LOADING -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/TitleView.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/TitleView.kt index 579cf80f..5da6a69a 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/TitleView.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/TitleView.kt @@ -3,7 +3,6 @@ package com.kevinschildhorn.fotopresenter.ui.compose.common import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import com.kevinschildhorn.atomik.atomic.atoms.interfaces.TextAtom import com.kevinschildhorn.atomik.atomic.atoms.textStyle import com.kevinschildhorn.atomik.color.base.composeColor import com.kevinschildhorn.fotopresenter.ui.atoms.FotoTypography @@ -22,5 +21,4 @@ fun TitleView( style = atom.textStyle, modifier = modifier, ) - -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/FotoCheckbox.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/FotoCheckbox.kt index ce9c80d8..a3c32004 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/FotoCheckbox.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/FotoCheckbox.kt @@ -3,13 +3,11 @@ package com.kevinschildhorn.fotopresenter.ui.compose.login import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding import androidx.compose.material.Checkbox import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp @Composable fun FotoCheckbox( @@ -22,12 +20,12 @@ fun FotoCheckbox( Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.End, - modifier = modifier.fillMaxWidth() + modifier = modifier.fillMaxWidth(), ) { Text(title) Checkbox( checked = checked, - onCheckedChange = { onCheckedChange } + onCheckedChange = { onCheckedChange }, ) } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/FotoTextField.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/FotoTextField.kt index 2116c6f3..3b1ccdee 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/FotoTextField.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/FotoTextField.kt @@ -1,13 +1,10 @@ package com.kevinschildhorn.fotopresenter.ui.compose.login -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.padding import androidx.compose.material.OutlinedTextField import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.text.input.PasswordVisualTransformation -import androidx.compose.ui.unit.dp import com.kevinschildhorn.atomik.atomic.atoms.shape import com.kevinschildhorn.atomik.atomic.atoms.textStyle import com.kevinschildhorn.atomik.atomic.molecules.colors @@ -27,7 +24,7 @@ fun FotoTextField( placeholder = { Text( placeholder, - style = molecule.hintTextAtom?.textStyle ?: molecule.textAtom.textStyle + style = molecule.hintTextAtom?.textStyle ?: molecule.textAtom.textStyle, ) }, colors = molecule.colors(), @@ -53,7 +50,7 @@ fun FotoPasswordTextField( placeholder = { Text( placeholder, - style = molecule.hintTextAtom?.textStyle ?: molecule.textAtom.textStyle + style = molecule.hintTextAtom?.textStyle ?: molecule.textAtom.textStyle, ) }, colors = molecule.colors(), @@ -61,4 +58,4 @@ fun FotoPasswordTextField( textStyle = molecule.textAtom.textStyle, modifier = modifier, ) -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/LoginScreenForm.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/LoginScreenForm.kt index 69ccf2ea..ec982658 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/LoginScreenForm.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/login/LoginScreenForm.kt @@ -1,11 +1,8 @@ package com.kevinschildhorn.fotopresenter.ui.compose.login -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp @@ -28,11 +25,11 @@ fun LoginScreenForm( loginButtonClicked: () -> Unit, ) { Column(modifier = Modifier.padding(horizontal = 20.dp)) { - (uiState.state as? State.ERROR)?.let { ErrorView( "Error Occurred! ${it.message}", - modifier = Modifier.fillMaxWidth()) + modifier = Modifier.fillMaxWidth(), + ) } FormColumn( @@ -80,4 +77,4 @@ fun LoginScreenForm( ) } } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/state/LoginUiState.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/state/LoginUiState.kt index 03304fed..b1804520 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/state/LoginUiState.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/state/LoginUiState.kt @@ -9,27 +9,29 @@ data class LoginUiState( val password: String = "", val sharedFolder: String = "", val shouldAutoConnect: Boolean = false, - override val state: State = State.IDLE + override val state: State = State.IDLE, ) : UiState { - val isLoginButtonEnabled: Boolean - get() = hostname.isNotEmpty() && + get() = + hostname.isNotEmpty() && sharedFolder.isNotEmpty() && username.isNotEmpty() && password.isNotEmpty() val loginbuttonState: ButtonState - get() = when { - state == State.LOADING -> ButtonState.LOADING - isLoginButtonEnabled -> ButtonState.ENABLED - else -> ButtonState.DISABLED - } + get() = + when { + state == State.LOADING -> ButtonState.LOADING + isLoginButtonEnabled -> ButtonState.ENABLED + else -> ButtonState.DISABLED + } val asLoginCredentials: LoginCredentials - get() = LoginCredentials( - hostname = hostname, - username = username, - password = password, - sharedFolder = sharedFolder - ) + get() = + LoginCredentials( + hostname = hostname, + username = username, + password = password, + sharedFolder = sharedFolder, + ) } diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/state/UiState.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/state/UiState.kt index 16834d4f..e96a3b94 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/state/UiState.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/state/UiState.kt @@ -6,7 +6,10 @@ interface UiState { sealed class State { data object IDLE : State() + data object LOADING : State() + data class ERROR(val message: String) : State() + data object SUCCESS : State() -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/LoginViewModel.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/LoginViewModel.kt index 326c93fb..5a24e512 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/LoginViewModel.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/LoginViewModel.kt @@ -16,12 +16,10 @@ import kotlinx.coroutines.launch import org.koin.core.component.KoinComponent import org.koin.core.component.inject - class LoginViewModel( private val logger: Logger, private val credentialsRepository: CredentialsRepository, ) : ViewModel(), KoinComponent { - private val _uiState = MutableStateFlow(LoginUiState()) val uiState: StateFlow = _uiState.asStateFlow() @@ -36,7 +34,7 @@ class LoginViewModel( shouldAutoConnect = credentials.shouldAutoConnect, ) } - if(credentials.isComplete && credentials.shouldAutoConnect) { + if (credentials.isComplete && credentials.shouldAutoConnect) { attemptAutoLogin() } } @@ -68,9 +66,10 @@ class LoginViewModel( val connectToServer: ConnectToServerUseCase by inject() viewModelScope.launch(Dispatchers.Default) { - val result = connectToServer( - _uiState.value.asLoginCredentials - ) + val result = + connectToServer( + _uiState.value.asLoginCredentials, + ) if (!result) { _uiState.update { it.copy(state = State.ERROR("")) } @@ -92,4 +91,4 @@ class LoginViewModel( } } } -} \ No newline at end of file +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt index 13cf8673..b7c4eec5 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt @@ -4,5 +4,6 @@ import kotlinx.coroutines.CoroutineScope expect abstract class ViewModel() { val viewModelScope: CoroutineScope + protected open fun onCleared() -} \ No newline at end of file +} diff --git a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/KoinTest.kt b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/KoinTest.kt index d20fc6db..3fd5cb87 100644 --- a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/KoinTest.kt +++ b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/KoinTest.kt @@ -3,7 +3,6 @@ package com.kevinschildhorn.fotopresenter import co.touchlab.kermit.Logger import co.touchlab.kermit.LoggerConfig import com.kevinschildhorn.fotopresenter.data.datasources.CredentialsDataSource -import com.kevinschildhorn.fotopresenter.data.datasources.CredentialsDataSourceTest import com.kevinschildhorn.fotopresenter.data.network.MockNetworkHandler import com.kevinschildhorn.fotopresenter.data.network.NetworkHandler import com.kevinschildhorn.fotopresenter.data.repositories.CredentialsRepository @@ -11,14 +10,13 @@ import com.kevinschildhorn.fotopresenter.domain.AutoConnectUseCase import com.kevinschildhorn.fotopresenter.domain.ConnectToServerUseCase import com.kevinschildhorn.fotopresenter.domain.SaveCredentialsUseCase import com.kevinschildhorn.fotopresenter.ui.viewmodel.LoginViewModel -import com.kevinschildhorn.fotopresenter.ui.viewmodel.LoginViewModelTest import com.russhwolf.settings.MapSettings import com.russhwolf.settings.Settings import org.koin.dsl.module private val baseLogger = Logger(LoggerConfig.default) -fun testingModule(settings:MapSettings = MapSettings()) = +fun testingModule(settings: MapSettings = MapSettings()) = module { single { MockNetworkHandler() } single { settings } @@ -28,4 +26,4 @@ fun testingModule(settings:MapSettings = MapSettings()) = single { SaveCredentialsUseCase(get(), baseLogger) } single { LoginViewModel(baseLogger, get()) } factory { AutoConnectUseCase(get(), get()) } - } \ No newline at end of file + } diff --git a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/CredentialsDataSourceTest.kt b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/CredentialsDataSourceTest.kt index f7bf31d2..b732b124 100644 --- a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/CredentialsDataSourceTest.kt +++ b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/datasources/CredentialsDataSourceTest.kt @@ -9,20 +9,19 @@ import kotlin.test.assertEquals Testing [CredentialsDataSource] **/ class CredentialsDataSourceTest { - - private val settings = MapSettings( - KEY_HOSTNAME to "google.com", - KEY_SHAREDFOLDER to "Public", - KEY_USERNAME to "John", - KEY_PASSWORD to "secret", - KEY_AUTOCONNECT to true, - ) + private val settings = + MapSettings( + KEY_HOSTNAME to "google.com", + KEY_SHAREDFOLDER to "Public", + KEY_USERNAME to "John", + KEY_PASSWORD to "secret", + KEY_AUTOCONNECT to true, + ) private val dataSource = CredentialsDataSource(settings) @Test fun `update Credentials`() { - assertEquals("google.com", dataSource.hostname) assertEquals("John", dataSource.username) assertEquals("secret", dataSource.password) @@ -59,4 +58,4 @@ class CredentialsDataSourceTest { private const val KEY_PASSWORD = "password" private const val KEY_AUTOCONNECT = "autoConnect" } -} \ No newline at end of file +} diff --git a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/network/MockNetworkHandler.kt b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/network/MockNetworkHandler.kt index 0b58d61e..1402e144 100644 --- a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/network/MockNetworkHandler.kt +++ b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/network/MockNetworkHandler.kt @@ -4,33 +4,34 @@ import androidx.compose.ui.graphics.ImageBitmap import com.kevinschildhorn.fotopresenter.data.LoginCredentials class MockNetworkHandler : NetworkHandler { - private val successLoginCredentials = LoginCredentials( - "192.168.1.1", - "admin", - "password", - "Public", - shouldAutoConnect = false, - ) + private val successLoginCredentials = + LoginCredentials( + "192.168.1.1", + "admin", + "password", + "Public", + shouldAutoConnect = false, + ) - private val successDirectory:String = "photos" - private val successImageName:String = "image.jpg" + private val successDirectory: String = "photos" + private val successImageName: String = "image.jpg" @Throws(Exception::class) override suspend fun connect(credentials: LoginCredentials): Boolean { - if(credentials.hostname == "throw") throw Exception() + if (credentials.hostname == "throw") throw Exception() return credentials == successLoginCredentials } override fun openDirectory(directoryName: String) { - if(directoryName == successDirectory){ + if (directoryName == successDirectory) { print("") } } override fun openImage(imageName: String): ImageBitmap? { - if(imageName == successImageName){ + if (imageName == successImageName) { print("") } return null } -} \ No newline at end of file +} diff --git a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/repositories/CredentialsRepositoryTest.kt b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/repositories/CredentialsRepositoryTest.kt index 0bf5e686..92a2f525 100644 --- a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/repositories/CredentialsRepositoryTest.kt +++ b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/data/repositories/CredentialsRepositoryTest.kt @@ -1,12 +1,8 @@ package com.kevinschildhorn.fotopresenter.data.repositories -import com.kevinschildhorn.fotopresenter.data.datasources.CredentialsDataSource import com.kevinschildhorn.fotopresenter.testingModule -import com.russhwolf.settings.MapSettings -import com.russhwolf.settings.Settings import org.koin.core.context.startKoin import org.koin.core.context.stopKoin -import org.koin.dsl.module import org.koin.test.KoinTest import org.koin.test.get import org.koin.test.inject @@ -19,7 +15,6 @@ import kotlin.test.assertEquals Testing [CredentialsRepository] **/ class CredentialsRepositoryTest : KoinTest { - private val repository: CredentialsRepository by inject() @BeforeTest @@ -47,7 +42,7 @@ class CredentialsRepositoryTest : KoinTest { username = username, password = password, sharedFolder = sharedFolder, - shouldAutoConnect = shouldAutoConnect + shouldAutoConnect = shouldAutoConnect, ) val credentials = repository.fetchCredentials() assertEquals(hostname, credentials.hostname) @@ -56,4 +51,4 @@ class CredentialsRepositoryTest : KoinTest { assertEquals(password, credentials.password) assertEquals(shouldAutoConnect, credentials.shouldAutoConnect) } -} \ No newline at end of file +} diff --git a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCaseTest.kt b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCaseTest.kt index cdb86ca4..a4640bb6 100644 --- a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCaseTest.kt +++ b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCaseTest.kt @@ -16,7 +16,6 @@ import kotlin.test.assertTrue Testing [AutoConnectUseCase] **/ class AutoConnectUseCaseTest : KoinTest { - private val useCase: AutoConnectUseCase by inject() @AfterTest @@ -25,60 +24,79 @@ class AutoConnectUseCaseTest : KoinTest { } @Test - fun `connect to server success`() = runBlocking { - startKoin { - modules(testingModule(settings = MapSettings( - KEY_HOSTNAME to "192.168.1.1", - KEY_USERNAME to "admin", - KEY_PASSWORD to "password", - KEY_SHAREDFOLDER to "Public", - KEY_AUTOCONNECT to false, - ))) - } + fun `connect to server success`() = + runBlocking { + startKoin { + modules( + testingModule( + settings = + MapSettings( + KEY_HOSTNAME to "192.168.1.1", + KEY_USERNAME to "admin", + KEY_PASSWORD to "password", + KEY_SHAREDFOLDER to "Public", + KEY_AUTOCONNECT to false, + ), + ), + ) + } - val result = useCase() - assertTrue(result, "Failed to Connect to Server") - } + val result = useCase() + assertTrue(result, "Failed to Connect to Server") + } @Test - fun `connect to server failure`() = runBlocking { - startKoin { - modules(testingModule(settings = MapSettings( - KEY_HOSTNAME to "google.com", - KEY_USERNAME to "admin", - KEY_PASSWORD to "password", - KEY_SHAREDFOLDER to "Public", - KEY_AUTOCONNECT to false, - ))) + fun `connect to server failure`() = + runBlocking { + startKoin { + modules( + testingModule( + settings = + MapSettings( + KEY_HOSTNAME to "google.com", + KEY_USERNAME to "admin", + KEY_PASSWORD to "password", + KEY_SHAREDFOLDER to "Public", + KEY_AUTOCONNECT to false, + ), + ), + ) + } + val result = useCase() + assertFalse(result, "Should not have Connected to Server") } - val result = useCase() - assertFalse(result, "Should not have Connected to Server") - } @Test - fun `connect to server empty failure`() = runBlocking { - startKoin { - modules(testingModule()) + fun `connect to server empty failure`() = + runBlocking { + startKoin { + modules(testingModule()) + } + val result = useCase() + assertFalse(result, "Should not have Connected to Server") } - val result = useCase() - assertFalse(result, "Should not have Connected to Server") - } @Test - fun `connect to server throw`() = runBlocking { - startKoin { - modules(testingModule(settings = MapSettings( - KEY_HOSTNAME to "throw", - KEY_USERNAME to "admin", - KEY_PASSWORD to "password", - KEY_SHAREDFOLDER to "Public", - KEY_AUTOCONNECT to false, - ))) - } + fun `connect to server throw`() = + runBlocking { + startKoin { + modules( + testingModule( + settings = + MapSettings( + KEY_HOSTNAME to "throw", + KEY_USERNAME to "admin", + KEY_PASSWORD to "password", + KEY_SHAREDFOLDER to "Public", + KEY_AUTOCONNECT to false, + ), + ), + ) + } - val result = useCase() - assertFalse(result, "Should not have Connected to Server") - } + val result = useCase() + assertFalse(result, "Should not have Connected to Server") + } companion object { private const val KEY_HOSTNAME = "hostname" @@ -87,4 +105,4 @@ class AutoConnectUseCaseTest : KoinTest { private const val KEY_PASSWORD = "password" private const val KEY_AUTOCONNECT = "autoConnect" } -} \ No newline at end of file +} diff --git a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/ConnectToServerUseCaseTest.kt b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/ConnectToServerUseCaseTest.kt index 868816d9..40b619c3 100644 --- a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/ConnectToServerUseCaseTest.kt +++ b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/ConnectToServerUseCaseTest.kt @@ -1,19 +1,10 @@ package com.kevinschildhorn.fotopresenter.domain -import co.touchlab.kermit.Logger -import co.touchlab.kermit.LoggerConfig import com.kevinschildhorn.fotopresenter.data.LoginCredentials -import com.kevinschildhorn.fotopresenter.data.datasources.CredentialsDataSource -import com.kevinschildhorn.fotopresenter.data.network.MockNetworkHandler -import com.kevinschildhorn.fotopresenter.data.network.NetworkHandler -import com.kevinschildhorn.fotopresenter.data.repositories.CredentialsRepository import com.kevinschildhorn.fotopresenter.testingModule -import com.russhwolf.settings.MapSettings -import com.russhwolf.settings.Settings import kotlinx.coroutines.runBlocking import org.koin.core.context.startKoin import org.koin.core.context.stopKoin -import org.koin.dsl.module import org.koin.test.KoinTest import org.koin.test.inject import kotlin.test.AfterTest @@ -26,7 +17,6 @@ import kotlin.test.assertTrue Testing [ConnectToServerUseCase] **/ class ConnectToServerUseCaseTest : KoinTest { - private val useCase: ConnectToServerUseCase by inject() @BeforeTest @@ -42,41 +32,47 @@ class ConnectToServerUseCaseTest : KoinTest { } @Test - fun `connect to server success`() = runBlocking { - val loginCredentials = LoginCredentials( - "192.168.1.1", - "admin", - "password", - "Public", - shouldAutoConnect = false, - ) - val result = useCase(loginCredentials) - assertTrue(result, "Failed to Connect to Server") - } + fun `connect to server success`() = + runBlocking { + val loginCredentials = + LoginCredentials( + "192.168.1.1", + "admin", + "password", + "Public", + shouldAutoConnect = false, + ) + val result = useCase(loginCredentials) + assertTrue(result, "Failed to Connect to Server") + } @Test - fun `connect to server failure`() = runBlocking { - val loginCredentials = LoginCredentials( - "google.com", - "admin", - "password", - "Public", - shouldAutoConnect = false, - ) - val result = useCase(loginCredentials) - assertFalse(result, "Should not have Connected to Server") - } + fun `connect to server failure`() = + runBlocking { + val loginCredentials = + LoginCredentials( + "google.com", + "admin", + "password", + "Public", + shouldAutoConnect = false, + ) + val result = useCase(loginCredentials) + assertFalse(result, "Should not have Connected to Server") + } @Test - fun `connect to server throw`() = runBlocking { - val loginCredentials = LoginCredentials( - "throw", - "admin", - "password", - "Public", - shouldAutoConnect = false, - ) - val result = useCase(loginCredentials) - assertFalse(result, "Should not have Connected to Server") - } -} \ No newline at end of file + fun `connect to server throw`() = + runBlocking { + val loginCredentials = + LoginCredentials( + "throw", + "admin", + "password", + "Public", + shouldAutoConnect = false, + ) + val result = useCase(loginCredentials) + assertFalse(result, "Should not have Connected to Server") + } +} diff --git a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/SaveCredentialsUseCaseTest.kt b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/SaveCredentialsUseCaseTest.kt index 9c3ea9ba..2a986307 100644 --- a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/SaveCredentialsUseCaseTest.kt +++ b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/SaveCredentialsUseCaseTest.kt @@ -3,14 +3,9 @@ package com.kevinschildhorn.fotopresenter.domain import co.touchlab.kermit.Logger import co.touchlab.kermit.LoggerConfig import com.kevinschildhorn.fotopresenter.data.LoginCredentials -import com.kevinschildhorn.fotopresenter.data.datasources.CredentialsDataSource -import com.kevinschildhorn.fotopresenter.data.repositories.CredentialsRepository import com.kevinschildhorn.fotopresenter.testingModule -import com.russhwolf.settings.MapSettings -import com.russhwolf.settings.Settings import org.koin.core.context.startKoin import org.koin.core.context.stopKoin -import org.koin.dsl.module import org.koin.test.KoinTest import org.koin.test.inject import kotlin.test.AfterTest @@ -22,7 +17,6 @@ import kotlin.test.assertTrue Testing [SaveCredentialsUseCase] **/ class SaveCredentialsUseCaseTest : KoinTest { - private val useCase: SaveCredentialsUseCase by inject() @BeforeTest @@ -41,14 +35,15 @@ class SaveCredentialsUseCaseTest : KoinTest { @Test fun `save credentials success`() { - val loginCredentials = LoginCredentials( - "192.168.1.1", - "admin", - "password", - "Public", - shouldAutoConnect = false, - ) + val loginCredentials = + LoginCredentials( + "192.168.1.1", + "admin", + "password", + "Public", + shouldAutoConnect = false, + ) val result = useCase.invoke(loginCredentials) assertTrue(result, "Failed to save credentials") } -} \ No newline at end of file +} diff --git a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/LoginViewModelTest.kt b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/LoginViewModelTest.kt index 84c5b1a7..d9f43f7a 100644 --- a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/LoginViewModelTest.kt +++ b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/LoginViewModelTest.kt @@ -1,17 +1,8 @@ package com.kevinschildhorn.fotopresenter.ui.viewmodel -import co.touchlab.kermit.Logger -import co.touchlab.kermit.LoggerConfig -import com.kevinschildhorn.fotopresenter.data.datasources.CredentialsDataSource -import com.kevinschildhorn.fotopresenter.data.network.MockNetworkHandler -import com.kevinschildhorn.fotopresenter.data.network.NetworkHandler -import com.kevinschildhorn.fotopresenter.data.repositories.CredentialsRepository -import com.kevinschildhorn.fotopresenter.domain.ConnectToServerUseCase -import com.kevinschildhorn.fotopresenter.domain.SaveCredentialsUseCase import com.kevinschildhorn.fotopresenter.testingModule import com.kevinschildhorn.fotopresenter.ui.state.State import com.russhwolf.settings.MapSettings -import com.russhwolf.settings.Settings import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.cancel @@ -22,7 +13,6 @@ import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.setMain import org.koin.core.context.startKoin import org.koin.core.context.stopKoin -import org.koin.dsl.module import org.koin.test.KoinTest import org.koin.test.inject import kotlin.test.AfterTest @@ -30,19 +20,18 @@ import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse -import kotlin.test.assertNull import kotlin.test.assertTrue @OptIn(ExperimentalCoroutinesApi::class) class LoginViewModelTest : KoinTest { - private val viewModel: LoginViewModel by inject() private val testDispatcher = StandardTestDispatcher() - private val settings = MapSettings( - KEY_HOSTNAME to "defaultHostname", - KEY_USERNAME to "defaultUsername", - KEY_PASSWORD to "defaultPassword", - ) + private val settings = + MapSettings( + KEY_HOSTNAME to "defaultHostname", + KEY_USERNAME to "defaultUsername", + KEY_PASSWORD to "defaultPassword", + ) private val emptySettings = MapSettings() @BeforeTest @@ -58,147 +47,152 @@ class LoginViewModelTest : KoinTest { } @Test - fun `UI State`() = runTest { - startKoin { - modules(testingModule(settings = emptySettings)) - } - with(viewModel.uiState.value) { - assertEquals(hostname, "") - assertEquals(username, "") - assertEquals(password, "") - assertEquals(sharedFolder, "") - assertEquals(shouldAutoConnect, false) - assertEquals(state, State.IDLE) - } - - viewModel.updateHost("google.com") - viewModel.updateUsername("John") - viewModel.updatePassword("Secret") - viewModel.updateSharedFolder("Public") - viewModel.updateShouldAutoConnect(true) - - with(viewModel.uiState.value) { - assertEquals(hostname, "google.com") - assertEquals(username, "John") - assertEquals(password, "Secret") - assertEquals(sharedFolder, "Public") - assertEquals(shouldAutoConnect, true) - assertEquals(state, State.IDLE) - } - } - - @Test - fun `UI State Auto Populate`() = runTest { - startKoin { - modules(testingModule(settings = settings)) + fun `UI State`() = + runTest { + startKoin { + modules(testingModule(settings = emptySettings)) + } with(viewModel.uiState.value) { - assertEquals(hostname, "defaultHostname") - assertEquals(username, "defaultUsername") - assertEquals(password, "defaultPassword") + assertEquals(hostname, "") + assertEquals(username, "") + assertEquals(password, "") assertEquals(sharedFolder, "") assertEquals(shouldAutoConnect, false) assertEquals(state, State.IDLE) } + + viewModel.updateHost("google.com") + viewModel.updateUsername("John") + viewModel.updatePassword("Secret") + viewModel.updateSharedFolder("Public") + viewModel.updateShouldAutoConnect(true) + + with(viewModel.uiState.value) { + assertEquals(hostname, "google.com") + assertEquals(username, "John") + assertEquals(password, "Secret") + assertEquals(sharedFolder, "Public") + assertEquals(shouldAutoConnect, true) + assertEquals(state, State.IDLE) + } } - } @Test - fun `Login Button State`() = runTest { - startKoin { - modules(testingModule(settings = emptySettings)) + fun `UI State Auto Populate`() = + runTest { + startKoin { + modules(testingModule(settings = settings)) + with(viewModel.uiState.value) { + assertEquals(hostname, "defaultHostname") + assertEquals(username, "defaultUsername") + assertEquals(password, "defaultPassword") + assertEquals(sharedFolder, "") + assertEquals(shouldAutoConnect, false) + assertEquals(state, State.IDLE) + } + } } - val host = "google.com" - val username = "John" - val password = "Secret" - val sharedFolder = "Public" - - val uiState = viewModel.uiState - assertFalse(uiState.value.isLoginButtonEnabled) - - viewModel.updateHost(host) - viewModel.updateUsername(username) - viewModel.updatePassword(password) - viewModel.updateSharedFolder(sharedFolder) - viewModel.updateShouldAutoConnect(true) - assertTrue(uiState.value.isLoginButtonEnabled) - - // Host - viewModel.updateHost("") - assertFalse(uiState.value.isLoginButtonEnabled) - - // Username - viewModel.updateHost(host) - assertTrue(uiState.value.isLoginButtonEnabled) - viewModel.updateUsername("") - assertFalse(uiState.value.isLoginButtonEnabled) - - // Password - viewModel.updateUsername(username) - assertTrue(uiState.value.isLoginButtonEnabled) - viewModel.updatePassword("") - assertFalse(uiState.value.isLoginButtonEnabled) - - // Shared Folder - viewModel.updatePassword(password) - assertTrue(uiState.value.isLoginButtonEnabled) - viewModel.updateSharedFolder("") - assertFalse(uiState.value.isLoginButtonEnabled) - - // Password - viewModel.updateSharedFolder(sharedFolder) - assertTrue(uiState.value.isLoginButtonEnabled) - - viewModel.updateShouldAutoConnect(false) - assertTrue(uiState.value.isLoginButtonEnabled) - } @Test - fun `Login Failure`() = runTest { - startKoin { - modules(testingModule(settings = emptySettings)) - } - viewModel.updateHost("google.com") - viewModel.updateUsername("John") - viewModel.updatePassword("Secret") - viewModel.updateSharedFolder("Public") - viewModel.updateShouldAutoConnect(true) - viewModel.login() - - with(viewModel.uiState.value) { - assertEquals(State.LOADING, state) + fun `Login Button State`() = + runTest { + startKoin { + modules(testingModule(settings = emptySettings)) + } + val host = "google.com" + val username = "John" + val password = "Secret" + val sharedFolder = "Public" + + val uiState = viewModel.uiState + assertFalse(uiState.value.isLoginButtonEnabled) + + viewModel.updateHost(host) + viewModel.updateUsername(username) + viewModel.updatePassword(password) + viewModel.updateSharedFolder(sharedFolder) + viewModel.updateShouldAutoConnect(true) + assertTrue(uiState.value.isLoginButtonEnabled) + + // Host + viewModel.updateHost("") + assertFalse(uiState.value.isLoginButtonEnabled) + + // Username + viewModel.updateHost(host) + assertTrue(uiState.value.isLoginButtonEnabled) + viewModel.updateUsername("") + assertFalse(uiState.value.isLoginButtonEnabled) + + // Password + viewModel.updateUsername(username) + assertTrue(uiState.value.isLoginButtonEnabled) + viewModel.updatePassword("") + assertFalse(uiState.value.isLoginButtonEnabled) + + // Shared Folder + viewModel.updatePassword(password) + assertTrue(uiState.value.isLoginButtonEnabled) + viewModel.updateSharedFolder("") + assertFalse(uiState.value.isLoginButtonEnabled) + + // Password + viewModel.updateSharedFolder(sharedFolder) + assertTrue(uiState.value.isLoginButtonEnabled) + + viewModel.updateShouldAutoConnect(false) + assertTrue(uiState.value.isLoginButtonEnabled) } - delay(2000) - with(viewModel.uiState.value) { - assertTrue(state is State.ERROR) + @Test + fun `Login Failure`() = + runTest { + startKoin { + modules(testingModule(settings = emptySettings)) + } + viewModel.updateHost("google.com") + viewModel.updateUsername("John") + viewModel.updatePassword("Secret") + viewModel.updateSharedFolder("Public") + viewModel.updateShouldAutoConnect(true) + viewModel.login() + + with(viewModel.uiState.value) { + assertEquals(State.LOADING, state) + } + + delay(2000) + with(viewModel.uiState.value) { + assertTrue(state is State.ERROR) + } } - } @Test - fun `Login Success`() = runTest { - startKoin { - modules(testingModule(settings = emptySettings)) - } - viewModel.updateHost("192.168.1.1") - viewModel.updateUsername("admin") - viewModel.updatePassword("password") - viewModel.updateSharedFolder("Public") - viewModel.updateShouldAutoConnect(false) - viewModel.login() - - with(viewModel.uiState.value) { - assertEquals(State.LOADING, state) - } + fun `Login Success`() = + runTest { + startKoin { + modules(testingModule(settings = emptySettings)) + } + viewModel.updateHost("192.168.1.1") + viewModel.updateUsername("admin") + viewModel.updatePassword("password") + viewModel.updateSharedFolder("Public") + viewModel.updateShouldAutoConnect(false) + viewModel.login() - delay(2000) - with(viewModel.uiState.value) { - assertEquals(State.SUCCESS, state) + with(viewModel.uiState.value) { + assertEquals(State.LOADING, state) + } + + delay(2000) + with(viewModel.uiState.value) { + assertEquals(State.SUCCESS, state) + } } - } companion object { private const val KEY_HOSTNAME = "hostname" private const val KEY_USERNAME = "username" private const val KEY_PASSWORD = "password" } -} \ No newline at end of file +} diff --git a/shared/src/desktopMain/kotlin/Main.desktop.kt b/shared/src/desktopMain/kotlin/Main.desktop.kt new file mode 100644 index 00000000..1ac27e86 --- /dev/null +++ b/shared/src/desktopMain/kotlin/Main.desktop.kt @@ -0,0 +1,11 @@ +actual fun getPlatformName(): String = "Desktop" +/* +private val viewModel: LoginViewModel by inject() + +@Composable fun MainView() = App(viewModel) + +@Preview +@Composable +fun AppPreview() { + App(viewModel) +}*/ diff --git a/shared/src/desktopMain/kotlin/com/kevinschildhorn/fotopresenter/koinDesktop.kt b/shared/src/desktopMain/kotlin/com/kevinschildhorn/fotopresenter/KoinDesktop.kt similarity index 99% rename from shared/src/desktopMain/kotlin/com/kevinschildhorn/fotopresenter/koinDesktop.kt rename to shared/src/desktopMain/kotlin/com/kevinschildhorn/fotopresenter/KoinDesktop.kt index 3b606d9a..20ba23b1 100644 --- a/shared/src/desktopMain/kotlin/com/kevinschildhorn/fotopresenter/koinDesktop.kt +++ b/shared/src/desktopMain/kotlin/com/kevinschildhorn/fotopresenter/KoinDesktop.kt @@ -21,4 +21,4 @@ internal actual val platformModule: Module = module { single { SMBJHandler } -} \ No newline at end of file +} diff --git a/shared/src/desktopMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt b/shared/src/desktopMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt index 2df5bdb1..9c61fd13 100644 --- a/shared/src/desktopMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt +++ b/shared/src/desktopMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt @@ -9,12 +9,14 @@ import kotlinx.coroutines.MainScope */ actual abstract class ViewModel { actual val viewModelScope = MainScope() + /** * Override this to do any cleanup immediately before the internal [CoroutineScope][kotlinx.coroutines.CoroutineScope] * is cancelled in [clear] */ protected actual open fun onCleared() { } + /** * Cancels the internal [CoroutineScope][kotlinx.coroutines.CoroutineScope]. After this is called, the ViewModel should * no longer be used. @@ -23,4 +25,4 @@ actual abstract class ViewModel { onCleared() // viewModelScope.cancel() TODO } -} \ No newline at end of file +} diff --git a/shared/src/desktopMain/kotlin/main.desktop.kt b/shared/src/desktopMain/kotlin/main.desktop.kt deleted file mode 100644 index e608cf16..00000000 --- a/shared/src/desktopMain/kotlin/main.desktop.kt +++ /dev/null @@ -1,16 +0,0 @@ -import androidx.compose.desktop.ui.tooling.preview.Preview -import androidx.compose.runtime.Composable -import com.kevinschildhorn.fotopresenter.ui.viewmodel.LoginViewModel -import org.koin.java.KoinJavaComponent.inject - -actual fun getPlatformName(): String = "Desktop" -/* -private val viewModel: LoginViewModel by inject() - -@Composable fun MainView() = App(viewModel) - -@Preview -@Composable -fun AppPreview() { - App(viewModel) -}*/ \ No newline at end of file diff --git a/shared/src/iosMain/kotlin/main.ios.kt b/shared/src/iosMain/kotlin/Main.ios.kt similarity index 63% rename from shared/src/iosMain/kotlin/main.ios.kt rename to shared/src/iosMain/kotlin/Main.ios.kt index 1f0e256d..5c10a822 100644 --- a/shared/src/iosMain/kotlin/main.ios.kt +++ b/shared/src/iosMain/kotlin/Main.ios.kt @@ -2,4 +2,4 @@ import androidx.compose.ui.window.ComposeUIViewController actual fun getPlatformName(): String = "iOS" -fun MainViewController() = ComposeUIViewController { App() } \ No newline at end of file +fun MainViewController() = ComposeUIViewController { App() } diff --git a/shared/src/iosMain/kotlin/com/kevinschildhorn/fotopresenter/koiniOS.kt b/shared/src/iosMain/kotlin/com/kevinschildhorn/fotopresenter/KoiniOS.kt similarity index 98% rename from shared/src/iosMain/kotlin/com/kevinschildhorn/fotopresenter/koiniOS.kt rename to shared/src/iosMain/kotlin/com/kevinschildhorn/fotopresenter/KoiniOS.kt index ef6503a7..7e1a3762 100644 --- a/shared/src/iosMain/kotlin/com/kevinschildhorn/fotopresenter/koiniOS.kt +++ b/shared/src/iosMain/kotlin/com/kevinschildhorn/fotopresenter/KoiniOS.kt @@ -27,7 +27,7 @@ internal actual val platformModule: Module = module { defaultProperties = arrayOf( kSecAttrService to CFBridgingRetain(CredentialsDataSource.DATABASE_NAME), kSecAttrAccessible to kSecAttrAccessibleAfterFirstUnlock, - ) + ), ) } -} \ No newline at end of file +} diff --git a/shared/src/iosMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt b/shared/src/iosMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt index 2df5bdb1..9c61fd13 100644 --- a/shared/src/iosMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt +++ b/shared/src/iosMain/kotlin/com/kevinschildhorn/fotopresenter/ui/viewmodel/ViewModel.kt @@ -9,12 +9,14 @@ import kotlinx.coroutines.MainScope */ actual abstract class ViewModel { actual val viewModelScope = MainScope() + /** * Override this to do any cleanup immediately before the internal [CoroutineScope][kotlinx.coroutines.CoroutineScope] * is cancelled in [clear] */ protected actual open fun onCleared() { } + /** * Cancels the internal [CoroutineScope][kotlinx.coroutines.CoroutineScope]. After this is called, the ViewModel should * no longer be used. @@ -23,4 +25,4 @@ actual abstract class ViewModel { onCleared() // viewModelScope.cancel() TODO } -} \ No newline at end of file +} diff --git a/shared/src/jvmMain/kotlin/com/kevinschildhorn/fotopresenter/data/network/SMBJHandler.kt b/shared/src/jvmMain/kotlin/com/kevinschildhorn/fotopresenter/data/network/SMBJHandler.kt index 18b04f25..42e8e472 100644 --- a/shared/src/jvmMain/kotlin/com/kevinschildhorn/fotopresenter/data/network/SMBJHandler.kt +++ b/shared/src/jvmMain/kotlin/com/kevinschildhorn/fotopresenter/data/network/SMBJHandler.kt @@ -13,7 +13,7 @@ import com.hierynomus.smbj.session.Session import com.hierynomus.smbj.share.DiskShare import com.kevinschildhorn.fotopresenter.data.LoginCredentials -object SMBJHandler: NetworkHandler { +object SMBJHandler : NetworkHandler { private val client = SMBClient() private var connection: Connection? = null private var session: Session? = null @@ -26,7 +26,6 @@ object SMBJHandler: NetworkHandler { private val createOptions: Set = setOf(SMB2CreateOptions.FILE_NON_DIRECTORY_FILE) - override suspend fun connect(credentials: LoginCredentials): Boolean { try { with(credentials) { @@ -35,7 +34,7 @@ object SMBJHandler: NetworkHandler { AuthenticationContext( username, password.toCharArray(), - null + null, ) val session: Session? = connection?.authenticate(context) share = session?.connectShare("Public") as? DiskShare @@ -53,17 +52,27 @@ object SMBJHandler: NetworkHandler { override fun openDirectory(directoryName: String) { share?.openDirectory( - directoryName, accessMask, attributes, shareAccesses, createDisposition, createOptions + directoryName, + accessMask, + attributes, + shareAccesses, + createDisposition, + createOptions, ) } override fun openImage(imageName: String): ImageBitmap? { val file = share?.openFile( - imageName, accessMask, attributes, shareAccesses, createDisposition, createOptions + imageName, + accessMask, + attributes, + shareAccesses, + createDisposition, + createOptions, ) return null - //val bMap = BitmapFactory.decodeStream(file.inputStream) - //return bMap + // val bMap = BitmapFactory.decodeStream(file.inputStream) + // return bMap } private fun closeConnection() { @@ -74,4 +83,4 @@ object SMBJHandler: NetworkHandler { session = null connection = null } -} \ No newline at end of file +} From 25590133042838417b54a72d41b43adfe205093b Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Mon, 4 Dec 2023 09:16:12 -0500 Subject: [PATCH 02/11] more formatting and action --- .github/workflows/lint-action.yml | 9 ++-- .../atomik/atomic/atoms/TextFieldAtom.kt | 14 ------- .../molecules/OutlinedTextFieldMolecule.kt | 39 +++++++++-------- .../atomic/molecules/TextFieldMolecule.kt | 32 ++++++++------ shared/build.gradle.kts | 4 ++ .../ui/atoms/LoginScreenAtoms.kt | 10 ++--- .../fotopresenter/ui/compose/LoginScreen.kt | 10 ++--- .../ui/compose/common/ErrorView.kt | 8 ++-- .../ui/compose/common/PrimaryButton.kt | 8 ++-- .../domain/AutoConnectUseCaseTest.kt | 42 +++++++++---------- 10 files changed, 87 insertions(+), 89 deletions(-) delete mode 100644 atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/TextFieldAtom.kt diff --git a/.github/workflows/lint-action.yml b/.github/workflows/lint-action.yml index d0a15a59..4c40f303 100644 --- a/.github/workflows/lint-action.yml +++ b/.github/workflows/lint-action.yml @@ -1,11 +1,14 @@ name: Lint Action -run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +run-name: Running KtLint for linting on: [pull_request] jobs: Lint-Action: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: GitHub Action for ktlint + uses: yutailang0119/action-ktlint@v3.1.0 + + + - - name: Run KtFormat - run: ./gradlew ktFormat diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/TextFieldAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/TextFieldAtom.kt deleted file mode 100644 index 9a67addd..00000000 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/TextFieldAtom.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.kevinschildhorn.atomik.atomic.atoms - -/* -public class TextFieldAtom( - override val textColor: AtomikColor, - private val disabledTextColor: AtomikColor, - private val hintTextColor: AtomikColor, - override val borderColor: AtomikColor, - override val typography: AtomikTypography, - override val fontFamily: AtomikFontFamily?, -) : Atom(), TextAtom, BorderedAtom { - override val type: AtomType - get() = AtomType.TEXTFIELD -}*/ diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt index a4edccee..5c144c65 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt @@ -35,17 +35,16 @@ public open class OutlinedTextFieldMolecule( override val unFocusedBorderColor: AtomikColor = focusedBorderColor, override val radius: Int, ) : TextFieldMolecule( - textAtom, - backgroundColorAtom, - hintTextAtom, - errorTextAtom, - disabledColorAtom, - cursorColor, - errorColor, -), + textAtom, + backgroundColorAtom, + hintTextAtom, + errorTextAtom, + disabledColorAtom, + cursorColor, + errorColor, + ), BorderedAtom, RoundedAtom { - @Composable public fun colors(): TextFieldColors { val textColor = textAtom.textColor.composeColor @@ -57,26 +56,26 @@ public open class OutlinedTextFieldMolecule( textColor = textColor, backgroundColor = backgroundColor, placeholderColor = - hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( - ContentAlpha.medium, - ), + hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( + ContentAlpha.medium, + ), cursorColor = cursorColor?.composeColor ?: textColor, focusedBorderColor = focusedBorderColor.composeColor, unfocusedBorderColor = unFocusedBorderColor.composeColor, disabledTextColor = - disabledColorAtom?.color?.composeColor - ?: textColor.copy(ContentAlpha.disabled), + disabledColorAtom?.color?.composeColor + ?: textColor.copy(ContentAlpha.disabled), disabledBorderColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, disabledLabelColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, disabledLeadingIconColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledPlaceholderColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledTrailingIconColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, errorCursorColor = errorColor?.composeColor ?: errorTextColor, errorBorderColor = errorColor?.composeColor ?: errorTextColor, errorLabelColor = errorColor?.composeColor ?: errorTextColor, diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt index 62d5791e..45edde9e 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt @@ -43,21 +43,27 @@ public open class TextFieldMolecule( return TextFieldDefaults.textFieldColors( textColor = textColor, backgroundColor = backgroundColor, - placeholderColor = hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( - ContentAlpha.medium, - ), + placeholderColor = + hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( + ContentAlpha.medium, + ), cursorColor = cursorColor?.composeColor ?: textColor, - disabledTextColor = disabledColorAtom?.color?.composeColor - ?: textColor.copy(ContentAlpha.disabled), - disabledIndicatorColor = disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledTextColor = + disabledColorAtom?.color?.composeColor + ?: textColor.copy(ContentAlpha.disabled), + disabledIndicatorColor = + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledLabelColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, - disabledLeadingIconColor = disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, - disabledPlaceholderColor = disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, - disabledTrailingIconColor = disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledLeadingIconColor = + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, + disabledPlaceholderColor = + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, + disabledTrailingIconColor = + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, errorCursorColor = errorColor?.composeColor ?: errorTextColor, errorIndicatorColor = errorColor?.composeColor ?: errorTextColor, errorLabelColor = errorColor?.composeColor ?: errorTextColor, diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index f1c8943d..a08359e5 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -113,3 +113,7 @@ android { multiplatformResources { multiplatformResourcesPackage = "com.kevinschildhorn.fotopresenter" // required } + +dependencies { + ktlintRuleset("com.twitter.compose.rules:ktlint:0.0.26") +} diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/LoginScreenAtoms.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/LoginScreenAtoms.kt index b3b28f06..da75ce3a 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/LoginScreenAtoms.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/atoms/LoginScreenAtoms.kt @@ -33,11 +33,11 @@ object LoginScreenAtoms { disabledColor = FotoColors.disabled, radius = 15, textAtom = - SimpleTextAtom( - textColor = FotoColors.primaryText, - typography = FotoTypography.button, - fontFamily = null, - ), + SimpleTextAtom( + textColor = FotoColors.primaryText, + typography = FotoTypography.button, + fontFamily = null, + ), ) val textFieldMolecule = OutlinedTextFieldMolecule( diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt index 78896a9a..52141fb2 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt @@ -33,11 +33,11 @@ fun LoginScreen( TitleView( "Foto", modifier = - Modifier.padding( - top = Padding.SMALL.dp, - start = Padding.STANDARD.dp, - bottom = Padding.LARGE.dp, - ), + Modifier.padding( + top = Padding.SMALL.dp, + start = Padding.STANDARD.dp, + bottom = Padding.LARGE.dp, + ), ) LoginScreenForm( uiState = uiState, diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt index 9bbbf39f..65e73ae0 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt @@ -24,10 +24,10 @@ fun ErrorView( } Box( modifier = - configuredModifier.padding( - horizontal = atom.paddingHorizontal?.dp ?: 0.dp, - vertical = atom.paddingVertical?.dp ?: 0.dp, - ), + configuredModifier.padding( + horizontal = atom.paddingHorizontal?.dp ?: 0.dp, + vertical = atom.paddingVertical?.dp ?: 0.dp, + ), ) { Text( text = message, diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt index 6adff0cd..96ff0768 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt @@ -26,10 +26,10 @@ fun PrimaryButton( modifier = modifier.height(44.dp), enabled = buttonState.enabled, colors = - ButtonDefaults.buttonColors( - backgroundColor = molecule.color.composeColor, - disabledBackgroundColor = molecule.disabledColor.composeColor, - ), + ButtonDefaults.buttonColors( + backgroundColor = molecule.color.composeColor, + disabledBackgroundColor = molecule.disabledColor.composeColor, + ), ) { if (buttonState.loading) { CircularProgressIndicator( diff --git a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCaseTest.kt b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCaseTest.kt index a4640bb6..e13e7367 100644 --- a/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCaseTest.kt +++ b/shared/src/commonTest/kotlin/com/kevinschildhorn/fotopresenter/domain/AutoConnectUseCaseTest.kt @@ -30,13 +30,13 @@ class AutoConnectUseCaseTest : KoinTest { modules( testingModule( settings = - MapSettings( - KEY_HOSTNAME to "192.168.1.1", - KEY_USERNAME to "admin", - KEY_PASSWORD to "password", - KEY_SHAREDFOLDER to "Public", - KEY_AUTOCONNECT to false, - ), + MapSettings( + KEY_HOSTNAME to "192.168.1.1", + KEY_USERNAME to "admin", + KEY_PASSWORD to "password", + KEY_SHAREDFOLDER to "Public", + KEY_AUTOCONNECT to false, + ), ), ) } @@ -52,13 +52,13 @@ class AutoConnectUseCaseTest : KoinTest { modules( testingModule( settings = - MapSettings( - KEY_HOSTNAME to "google.com", - KEY_USERNAME to "admin", - KEY_PASSWORD to "password", - KEY_SHAREDFOLDER to "Public", - KEY_AUTOCONNECT to false, - ), + MapSettings( + KEY_HOSTNAME to "google.com", + KEY_USERNAME to "admin", + KEY_PASSWORD to "password", + KEY_SHAREDFOLDER to "Public", + KEY_AUTOCONNECT to false, + ), ), ) } @@ -83,13 +83,13 @@ class AutoConnectUseCaseTest : KoinTest { modules( testingModule( settings = - MapSettings( - KEY_HOSTNAME to "throw", - KEY_USERNAME to "admin", - KEY_PASSWORD to "password", - KEY_SHAREDFOLDER to "Public", - KEY_AUTOCONNECT to false, - ), + MapSettings( + KEY_HOSTNAME to "throw", + KEY_USERNAME to "admin", + KEY_PASSWORD to "password", + KEY_SHAREDFOLDER to "Public", + KEY_AUTOCONNECT to false, + ), ), ) } From 47f3c04dda0a3a1b88d2898f67f2ac533d367145 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Mon, 4 Dec 2023 09:17:30 -0500 Subject: [PATCH 03/11] Update lint-action.yml --- .github/workflows/lint-action.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-action.yml b/.github/workflows/lint-action.yml index 4c40f303..d0d3e394 100644 --- a/.github/workflows/lint-action.yml +++ b/.github/workflows/lint-action.yml @@ -6,8 +6,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: GitHub Action for ktlint - uses: yutailang0119/action-ktlint@v3.1.0 + - name: Run ktlint with reviewdog + uses: ScaCap/action-ktlint@v1.8.0 + From 16228ae419aab98c9fa6ce90ec6faa6127a1a315 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Mon, 4 Dec 2023 09:20:55 -0500 Subject: [PATCH 04/11] Update lint-action.yml --- .github/workflows/lint-action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint-action.yml b/.github/workflows/lint-action.yml index d0d3e394..a6a5225c 100644 --- a/.github/workflows/lint-action.yml +++ b/.github/workflows/lint-action.yml @@ -7,6 +7,8 @@ jobs: steps: - uses: actions/checkout@v2 - name: Run ktlint with reviewdog + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: ScaCap/action-ktlint@v1.8.0 From e97e3b35bd56a3940f13f874ece5f97040c26cb9 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Mon, 4 Dec 2023 09:23:03 -0500 Subject: [PATCH 05/11] Update lint-action.yml --- .github/workflows/lint-action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-action.yml b/.github/workflows/lint-action.yml index a6a5225c..ce78555e 100644 --- a/.github/workflows/lint-action.yml +++ b/.github/workflows/lint-action.yml @@ -4,11 +4,11 @@ on: [pull_request] jobs: Lint-Action: runs-on: ubuntu-latest + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 - name: Run ktlint with reviewdog - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} uses: ScaCap/action-ktlint@v1.8.0 From 9d6bcef77dca8d9d13367a8edca213c9ef34d9e3 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Mon, 4 Dec 2023 09:26:41 -0500 Subject: [PATCH 06/11] Update lint-action.yml --- .github/workflows/lint-action.yml | 32 ++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/.github/workflows/lint-action.yml b/.github/workflows/lint-action.yml index ce78555e..31bd1d84 100644 --- a/.github/workflows/lint-action.yml +++ b/.github/workflows/lint-action.yml @@ -1,15 +1,33 @@ name: Lint Action -run-name: Running KtLint for linting -on: [pull_request] +on: + pull_request: + paths: + - '**/*.kt' + jobs: - Lint-Action: + build: runs-on: ubuntu-latest - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: - uses: actions/checkout@v2 - - name: Run ktlint with reviewdog - uses: ScaCap/action-ktlint@v1.8.0 + + - uses: actions/setup-java@v2 + with: + distribution: "adopt" + java-version: "17" + + - uses: reviewdog/action-setup@v1 + - uses: touchlab-lab/ktlint-action-setup@1.0.0 + with: + ktlint_version: 0.50.0 + + - name: Run reviewdog + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + ktlint --reporter=checkstyle --relative \ + | reviewdog -f=checkstyle -name="ktlint" -reporter=github-pr-review -filter-mode=added -level=warning + From 3c4ecc65926fe29100e3f91a807039d32e2d2a80 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Mon, 4 Dec 2023 09:34:42 -0500 Subject: [PATCH 07/11] moreformatting --- .../atomic/atoms/xml/TextViewExtensions.kt | 1 - .../atomik/atomic/atoms/xml/ViewExtensions.kt | 1 - .../typography/AtomikTypographyExtensions.kt | 1 - .../atomik/atomic/atoms/Atom.kt | 3 +- .../atomic/atoms/compose/+AtomikColorType.kt | 1 - .../atomic/atoms/compose/+ConstrainedAtom.kt | 1 - .../atomic/atoms/compose/+EnablableAtom.kt | 1 - .../atomic/atoms/compose/+FixedSizeAtom.kt | 1 - .../atomic/atoms/compose/+RoundedAtom.kt | 1 - .../atomik/atomic/atoms/compose/+TextAtom.kt | 1 - .../molecules/OutlinedTextFieldMolecule.kt | 43 +++++++++---------- .../atomic/molecules/TextFieldMolecule.kt | 28 ++++++------ shared/src/androidMain/kotlin/Main.android.kt | 3 +- .../fotopresenter/data/LoginCredentials.kt | 6 +-- .../fotopresenter/ui/compose/LoginScreen.kt | 10 ++--- .../ui/compose/common/ErrorView.kt | 8 ++-- .../ui/compose/common/PrimaryButton.kt | 8 ++-- 17 files changed, 55 insertions(+), 63 deletions(-) diff --git a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/TextViewExtensions.kt b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/TextViewExtensions.kt index 48336f2f..b4c03cfb 100644 --- a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/TextViewExtensions.kt +++ b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/TextViewExtensions.kt @@ -1,4 +1,3 @@ - @file:Suppress("ktlint:standard:filename") package com.kevinschildhorn.atomik.atomic.atoms.xml diff --git a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/ViewExtensions.kt b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/ViewExtensions.kt index 869e2cf6..2d830197 100644 --- a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/ViewExtensions.kt +++ b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/xml/ViewExtensions.kt @@ -1,4 +1,3 @@ - @file:Suppress("ktlint:standard:filename") package com.kevinschildhorn.atomik.atomic.atoms.xml diff --git a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/typography/AtomikTypographyExtensions.kt b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/typography/AtomikTypographyExtensions.kt index f8766559..ebaad42f 100644 --- a/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/typography/AtomikTypographyExtensions.kt +++ b/atomik/src/androidMain/kotlin/com/kevinschildhorn/atomik/typography/AtomikTypographyExtensions.kt @@ -1,4 +1,3 @@ - @file:Suppress("ktlint:standard:filename") package com.kevinschildhorn.atomik.typography diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/Atom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/Atom.kt index 17b517e8..7fbaea50 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/Atom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/Atom.kt @@ -35,5 +35,6 @@ public abstract class Atom { * Finds a subComponent matching a specified [AtomInterface] if it exists * @return the subComponent of a specified interface if it's found */ - public inline fun subAtom(): T? = subComponents.find { it is T } as? T + public inline fun subAtom(): T? = + subComponents.find { it is T } as? T } diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+AtomikColorType.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+AtomikColorType.kt index 474578e1..beee947a 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+AtomikColorType.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+AtomikColorType.kt @@ -1,4 +1,3 @@ - @file:Suppress("ktlint:standard:filename") package com.kevinschildhorn.atomik.atomic.atoms.compose diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+ConstrainedAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+ConstrainedAtom.kt index 92124a96..60b794cc 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+ConstrainedAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+ConstrainedAtom.kt @@ -1,4 +1,3 @@ - @file:Suppress("ktlint:standard:filename") package com.kevinschildhorn.atomik.atomic.atoms diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+EnablableAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+EnablableAtom.kt index e0cfe9e0..3a7e1013 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+EnablableAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+EnablableAtom.kt @@ -1,4 +1,3 @@ - @file:Suppress("ktlint:standard:filename") package com.kevinschildhorn.atomik.atomic.atoms.compose diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+FixedSizeAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+FixedSizeAtom.kt index e736fff1..1fdf5825 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+FixedSizeAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+FixedSizeAtom.kt @@ -1,4 +1,3 @@ - @file:Suppress("ktlint:standard:filename") package com.kevinschildhorn.atomik.atomic.atoms diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+RoundedAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+RoundedAtom.kt index e2af884e..b7cb7ba7 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+RoundedAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+RoundedAtom.kt @@ -1,4 +1,3 @@ - @file:Suppress("ktlint:standard:filename") package com.kevinschildhorn.atomik.atomic.atoms diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+TextAtom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+TextAtom.kt index 1431ebfa..296a704d 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+TextAtom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/compose/+TextAtom.kt @@ -1,4 +1,3 @@ - @file:Suppress("ktlint:standard:filename") package com.kevinschildhorn.atomik.atomic.atoms diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt index 5c144c65..9ae70090 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt @@ -35,18 +35,17 @@ public open class OutlinedTextFieldMolecule( override val unFocusedBorderColor: AtomikColor = focusedBorderColor, override val radius: Int, ) : TextFieldMolecule( - textAtom, - backgroundColorAtom, - hintTextAtom, - errorTextAtom, - disabledColorAtom, - cursorColor, - errorColor, - ), - BorderedAtom, - RoundedAtom { + textAtom, + backgroundColorAtom, + hintTextAtom, + errorTextAtom, + disabledColorAtom, + cursorColor, + errorColor, +), BorderedAtom, RoundedAtom { + @Composable - public fun colors(): TextFieldColors { + public override fun colors(): TextFieldColors { val textColor = textAtom.textColor.composeColor val backgroundColor = backgroundColorAtom.color.composeColor val disabledBackgroundColor = backgroundColor.copy(alpha = ContentAlpha.disabled) @@ -56,26 +55,26 @@ public open class OutlinedTextFieldMolecule( textColor = textColor, backgroundColor = backgroundColor, placeholderColor = - hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( - ContentAlpha.medium, - ), + hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( + ContentAlpha.medium, + ), cursorColor = cursorColor?.composeColor ?: textColor, focusedBorderColor = focusedBorderColor.composeColor, unfocusedBorderColor = unFocusedBorderColor.composeColor, disabledTextColor = - disabledColorAtom?.color?.composeColor - ?: textColor.copy(ContentAlpha.disabled), + disabledColorAtom?.color?.composeColor + ?: textColor.copy(ContentAlpha.disabled), disabledBorderColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, disabledLabelColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, disabledLeadingIconColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledPlaceholderColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledTrailingIconColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, errorCursorColor = errorColor?.composeColor ?: errorTextColor, errorBorderColor = errorColor?.composeColor ?: errorTextColor, errorLabelColor = errorColor?.composeColor ?: errorTextColor, diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt index 45edde9e..dff77771 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt @@ -34,7 +34,7 @@ public open class TextFieldMolecule( get() = listOf() @Composable - public fun colors(): TextFieldColors { + public open fun colors(): TextFieldColors { val textColor = textAtom.textColor.composeColor val backgroundColor = backgroundColorAtom.color.composeColor val disabledBackgroundColor = backgroundColor.copy(alpha = ContentAlpha.disabled) @@ -44,26 +44,26 @@ public open class TextFieldMolecule( textColor = textColor, backgroundColor = backgroundColor, placeholderColor = - hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( - ContentAlpha.medium, - ), + hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( + ContentAlpha.medium, + ), cursorColor = cursorColor?.composeColor ?: textColor, disabledTextColor = - disabledColorAtom?.color?.composeColor - ?: textColor.copy(ContentAlpha.disabled), + disabledColorAtom?.color?.composeColor + ?: textColor.copy(ContentAlpha.disabled), disabledIndicatorColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledLabelColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, disabledLeadingIconColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledPlaceholderColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledTrailingIconColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, errorCursorColor = errorColor?.composeColor ?: errorTextColor, errorIndicatorColor = errorColor?.composeColor ?: errorTextColor, errorLabelColor = errorColor?.composeColor ?: errorTextColor, diff --git a/shared/src/androidMain/kotlin/Main.android.kt b/shared/src/androidMain/kotlin/Main.android.kt index 02e27d54..ff5574ca 100644 --- a/shared/src/androidMain/kotlin/Main.android.kt +++ b/shared/src/androidMain/kotlin/Main.android.kt @@ -3,4 +3,5 @@ import com.kevinschildhorn.fotopresenter.ui.viewmodel.LoginViewModel actual fun getPlatformName(): String = "Android" -@Composable fun MainView(viewModel: LoginViewModel) = App(viewModel) +@Composable +fun MainView(viewModel: LoginViewModel) = App(viewModel) diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/LoginCredentials.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/LoginCredentials.kt index 1a9d4444..4e21dff6 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/LoginCredentials.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/data/LoginCredentials.kt @@ -13,7 +13,7 @@ data class LoginCredentials( val isComplete: Boolean get() = hostname.isNotBlank() && - username.isNotBlank() && - password.isNotBlank() && - sharedFolder.isNotBlank() + username.isNotBlank() && + password.isNotBlank() && + sharedFolder.isNotBlank() } diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt index 52141fb2..78896a9a 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/LoginScreen.kt @@ -33,11 +33,11 @@ fun LoginScreen( TitleView( "Foto", modifier = - Modifier.padding( - top = Padding.SMALL.dp, - start = Padding.STANDARD.dp, - bottom = Padding.LARGE.dp, - ), + Modifier.padding( + top = Padding.SMALL.dp, + start = Padding.STANDARD.dp, + bottom = Padding.LARGE.dp, + ), ) LoginScreenForm( uiState = uiState, diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt index 65e73ae0..9bbbf39f 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/ErrorView.kt @@ -24,10 +24,10 @@ fun ErrorView( } Box( modifier = - configuredModifier.padding( - horizontal = atom.paddingHorizontal?.dp ?: 0.dp, - vertical = atom.paddingVertical?.dp ?: 0.dp, - ), + configuredModifier.padding( + horizontal = atom.paddingHorizontal?.dp ?: 0.dp, + vertical = atom.paddingVertical?.dp ?: 0.dp, + ), ) { Text( text = message, diff --git a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt index 96ff0768..6adff0cd 100644 --- a/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt +++ b/shared/src/commonMain/kotlin/com/kevinschildhorn/fotopresenter/ui/compose/common/PrimaryButton.kt @@ -26,10 +26,10 @@ fun PrimaryButton( modifier = modifier.height(44.dp), enabled = buttonState.enabled, colors = - ButtonDefaults.buttonColors( - backgroundColor = molecule.color.composeColor, - disabledBackgroundColor = molecule.disabledColor.composeColor, - ), + ButtonDefaults.buttonColors( + backgroundColor = molecule.color.composeColor, + disabledBackgroundColor = molecule.disabledColor.composeColor, + ), ) { if (buttonState.loading) { CircularProgressIndicator( From c5a12aebece59491f95417fe10f7aa7f69a2aa3b Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Mon, 4 Dec 2023 09:38:19 -0500 Subject: [PATCH 08/11] another try --- .github/workflows/lint-action.yml | 19 +++---------------- .../molecules/OutlinedTextFieldMolecule.kt | 4 +++- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/.github/workflows/lint-action.yml b/.github/workflows/lint-action.yml index 31bd1d84..6984f4a4 100644 --- a/.github/workflows/lint-action.yml +++ b/.github/workflows/lint-action.yml @@ -16,20 +16,7 @@ jobs: distribution: "adopt" java-version: "17" - - uses: reviewdog/action-setup@v1 - - uses: touchlab-lab/ktlint-action-setup@1.0.0 - with: - ktlint_version: 0.50.0 - - - name: Run reviewdog + - name: Run ktlint with reviewdog + uses: ScaCap/action-ktlint@v1.8.0 env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - ktlint --reporter=checkstyle --relative \ - | reviewdog -f=checkstyle -name="ktlint" -reporter=github-pr-review -filter-mode=added -level=warning - - - - - - + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt index 9ae70090..aaf1731b 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt @@ -42,7 +42,9 @@ public open class OutlinedTextFieldMolecule( disabledColorAtom, cursorColor, errorColor, -), BorderedAtom, RoundedAtom { +), + BorderedAtom, + RoundedAtom { @Composable public override fun colors(): TextFieldColors { From 35774266de46abdc80960b74fcb6eb09f4e6fa70 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Mon, 4 Dec 2023 09:40:23 -0500 Subject: [PATCH 09/11] Update lint-action.yml --- .github/workflows/lint-action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-action.yml b/.github/workflows/lint-action.yml index 6984f4a4..5647dfe9 100644 --- a/.github/workflows/lint-action.yml +++ b/.github/workflows/lint-action.yml @@ -18,5 +18,5 @@ jobs: - name: Run ktlint with reviewdog uses: ScaCap/action-ktlint@v1.8.0 - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + with: + github_token: ${{ secrets.github_token }} From 8170df76c4493a62a37ef4e8c5893f4a0a465234 Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Mon, 4 Dec 2023 09:41:17 -0500 Subject: [PATCH 10/11] Update lint-action.yml --- .github/workflows/lint-action.yml | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/.github/workflows/lint-action.yml b/.github/workflows/lint-action.yml index 5647dfe9..9c9ddbb5 100644 --- a/.github/workflows/lint-action.yml +++ b/.github/workflows/lint-action.yml @@ -1,22 +1,16 @@ -name: Lint Action -on: - pull_request: - paths: - - '**/*.kt' - +name: reviewdog +on: [pull_request] jobs: - build: + ktlint: + name: Check Code Quality runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - uses: actions/setup-java@v2 + - name: Clone repo + uses: actions/checkout@master with: - distribution: "adopt" - java-version: "17" - - - name: Run ktlint with reviewdog - uses: ScaCap/action-ktlint@v1.8.0 + fetch-depth: 1 + - name: ktlint + uses: ScaCap/action-ktlint@master with: github_token: ${{ secrets.github_token }} From 44a75e50b9597509257ab561c0fbef08ed2c280f Mon Sep 17 00:00:00 2001 From: Kevin Schildhorn Date: Mon, 4 Dec 2023 09:43:22 -0500 Subject: [PATCH 11/11] formatting --- .../atomik/atomic/atoms/Atom.kt | 3 +- .../molecules/OutlinedTextFieldMolecule.kt | 39 +++++++++---------- .../atomic/molecules/TextFieldMolecule.kt | 26 ++++++------- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/Atom.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/Atom.kt index 7fbaea50..17b517e8 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/Atom.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/atoms/Atom.kt @@ -35,6 +35,5 @@ public abstract class Atom { * Finds a subComponent matching a specified [AtomInterface] if it exists * @return the subComponent of a specified interface if it's found */ - public inline fun subAtom(): T? = - subComponents.find { it is T } as? T + public inline fun subAtom(): T? = subComponents.find { it is T } as? T } diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt index aaf1731b..e31ae0fe 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/OutlinedTextFieldMolecule.kt @@ -35,17 +35,16 @@ public open class OutlinedTextFieldMolecule( override val unFocusedBorderColor: AtomikColor = focusedBorderColor, override val radius: Int, ) : TextFieldMolecule( - textAtom, - backgroundColorAtom, - hintTextAtom, - errorTextAtom, - disabledColorAtom, - cursorColor, - errorColor, -), + textAtom, + backgroundColorAtom, + hintTextAtom, + errorTextAtom, + disabledColorAtom, + cursorColor, + errorColor, + ), BorderedAtom, RoundedAtom { - @Composable public override fun colors(): TextFieldColors { val textColor = textAtom.textColor.composeColor @@ -57,26 +56,26 @@ public open class OutlinedTextFieldMolecule( textColor = textColor, backgroundColor = backgroundColor, placeholderColor = - hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( - ContentAlpha.medium, - ), + hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( + ContentAlpha.medium, + ), cursorColor = cursorColor?.composeColor ?: textColor, focusedBorderColor = focusedBorderColor.composeColor, unfocusedBorderColor = unFocusedBorderColor.composeColor, disabledTextColor = - disabledColorAtom?.color?.composeColor - ?: textColor.copy(ContentAlpha.disabled), + disabledColorAtom?.color?.composeColor + ?: textColor.copy(ContentAlpha.disabled), disabledBorderColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, disabledLabelColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, disabledLeadingIconColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledPlaceholderColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledTrailingIconColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, errorCursorColor = errorColor?.composeColor ?: errorTextColor, errorBorderColor = errorColor?.composeColor ?: errorTextColor, errorLabelColor = errorColor?.composeColor ?: errorTextColor, diff --git a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt index dff77771..b503224a 100644 --- a/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt +++ b/atomik/src/commonMain/kotlin/com/kevinschildhorn/atomik/atomic/molecules/TextFieldMolecule.kt @@ -44,26 +44,26 @@ public open class TextFieldMolecule( textColor = textColor, backgroundColor = backgroundColor, placeholderColor = - hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( - ContentAlpha.medium, - ), + hintTextAtom?.textColor?.composeColor ?: backgroundColor.copy( + ContentAlpha.medium, + ), cursorColor = cursorColor?.composeColor ?: textColor, disabledTextColor = - disabledColorAtom?.color?.composeColor - ?: textColor.copy(ContentAlpha.disabled), + disabledColorAtom?.color?.composeColor + ?: textColor.copy(ContentAlpha.disabled), disabledIndicatorColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledLabelColor = disabledColorAtom?.color?.composeColor ?: disabledBackgroundColor, disabledLeadingIconColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledPlaceholderColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, disabledTrailingIconColor = - disabledColorAtom?.color?.composeColor - ?: disabledBackgroundColor, + disabledColorAtom?.color?.composeColor + ?: disabledBackgroundColor, errorCursorColor = errorColor?.composeColor ?: errorTextColor, errorIndicatorColor = errorColor?.composeColor ?: errorTextColor, errorLabelColor = errorColor?.composeColor ?: errorTextColor,