Skip to content

Commit

Permalink
Merge pull request #28 from KevinSchildhorn/KtFormat
Browse files Browse the repository at this point in the history
running formatting
  • Loading branch information
KevinSchildhorn authored Dec 4, 2023
2 parents 601c653 + d4f488c commit 89749c7
Show file tree
Hide file tree
Showing 102 changed files with 760 additions and 765 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/lint-action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: Lint Action
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
name: reviewdog
on: [pull_request]
jobs:
Lint-Action:
ktlint:
name: Check Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Run KtFormat
run: ./gradlew ktFormat
steps:
- name: Clone repo
uses: actions/checkout@master
with:
fetch-depth: 1
- name: ktlint
uses: ScaCap/action-ktlint@master
with:
github_token: ${{ secrets.github_token }}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class MainActivity : AppCompatActivity(), KoinComponent {
MainView(viewModel)
}
}
}
}
5 changes: 3 additions & 2 deletions atomik/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
kotlin("multiplatform")
id("com.android.library")
id("org.jetbrains.compose")
id("org.jlleitschuh.gradle.ktlint")
}
/*
// Exclude compose from iOS
Expand Down Expand Up @@ -31,14 +32,14 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach
kotlin {
explicitApi()
applyDefaultHierarchyTemplate()
androidTarget() {
androidTarget {
publishLibraryVariants("debug", "release")
}
jvm("desktop")
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
iosSimulatorArm64(),
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "atomik"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ktlint-disable filename
@file:Suppress("ktlint:standard:filename")

package com.kevinschildhorn.atomik.atomic.atoms.xml

import android.widget.TextView
Expand Down Expand Up @@ -27,7 +28,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)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 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
Expand All @@ -16,7 +16,6 @@ public fun AtomikTypography.asComposeTextStyle(fontFamily: FontFamily): TextStyl
fontSize = this.size.sp,
)


/*
* Converting the Weight to a Typeface
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public open class DesignSystem(
public open val colorSet: ColorSet,
public open val typographySet: TypographySet,
public open val components: Map<String, Atom>,
public open var fontFamily: AtomikFontFamily? = null
public open var fontFamily: AtomikFontFamily? = null,
)
/*
@OptIn(ExperimentalAtomik::class)
Expand Down Expand Up @@ -59,5 +59,5 @@ internal class CustomDesignSystem(
override val colorSet: CustomColorSet,
override val typographySet: CustomTypographySet,
override val components: Map<String, Atom>,
override var fontFamily: AtomikFontFamily?
override var fontFamily: AtomikFontFamily?,
) : DesignSystem(colorSet, typographySet, components, fontFamily)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

/**
Expand Down Expand Up @@ -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

/**
Expand Down Expand Up @@ -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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ktlint-disable filename
@file:Suppress("ktlint:standard:filename")

package com.kevinschildhorn.atomik.atomic.atoms.compose
/*
import androidx.compose.ui.graphics.Color
Expand All @@ -10,4 +11,4 @@ import com.kevinschildhorn.atomik.color.base.AtomikColorType
*/
internal val AtomikColorType.composeColor: Color
get() = color.composeColor
*/
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ktlint-disable filename
@file:Suppress("ktlint:standard:filename")

package com.kevinschildhorn.atomik.atomic.atoms

import androidx.compose.ui.Alignment
Expand All @@ -11,23 +12,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
Expand All @@ -36,17 +39,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
}
get() =
when (this.constraintX) {
AtomikConstraintX.ALIGN_LEFT -> -1f
AtomikConstraintX.ALIGN_RIGHT -> 1f
AtomikConstraintX.CENTER -> 0f
AtomikConstraintX.SCALE -> 0f
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ktlint-disable filename
@file:Suppress("ktlint:standard:filename")

package com.kevinschildhorn.atomik.atomic.atoms.compose

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ktlint-disable filename
@file:Suppress("ktlint:standard:filename")

package com.kevinschildhorn.atomik.atomic.atoms
/*
import androidx.compose.foundation.layout.height
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ktlint-disable filename
@file:Suppress("ktlint:standard:filename")

package com.kevinschildhorn.atomik.atomic.atoms

import androidx.compose.foundation.shape.RoundedCornerShape
Expand All @@ -8,4 +9,3 @@ import com.kevinschildhorn.atomik.atomic.atoms.interfaces.RoundedAtom

public val RoundedAtom.shape: Shape
get() = RoundedCornerShape(radius.dp)

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ktlint-disable filename
@file:Suppress("ktlint:standard:filename")

package com.kevinschildhorn.atomik.atomic.atoms

import androidx.compose.runtime.Composable
Expand All @@ -23,7 +24,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,
)
}

Expand All @@ -38,5 +39,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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public enum class AtomType {
TEXT,
IMAGE,
TEXTFIELD,
VIEW
VIEW,
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.kevinschildhorn.atomik.color.base.AtomikColor
internal interface BorderedAtom : AtomInterface {
public val focusedBorderColor: AtomikColor
public val unFocusedBorderColor: AtomikColor

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public enum class AtomikConstraintX {
CENTER,
ALIGN_LEFT,
ALIGN_RIGHT,
SCALE
SCALE,
}

/**
Expand All @@ -30,7 +30,7 @@ public enum class AtomikConstraintY {
CENTER,
ALIGN_TOP,
ALIGN_BOTTOM,
SCALE
SCALE,
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}
Loading

0 comments on commit 89749c7

Please sign in to comment.