diff --git a/app/build.gradle b/app/build.gradle index 8e846ceb..5914d532 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,7 +18,7 @@ android { minSdk 22 targetSdk 33 versionCode 1 - versionName "1.0" + versionName "1.0.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/jeluchu/composer/MainActivity.kt b/app/src/main/java/com/jeluchu/composer/MainActivity.kt index 2e731a11..9393aa11 100644 --- a/app/src/main/java/com/jeluchu/composer/MainActivity.kt +++ b/app/src/main/java/com/jeluchu/composer/MainActivity.kt @@ -7,7 +7,6 @@ package com.jeluchu.composer import android.os.Bundle -import android.widget.SearchView import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.Image @@ -34,8 +33,9 @@ import com.jeluchu.jchucomponents.ui.animations.lists.animateItem import com.jeluchu.jchucomponents.ui.composables.cards.DebutCard import com.jeluchu.jchucomponents.ui.composables.cards.PostCardTop import com.jeluchu.jchucomponents.ui.composables.cards.StoryCard -import com.jeluchu.jchucomponents.ui.migration.sheets.BottomSheetWithCloseDialog +import com.jeluchu.jchucomponents.ui.composables.sheets.BottomSheetWithCloseDialog import com.jeluchu.jchucomponents.ui.composables.textfields.SearchTextField +import com.jeluchu.jchucomponents.ui.composables.toolbars.Toolbar import com.jeluchu.jchucomponents.ui.themes.darkPastelBlue class MainActivity : ComponentActivity() { @@ -65,6 +65,12 @@ class MainActivity : ComponentActivity() { horizontalAlignment = Alignment.CenterHorizontally ) { + Toolbar( + modifier = Modifier, + title = "Villagers", + navigateToBackScreen = { } + ) + val textState = remember { mutableStateOf(String.empty()) } SearchTextField(state = textState) diff --git a/build.gradle b/build.gradle index c202f56c..2abdcc93 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.0' + classpath libs.com.android.tools.build.gradle classpath libs.org.jetbrains.kotlin.kotlin.gradle.plugin classpath libs.org.jetbrains.dokka.dokka.gradle.plugin } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b98490e2..2cfc7b35 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -45,7 +45,7 @@ com-google-firebase-firebase-analytics-ktx = "com.google.firebase:firebase-analy com-google-code-gson = "com.google.code.gson:gson:2.10" com-google-android-gms-play-services-base = "com.google.android.gms:play-services-base:18.1.0" com-google-accompanist-accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "com-google-accompanist" } -com-android-tools-build-gradle = "com.android.tools.build:gradle:7.3.1" +com-android-tools-build-gradle = "com.android.tools.build:gradle:7.4.0" androidx-navigation-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "androidx-navigation" } androidx-preference = "androidx.preference:preference-ktx:1.2.0" androidx-browser = "androidx.browser:browser:1.4.0" diff --git a/jchucomponents-ktx/src/androidTest/java/com/jeluchu/jchucomponents/ExampleInstrumentedTest.kt b/jchucomponents-ktx/src/androidTest/java/com/jeluchu/jchucomponents/ExampleInstrumentedTest.kt index 271a1107..24020377 100644 --- a/jchucomponents-ktx/src/androidTest/java/com/jeluchu/jchucomponents/ExampleInstrumentedTest.kt +++ b/jchucomponents-ktx/src/androidTest/java/com/jeluchu/jchucomponents/ExampleInstrumentedTest.kt @@ -1,13 +1,11 @@ package com.jeluchu.jchucomponents -import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 - +import androidx.test.platform.app.InstrumentationRegistry +import org.junit.Assert.* import org.junit.Test import org.junit.runner.RunWith -import org.junit.Assert.* - /** * Instrumented test, which will execute on an Android device. * diff --git a/jchucomponents-ktx/src/main/AndroidManifest.xml b/jchucomponents-ktx/src/main/AndroidManifest.xml index f0f34af3..8c4c9826 100644 --- a/jchucomponents-ktx/src/main/AndroidManifest.xml +++ b/jchucomponents-ktx/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ + \ No newline at end of file diff --git a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/context/ContextExensions.kt b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/context/ContextExensions.kt index 39767a67..0693b492 100644 --- a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/context/ContextExensions.kt +++ b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/context/ContextExensions.kt @@ -61,7 +61,6 @@ fun Context.addToClipboard(str: CharSequence?) { } - /** ---- PRIVATE METHODS ----------------------------------------------------------------------- **/ val Context.layoutInflater @@ -99,7 +98,6 @@ fun Context.createQR( } - /** ---- SAVE IMAGES --------------------------------------------------------------------------- **/ fun Context.saveBitmap( diff --git a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/gson/GsonExtensions.kt b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/gson/GsonExtensions.kt index 6af7ada2..dbfd84a4 100644 --- a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/gson/GsonExtensions.kt +++ b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/gson/GsonExtensions.kt @@ -35,7 +35,7 @@ inline fun T.convert(): R = gson.toJson(this).toObject() /** * Helps to get Map, List, Set or other generic type from Json using Gson. */ -inline fun Gson.fromJsonToGeneric(json: String): T { +inline fun Gson.fromJsonToGeneric(json: String): T { val type = object : TypeToken() {}.type return fromJson(json, type) } \ No newline at end of file diff --git a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/ints/IntExtensions.kt b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/ints/IntExtensions.kt index 975ade93..8022c25e 100644 --- a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/ints/IntExtensions.kt +++ b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/ints/IntExtensions.kt @@ -30,7 +30,7 @@ fun Float.Companion.empty() = 0f fun Float?.orEmpty(defaultValue: Float = Float.empty()): Float = this ?: defaultValue fun Long.Companion.empty() = 0L -fun Long?.orEmpty(defaultValue: Long = Long.empty()): Long = this ?: defaultValue +fun Long?.orEmpty(defaultValue: Long = Long.empty()): Long = this ?: defaultValue fun Int.milliSecondsToTimer(): String { diff --git a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/secure/CaesarCypher.kt b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/secure/CaesarCypher.kt index 14a786e1..f7ec4bdf 100644 --- a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/secure/CaesarCypher.kt +++ b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/secure/CaesarCypher.kt @@ -13,12 +13,10 @@ object CaesarCypher { if (c in 'A'..'Z') { d = c + offset if (d > 'Z') d -= 26 - } - else if (c in 'a'..'z') { + } else if (c in 'a'..'z') { d = c + offset if (d > 'z') d -= 26 - } - else + } else d = c chars[index] = d } diff --git a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/sharedprefs/SharedPrefsHelpers.kt b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/sharedprefs/SharedPrefsHelpers.kt index 129b2c79..27fd7083 100644 --- a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/sharedprefs/SharedPrefsHelpers.kt +++ b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/sharedprefs/SharedPrefsHelpers.kt @@ -119,7 +119,7 @@ class SharedPrefsHelpers { return datalist } - fun clearSession() { + fun clearSession() { val editor = mSharedPreferences!!.edit() editor.clear() editor.apply() diff --git a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/utilities/zxing/qrcode/QRCodeReader.kt b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/utilities/zxing/qrcode/QRCodeReader.kt index 88f0e2d4..1861e256 100644 --- a/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/utilities/zxing/qrcode/QRCodeReader.kt +++ b/jchucomponents-ktx/src/main/java/com/jeluchu/jchucomponents/ktx/utilities/zxing/qrcode/QRCodeReader.kt @@ -6,16 +6,9 @@ package com.jeluchu.jchucomponents.ktx.utilities.zxing.qrcode -import com.jeluchu.jchucomponents.ktx.utilities.zxing.BarcodeFormat -import com.jeluchu.jchucomponents.ktx.utilities.zxing.BinaryBitmap +import com.jeluchu.jchucomponents.ktx.utilities.zxing.* import com.jeluchu.jchucomponents.ktx.utilities.zxing.ChecksumException -import com.jeluchu.jchucomponents.ktx.utilities.zxing.DecodeHintType import com.jeluchu.jchucomponents.ktx.utilities.zxing.FormatException -import com.jeluchu.jchucomponents.ktx.utilities.zxing.NotFoundException -import com.jeluchu.jchucomponents.ktx.utilities.zxing.Reader -import com.jeluchu.jchucomponents.ktx.utilities.zxing.ResultMetadataType -import com.jeluchu.jchucomponents.ktx.utilities.zxing.ResultPoint -import com.jeluchu.jchucomponents.ktx.utilities.zxing.* import com.jeluchu.jchucomponents.ktx.utilities.zxing.common.BitMatrix import com.jeluchu.jchucomponents.ktx.utilities.zxing.common.DecoderResult import com.jeluchu.jchucomponents.ktx.utilities.zxing.qrcode.decoder.Decoder diff --git a/jchucomponents-ktx/src/main/res/drawable/ic_btn_share.xml b/jchucomponents-ktx/src/main/res/drawable/ic_btn_share.xml index d8ff075f..50a103d9 100644 --- a/jchucomponents-ktx/src/main/res/drawable/ic_btn_share.xml +++ b/jchucomponents-ktx/src/main/res/drawable/ic_btn_share.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/jchucomponents-ktx/src/test/java/com/jeluchu/jchucomponents/ExampleUnitTest.kt b/jchucomponents-ktx/src/test/java/com/jeluchu/jchucomponents/ExampleUnitTest.kt index 46887736..099e5f32 100644 --- a/jchucomponents-ktx/src/test/java/com/jeluchu/jchucomponents/ExampleUnitTest.kt +++ b/jchucomponents-ktx/src/test/java/com/jeluchu/jchucomponents/ExampleUnitTest.kt @@ -1,8 +1,7 @@ package com.jeluchu.jchucomponents -import org.junit.Test - import org.junit.Assert.* +import org.junit.Test /** * Example local unit test, which will execute on the development machine (host). diff --git a/jchucomponents-ui/build.gradle b/jchucomponents-ui/build.gradle index 485947bb..50f26eeb 100644 --- a/jchucomponents-ui/build.gradle +++ b/jchucomponents-ui/build.gradle @@ -73,7 +73,7 @@ afterEvaluate { from components.release groupId = "com.github.jeluchu" artifactId = "jchucomponents-ui" - version = "1.0.0-beta16" + version = "1.0.0-rc01" } } } diff --git a/jchucomponents-ui/src/androidTest/java/com/jeluchu/jchucomponents/ExampleInstrumentedTest.kt b/jchucomponents-ui/src/androidTest/java/com/jeluchu/jchucomponents/ExampleInstrumentedTest.kt index aee052aa..5ebda8d3 100644 --- a/jchucomponents-ui/src/androidTest/java/com/jeluchu/jchucomponents/ExampleInstrumentedTest.kt +++ b/jchucomponents-ui/src/androidTest/java/com/jeluchu/jchucomponents/ExampleInstrumentedTest.kt @@ -1,13 +1,11 @@ package com.jeluchu.jchucomponents -import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 - +import androidx.test.platform.app.InstrumentationRegistry +import org.junit.Assert.* import org.junit.Test import org.junit.runner.RunWith -import org.junit.Assert.* - /** * Instrumented test, which will execute on an Android device. * diff --git a/jchucomponents-ui/src/main/AndroidManifest.xml b/jchucomponents-ui/src/main/AndroidManifest.xml index a5918e68..44008a43 100644 --- a/jchucomponents-ui/src/main/AndroidManifest.xml +++ b/jchucomponents-ui/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/animations/navigation/NavigationAnimations.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/animations/navigation/NavigationAnimations.kt index 4dc94c84..72bab88a 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/animations/navigation/NavigationAnimations.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/animations/navigation/NavigationAnimations.kt @@ -6,10 +6,16 @@ package com.jeluchu.jchucomponents.ui.animations.navigation -import androidx.compose.animation.* +import androidx.compose.animation.AnimatedContentScope +import androidx.compose.animation.EnterTransition +import androidx.compose.animation.ExitTransition +import androidx.compose.animation.ExperimentalAnimationApi import androidx.compose.animation.core.FastOutLinearInEasing import androidx.compose.animation.core.FastOutSlowInEasing import androidx.compose.animation.core.tween +import androidx.compose.animation.fadeIn +import androidx.compose.animation.slideInHorizontally +import androidx.compose.animation.slideOutHorizontally import androidx.navigation.NavBackStackEntry @ExperimentalAnimationApi diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/accessibility/Tooltip.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/accessibility/Tooltip.kt index 85855f22..a61657e3 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/accessibility/Tooltip.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/accessibility/Tooltip.kt @@ -10,18 +10,38 @@ import androidx.compose.animation.core.MutableTransitionState import androidx.compose.animation.core.animateFloat import androidx.compose.animation.core.tween import androidx.compose.animation.core.updateTransition -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.ColumnScope +import androidx.compose.foundation.layout.IntrinsicSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll -import androidx.compose.material.* -import androidx.compose.runtime.* +import androidx.compose.material.Card +import androidx.compose.material.DropdownMenu +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text +import androidx.compose.material.contentColorFor +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.takeOrElse import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.* +import androidx.compose.ui.unit.Density +import androidx.compose.ui.unit.DpOffset +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.IntRect +import androidx.compose.ui.unit.IntSize +import androidx.compose.ui.unit.LayoutDirection +import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Popup import androidx.compose.ui.window.PopupPositionProvider import androidx.compose.ui.window.PopupProperties diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/cards/StoriesCard.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/cards/StoriesCard.kt index 51435b9a..02eb3e9b 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/cards/StoriesCard.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/cards/StoriesCard.kt @@ -9,7 +9,12 @@ package com.jeluchu.jchucomponents.ui.composables.cards import androidx.compose.foundation.Image import androidx.compose.foundation.border import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.Card diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/chips/ChipTagView.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/chips/ChipTagView.kt index 2c5c7cc8..70542d92 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/chips/ChipTagView.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/chips/ChipTagView.kt @@ -7,7 +7,13 @@ package com.jeluchu.jchucomponents.ui.composables.chips import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/chips/Chips.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/chips/Chips.kt index 6de4b173..5daf5f67 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/chips/Chips.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/chips/Chips.kt @@ -10,13 +10,13 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Check +import androidx.compose.material.icons.filled.HighlightOff import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Check -import androidx.compose.material.icons.filled.HighlightOff import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/loaders/PulseLoading.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/loaders/PulseLoading.kt index af623dc6..e19977c9 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/loaders/PulseLoading.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/loaders/PulseLoading.kt @@ -6,7 +6,12 @@ package com.jeluchu.jchucomponents.ui.composables.loaders -import androidx.compose.animation.core.* +import androidx.compose.animation.core.LinearEasing +import androidx.compose.animation.core.RepeatMode +import androidx.compose.animation.core.animateFloat +import androidx.compose.animation.core.infiniteRepeatable +import androidx.compose.animation.core.rememberInfiniteTransition +import androidx.compose.animation.core.tween import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.size diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/pager/PageIndicator.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/pager/PageIndicator.kt index 08c2be78..6b1a8bd5 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/pager/PageIndicator.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/pager/PageIndicator.kt @@ -7,7 +7,12 @@ package com.jeluchu.jchucomponents.ui.composables.pager import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/particles/Particles.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/particles/Particles.kt index 0f8dc51a..6f00259e 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/particles/Particles.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/particles/Particles.kt @@ -8,7 +8,14 @@ package com.jeluchu.jchucomponents.ui.composables.particles import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.ExitTransition -import androidx.compose.animation.core.* +import androidx.compose.animation.core.LinearEasing +import androidx.compose.animation.core.LinearOutSlowInEasing +import androidx.compose.animation.core.MutableTransitionState +import androidx.compose.animation.core.animateFloat +import androidx.compose.animation.core.animateInt +import androidx.compose.animation.core.keyframes +import androidx.compose.animation.core.tween +import androidx.compose.animation.core.updateTransition import androidx.compose.animation.slideInVertically import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentSize diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/progress/CircularProgressbar.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/progress/CircularProgressbar.kt index 66292974..211b93fa 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/progress/CircularProgressbar.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/progress/CircularProgressbar.kt @@ -15,7 +15,11 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material3.Icon -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/sheets/BottomSheetWithClose.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/sheets/BottomSheetWithClose.kt new file mode 100644 index 00000000..1221a5c8 --- /dev/null +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/sheets/BottomSheetWithClose.kt @@ -0,0 +1,95 @@ +/* + * + * Copyright 2022 Jeluchu + * + */ + +package com.jeluchu.jchucomponents.ui.composables.sheets + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Close +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp + +/** + * + * Author: @Jeluchu + * + * This component displays a BottomSheet with an icon to close it + * + * @param modifier modifier that will be used to change the color, size... + * @param bottomSheetSettings Configuration and customization of colors and actions of the modal, + * to learn more you can see [BottomSheetSettings] + * @param content will include the [Composable] that will subsequently be displayed in the modal + * + */ + +@Composable +fun BottomSheetWithCloseDialog( + modifier: Modifier = Modifier, + bottomSheetSettings: BottomSheetSettings = BottomSheetSettings(), + content: @Composable () -> Unit +) = Box(modifier.fillMaxWidth()) { + + if (bottomSheetSettings.isCardCloseShow) + Card( + modifier = bottomSheetSettings.contentModifier.align(Alignment.TopCenter), + colors = CardDefaults.cardColors( + containerColor = bottomSheetSettings.buttonTint.copy(.6f) + ), + elevation = CardDefaults.cardElevation( + defaultElevation = 0.dp, + pressedElevation = 0.dp, + focusedElevation = 0.dp, + hoveredElevation = 0.dp, + draggedElevation = 0.dp, + disabledElevation = 0.dp, + ), + shape = CircleShape, + content = {} + ) + + content() + + if (bottomSheetSettings.isCloseIconShow) + IconButton( + onClick = bottomSheetSettings.onClosePressed, + modifier = Modifier + .align(Alignment.TopEnd) + .padding(16.dp) + .size(29.dp) + ) { + Icon( + imageVector = Icons.Filled.Close, + tint = bottomSheetSettings.buttonTint, + contentDescription = null + ) + } +} + +@Immutable +class BottomSheetSettings constructor( + val contentModifier: Modifier = Modifier + .width(125.dp) + .height(20.dp) + .padding(vertical = 8.dp), + val buttonTint: Color = Color.Gray, + val isCardCloseShow: Boolean = true, + val isCloseIconShow: Boolean = false, + val onClosePressed: () -> Unit = {} +) \ No newline at end of file diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/MiniPostItemShimmer.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/MiniPostItemShimmer.kt index 2146f4ea..b836de10 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/MiniPostItemShimmer.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/MiniPostItemShimmer.kt @@ -7,7 +7,13 @@ package com.jeluchu.jchucomponents.ui.composables.shimmer import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Brush diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/MovieItemShimmer.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/MovieItemShimmer.kt index 97940f07..c8f0670a 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/MovieItemShimmer.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/MovieItemShimmer.kt @@ -7,7 +7,12 @@ package com.jeluchu.jchucomponents.ui.composables.shimmer import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +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.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/PostItemShimmer.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/PostItemShimmer.kt index dd776a6b..8fe38d04 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/PostItemShimmer.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/shimmer/PostItemShimmer.kt @@ -7,7 +7,12 @@ package com.jeluchu.jchucomponents.ui.composables.shimmer import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Brush diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/snackbar/Snackbar.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/snackbar/Snackbar.kt index 794eaa0b..de6c869c 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/snackbar/Snackbar.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/snackbar/Snackbar.kt @@ -6,7 +6,11 @@ package com.jeluchu.jchucomponents.ui.composables.snackbar -import androidx.compose.foundation.layout.* +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.foundation.layout.paddingFromBaseline import androidx.compose.material.* import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider @@ -15,7 +19,11 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.compositeOver -import androidx.compose.ui.layout.* +import androidx.compose.ui.layout.AlignmentLine +import androidx.compose.ui.layout.FirstBaseline +import androidx.compose.ui.layout.LastBaseline +import androidx.compose.ui.layout.Layout +import androidx.compose.ui.layout.layoutId import androidx.compose.ui.text.TextStyle import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/templates/Scaffold.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/structures/Scaffold.kt similarity index 96% rename from jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/templates/Scaffold.kt rename to jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/structures/Scaffold.kt index 1e883007..34d73cc6 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/templates/Scaffold.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/structures/Scaffold.kt @@ -21,10 +21,8 @@ import androidx.compose.ui.graphics.Color * * Author: @Jeluchu * - * This component is based on EditText in which you can check - * how many characters you have typed and what is the maximum - * - * @sample CountTextFieldPreview + * This component is useful to check the status of a response to a request to the service, + * and depending on the result it can display information, an error or the loading progress * * @param modifier optional Modifier for the root of the [Scaffold] * @param scaffoldState state of this scaffold widget. It contains the state of the screen, e.g. diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/textfields/CountTextField.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/textfields/CountTextField.kt index 09e337a2..dcd9fb67 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/textfields/CountTextField.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/textfields/CountTextField.kt @@ -57,55 +57,55 @@ fun CountTextField( styleLabel: TextStyle = LocalTextStyle.current ) = Column { - var textState by rememberMutableStateOf(String.empty()) + var textState by rememberMutableStateOf(String.empty()) - Text( - text = title, - modifier = Modifier - .fillMaxWidth() - .padding(bottom = 4.dp), - textAlign = TextAlign.Start, - color = countField.counterTextColor, - style = styleLabel - ) + Text( + text = title, + modifier = Modifier + .fillMaxWidth() + .padding(bottom = 4.dp), + textAlign = TextAlign.Start, + color = countField.counterTextColor, + style = styleLabel + ) - TextField( - modifier = Modifier.fillMaxWidth(), - value = textState, - colors = TextFieldDefaults.textFieldColors( - containerColor = countField.backgroundColor, - cursorColor = countField.cursorColor, - disabledLabelColor = countField.disabledLabelColor, - focusedIndicatorColor = Color.Transparent, - unfocusedIndicatorColor = Color.Transparent - ), - onValueChange = { - if (it.length <= maxLength) textState = it - }, - shape = RoundedCornerShape(8.dp), - singleLine = true, - textStyle = styleLabel, - trailingIcon = { - if (textState.isNotEmpty()) { - IconButton(onClick = { textState = "" }) { - Icon( - imageVector = Icons.Outlined.Close, - contentDescription = null - ) - } + TextField( + modifier = Modifier.fillMaxWidth(), + value = textState, + colors = TextFieldDefaults.textFieldColors( + containerColor = countField.backgroundColor, + cursorColor = countField.cursorColor, + disabledLabelColor = countField.disabledLabelColor, + focusedIndicatorColor = Color.Transparent, + unfocusedIndicatorColor = Color.Transparent + ), + onValueChange = { + if (it.length <= maxLength) textState = it + }, + shape = RoundedCornerShape(8.dp), + singleLine = true, + textStyle = styleLabel, + trailingIcon = { + if (textState.isNotEmpty()) { + IconButton(onClick = { textState = "" }) { + Icon( + imageVector = Icons.Outlined.Close, + contentDescription = null + ) } } - ) - Text( - text = "${textState.length} / $maxLength", - modifier = Modifier - .fillMaxWidth() - .padding(top = 4.dp), - textAlign = TextAlign.End, - color = countField.counterTextColor, - style = styleLabel - ) - } + } + ) + Text( + text = "${textState.length} / $maxLength", + modifier = Modifier + .fillMaxWidth() + .padding(top = 4.dp), + textAlign = TextAlign.End, + color = countField.counterTextColor, + style = styleLabel + ) +} @Immutable class CountField constructor( diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/toolbars/Toolbar.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/toolbars/Toolbar.kt similarity index 88% rename from jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/toolbars/Toolbar.kt rename to jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/toolbars/Toolbar.kt index f14069ff..8a9c8132 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/toolbars/Toolbar.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/composables/toolbars/Toolbar.kt @@ -4,7 +4,7 @@ * */ -package com.jeluchu.jchucomponents.ui.migration.toolbars +package com.jeluchu.jchucomponents.ui.composables.toolbars import androidx.annotation.DrawableRes import androidx.compose.foundation.background @@ -19,6 +19,7 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar @@ -74,7 +75,7 @@ fun Toolbar( .clip(CircleShape) .clickable(onClick = navigateToBackScreen), tint = topBarSettings.tintActionsColor, - imageVector = ImageVector.vectorResource(id = R.drawable.ic_arrow_left), + imageVector = ImageVector.vectorResource(id = topBarSettings.navIcon), contentDescription = null ) Icon( @@ -129,21 +130,22 @@ fun Toolbar( containerColor = topBarSettings.backgroundColor ), navigationIcon = { - Icon( - modifier = Modifier - .size(40.dp) - .padding(8.dp) - .clip(CircleShape) - .clickable(onClick = navigateToBackScreen), - tint = topBarSettings.contentColor, - imageVector = ImageVector.vectorResource(id = R.drawable.ic_arrow_left), - contentDescription = null - ) + IconButton(onClick = navigateToBackScreen) { + Icon( + modifier = Modifier + .size(40.dp) + .padding(8.dp), + tint = topBarSettings.contentColor, + imageVector = ImageVector.vectorResource(id = topBarSettings.navIcon), + contentDescription = null + ) + } } ) @Immutable class TopBarSettings constructor( + @DrawableRes val navIcon: Int = R.drawable.ic_arrow_left, @DrawableRes val actionIcon: Int = R.drawable.ic_btn_qrcode, val contentColor: Color = Color.DarkGray, val actionsBackgroundColor: Color = Color.DarkGray, diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/extensions/modifier/Modifier.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/extensions/modifier/Modifier.kt index 09e09e35..befdd527 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/extensions/modifier/Modifier.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/extensions/modifier/Modifier.kt @@ -13,7 +13,11 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.composed import androidx.compose.ui.draw.drawBehind diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/canva/CanvasBackground.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/canva/CanvasBackground.kt index 17ece7fc..e7e8f463 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/canva/CanvasBackground.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/canva/CanvasBackground.kt @@ -10,8 +10,12 @@ import android.graphics.Bitmap import androidx.compose.foundation.Canvas import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.* +import androidx.compose.ui.graphics.ImageShader +import androidx.compose.ui.graphics.Paint +import androidx.compose.ui.graphics.TileMode +import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.drawscope.drawIntoCanvas +import androidx.compose.ui.graphics.nativeCanvas import androidx.compose.ui.platform.LocalContext import com.jeluchu.jchucomponents.ui.extensions.getBitmapFromVectorDrawable diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/icon/Icon.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/icon/Icon.kt index 2f082dd5..10aa6a82 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/icon/Icon.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/icon/Icon.kt @@ -3,16 +3,16 @@ package com.jeluchu.jchucomponents.ui.foundation.icon import androidx.annotation.StringRes +import androidx.compose.material.Icon import androidx.compose.material.LocalContentColor import androidx.compose.runtime.Composable import androidx.compose.runtime.NonRestartableComposable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ImageBitmap -import androidx.compose.ui.res.stringResource -import androidx.compose.material.Icon import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.res.stringResource /** * diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/LazyColumnDragAndDrop.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/LazyColumnDragAndDrop.kt index d82c6e83..2fceeb1c 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/LazyColumnDragAndDrop.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/LazyColumnDragAndDrop.kt @@ -17,7 +17,13 @@ import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.lazy.LazyItemScope import androidx.compose.foundation.lazy.LazyListItemInfo import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.runtime.* +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.graphicsLayer diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/LazyGrid.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/LazyGrid.kt new file mode 100644 index 00000000..aecc2b17 --- /dev/null +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/LazyGrid.kt @@ -0,0 +1,41 @@ +/* + * + * Copyright 2022 Jeluchu + * + */ + +package com.jeluchu.jchucomponents.ui.migration.lists.grids + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.LazyItemScope +import androidx.compose.foundation.lazy.itemsIndexed +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp + +@Composable +fun LazyGrid( + items: List = listOf(), + rows: Int = 3, + horizontalPadding: Int = 8, + itemContent: @Composable LazyItemScope.(T, Int) -> Unit +) = LazyColumn(modifier = Modifier.padding(horizontal = horizontalPadding.dp)) { + itemsIndexed(items.chunked(rows)) { index, elements -> + Row { + elements.forEachIndexed { rowIndex, item -> + Box( + modifier = Modifier + .weight(1f) + .align(Alignment.Top) + .padding(5.dp), + contentAlignment = Alignment.Center + ) { itemContent(item, index * rows + rowIndex) } + } + repeat(rows - elements.size) { Box(modifier = Modifier.weight(1f)) {} } + } + } +} \ No newline at end of file diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/LazyHorizontalGrid.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/LazyHorizontalGrid.kt similarity index 90% rename from jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/LazyHorizontalGrid.kt rename to jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/LazyHorizontalGrid.kt index 1dc755ba..005d8669 100644 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/LazyHorizontalGrid.kt +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/LazyHorizontalGrid.kt @@ -4,11 +4,19 @@ * */ -package com.jeluchu.jchucomponents.ui.migration.lists.grids +package com.jeluchu.jchucomponents.ui.foundation.lists import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.lazy.* +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.BoxWithConstraints +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.lazy.LazyItemScope +import androidx.compose.foundation.lazy.LazyListState +import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.Dp @@ -58,7 +66,7 @@ sealed class GridCells { /** * Combines cells with fixed number rows or columns. * - * For example, for the vertical [LazyVerticalGrid] Fixed(3) would mean that there are 3 columns 1/3 + * For example, for the vertical LazyVerticalGrid Fixed(3) would mean that there are 3 columns 1/3 * of the parent wide. */ @ExperimentalFoundationApi @@ -69,7 +77,7 @@ sealed class GridCells { * or columns as possible on the condition that every cell has at least [minSize] space and * all extra space distributed evenly. * - * For example, for the vertical [LazyVerticalGrid] Adaptive(20.dp) would mean that there will be as + * For example, for the vertical LazyVerticalGrid Adaptive(20.dp) would mean that there will be as * many columns as possible and every column will be at least 20.dp and all the columns will * have equal width. If the screen is 88.dp wide then there will be 4 columns 22.dp each. */ @@ -78,7 +86,7 @@ sealed class GridCells { } /** - * Receiver scope which is used by [LazyVerticalGrid]. + * Receiver scope which is used by LazyVerticalGrid. */ @ExperimentalFoundationApi interface LazyGridScope { diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/VerticalGrid.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/VerticalGrid.kt new file mode 100644 index 00000000..c9d357aa --- /dev/null +++ b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/foundation/lists/VerticalGrid.kt @@ -0,0 +1,62 @@ +/* + * + * Copyright 2022 Jeluchu + * + */ + +package com.jeluchu.jchucomponents.ui.migration.lists.grids + +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.layout.Layout + +/** + * + * Author: @Jeluchu + * + * A custom layout to recreate a GridLayout which lays elements + * out vertically in evenly sized columns + * + * @param modifier modifier that will be used to change the color, size... + * @param columns number of columns to be displayed + * @param content the item to be painted within the layout + * + */ + +@Composable +fun VerticalGrid( + modifier: Modifier = Modifier, + columns: Int = 2, + content: @Composable () -> Unit +) = Layout( + content = content, + modifier = modifier +) { measurables, constraints -> + val itemWidth = constraints.maxWidth / columns + val itemConstraints = constraints.copy( + minWidth = itemWidth, + maxWidth = itemWidth + ) + val placeables = measurables.map { it.measure(itemConstraints) } + val columnHeights = Array(columns) { 0 } + placeables.forEachIndexed { index, placeable -> + val column = index % columns + columnHeights[column] += placeable.height + } + val height = (columnHeights.maxOrNull() ?: constraints.minHeight) + .coerceAtMost(constraints.maxHeight) + layout( + width = constraints.maxWidth, + height = height + ) { + val columnY = Array(columns) { 0 } + placeables.forEachIndexed { index, placeable -> + val column = index % columns + placeable.place( + x = column * itemWidth, + y = columnY[column] + ) + columnY[column] += placeable.height + } + } +} \ No newline at end of file diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/LazyGrid.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/LazyGrid.kt deleted file mode 100644 index f35b1301..00000000 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/LazyGrid.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * Copyright 2022 Jeluchu - * - */ - -package com.jeluchu.jchucomponents.ui.migration.lists.grids - -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.lazy.LazyItemScope -import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp - -@Composable -fun LazyGrid( - items: List = listOf(), - rows: Int = 3, - hPadding: Int = 8, - itemContent: @Composable LazyItemScope.(T, Int) -> Unit -) { - val chunkedList = items.chunked(rows) - LazyColumn(modifier = Modifier.padding(horizontal = hPadding.dp)) { - - itemsIndexed(chunkedList) { index, it -> - - Row { - it.forEachIndexed { rowIndex, item -> - Box( - modifier = Modifier - .weight(1F) - .align(Alignment.Top) - .padding(5.dp), - contentAlignment = Alignment.Center - ) { - itemContent(item, index * rows + rowIndex) - } - } - repeat(rows - it.size) { - Box(modifier = Modifier.weight(1F)) {} - } - } - - } - - } -} \ No newline at end of file diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/StaggeredHorizontalGrid.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/StaggeredHorizontalGrid.kt deleted file mode 100644 index c667ca03..00000000 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/StaggeredHorizontalGrid.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Copyright 2022 Jeluchu - * - */ - -package com.jeluchu.jchucomponents.ui.migration.lists.grids - -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.Layout -import kotlin.math.max - -@Composable -fun StaggeredHorizontalGrid( - modifier: Modifier = Modifier, - rows: Int = 3, - content: @Composable () -> Unit -) { - Layout( - modifier = modifier, - content = content - ) { measurables, constraints -> - - val rowWidths = IntArray(rows) { 0 } - val rowHeights = IntArray(rows) { 0 } - - val placeables = measurables.mapIndexed { index, measurable -> - val placeable = measurable.measure(constraints) - val row = index % rows - rowWidths[row] += placeable.width - rowHeights[row] = max(rowHeights[row], placeable.height) - placeable - } - - val width = rowWidths.maxOrNull() - ?.coerceIn(constraints.minWidth.rangeTo(constraints.maxWidth)) ?: constraints.minWidth - - val height = rowHeights.sumOf { it } - .coerceIn(constraints.minHeight.rangeTo(constraints.maxHeight)) - - val rowY = IntArray(rows) { 0 } - for (i in 1 until rows) { - rowY[i] = rowY[i - 1] + rowHeights[i - 1] - } - - layout(width, height) { - val rowX = IntArray(rows) { 0 } - placeables.forEachIndexed { index, placeable -> - val row = index % rows - placeable.placeRelative( - x = rowX[row], - y = rowY[row] - ) - rowX[row] += placeable.width - } - } - } -} \ No newline at end of file diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/StaggeredVerticalGrid.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/StaggeredVerticalGrid.kt deleted file mode 100644 index 89dad578..00000000 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/StaggeredVerticalGrid.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * Copyright 2022 Jeluchu - * - */ - -package com.jeluchu.jchucomponents.ui.migration.lists.grids - -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.Layout -import androidx.compose.ui.layout.Placeable -import androidx.compose.ui.unit.Dp -import kotlin.math.ceil - -@Composable -fun StaggeredVerticalGrid( - modifier: Modifier = Modifier, - maxColumnWidth: Dp, - content: @Composable () -> Unit -) { - Layout( - content = content, - modifier = modifier - ) { measurables, constraints -> - val placeableXY: MutableMap> = mutableMapOf() - - check(constraints.hasBoundedWidth) { - "Unbounded width not supported" - } - val columns = ceil(constraints.maxWidth / maxColumnWidth.toPx()).toInt() - val columnWidth = constraints.maxWidth / columns - val itemConstraints = constraints.copy(maxWidth = columnWidth) - val colHeights = IntArray(columns) { 0 } // track each column's height - val placeables = measurables.map { measurable -> - val column = shortestColumn(colHeights) - val placeable = measurable.measure(itemConstraints) - placeableXY[placeable] = Pair(columnWidth * column, colHeights[column]) - colHeights[column] += placeable.height - placeable - } - - val height = colHeights.maxOrNull() - ?.coerceIn(constraints.minHeight, constraints.maxHeight) - ?: constraints.minHeight - layout( - width = constraints.maxWidth, - height = height - ) { - placeables.forEach { placeable -> - placeable.place( - x = placeableXY.getValue(placeable).first, - y = placeableXY.getValue(placeable).second - ) - } - } - } -} - -private fun shortestColumn(colHeights: IntArray): Int { - var minHeight = Int.MAX_VALUE - var column = 0 - colHeights.forEachIndexed { index, height -> - if (height < minHeight) { - minHeight = height - column = index - } - } - return column -} \ No newline at end of file diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/VerticalGrid.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/VerticalGrid.kt deleted file mode 100644 index 8db51532..00000000 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/lists/grids/VerticalGrid.kt +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Copyright 2022 Jeluchu - * - */ - -package com.jeluchu.jchucomponents.ui.migration.lists.grids - -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.Layout - -/** - * - * Author: @Jeluchu - * - * A custom layout to recreate a GridLayout which lays elements - * out vertically in evenly sized columns - * - * @param modifier modifier that will be used to change the color, size... - * @param columns number of columns to be displayed - * @param content the item to be painted within the layout - * - */ - -@Composable -fun VerticalGrid( - modifier: Modifier = Modifier, - columns: Int = 2, - content: @Composable () -> Unit -) { - Layout( - content = content, - modifier = modifier - ) { measurables, constraints -> - val itemWidth = constraints.maxWidth / columns - val itemConstraints = constraints.copy( - minWidth = itemWidth, - maxWidth = itemWidth - ) - val placeables = measurables.map { it.measure(itemConstraints) } - val columnHeights = Array(columns) { 0 } - placeables.forEachIndexed { index, placeable -> - val column = index % columns - columnHeights[column] += placeable.height - } - val height = (columnHeights.maxOrNull() ?: constraints.minHeight) - .coerceAtMost(constraints.maxHeight) - layout( - width = constraints.maxWidth, - height = height - ) { - val columnY = Array(columns) { 0 } - placeables.forEachIndexed { index, placeable -> - val column = index % columns - placeable.place( - x = column * itemWidth, - y = columnY[column] - ) - columnY[column] += placeable.height - } - } - } -} \ No newline at end of file diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/sheets/BottomSheetWithClose.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/sheets/BottomSheetWithClose.kt deleted file mode 100644 index 68e7e8ad..00000000 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/sheets/BottomSheetWithClose.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * Copyright 2022 Jeluchu - * - */ - -package com.jeluchu.jchucomponents.ui.migration.sheets - -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.Card -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Close -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp - -/** - * - * Author: @Jeluchu - * - * This component displays a BottomSheet with an icon to close it - * - * @param content change the color of the system notification bar - * @param modifier modifier that will be used to change the color, size... - * @param onClosePressed action that will be performed when the close button is pressed - * @param closeButtonColor color of the close button - * - */ - -@Composable -fun BottomSheetWithCloseDialog( - modifier: Modifier = Modifier, - cardCloseModifier: Modifier = Modifier - .width(125.dp) - .height(20.dp) - .padding(vertical = 8.dp), - isCardCloseShow: Boolean = true, - isCloseIconShow: Boolean = false, - closeButtonColor: Color = Color.Gray, - onClosePressed: () -> Unit = {}, - content: @Composable () -> Unit -) { - - Box(modifier.fillMaxWidth()) { - - if (isCardCloseShow) - Card( - modifier = cardCloseModifier.align(Alignment.TopCenter), - backgroundColor = closeButtonColor.copy(.6f), - shape = CircleShape, - elevation = 0.dp - ) {} - - content() - - if (isCloseIconShow) - IconButton( - onClick = onClosePressed, - modifier = Modifier - .align(Alignment.TopEnd) - .padding(16.dp) - .size(29.dp) - ) { Icon(Icons.Filled.Close, tint = closeButtonColor, contentDescription = null) } - - - } -} \ No newline at end of file diff --git a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/toolbars/SimpleToolbar.kt b/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/toolbars/SimpleToolbar.kt deleted file mode 100644 index 01e63daa..00000000 --- a/jchucomponents-ui/src/main/java/com/jeluchu/jchucomponents/ui/migration/toolbars/SimpleToolbar.kt +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * Copyright 2022 Jeluchu - * - */ - -package com.jeluchu.jchucomponents.ui.migration.toolbars - -import androidx.compose.foundation.layout.padding -import androidx.compose.material.Icon -import androidx.compose.material.IconButton -import androidx.compose.material.Text -import androidx.compose.material3.LocalTextStyle -import androidx.compose.material3.MaterialTheme -import androidx.compose.material.TopAppBar -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.res.vectorResource -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.jeluchu.jchucomponents.ktx.strings.empty -import com.jeluchu.jchucomponents.ui.R -import com.jeluchu.jchucomponents.ui.foundation.text.MarqueeText -import com.jeluchu.jchucomponents.ui.themes.artichoke - -@Composable -fun SimpleToolbar( - title: String = String.empty(), - backgroundColor: Color, - tintContent: Color = Color.DarkGray, - style: TextStyle = LocalTextStyle.current, - leftIcon: Int, - largeText: Boolean = false, - navigateAction: () -> Unit -) { - TopAppBar( - actions = { - if (!largeText) - Text( - text = title, - modifier = Modifier.padding(end = 15.dp), - color = tintContent, - style = style, - fontSize = 20.sp, - textAlign = TextAlign.End - ) - else - MarqueeText( - text = title, - modifier = Modifier.padding(end = 15.dp), - color = tintContent, - style = style, - fontSize = 20.sp, - textAlign = TextAlign.End, - gradientEdgeColor = Color.Transparent - ) - }, - title = {}, - backgroundColor = backgroundColor, - elevation = 0.dp, - navigationIcon = { - IconButton(onClick = navigateAction) { - Icon( - imageVector = ImageVector.vectorResource(id = leftIcon), - tint = tintContent, - contentDescription = null - ) - } - } - ) -} - -@Preview -@Composable -fun ToolbarSPreview() { - SimpleToolbar( - title = "titleBar", - backgroundColor = artichoke, - leftIcon = R.drawable.ic_arrow_left, - style = MaterialTheme.typography.titleLarge, - navigateAction = { } - ) -} \ No newline at end of file diff --git a/jchucomponents-ui/src/main/res/drawable/ic_btn_share.xml b/jchucomponents-ui/src/main/res/drawable/ic_btn_share.xml index d8ff075f..50a103d9 100644 --- a/jchucomponents-ui/src/main/res/drawable/ic_btn_share.xml +++ b/jchucomponents-ui/src/main/res/drawable/ic_btn_share.xml @@ -3,7 +3,7 @@ android:height="24dp" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/jchucomponents-ui/src/test/java/com/jeluchu/jchucomponents/ExampleUnitTest.kt b/jchucomponents-ui/src/test/java/com/jeluchu/jchucomponents/ExampleUnitTest.kt index 46887736..099e5f32 100644 --- a/jchucomponents-ui/src/test/java/com/jeluchu/jchucomponents/ExampleUnitTest.kt +++ b/jchucomponents-ui/src/test/java/com/jeluchu/jchucomponents/ExampleUnitTest.kt @@ -1,8 +1,7 @@ package com.jeluchu.jchucomponents -import org.junit.Test - import org.junit.Assert.* +import org.junit.Test /** * Example local unit test, which will execute on the development machine (host).