From 5f751e5d453b987156e6accd7b05ddc9c44943fe Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Sat, 13 Jul 2024 12:19:49 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[BASE]=20#13=20feature:addpokit=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/addpokit/.gitignore | 1 + feature/addpokit/build.gradle.kts | 43 +++++++++++++++++++ feature/addpokit/consumer-rules.pro | 0 feature/addpokit/proguard-rules.pro | 21 +++++++++ .../addpokit/ExampleInstrumentedTest.kt | 24 +++++++++++ feature/addpokit/src/main/AndroidManifest.xml | 4 ++ .../strayalpaca/addpokit/ExampleUnitTest.kt | 17 ++++++++ 7 files changed, 110 insertions(+) create mode 100644 feature/addpokit/.gitignore create mode 100644 feature/addpokit/build.gradle.kts create mode 100644 feature/addpokit/consumer-rules.pro create mode 100644 feature/addpokit/proguard-rules.pro create mode 100644 feature/addpokit/src/androidTest/java/com/strayalpaca/addpokit/ExampleInstrumentedTest.kt create mode 100644 feature/addpokit/src/main/AndroidManifest.xml create mode 100644 feature/addpokit/src/test/java/com/strayalpaca/addpokit/ExampleUnitTest.kt diff --git a/feature/addpokit/.gitignore b/feature/addpokit/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/feature/addpokit/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/feature/addpokit/build.gradle.kts b/feature/addpokit/build.gradle.kts new file mode 100644 index 00000000..98719b92 --- /dev/null +++ b/feature/addpokit/build.gradle.kts @@ -0,0 +1,43 @@ +plugins { + alias(libs.plugins.com.android.library) + alias(libs.plugins.org.jetbrains.kotlin.android) +} + +android { + namespace = "com.strayalpaca.addpokit" + compileSdk = 34 + + defaultConfig { + minSdk = 24 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles("consumer-rules.pro") + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } +} + +dependencies { + + implementation(libs.androidx.core.ktx) + implementation(libs.appcompat) + implementation(libs.material) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) +} diff --git a/feature/addpokit/consumer-rules.pro b/feature/addpokit/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/feature/addpokit/proguard-rules.pro b/feature/addpokit/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/feature/addpokit/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/feature/addpokit/src/androidTest/java/com/strayalpaca/addpokit/ExampleInstrumentedTest.kt b/feature/addpokit/src/androidTest/java/com/strayalpaca/addpokit/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..cfe6234b --- /dev/null +++ b/feature/addpokit/src/androidTest/java/com/strayalpaca/addpokit/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.strayalpaca.addpokit + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.strayalpaca.addpokit.test", appContext.packageName) + } +} diff --git a/feature/addpokit/src/main/AndroidManifest.xml b/feature/addpokit/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/feature/addpokit/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/feature/addpokit/src/test/java/com/strayalpaca/addpokit/ExampleUnitTest.kt b/feature/addpokit/src/test/java/com/strayalpaca/addpokit/ExampleUnitTest.kt new file mode 100644 index 00000000..6ac746b1 --- /dev/null +++ b/feature/addpokit/src/test/java/com/strayalpaca/addpokit/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.strayalpaca.addpokit + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} From fb3e800239c6e903c74cc9343c856583652b52a6 Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Sat, 13 Jul 2024 15:33:23 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[BASE]=20#13=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=EC=84=A0=ED=83=9D=EB=B6=80=EB=B6=84=EC=9D=84=20=EC=A0=9C?= =?UTF-8?q?=EC=99=B8=ED=95=9C=20=ED=8F=AC=ED=82=B7=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/addpokit/build.gradle.kts | 25 +- .../strayalpaca/addpokit/AddPokitScreen.kt | 225 ++++++++++++++++++ .../strayalpaca/addpokit/AddPokitViewModel.kt | 73 ++++++ .../java/com/strayalpaca/addpokit/Preview.kt | 26 ++ .../addpokit/components/block/Toolbar.kt | 53 +++++ .../addpokit/model/AddPokitScreenState.kt | 23 ++ .../com/strayalpaca/addpokit/model/Pokit.kt | 15 ++ .../addpokit/utils/BackPressHandler.kt | 36 +++ .../addpokit/src/main/res/values/string.xml | 11 + 9 files changed, 485 insertions(+), 2 deletions(-) create mode 100644 feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt create mode 100644 feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt create mode 100644 feature/addpokit/src/main/java/com/strayalpaca/addpokit/Preview.kt create mode 100644 feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/block/Toolbar.kt create mode 100644 feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/AddPokitScreenState.kt create mode 100644 feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/Pokit.kt create mode 100644 feature/addpokit/src/main/java/com/strayalpaca/addpokit/utils/BackPressHandler.kt create mode 100644 feature/addpokit/src/main/res/values/string.xml diff --git a/feature/addpokit/build.gradle.kts b/feature/addpokit/build.gradle.kts index 98719b92..0c700c02 100644 --- a/feature/addpokit/build.gradle.kts +++ b/feature/addpokit/build.gradle.kts @@ -23,6 +23,12 @@ android { ) } } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.5.1" + } compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 @@ -35,9 +41,24 @@ android { dependencies { implementation(libs.androidx.core.ktx) - implementation(libs.appcompat) - implementation(libs.material) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.ui) + implementation(libs.androidx.ui.graphics) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.material3) testImplementation(libs.junit) androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.ui.test.junit4) + debugImplementation(libs.androidx.ui.tooling) + debugImplementation(libs.androidx.ui.test.manifest) + + implementation(libs.orbit.compose) + implementation(libs.orbit.core) + implementation(libs.orbit.viewmodel) + + implementation(project(":core:ui")) } diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt new file mode 100644 index 00000000..e019d828 --- /dev/null +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt @@ -0,0 +1,225 @@ +package com.strayalpaca.addpokit + +import androidx.compose.foundation.Image +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.ColorFilter +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import com.strayalpaca.addpokit.components.block.Toolbar +import com.strayalpaca.addpokit.model.AddPokitScreenState +import com.strayalpaca.addpokit.model.AddPokitScreenStep +import com.strayalpaca.addpokit.model.AddPokitSideEffect +import com.strayalpaca.addpokit.model.Pokit +import com.strayalpaca.addpokit.utils.BackPressHandler +import org.orbitmvi.orbit.compose.collectSideEffect +import pokitmons.pokit.core.ui.components.atom.button.PokitButton +import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonSize +import pokitmons.pokit.core.ui.components.block.labeledinput.LabeledInput +import pokitmons.pokit.core.ui.components.block.pokitlist.PokitList +import pokitmons.pokit.core.ui.components.block.pokitlist.attributes.PokitListState +import pokitmons.pokit.core.ui.theme.PokitTheme + +@Composable +fun AddPokitScreenContainer( + viewModel: AddPokitViewModel, + onBackPressed: () -> Unit, +) { + val state by viewModel.container.stateFlow.collectAsState() + + val pokitName by viewModel.pokitName.collectAsState() + + val saveButtonEnable = remember { + derivedStateOf { + state.step != AddPokitScreenStep.POKIT_SAVE_LOADING && + state.step != AddPokitScreenStep.POKIT_LIST_LOADING && + state.pokitInputErrorMessage == null + } + } + + viewModel.collectSideEffect { sideEffect -> + when (sideEffect) { + AddPokitSideEffect.AddPokitSuccess -> { + onBackPressed() + } + + AddPokitSideEffect.OnNavigationBack -> { + onBackPressed() + } + } + } + + BackPressHandler(onBackPressed = viewModel::onBackPressed) + + AddPokitScreen( + pokitName = pokitName, + state = state, + saveButtonEnable = saveButtonEnable.value, + onclickAddPokit = viewModel::savePokit, + inputPokitName = viewModel::inputPokitName, + onBackPressed = viewModel::onBackPressed + ) +} + +@Composable +fun AddPokitScreen( + pokitName: String = "", + state: AddPokitScreenState = AddPokitScreenState(), + saveButtonEnable: Boolean = true, + onclickAddPokit: () -> Unit = {}, + inputPokitName: (String) -> Unit = {}, + onBackPressed: () -> Unit = {}, +) { + + Column( + modifier = Modifier + .fillMaxSize() + .padding(vertical = 16.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Toolbar( + onClickBack = onBackPressed, + title = stringResource(id = R.string.title_add_pokit) + ) + + Box(modifier = Modifier.size(80.dp)) { + Image( + painter = painterResource(id = pokitmons.pokit.core.ui.R.drawable.icon_24_google), + contentDescription = null, + modifier = Modifier + .size(80.dp) + .clip(shape = RoundedCornerShape(12.dp)) + ) + + Box( + modifier = Modifier + .align(Alignment.BottomEnd) + .offset(x = 7.dp, y = (-7).dp) + .size(24.dp) + .background( + color = PokitTheme.colors.inverseWh, + shape = CircleShape + ) + .border( + width = 1.dp, + color = PokitTheme.colors.borderSecondary, + shape = CircleShape + ) + .clip( + shape = CircleShape + ) + .clickable { + + } + .padding(3.dp) + ) { + Image( + painter = painterResource(id = pokitmons.pokit.core.ui.R.drawable.icon_24_edit), + contentDescription = "null", + modifier = Modifier + .size(18.dp), + colorFilter = ColorFilter.tint( + color = PokitTheme.colors.iconTertiary + ) + ) + } + } + + Spacer(modifier = Modifier.height(12.dp)) + + LabeledInput( + modifier = Modifier.padding(horizontal = 20.dp), + label = stringResource(id = R.string.pokit_name), + inputText = pokitName, + hintText = stringResource(id = R.string.placeholder_pokit_name), + onChangeText = inputPokitName, + isError = state.pokitInputErrorMessage != null, + sub = state.pokitInputErrorMessage?.let { stringResource(id = it.resourceId) } ?: "", + enable = (state.step != AddPokitScreenStep.POKIT_SAVE_LOADING), + maxLength = 10 + ) + + Spacer(modifier = Modifier.height(28.dp)) + + Text( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp), + text = stringResource(id = R.string.my_pokit), + style = PokitTheme.typography.body2Medium.copy(color = PokitTheme.colors.textSecondary) + ) + + Spacer(modifier = Modifier.height(8.dp)) + + Box( + modifier = Modifier + .fillMaxSize() + .weight(1f), + contentAlignment = Alignment.Center + ) { + LazyColumn( + modifier = Modifier.fillMaxSize() + ) { + items(state.pokitList) { item: Pokit -> + PokitList( + item = item, + title = item.title, + sub = stringResource(id = pokitmons.pokit.core.ui.R.string.pokit_count_format, item.count), + onClickKebab = {}, + onClickItem = {}, + state = PokitListState.DEFAULT + ) + } + } + + if (state.step == AddPokitScreenStep.POKIT_LIST_LOADING) { + CircularProgressIndicator( + modifier = Modifier.width(64.dp), + color = PokitTheme.colors.brand, + trackColor = PokitTheme.colors.backgroundSecondary, + ) + } + } + + Box( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp) + ) { + PokitButton( + text = stringResource(id = R.string.save), + icon = null, + onClick = onclickAddPokit, + modifier = Modifier.fillMaxWidth(), + size = PokitButtonSize.LARGE, + enable = saveButtonEnable + ) + } + } +} diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt new file mode 100644 index 00000000..64a80209 --- /dev/null +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt @@ -0,0 +1,73 @@ +package com.strayalpaca.addpokit + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.strayalpaca.addpokit.model.AddPokitScreenState +import com.strayalpaca.addpokit.model.AddPokitScreenStep +import com.strayalpaca.addpokit.model.AddPokitSideEffect +import com.strayalpaca.addpokit.model.PokitInputErrorMessage +import com.strayalpaca.addpokit.model.samplePokitList +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch +import org.orbitmvi.orbit.Container +import org.orbitmvi.orbit.ContainerHost +import org.orbitmvi.orbit.syntax.simple.intent +import org.orbitmvi.orbit.syntax.simple.reduce +import org.orbitmvi.orbit.viewmodel.container + +class AddPokitViewModel : ContainerHost, ViewModel() { + override val container: Container = container(AddPokitScreenState()) + + private val _pokitName = MutableStateFlow("") + val pokitName : StateFlow = _pokitName.asStateFlow() + + init { + loadPokitList() + } + + private fun loadPokitList() = intent { + viewModelScope.launch { + reduce { + state.copy( + step = AddPokitScreenStep.POKIT_LIST_LOADING, + pokitInputErrorMessage = null, + pokitList = emptyList() + ) + } + // todo 포킷 리스트 로드 api 연동 + delay(1000L) + + reduce { + state.copy( + step = AddPokitScreenStep.IDLE, + pokitList = samplePokitList + ) + } + } + } + + fun inputPokitName(pokitName : String) { + _pokitName.update { pokitName } + + intent { + val errorMessage = if (pokitName.length > 10) { + PokitInputErrorMessage.TEXT_LENGTH_LIMIT + } else { + null + } + reduce { state.copy(pokitInputErrorMessage = errorMessage) } + } + } + + fun savePokit() { + + } + + fun onBackPressed() { + + } +} diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/Preview.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/Preview.kt new file mode 100644 index 00000000..cc051b9a --- /dev/null +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/Preview.kt @@ -0,0 +1,26 @@ +package com.strayalpaca.addpokit + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import com.strayalpaca.addpokit.model.AddPokitScreenState +import com.strayalpaca.addpokit.model.samplePokitList +import pokitmons.pokit.core.ui.theme.PokitTheme + +@Preview(showBackground = true) +@Composable +fun Preview( + +) { + PokitTheme { + Column( + modifier = Modifier.fillMaxSize() + ) { + AddPokitScreen( + state = AddPokitScreenState().copy(pokitList = samplePokitList) + ) + } + } +} diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/block/Toolbar.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/block/Toolbar.kt new file mode 100644 index 00000000..9648c186 --- /dev/null +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/block/Toolbar.kt @@ -0,0 +1,53 @@ +package com.strayalpaca.addpokit.components.block + +import androidx.compose.foundation.layout.Arrangement +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.size +import androidx.compose.foundation.layout.width +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import pokitmons.pokit.core.ui.theme.PokitTheme + +@Composable +internal fun Toolbar( + onClickBack: () -> Unit, + title: String, + modifier: Modifier = Modifier, +) { + Row( + modifier = modifier + .height(56.dp) + .padding(horizontal = 12.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center + ) { + IconButton( + modifier = Modifier.size(48.dp), + onClick = onClickBack + ) { + Icon( + painter = painterResource(id = pokitmons.pokit.core.ui.R.drawable.icon_24_arrow_left), + contentDescription = "back button" + ) + } + + Text( + modifier = Modifier.weight(1f), + text = title, + style = PokitTheme.typography.title3.copy(color = PokitTheme.colors.textPrimary), + textAlign = TextAlign.Center + ) + + Spacer(modifier = Modifier.width(48.dp)) + } +} diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/AddPokitScreenState.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/AddPokitScreenState.kt new file mode 100644 index 00000000..9987403c --- /dev/null +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/AddPokitScreenState.kt @@ -0,0 +1,23 @@ +package com.strayalpaca.addpokit.model + +import com.strayalpaca.addpokit.R + +data class AddPokitScreenState( + val pokitInputErrorMessage: PokitInputErrorMessage? = null, + val pokitList : List = emptyList(), + val step : AddPokitScreenStep = AddPokitScreenStep.POKIT_LIST_LOADING +) + +enum class AddPokitScreenStep { + IDLE, POKIT_LIST_LOADING, POKIT_SAVE_LOADING, SELECT_POKIT_IMAGE +} + +sealed class AddPokitSideEffect { + data object AddPokitSuccess : AddPokitSideEffect() + data object OnNavigationBack : AddPokitSideEffect() +} + +enum class PokitInputErrorMessage(val resourceId : Int) { + TEXT_LENGTH_LIMIT(R.string.text_length_limit_format), + ALREADY_USED_POKIT_NAME(R.string.already_used_pokit_name) +} diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/Pokit.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/Pokit.kt new file mode 100644 index 00000000..1b004274 --- /dev/null +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/Pokit.kt @@ -0,0 +1,15 @@ +package com.strayalpaca.addpokit.model + +data class Pokit( + val title: String, + val id: String, + val count: Int, +) + +internal val samplePokitList = listOf( + Pokit(title = "안드로이드", id = "1", count = 2), + Pokit(title = "IOS", id = "2", count = 2), + Pokit(title = "디자인", id = "3", count = 2), + Pokit(title = "PM", id = "4", count = 1), + Pokit(title = "서버", id = "5", count = 2) +) diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/utils/BackPressHandler.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/utils/BackPressHandler.kt new file mode 100644 index 00000000..8726170c --- /dev/null +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/utils/BackPressHandler.kt @@ -0,0 +1,36 @@ +package com.strayalpaca.addpokit.utils + +import androidx.activity.OnBackPressedCallback +import androidx.activity.OnBackPressedDispatcher +import androidx.activity.compose.LocalOnBackPressedDispatcherOwner +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberUpdatedState + + +@Composable +internal fun BackPressHandler( + backPressedDispatcher: OnBackPressedDispatcher? = + LocalOnBackPressedDispatcherOwner.current?.onBackPressedDispatcher, + onBackPressed: () -> Unit, +) { + val currentOnBackPressed by rememberUpdatedState(newValue = onBackPressed) + + val backCallback = remember { + object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + currentOnBackPressed() + } + } + } + + DisposableEffect(backPressedDispatcher) { + backPressedDispatcher?.addCallback(backCallback) + + onDispose { + backCallback.remove() + } + } +} diff --git a/feature/addpokit/src/main/res/values/string.xml b/feature/addpokit/src/main/res/values/string.xml new file mode 100644 index 00000000..09e348fc --- /dev/null +++ b/feature/addpokit/src/main/res/values/string.xml @@ -0,0 +1,11 @@ + + + 포킷 추가 + 포킷 이름 + 카테고리 이름을 입력해주세요. + 저장하기 + 내 포킷 + + 최대 10자까지 입력 가능합니다. + 사용 중인 포킷명입니다. + \ No newline at end of file From 29d281f8de980049eb31d7d316c8d2f4f3edb42f Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Sun, 14 Jul 2024 10:29:51 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[FEATURE]=20#13=20=ED=8F=AC=ED=82=B7=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=84=A0=ED=83=9D=EB=B6=80?= =?UTF-8?q?=EB=B6=84=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../addpokit/ExampleInstrumentedTest.kt | 6 +-- .../strayalpaca/addpokit/AddPokitScreen.kt | 48 ++++++++++++++--- .../strayalpaca/addpokit/AddPokitViewModel.kt | 52 +++++++++++++++++-- .../components/atom/PokitProfileImage.kt | 48 +++++++++++++++++ .../addpokit/model/AddPokitScreenState.kt | 18 ++++--- .../addpokit/model/PokitProfile.kt | 13 +++++ .../strayalpaca/addpokit/ExampleUnitTest.kt | 3 +- 7 files changed, 163 insertions(+), 25 deletions(-) create mode 100644 feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/atom/PokitProfileImage.kt create mode 100644 feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/PokitProfile.kt diff --git a/feature/addpokit/src/androidTest/java/com/strayalpaca/addpokit/ExampleInstrumentedTest.kt b/feature/addpokit/src/androidTest/java/com/strayalpaca/addpokit/ExampleInstrumentedTest.kt index cfe6234b..943ab772 100644 --- a/feature/addpokit/src/androidTest/java/com/strayalpaca/addpokit/ExampleInstrumentedTest.kt +++ b/feature/addpokit/src/androidTest/java/com/strayalpaca/addpokit/ExampleInstrumentedTest.kt @@ -1,13 +1,11 @@ package com.strayalpaca.addpokit -import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 - +import androidx.test.platform.app.InstrumentationRegistry +import org.junit.Assert.assertEquals 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/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt index e019d828..240e52db 100644 --- a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt @@ -4,6 +4,7 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer @@ -15,6 +16,9 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape @@ -32,11 +36,14 @@ import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import com.strayalpaca.addpokit.components.atom.PokitProfileImage import com.strayalpaca.addpokit.components.block.Toolbar import com.strayalpaca.addpokit.model.AddPokitScreenState import com.strayalpaca.addpokit.model.AddPokitScreenStep import com.strayalpaca.addpokit.model.AddPokitSideEffect import com.strayalpaca.addpokit.model.Pokit +import com.strayalpaca.addpokit.model.PokitProfile +import com.strayalpaca.addpokit.model.samplePokitProfileList import com.strayalpaca.addpokit.utils.BackPressHandler import org.orbitmvi.orbit.compose.collectSideEffect import pokitmons.pokit.core.ui.components.atom.button.PokitButton @@ -44,6 +51,7 @@ import pokitmons.pokit.core.ui.components.atom.button.attributes.PokitButtonSize import pokitmons.pokit.core.ui.components.block.labeledinput.LabeledInput import pokitmons.pokit.core.ui.components.block.pokitlist.PokitList import pokitmons.pokit.core.ui.components.block.pokitlist.attributes.PokitListState +import pokitmons.pokit.core.ui.components.template.bottomsheet.PokitBottomSheet import pokitmons.pokit.core.ui.theme.PokitTheme @Composable @@ -52,14 +60,14 @@ fun AddPokitScreenContainer( onBackPressed: () -> Unit, ) { val state by viewModel.container.stateFlow.collectAsState() - val pokitName by viewModel.pokitName.collectAsState() val saveButtonEnable = remember { derivedStateOf { state.step != AddPokitScreenStep.POKIT_SAVE_LOADING && state.step != AddPokitScreenStep.POKIT_LIST_LOADING && - state.pokitInputErrorMessage == null + state.pokitInputErrorMessage == null && + state.pokitProfile != null } } @@ -83,7 +91,10 @@ fun AddPokitScreenContainer( saveButtonEnable = saveButtonEnable.value, onclickAddPokit = viewModel::savePokit, inputPokitName = viewModel::inputPokitName, - onBackPressed = viewModel::onBackPressed + onBackPressed = viewModel::onBackPressed, + hideProfileSelectBottomSheet = viewModel::hidePokitProfileSelectBottomSheet, + showSelectProfileBottomSheet = viewModel::showPokitProfileSelectBottomSheet, + selectPokitProfileImage = viewModel::selectPoktiProfile ) } @@ -95,8 +106,10 @@ fun AddPokitScreen( onclickAddPokit: () -> Unit = {}, inputPokitName: (String) -> Unit = {}, onBackPressed: () -> Unit = {}, + hideProfileSelectBottomSheet: () -> Unit = {}, + showSelectProfileBottomSheet: () -> Unit = {}, + selectPokitProfileImage: (PokitProfile) -> Unit = {}, ) { - Column( modifier = Modifier .fillMaxSize() @@ -134,9 +147,9 @@ fun AddPokitScreen( .clip( shape = CircleShape ) - .clickable { - - } + .clickable( + onClick = showSelectProfileBottomSheet + ) .padding(3.dp) ) { Image( @@ -202,7 +215,7 @@ fun AddPokitScreen( CircularProgressIndicator( modifier = Modifier.width(64.dp), color = PokitTheme.colors.brand, - trackColor = PokitTheme.colors.backgroundSecondary, + trackColor = PokitTheme.colors.backgroundSecondary ) } } @@ -221,5 +234,24 @@ fun AddPokitScreen( enable = saveButtonEnable ) } + + if (state.step == AddPokitScreenStep.SELECT_PROFILE) { + PokitBottomSheet(onHideBottomSheet = hideProfileSelectBottomSheet) { + LazyVerticalGrid( + modifier = Modifier.padding(vertical = 12.dp, horizontal = 40.dp), + columns = GridCells.Adaptive(66.dp), + horizontalArrangement = Arrangement.spacedBy(20.dp), + verticalArrangement = Arrangement.spacedBy(12.dp) + ) { + items(samplePokitProfileList) { profileImage -> + PokitProfileImage( + pokitProfile = profileImage, + onClick = selectPokitProfileImage, + focused = (state.pokitProfile?.id == profileImage.id) + ) + } + } + } + } } } diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt index 64a80209..a5a3fe69 100644 --- a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt @@ -6,6 +6,7 @@ import com.strayalpaca.addpokit.model.AddPokitScreenState import com.strayalpaca.addpokit.model.AddPokitScreenStep import com.strayalpaca.addpokit.model.AddPokitSideEffect import com.strayalpaca.addpokit.model.PokitInputErrorMessage +import com.strayalpaca.addpokit.model.PokitProfile import com.strayalpaca.addpokit.model.samplePokitList import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow @@ -16,6 +17,7 @@ import kotlinx.coroutines.launch import org.orbitmvi.orbit.Container import org.orbitmvi.orbit.ContainerHost import org.orbitmvi.orbit.syntax.simple.intent +import org.orbitmvi.orbit.syntax.simple.postSideEffect import org.orbitmvi.orbit.syntax.simple.reduce import org.orbitmvi.orbit.viewmodel.container @@ -23,7 +25,7 @@ class AddPokitViewModel : ContainerHost override val container: Container = container(AddPokitScreenState()) private val _pokitName = MutableStateFlow("") - val pokitName : StateFlow = _pokitName.asStateFlow() + val pokitName: StateFlow = _pokitName.asStateFlow() init { loadPokitList() @@ -50,12 +52,17 @@ class AddPokitViewModel : ContainerHost } } - fun inputPokitName(pokitName : String) { + fun inputPokitName(pokitName: String) { _pokitName.update { pokitName } intent { - val errorMessage = if (pokitName.length > 10) { + val isInAvailableLength = pokitName.length > 10 + val isDuplicatePokitName = state.pokitList.find { it.title == pokitName } != null + + val errorMessage = if (isInAvailableLength) { PokitInputErrorMessage.TEXT_LENGTH_LIMIT + } else if (isDuplicatePokitName) { + PokitInputErrorMessage.ALREADY_USED_POKIT_NAME } else { null } @@ -63,11 +70,46 @@ class AddPokitViewModel : ContainerHost } } - fun savePokit() { + fun savePokit() = intent { + reduce { + state.copy(step = AddPokitScreenStep.POKIT_SAVE_LOADING) + } + // todo 포킷 저장 api 연동 + delay(1000L) + reduce { + state.copy(step = AddPokitScreenStep.IDLE) + } + postSideEffect(AddPokitSideEffect.AddPokitSuccess) + } + fun onBackPressed() = intent { + val currentStep = state.step + when (currentStep) { + AddPokitScreenStep.POKIT_SAVE_LOADING -> {} // discard + AddPokitScreenStep.SELECT_PROFILE -> { + reduce { state.copy(step = AddPokitScreenStep.IDLE) } + } + else -> { + postSideEffect(AddPokitSideEffect.OnNavigationBack) + } + } } - fun onBackPressed() { + fun showPokitProfileSelectBottomSheet() = intent { + reduce { + state.copy(step = AddPokitScreenStep.SELECT_PROFILE) + } + } + + fun hidePokitProfileSelectBottomSheet() = intent { + reduce { + state.copy(step = AddPokitScreenStep.IDLE) + } + } + fun selectPoktiProfile(pokitProfile: PokitProfile) = intent { + reduce { + state.copy(pokitProfile = pokitProfile) + } } } diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/atom/PokitProfileImage.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/atom/PokitProfileImage.kt new file mode 100644 index 00000000..285a6a00 --- /dev/null +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/atom/PokitProfileImage.kt @@ -0,0 +1,48 @@ +package com.strayalpaca.addpokit.components.atom + +import androidx.compose.foundation.Image +import androidx.compose.foundation.border +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp +import com.strayalpaca.addpokit.model.PokitProfile +import pokitmons.pokit.core.ui.theme.PokitTheme + +@Composable +fun PokitProfileImage( + pokitProfile: PokitProfile, + onClick: (PokitProfile) -> Unit, + focused: Boolean = false, +) { + val activeStrokeColor = PokitTheme.colors.brand + val strokeColor = remember(focused) { + if (focused) { + activeStrokeColor + } else { + Color.Unspecified + } + } + + Image( + painter = painterResource(id = pokitmons.pokit.core.ui.R.drawable.icon_24_plus_r), + contentDescription = "pokit profile image", + modifier = Modifier + .size(66.dp) + .clip(shape = RoundedCornerShape(12.dp)) + .clickable { + onClick(pokitProfile) + } + .border( + color = strokeColor, + width = 1.dp, + shape = RoundedCornerShape(12.dp) + ) + ) +} diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/AddPokitScreenState.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/AddPokitScreenState.kt index 9987403c..511ee69c 100644 --- a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/AddPokitScreenState.kt +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/AddPokitScreenState.kt @@ -1,15 +1,21 @@ package com.strayalpaca.addpokit.model +import androidx.compose.runtime.Immutable import com.strayalpaca.addpokit.R +@Immutable data class AddPokitScreenState( val pokitInputErrorMessage: PokitInputErrorMessage? = null, - val pokitList : List = emptyList(), - val step : AddPokitScreenStep = AddPokitScreenStep.POKIT_LIST_LOADING + val pokitList: List = emptyList(), + val step: AddPokitScreenStep = AddPokitScreenStep.POKIT_LIST_LOADING, + val pokitProfile: PokitProfile? = null, ) -enum class AddPokitScreenStep { - IDLE, POKIT_LIST_LOADING, POKIT_SAVE_LOADING, SELECT_POKIT_IMAGE +sealed class AddPokitScreenStep { + data object IDLE : AddPokitScreenStep() + data object POKIT_LIST_LOADING : AddPokitScreenStep() + data object POKIT_SAVE_LOADING : AddPokitScreenStep() + data object SELECT_PROFILE : AddPokitScreenStep() } sealed class AddPokitSideEffect { @@ -17,7 +23,7 @@ sealed class AddPokitSideEffect { data object OnNavigationBack : AddPokitSideEffect() } -enum class PokitInputErrorMessage(val resourceId : Int) { +enum class PokitInputErrorMessage(val resourceId: Int) { TEXT_LENGTH_LIMIT(R.string.text_length_limit_format), - ALREADY_USED_POKIT_NAME(R.string.already_used_pokit_name) + ALREADY_USED_POKIT_NAME(R.string.already_used_pokit_name), } diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/PokitProfile.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/PokitProfile.kt new file mode 100644 index 00000000..41274e56 --- /dev/null +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/model/PokitProfile.kt @@ -0,0 +1,13 @@ +package com.strayalpaca.addpokit.model + +data class PokitProfile( + val id: String, +) + +internal val samplePokitProfileList = + listOf( + PokitProfile("1"), PokitProfile("2"), PokitProfile("3"), PokitProfile("4"), + PokitProfile("5"), PokitProfile("6"), PokitProfile("7"), PokitProfile("8"), + PokitProfile("9"), PokitProfile("10"), PokitProfile("11"), PokitProfile("12"), + PokitProfile("13"), PokitProfile("14"), PokitProfile("15") + ) diff --git a/feature/addpokit/src/test/java/com/strayalpaca/addpokit/ExampleUnitTest.kt b/feature/addpokit/src/test/java/com/strayalpaca/addpokit/ExampleUnitTest.kt index 6ac746b1..03eade60 100644 --- a/feature/addpokit/src/test/java/com/strayalpaca/addpokit/ExampleUnitTest.kt +++ b/feature/addpokit/src/test/java/com/strayalpaca/addpokit/ExampleUnitTest.kt @@ -1,9 +1,8 @@ package com.strayalpaca.addpokit +import org.junit.Assert.assertEquals import org.junit.Test -import org.junit.Assert.* - /** * Example local unit test, which will execute on the development machine (host). * From 318788bed835a34c74e5e77a9e1df182838f8eb7 Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Sun, 14 Jul 2024 10:30:47 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[CHORE]=20#13=20ktlint=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/strayalpaca/addpokit/Preview.kt | 4 +--- .../java/com/strayalpaca/addpokit/utils/BackPressHandler.kt | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/Preview.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/Preview.kt index cc051b9a..dbb00c58 100644 --- a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/Preview.kt +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/Preview.kt @@ -11,9 +11,7 @@ import pokitmons.pokit.core.ui.theme.PokitTheme @Preview(showBackground = true) @Composable -fun Preview( - -) { +fun Preview() { PokitTheme { Column( modifier = Modifier.fillMaxSize() diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/utils/BackPressHandler.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/utils/BackPressHandler.kt index 8726170c..2459aad0 100644 --- a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/utils/BackPressHandler.kt +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/utils/BackPressHandler.kt @@ -9,7 +9,6 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.runtime.rememberUpdatedState - @Composable internal fun BackPressHandler( backPressedDispatcher: OnBackPressedDispatcher? = From 06578b70677f9faac3c6112f4299e32f6498b4a0 Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Sun, 14 Jul 2024 14:31:28 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[CHORE]=20#13=20=ED=8F=AC=ED=82=B7=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=B5=9C=EB=8C=80=20=EA=B8=80=EC=9E=90?= =?UTF-8?q?=EC=88=98=20=EC=83=81=EC=88=98=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt | 3 ++- .../src/main/java/com/strayalpaca/addpokit/const/Consts.kt | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 feature/addpokit/src/main/java/com/strayalpaca/addpokit/const/Consts.kt diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt index a5a3fe69..590775db 100644 --- a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitViewModel.kt @@ -2,6 +2,7 @@ package com.strayalpaca.addpokit import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.strayalpaca.addpokit.const.POKIT_NAME_MAX_LENGTH import com.strayalpaca.addpokit.model.AddPokitScreenState import com.strayalpaca.addpokit.model.AddPokitScreenStep import com.strayalpaca.addpokit.model.AddPokitSideEffect @@ -56,7 +57,7 @@ class AddPokitViewModel : ContainerHost _pokitName.update { pokitName } intent { - val isInAvailableLength = pokitName.length > 10 + val isInAvailableLength = pokitName.length > POKIT_NAME_MAX_LENGTH val isDuplicatePokitName = state.pokitList.find { it.title == pokitName } != null val errorMessage = if (isInAvailableLength) { diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/const/Consts.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/const/Consts.kt new file mode 100644 index 00000000..9ec703a4 --- /dev/null +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/const/Consts.kt @@ -0,0 +1,3 @@ +package com.strayalpaca.addpokit.const + +internal const val POKIT_NAME_MAX_LENGTH = 10 From 8a2b365a8398a366c5684df9ad39905f4b12d138 Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Sun, 14 Jul 2024 14:36:16 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[CHORE]=20#13=20core=20=EB=AA=A8=EB=93=88?= =?UTF-8?q?=20resource=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=EC=9D=84=20alias=20import=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/strayalpaca/addpokit/AddPokitScreen.kt | 8 +++++--- .../addpokit/components/atom/PokitProfileImage.kt | 3 ++- .../com/strayalpaca/addpokit/components/block/Toolbar.kt | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt index 240e52db..120d66be 100644 --- a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/AddPokitScreen.kt @@ -53,6 +53,8 @@ import pokitmons.pokit.core.ui.components.block.pokitlist.PokitList import pokitmons.pokit.core.ui.components.block.pokitlist.attributes.PokitListState import pokitmons.pokit.core.ui.components.template.bottomsheet.PokitBottomSheet import pokitmons.pokit.core.ui.theme.PokitTheme +import pokitmons.pokit.core.ui.R.drawable as coreDrawable +import pokitmons.pokit.core.ui.R.string as coreString @Composable fun AddPokitScreenContainer( @@ -123,7 +125,7 @@ fun AddPokitScreen( Box(modifier = Modifier.size(80.dp)) { Image( - painter = painterResource(id = pokitmons.pokit.core.ui.R.drawable.icon_24_google), + painter = painterResource(id = coreDrawable.icon_24_google), contentDescription = null, modifier = Modifier .size(80.dp) @@ -153,7 +155,7 @@ fun AddPokitScreen( .padding(3.dp) ) { Image( - painter = painterResource(id = pokitmons.pokit.core.ui.R.drawable.icon_24_edit), + painter = painterResource(id = coreDrawable.icon_24_edit), contentDescription = "null", modifier = Modifier .size(18.dp), @@ -203,7 +205,7 @@ fun AddPokitScreen( PokitList( item = item, title = item.title, - sub = stringResource(id = pokitmons.pokit.core.ui.R.string.pokit_count_format, item.count), + sub = stringResource(id = coreString.pokit_count_format, item.count), onClickKebab = {}, onClickItem = {}, state = PokitListState.DEFAULT diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/atom/PokitProfileImage.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/atom/PokitProfileImage.kt index 285a6a00..91579c71 100644 --- a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/atom/PokitProfileImage.kt +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/atom/PokitProfileImage.kt @@ -14,6 +14,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp import com.strayalpaca.addpokit.model.PokitProfile import pokitmons.pokit.core.ui.theme.PokitTheme +import pokitmons.pokit.core.ui.R.drawable as coreDrawable @Composable fun PokitProfileImage( @@ -31,7 +32,7 @@ fun PokitProfileImage( } Image( - painter = painterResource(id = pokitmons.pokit.core.ui.R.drawable.icon_24_plus_r), + painter = painterResource(id = coreDrawable.icon_24_plus_r), contentDescription = "pokit profile image", modifier = Modifier .size(66.dp) diff --git a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/block/Toolbar.kt b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/block/Toolbar.kt index 9648c186..8154ecce 100644 --- a/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/block/Toolbar.kt +++ b/feature/addpokit/src/main/java/com/strayalpaca/addpokit/components/block/Toolbar.kt @@ -17,6 +17,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import pokitmons.pokit.core.ui.theme.PokitTheme +import pokitmons.pokit.core.ui.R.drawable as coreDrawable @Composable internal fun Toolbar( @@ -36,7 +37,7 @@ internal fun Toolbar( onClick = onClickBack ) { Icon( - painter = painterResource(id = pokitmons.pokit.core.ui.R.drawable.icon_24_arrow_left), + painter = painterResource(id = coreDrawable.icon_24_arrow_left), contentDescription = "back button" ) }