From d03f102b300afad438e35ee9094f7c4c7e76f87c Mon Sep 17 00:00:00 2001 From: Petrus Nguyen Thai Hoc Date: Sat, 22 Jan 2022 17:44:19 +0700 Subject: [PATCH 1/8] feat(UI): migrate to Material Design 3 --- app/build.gradle.kts | 1 + app/src/main/java/com/hoc/flowmvi/App.kt | 4 ++ buildSrc/src/main/kotlin/deps.kt | 2 +- core-ui/src/main/res/values-night/themes.xml | 31 ++++++++++ core-ui/src/main/res/values/colors.xml | 59 +++++++++++++++++-- core-ui/src/main/res/values/styles.xml | 12 +--- core-ui/src/main/res/values/themes.xml | 30 ++++++++++ .../res/layout/item_recycler_search_user.xml | 2 +- 8 files changed, 124 insertions(+), 17 deletions(-) create mode 100644 core-ui/src/main/res/values-night/themes.xml create mode 100644 core-ui/src/main/res/values/themes.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0f04686a..0e998616 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -66,6 +66,7 @@ dependencies { implementation(deps.coroutines.android) implementation(deps.koin.android) + implementation(deps.androidx.material) debugImplementation(deps.squareup.leakCanary) implementation(deps.timber) diff --git a/app/src/main/java/com/hoc/flowmvi/App.kt b/app/src/main/java/com/hoc/flowmvi/App.kt index 2b5ad671..27bd8819 100644 --- a/app/src/main/java/com/hoc/flowmvi/App.kt +++ b/app/src/main/java/com/hoc/flowmvi/App.kt @@ -1,6 +1,7 @@ package com.hoc.flowmvi import android.app.Application +import com.google.android.material.color.DynamicColors import com.hoc.flowmvi.core.coreModule import com.hoc.flowmvi.data.dataModule import com.hoc.flowmvi.domain.domainModule @@ -20,6 +21,7 @@ import kotlin.time.ExperimentalTime @ExperimentalCoroutinesApi @ExperimentalStdlibApi @ExperimentalTime +@JvmField val allModules = listOf( coreModule, dataModule, @@ -38,6 +40,8 @@ class App : Application() { override fun onCreate() { super.onCreate() + DynamicColors.applyToActivitiesIfAvailable(this) + if (BuildConfig.DEBUG) { Timber.plant(Timber.DebugTree()) } else { diff --git a/buildSrc/src/main/kotlin/deps.kt b/buildSrc/src/main/kotlin/deps.kt index ad167305..0ead56b6 100644 --- a/buildSrc/src/main/kotlin/deps.kt +++ b/buildSrc/src/main/kotlin/deps.kt @@ -32,7 +32,7 @@ object deps { const val constraintLayout = "androidx.constraintlayout:constraintlayout:2.1.1" const val recyclerView = "androidx.recyclerview:recyclerview:1.2.1" const val swipeRefreshLayout = "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01" - const val material = "com.google.android.material:material:1.4.0" + const val material = "com.google.android.material:material:1.5.0" } object lifecycle { diff --git a/core-ui/src/main/res/values-night/themes.xml b/core-ui/src/main/res/values-night/themes.xml new file mode 100644 index 00000000..2fdca66c --- /dev/null +++ b/core-ui/src/main/res/values-night/themes.xml @@ -0,0 +1,31 @@ + + + + diff --git a/core-ui/src/main/res/values/colors.xml b/core-ui/src/main/res/values/colors.xml index 030098fe..6593bda4 100644 --- a/core-ui/src/main/res/values/colors.xml +++ b/core-ui/src/main/res/values/colors.xml @@ -1,6 +1,57 @@ - - #6200EE - #3700B3 - #03DAC5 + #6750A4 + #FFFFFF + #EADDFF + #21005D + #625B71 + #FFFFFF + #E8DEF8 + #1D192B + #7D5260 + #FFFFFF + #FFD8E4 + #31111D + #B3261E + #F9DEDC + #FFFFFF + #410E0B + #FFFBFE + #1C1B1F + #FFFBFE + #1C1B1F + #E7E0EC + #49454F + #79747E + #F4EFF4 + #313033 + #D0BCFF + + #D0BCFF + #381E72 + #4F378B + #EADDFF + #CCC2DC + #332D41 + #4A4458 + #E8DEF8 + #EFB8C8 + #492532 + #633B48 + #FFD8E4 + #F2B8B5 + #8C1D18 + #601410 + #F9DEDC + #1C1B1F + #E6E1E5 + #1C1B1F + #E6E1E5 + #49454F + #CAC4D0 + #938F99 + #1C1B1F + #E6E1E5 + #6750A4 + #6750A4 + #B3261E diff --git a/core-ui/src/main/res/values/styles.xml b/core-ui/src/main/res/values/styles.xml index 1c56072b..2c5844dd 100644 --- a/core-ui/src/main/res/values/styles.xml +++ b/core-ui/src/main/res/values/styles.xml @@ -1,11 +1 @@ - - - - - - + diff --git a/core-ui/src/main/res/values/themes.xml b/core-ui/src/main/res/values/themes.xml new file mode 100644 index 00000000..066f0166 --- /dev/null +++ b/core-ui/src/main/res/values/themes.xml @@ -0,0 +1,30 @@ + + + diff --git a/feature-search/src/main/res/layout/item_recycler_search_user.xml b/feature-search/src/main/res/layout/item_recycler_search_user.xml index 4431f021..dae01809 100644 --- a/feature-search/src/main/res/layout/item_recycler_search_user.xml +++ b/feature-search/src/main/res/layout/item_recycler_search_user.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@android:color/white" + android:background="?attr/backgroundColor" tools:layout_width="150dp"> Date: Sat, 22 Jan 2022 17:50:40 +0700 Subject: [PATCH 2/8] feat(UI): migrate to Material Design 3 --- core-ui/src/main/res/values/themes.xml | 2 +- feature-main/src/main/res/layout/activity_main.xml | 1 - .../src/main/res/layout/item_recycler_search_user.xml | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core-ui/src/main/res/values/themes.xml b/core-ui/src/main/res/values/themes.xml index 066f0166..01983e75 100644 --- a/core-ui/src/main/res/values/themes.xml +++ b/core-ui/src/main/res/values/themes.xml @@ -1,5 +1,5 @@ - + diff --git a/core-ui/src/main/res/values/colors.xml b/core-ui/src/main/res/values/colors.xml index 6593bda4..9d27b0d3 100644 --- a/core-ui/src/main/res/values/colors.xml +++ b/core-ui/src/main/res/values/colors.xml @@ -1,57 +1,58 @@ - #6750A4 - #FFFFFF - #EADDFF - #21005D - #625B71 - #FFFFFF - #E8DEF8 - #1D192B - #7D5260 - #FFFFFF - #FFD8E4 - #31111D - #B3261E - #F9DEDC - #FFFFFF - #410E0B - #FFFBFE - #1C1B1F - #FFFBFE - #1C1B1F - #E7E0EC - #49454F - #79747E - #F4EFF4 - #313033 - #D0BCFF + #6750A4 + #FFFFFF + #EADDFF + #21005D + #625B71 + #FFFFFF + #E8DEF8 + #1D192B + #7D5260 + #FFFFFF + #FFD8E4 + #31111D + #B3261E + #F9DEDC + #FFFFFF + #410E0B + #FFFBFE + #1C1B1F + #FFFBFE + #1C1B1F + #E7E0EC + #49454F + #79747E + #F4EFF4 + #313033 + #D0BCFF - #D0BCFF - #381E72 - #4F378B - #EADDFF - #CCC2DC - #332D41 - #4A4458 - #E8DEF8 - #EFB8C8 - #492532 - #633B48 - #FFD8E4 - #F2B8B5 - #8C1D18 - #601410 - #F9DEDC - #1C1B1F - #E6E1E5 - #1C1B1F - #E6E1E5 - #49454F - #CAC4D0 - #938F99 - #1C1B1F - #E6E1E5 - #6750A4 - #6750A4 - #B3261E + #D0BCFF + #381E72 + #4F378B + #EADDFF + #CCC2DC + #332D41 + #4A4458 + #E8DEF8 + #EFB8C8 + #492532 + #633B48 + #FFD8E4 + #F2B8B5 + #8C1D18 + #601410 + #F9DEDC + #1C1B1F + #E6E1E5 + #1C1B1F + #E6E1E5 + #49454F + #CAC4D0 + #938F99 + #1C1B1F + #E6E1E5 + #6750A4 + #6750A4 + #B3261E + #f44336 From a86079e9f0cf64170be2b79fcbb436c0696c26de Mon Sep 17 00:00:00 2001 From: Petrus Nguyen Thai Hoc Date: Fri, 28 Jan 2022 01:01:24 +0700 Subject: [PATCH 6/8] feat(UI): migrate to Material Design 3 --- .../main/java/com/hoc/flowmvi/core_ui/ContextExtensions.kt | 4 +++- core-ui/src/main/res/values/colors.xml | 4 ++-- .../src/main/java/com/hoc/flowmvi/ui/main/MainActivity.kt | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core-ui/src/main/java/com/hoc/flowmvi/core_ui/ContextExtensions.kt b/core-ui/src/main/java/com/hoc/flowmvi/core_ui/ContextExtensions.kt index 40bc25cb..6f559a20 100644 --- a/core-ui/src/main/java/com/hoc/flowmvi/core_ui/ContextExtensions.kt +++ b/core-ui/src/main/java/com/hoc/flowmvi/core_ui/ContextExtensions.kt @@ -2,9 +2,11 @@ package com.hoc.flowmvi.core_ui import android.content.Context import android.widget.Toast +import androidx.annotation.Px @Suppress("NOTHING_TO_INLINE") inline fun Context.toast(text: CharSequence) = Toast.makeText(this, text, Toast.LENGTH_SHORT).show() +@Px @Suppress("NOTHING_TO_INLINE") -inline fun Context.dpToPx(dp: Int): Int = (dp * resources.displayMetrics.density).toInt() +inline fun Context.dpToPx(dp: Float): Int = (dp * resources.displayMetrics.density).toInt() diff --git a/core-ui/src/main/res/values/colors.xml b/core-ui/src/main/res/values/colors.xml index 9d27b0d3..fd84d864 100644 --- a/core-ui/src/main/res/values/colors.xml +++ b/core-ui/src/main/res/values/colors.xml @@ -21,7 +21,7 @@ #1C1B1F #E7E0EC #49454F - #79747E + #9A989C #F4EFF4 #313033 #D0BCFF @@ -48,7 +48,7 @@ #E6E1E5 #49454F #CAC4D0 - #938F99 + #6D6775 #1C1B1F #E6E1E5 #6750A4 diff --git a/feature-main/src/main/java/com/hoc/flowmvi/ui/main/MainActivity.kt b/feature-main/src/main/java/com/hoc/flowmvi/ui/main/MainActivity.kt index 48dbd17e..3231e46e 100644 --- a/feature-main/src/main/java/com/hoc/flowmvi/ui/main/MainActivity.kt +++ b/feature-main/src/main/java/com/hoc/flowmvi/ui/main/MainActivity.kt @@ -65,9 +65,10 @@ class MainActivity : adapter = userAdapter addItemDecoration( MaterialDividerItemDecoration(context, RecyclerView.VERTICAL).apply { - dividerInsetStart = dpToPx(8) - dividerInsetEnd = dpToPx(8) + dividerInsetStart = dpToPx(8f) + dividerInsetEnd = dpToPx(8f) isLastItemDecorated = false + dividerThickness = dpToPx(0.8f) } ) From 79f51c645ee0504ef03ee95ba641f95a9d554fb8 Mon Sep 17 00:00:00 2001 From: Petrus Nguyen Thai Hoc Date: Fri, 28 Jan 2022 19:52:24 +0700 Subject: [PATCH 7/8] feat(UI): migrate to Material Design 3 --- .../java/com/hoc/flowmvi/core_ui/SwipeLeftToDeleteCallback.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-ui/src/main/java/com/hoc/flowmvi/core_ui/SwipeLeftToDeleteCallback.kt b/core-ui/src/main/java/com/hoc/flowmvi/core_ui/SwipeLeftToDeleteCallback.kt index 099ed9f5..39b5ad6b 100644 --- a/core-ui/src/main/java/com/hoc/flowmvi/core_ui/SwipeLeftToDeleteCallback.kt +++ b/core-ui/src/main/java/com/hoc/flowmvi/core_ui/SwipeLeftToDeleteCallback.kt @@ -44,7 +44,7 @@ class SwipeLeftToDeleteCallback(context: Context, private val onSwipedCallback: val itemView = viewHolder.itemView when { - dX < 0 && isCurrentlyActive -> { + dX < 0 -> { val iconMargin = (itemView.height - iconDelete.intrinsicHeight) / 2 val iconTop = itemView.top + iconMargin val iconBottom = iconTop + iconDelete.intrinsicHeight From 26b3ab76ec2b4316c5026c41f9ea7fe7179ec206 Mon Sep 17 00:00:00 2001 From: Petrus Nguyen Thai Hoc Date: Fri, 28 Jan 2022 21:01:16 +0700 Subject: [PATCH 8/8] feat(UI): migrate to Material Design 3 --- feature-add/src/main/res/layout/activity_add.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/feature-add/src/main/res/layout/activity_add.xml b/feature-add/src/main/res/layout/activity_add.xml index bf4992ec..5a145e88 100644 --- a/feature-add/src/main/res/layout/activity_add.xml +++ b/feature-add/src/main/res/layout/activity_add.xml @@ -23,6 +23,7 @@