Skip to content

Commit d982875

Browse files
authored
feat(UI): migrate to Material Design 3 (#91)
* feat(UI): migrate to Material Design 3 * feat(UI): migrate to Material Design 3 * feat(UI): migrate to Material Design 3 * feat(UI): migrate to Material Design 3 * feat(UI): migrate to Material Design 3 * feat(UI): migrate to Material Design 3 * feat(UI): migrate to Material Design 3 * feat(UI): migrate to Material Design 3
1 parent df1479f commit d982875

File tree

22 files changed

+207
-55
lines changed

22 files changed

+207
-55
lines changed

.editorconfig

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
root = true
22

33
[*]
4-
indent_size=2
5-
end_of_line=lf
6-
charset=utf-8
7-
trim_trailing_whitespace=true
8-
insert_final_newline=true
4+
indent_size = 2
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
99

1010
[*.{kt,kts}]
11-
ij_kotlin_imports_layout=*
11+
ij_kotlin_imports_layout = *
12+
13+
[*.xml]
14+
indent_size = 4

.idea/compiler.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ dependencies {
6666

6767
implementation(deps.coroutines.android)
6868
implementation(deps.koin.android)
69+
implementation(deps.androidx.material)
6970

7071
debugImplementation(deps.squareup.leakCanary)
7172
implementation(deps.timber)

app/src/main/java/com/hoc/flowmvi/App.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.hoc.flowmvi
22

33
import android.app.Application
4+
import com.google.android.material.color.DynamicColors
45
import com.hoc.flowmvi.core.coreModule
56
import com.hoc.flowmvi.data.dataModule
67
import com.hoc.flowmvi.domain.domainModule
@@ -20,6 +21,7 @@ import kotlin.time.ExperimentalTime
2021
@ExperimentalCoroutinesApi
2122
@ExperimentalStdlibApi
2223
@ExperimentalTime
24+
@JvmField
2325
val allModules = listOf(
2426
coreModule,
2527
dataModule,
@@ -38,6 +40,8 @@ class App : Application() {
3840
override fun onCreate() {
3941
super.onCreate()
4042

43+
DynamicColors.applyToActivitiesIfAvailable(this)
44+
4145
if (BuildConfig.DEBUG) {
4246
Timber.plant(Timber.DebugTree())
4347
} else {

buildSrc/src/main/kotlin/deps.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ object deps {
3232
const val constraintLayout = "androidx.constraintlayout:constraintlayout:2.1.1"
3333
const val recyclerView = "androidx.recyclerview:recyclerview:1.2.1"
3434
const val swipeRefreshLayout = "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01"
35-
const val material = "com.google.android.material:material:1.4.0"
35+
const val material = "com.google.android.material:material:1.6.0-alpha02"
3636
}
3737

3838
object lifecycle {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.hoc.flowmvi.core_ui
2+
3+
import android.content.Context
4+
import android.widget.Toast
5+
import androidx.annotation.Px
6+
7+
@Suppress("NOTHING_TO_INLINE")
8+
inline fun Context.toast(text: CharSequence) = Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
9+
10+
@Px
11+
@Suppress("NOTHING_TO_INLINE")
12+
inline fun Context.dpToPx(dp: Float): Int = (dp * resources.displayMetrics.density).toInt()

core-ui/src/main/java/com/hoc/flowmvi/core_ui/FlowBinding.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.hoc.flowmvi.core_ui
22

3-
import android.content.Context
43
import android.os.Looper
54
import android.view.View
65
import android.widget.EditText
7-
import android.widget.Toast
86
import androidx.annotation.CheckResult
97
import androidx.appcompat.widget.SearchView
108
import androidx.core.widget.doOnTextChanged
@@ -121,5 +119,3 @@ fun EditText.textChanges(): Flow<CharSequence?> {
121119
awaitClose { removeTextChangedListener(listener) }
122120
}.onStart { emit(text) }
123121
}
124-
125-
fun Context.toast(text: CharSequence) = Toast.makeText(this, text, Toast.LENGTH_SHORT).show()

core-ui/src/main/java/com/hoc/flowmvi/core_ui/SwipeLeftToDeleteCallback.kt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@ package com.hoc.flowmvi.core_ui
22

33
import android.content.Context
44
import android.graphics.Canvas
5-
import android.graphics.Color
65
import android.graphics.drawable.ColorDrawable
7-
import androidx.core.content.ContextCompat
6+
import androidx.core.content.ContextCompat.getColor
7+
import androidx.core.content.ContextCompat.getDrawable
88
import androidx.recyclerview.widget.ItemTouchHelper
99
import androidx.recyclerview.widget.RecyclerView
10+
import kotlin.LazyThreadSafetyMode.NONE
1011

1112
class SwipeLeftToDeleteCallback(context: Context, private val onSwipedCallback: (Int) -> Unit) :
1213
ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT) {
13-
private val background: ColorDrawable = ColorDrawable(Color.parseColor("#f44336"))
14-
private val iconDelete =
15-
ContextCompat.getDrawable(context, R.drawable.ic_baseline_delete_white_24)!!
14+
private val background: ColorDrawable by lazy(NONE) {
15+
ColorDrawable(getColor(context, R.color.swipe_to_delete_background_color))
16+
}
17+
private val iconDelete by lazy(NONE) {
18+
getDrawable(context, R.drawable.ic_baseline_delete_white_24)!!
19+
}
1620

1721
override fun onMove(
1822
recyclerView: RecyclerView,
1923
viewHolder: RecyclerView.ViewHolder,
20-
target: RecyclerView.ViewHolder
24+
target: RecyclerView.ViewHolder,
2125
) = false
2226

2327
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
@@ -34,7 +38,7 @@ class SwipeLeftToDeleteCallback(context: Context, private val onSwipedCallback:
3438
dX: Float,
3539
dY: Float,
3640
actionState: Int,
37-
isCurrentlyActive: Boolean
41+
isCurrentlyActive: Boolean,
3842
) {
3943
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
4044
val itemView = viewHolder.itemView
@@ -56,7 +60,10 @@ class SwipeLeftToDeleteCallback(context: Context, private val onSwipedCallback:
5660
itemView.bottom
5761
)
5862
}
59-
else -> background.setBounds(0, 0, 0, 0)
63+
else -> {
64+
background.setBounds(0, 0, 0, 0)
65+
iconDelete.setBounds(0, 0, 0, 0)
66+
}
6067
}
6168
background.draw(c)
6269
iconDelete.draw(c)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<resources>
2+
3+
<style name="AppTheme" parent="Theme.Material3.DayNight">
4+
<item name="colorPrimary">@color/md_theme_dark_primary</item>
5+
<item name="colorOnPrimary">@color/md_theme_dark_onPrimary</item>
6+
<item name="colorPrimaryContainer">@color/md_theme_dark_primaryContainer</item>
7+
<item name="colorOnPrimaryContainer">@color/md_theme_dark_onPrimaryContainer</item>
8+
<item name="colorSecondary">@color/md_theme_dark_secondary</item>
9+
<item name="colorOnSecondary">@color/md_theme_dark_onSecondary</item>
10+
<item name="colorSecondaryContainer">@color/md_theme_dark_secondaryContainer</item>
11+
<item name="colorOnSecondaryContainer">@color/md_theme_dark_onSecondaryContainer</item>
12+
<item name="colorTertiary">@color/md_theme_dark_tertiary</item>
13+
<item name="colorOnTertiary">@color/md_theme_dark_onTertiary</item>
14+
<item name="colorTertiaryContainer">@color/md_theme_dark_tertiaryContainer</item>
15+
<item name="colorOnTertiaryContainer">@color/md_theme_dark_onTertiaryContainer</item>
16+
<item name="colorError">@color/md_theme_dark_error</item>
17+
<item name="colorErrorContainer">@color/md_theme_dark_errorContainer</item>
18+
<item name="colorOnError">@color/md_theme_dark_onError</item>
19+
<item name="colorOnErrorContainer">@color/md_theme_dark_onErrorContainer</item>
20+
<item name="android:colorBackground">@color/md_theme_dark_background</item>
21+
<item name="colorOnBackground">@color/md_theme_dark_onBackground</item>
22+
<item name="colorSurface">@color/md_theme_dark_surface</item>
23+
<item name="colorOnSurface">@color/md_theme_dark_onSurface</item>
24+
<item name="colorSurfaceVariant">@color/md_theme_dark_surfaceVariant</item>
25+
<item name="colorOnSurfaceVariant">@color/md_theme_dark_onSurfaceVariant</item>
26+
<item name="colorOutline">@color/md_theme_dark_outline</item>
27+
<item name="colorOnSurfaceInverse">@color/md_theme_dark_inverseOnSurface</item>
28+
<item name="colorSurfaceInverse">@color/md_theme_dark_inverseSurface</item>
29+
<item name="colorPrimaryInverse">@color/md_theme_dark_primaryInverse</item>
30+
</style>
31+
</resources>
Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,58 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<resources>
3-
<color name="colorPrimary">#6200EE</color>
4-
<color name="colorPrimaryDark">#3700B3</color>
5-
<color name="colorAccent">#03DAC5</color>
2+
<color name="md_theme_light_primary">#6750A4</color>
3+
<color name="md_theme_light_onPrimary">#FFFFFF</color>
4+
<color name="md_theme_light_primaryContainer">#EADDFF</color>
5+
<color name="md_theme_light_onPrimaryContainer">#21005D</color>
6+
<color name="md_theme_light_secondary">#625B71</color>
7+
<color name="md_theme_light_onSecondary">#FFFFFF</color>
8+
<color name="md_theme_light_secondaryContainer">#E8DEF8</color>
9+
<color name="md_theme_light_onSecondaryContainer">#1D192B</color>
10+
<color name="md_theme_light_tertiary">#7D5260</color>
11+
<color name="md_theme_light_onTertiary">#FFFFFF</color>
12+
<color name="md_theme_light_tertiaryContainer">#FFD8E4</color>
13+
<color name="md_theme_light_onTertiaryContainer">#31111D</color>
14+
<color name="md_theme_light_error">#B3261E</color>
15+
<color name="md_theme_light_errorContainer">#F9DEDC</color>
16+
<color name="md_theme_light_onError">#FFFFFF</color>
17+
<color name="md_theme_light_onErrorContainer">#410E0B</color>
18+
<color name="md_theme_light_background">#FFFBFE</color>
19+
<color name="md_theme_light_onBackground">#1C1B1F</color>
20+
<color name="md_theme_light_surface">#FFFBFE</color>
21+
<color name="md_theme_light_onSurface">#1C1B1F</color>
22+
<color name="md_theme_light_surfaceVariant">#E7E0EC</color>
23+
<color name="md_theme_light_onSurfaceVariant">#49454F</color>
24+
<color name="md_theme_light_outline">#9A989C</color>
25+
<color name="md_theme_light_inverseOnSurface">#F4EFF4</color>
26+
<color name="md_theme_light_inverseSurface">#313033</color>
27+
<color name="md_theme_light_primaryInverse">#D0BCFF</color>
28+
29+
<color name="md_theme_dark_primary">#D0BCFF</color>
30+
<color name="md_theme_dark_onPrimary">#381E72</color>
31+
<color name="md_theme_dark_primaryContainer">#4F378B</color>
32+
<color name="md_theme_dark_onPrimaryContainer">#EADDFF</color>
33+
<color name="md_theme_dark_secondary">#CCC2DC</color>
34+
<color name="md_theme_dark_onSecondary">#332D41</color>
35+
<color name="md_theme_dark_secondaryContainer">#4A4458</color>
36+
<color name="md_theme_dark_onSecondaryContainer">#E8DEF8</color>
37+
<color name="md_theme_dark_tertiary">#EFB8C8</color>
38+
<color name="md_theme_dark_onTertiary">#492532</color>
39+
<color name="md_theme_dark_tertiaryContainer">#633B48</color>
40+
<color name="md_theme_dark_onTertiaryContainer">#FFD8E4</color>
41+
<color name="md_theme_dark_error">#F2B8B5</color>
42+
<color name="md_theme_dark_errorContainer">#8C1D18</color>
43+
<color name="md_theme_dark_onError">#601410</color>
44+
<color name="md_theme_dark_onErrorContainer">#F9DEDC</color>
45+
<color name="md_theme_dark_background">#1C1B1F</color>
46+
<color name="md_theme_dark_onBackground">#E6E1E5</color>
47+
<color name="md_theme_dark_surface">#1C1B1F</color>
48+
<color name="md_theme_dark_onSurface">#E6E1E5</color>
49+
<color name="md_theme_dark_surfaceVariant">#49454F</color>
50+
<color name="md_theme_dark_onSurfaceVariant">#CAC4D0</color>
51+
<color name="md_theme_dark_outline">#6D6775</color>
52+
<color name="md_theme_dark_inverseOnSurface">#1C1B1F</color>
53+
<color name="md_theme_dark_inverseSurface">#E6E1E5</color>
54+
<color name="md_theme_dark_primaryInverse">#6750A4</color>
55+
<color name="seed">#6750A4</color>
56+
<color name="error">#B3261E</color>
57+
<color name="swipe_to_delete_background_color">#f44336</color>
658
</resources>
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
<resources>
2-
3-
<!-- Base application theme. -->
4-
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
5-
<!-- Customize your theme here. -->
6-
<item name="colorPrimary">@color/colorPrimary</item>
7-
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8-
<item name="colorAccent">@color/colorAccent</item>
9-
</style>
10-
11-
</resources>
1+
<resources />

0 commit comments

Comments
 (0)