diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..44caefc --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +Noostak-Android \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml new file mode 100644 index 0000000..b268ef3 --- /dev/null +++ b/.idea/deploymentTargetSelector.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..faa8c9c --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..6d0ee1c --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..481db9d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/other.xml b/.idea/other.xml new file mode 100644 index 0000000..a76f118 --- /dev/null +++ b/.idea/other.xml @@ -0,0 +1,329 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..4bcddf1 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,139 @@ + +import java.util.Properties + +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.serialization) + alias(libs.plugins.ksp) + alias(libs.plugins.hilt) + alias(libs.plugins.ktlint) + alias(libs.plugins.compose.compiler) +} + +val properties = + Properties().apply { load(project.rootProject.file("local.properties").inputStream()) } + +android { + namespace = "com.sopt.noostak" + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + applicationId = "com.sopt.noostak" + minSdk = libs.versions.minSdk.get().toInt() + targetSdk = libs.versions.targetSdk.get().toInt() + versionCode = libs.versions.versionCode.get().toInt() + versionName = libs.versions.versionName.get() + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + buildConfigField("String", "BASE_URL", properties["base.url"].toString()) + } + + 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 = libs.versions.jvmTarget.get() + } + buildFeatures { + compose = true + buildConfig = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +dependencies { + implementation(project(":core")) + implementation(project(":data")) + implementation(project(":domain")) + implementation(project(":presentation")) + + // Compose + implementation(libs.compose.compiler) + implementation(platform(libs.compose.bom)) + implementation(libs.ui) + implementation(libs.ui.tooling.preview) + implementation(libs.material3.compose) + implementation(libs.activity.compose) + implementation(libs.hilt.navigation.compose) + implementation(libs.lifecycle.compose) + implementation(libs.constraintlayout.compose) + + // Kotlin + implementation(libs.kotlinx.coroutines.android) + implementation(libs.kotlinx.coroutines.core) + implementation(libs.kotlinx.serialization.json) + implementation(libs.kotlinx.coroutines.test) + implementation(libs.kotlinx.datetime) + implementation(libs.kotlinx.collections) + + // AndroidX Core + implementation(libs.core.ktx) + implementation(libs.androidx.activity.ktx) + implementation(libs.androidx.splashscreen) + implementation(libs.androidx.paging) + implementation(libs.androidx.paging.common) + implementation(libs.androidx.paging.compose) + implementation(libs.accompanist.insets) + + // Hilt (Dependency Injection) + implementation(libs.hilt.android) + ksp(libs.hilt.compiler) + implementation(libs.javax.inject) + + // Retrofit (Networking) + implementation(libs.retrofit.core) + implementation(libs.retrofit.kotlin.serialization) + implementation(libs.okhttp.logging) + + // Image Loading + implementation(libs.coil.compose) + + // Logging + implementation(libs.timber) + + // DataStore (Local Storage) + implementation(libs.androidx.datastore.core) + implementation(libs.androidx.datastore.preferences) + implementation(libs.encrypted.datastore.preference.ksp) + implementation(libs.encrypted.datastore.preference.ksp.annotations) + implementation(libs.encrypted.datastore.preference.security) + + // ViewPager Indicator + implementation(libs.viewpager.indicator) + + // Testing + testImplementation(libs.junit) + androidTestImplementation(libs.espresso.core) + androidTestImplementation(platform(libs.compose.bom)) + androidTestImplementation(libs.ui.test.junit4) + debugImplementation(libs.ui.tooling) + debugImplementation(libs.ui.test.manifest) + + // Accompanist System UI Controller + implementation(libs.accompanist.systemuicontroller) + + // Kakao + implementation(libs.kakao.all) + implementation(libs.kakao.user) +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/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/app/src/androidTest/java/com/sopt/noostak/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/sopt/noostak/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..541591a --- /dev/null +++ b/app/src/androidTest/java/com/sopt/noostak/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.sopt.noostak + +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.sopt.noostak", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..9bc2bef --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/sopt/noostak/MyApp.kt b/app/src/main/java/com/sopt/noostak/MyApp.kt new file mode 100644 index 0000000..30d6058 --- /dev/null +++ b/app/src/main/java/com/sopt/noostak/MyApp.kt @@ -0,0 +1,17 @@ +package com.sopt.noostak + +import android.app.Application +import dagger.hilt.android.HiltAndroidApp +import timber.log.Timber + +@HiltAndroidApp +class MyApp : Application() { + override fun onCreate() { + super.onCreate() + setTimber() + } + + private fun setTimber() { + Timber.plant(Timber.DebugTree()) + } +} diff --git a/app/src/main/java/com/sopt/noostak/di/DataSourceModule.kt b/app/src/main/java/com/sopt/noostak/di/DataSourceModule.kt new file mode 100644 index 0000000..5a3d784 --- /dev/null +++ b/app/src/main/java/com/sopt/noostak/di/DataSourceModule.kt @@ -0,0 +1,18 @@ +package com.sopt.noostak.di + +import com.sopt.data.datasource.ExampleDataSource +import com.sopt.data.datasourceimpl.ExampleDataSourceImpl +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +abstract class DataSourceModule { + + @Binds + @Singleton + abstract fun bindExampleDataSource(exampleDataSourceImpl: ExampleDataSourceImpl): ExampleDataSource +} diff --git a/app/src/main/java/com/sopt/noostak/di/Qualifier.kt b/app/src/main/java/com/sopt/noostak/di/Qualifier.kt new file mode 100644 index 0000000..07021c1 --- /dev/null +++ b/app/src/main/java/com/sopt/noostak/di/Qualifier.kt @@ -0,0 +1,7 @@ +package com.sopt.noostak.di + +import javax.inject.Qualifier + +@Qualifier +@Retention(AnnotationRetention.BINARY) +annotation class ExampleRetrofit diff --git a/app/src/main/java/com/sopt/noostak/di/RepositoryModule.kt b/app/src/main/java/com/sopt/noostak/di/RepositoryModule.kt new file mode 100644 index 0000000..120b139 --- /dev/null +++ b/app/src/main/java/com/sopt/noostak/di/RepositoryModule.kt @@ -0,0 +1,18 @@ +package com.sopt.noostak.di + +import com.sopt.data.repositoryimpl.ExampleRepositoryImpl +import com.sopt.domain.repository.ExampleRepository +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +abstract class RepositoryModule { + + @Binds + @Singleton + abstract fun bindExampleRepository(exampleRepositoryImpl: ExampleRepositoryImpl): ExampleRepository +} diff --git a/app/src/main/java/com/sopt/noostak/di/RetrofitModule.kt b/app/src/main/java/com/sopt/noostak/di/RetrofitModule.kt new file mode 100644 index 0000000..9c3b346 --- /dev/null +++ b/app/src/main/java/com/sopt/noostak/di/RetrofitModule.kt @@ -0,0 +1,57 @@ +package com.sopt.noostak.di + +import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory +import com.sopt.core.extension.isJsonArray +import com.sopt.core.extension.isJsonObject +import com.sopt.noostak.BuildConfig.BASE_URL +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import kotlinx.serialization.json.Json +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor +import org.json.JSONArray +import org.json.JSONObject +import retrofit2.Retrofit +import timber.log.Timber +import java.util.concurrent.TimeUnit +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object RetrofitModule { + @Provides + @Singleton + fun provideOkHttpClient( + loggingInterceptor: HttpLoggingInterceptor + ): OkHttpClient = OkHttpClient.Builder() + .addInterceptor(loggingInterceptor) + .connectTimeout(30, TimeUnit.SECONDS) + .readTimeout(30, TimeUnit.SECONDS) + .build() + + @Provides + @Singleton + fun provideLoggingInterceptor(): HttpLoggingInterceptor { + val loggingInterceptor = HttpLoggingInterceptor { message -> + when { + message.isJsonObject() -> Timber.d(JSONObject(message).toString(4)) + message.isJsonArray() -> Timber.d(JSONArray(message).toString(4)) + else -> Timber.d("CONNECTION INFO -> $message") + } + } + loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY + return loggingInterceptor + } + + @Singleton + @Provides + @ExampleRetrofit + fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit = Retrofit.Builder() + .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) + .client(okHttpClient) + .baseUrl(BASE_URL) + .build() +} diff --git a/app/src/main/java/com/sopt/noostak/di/ServiceModule.kt b/app/src/main/java/com/sopt/noostak/di/ServiceModule.kt new file mode 100644 index 0000000..7207fff --- /dev/null +++ b/app/src/main/java/com/sopt/noostak/di/ServiceModule.kt @@ -0,0 +1,20 @@ +package com.sopt.noostak.di + +import com.sopt.data.service.ExampleApiService +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import retrofit2.Retrofit +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object ServiceModule { + + @Provides + @Singleton + fun provideExampleService( + @ExampleRetrofit retrofit: Retrofit + ): ExampleApiService = retrofit.create(ExampleApiService::class.java) +} diff --git a/app/src/test/java/com/sopt/noostak/ExampleUnitTest.kt b/app/src/test/java/com/sopt/noostak/ExampleUnitTest.kt new file mode 100644 index 0000000..a0e8664 --- /dev/null +++ b/app/src/test/java/com/sopt/noostak/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.sopt.noostak + +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) + } +} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..0962c22 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,19 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.android.library) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.kotlin.jvm) apply false + alias(libs.plugins.kotlin.serialization) apply false + alias(libs.plugins.ksp) apply false + alias(libs.plugins.hilt) apply false + alias(libs.plugins.ktlint) apply false + alias(libs.plugins.compose.compiler) apply false +} + +buildscript { + repositories { + google() + mavenCentral() + } +} \ No newline at end of file diff --git a/core/.gitignore b/core/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/core/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts new file mode 100644 index 0000000..540d32d --- /dev/null +++ b/core/build.gradle.kts @@ -0,0 +1,60 @@ +plugins { + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.compose.compiler) +} + +android { + namespace = "com.sopt.core" + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + minSdk = libs.versions.minSdk.get().toInt() + + 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 = libs.versions.jvmTarget.get() + } + buildFeatures { + compose = true + buildConfig = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() + } +} + +dependencies { + implementation(libs.kotlin) + implementation(libs.core.ktx) + implementation(libs.material) + + // Test + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.espresso.core) + + implementation(libs.ui.tooling.preview) + implementation(libs.material3.compose) + implementation(libs.ui.tooling) + + // Third Party + implementation(libs.coil.compose) + implementation(libs.lottie.compose) +} \ No newline at end of file diff --git a/core/consumer-rules.pro b/core/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/core/proguard-rules.pro b/core/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/core/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/core/src/androidTest/java/com/sopt/core/ExampleInstrumentedTest.kt b/core/src/androidTest/java/com/sopt/core/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..6d33b94 --- /dev/null +++ b/core/src/androidTest/java/com/sopt/core/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.sopt.core + +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.sopt.core.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/core/src/main/AndroidManifest.xml b/core/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a5918e6 --- /dev/null +++ b/core/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/designsystem/component/bottomsheet/BaseBottomSheet.kt b/core/src/main/java/com/sopt/core/designsystem/component/bottomsheet/BaseBottomSheet.kt new file mode 100644 index 0000000..7a424d3 --- /dev/null +++ b/core/src/main/java/com/sopt/core/designsystem/component/bottomsheet/BaseBottomSheet.kt @@ -0,0 +1,24 @@ +package com.sopt.core.designsystem.component.bottomsheet + +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.ModalBottomSheet +import androidx.compose.material3.SheetState +import androidx.compose.material3.rememberModalBottomSheetState +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun BaseBottomSheet( + content: @Composable () -> Unit, + onDismissRequest: () -> Unit, + sheetState: SheetState = rememberModalBottomSheetState() +) { + ModalBottomSheet( + onDismissRequest = { onDismissRequest() }, + sheetState = sheetState, + containerColor = Color.White, + ) { + content() + } +} \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/designsystem/component/button/BaseButton.kt b/core/src/main/java/com/sopt/core/designsystem/component/button/BaseButton.kt new file mode 100644 index 0000000..194407b --- /dev/null +++ b/core/src/main/java/com/sopt/core/designsystem/component/button/BaseButton.kt @@ -0,0 +1,52 @@ +package com.sopt.core.designsystem.component.button + +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.LocalRippleConfiguration +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import com.sopt.core.util.NoRippleConfiguration + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun BaseButton( + shape: Shape, + style: TextStyle, + paddingHorizontal: Dp = 0.dp, + paddingVertical: Dp, + text: String, + onButtonClick: () -> Unit, + modifier: Modifier = Modifier, + isEnabled: Boolean = true, +) { + CompositionLocalProvider(value = LocalRippleConfiguration provides NoRippleConfiguration) { + Button( + modifier = modifier, + shape = shape, + colors = ButtonDefaults.buttonColors( + containerColor = Color.Gray + ), + contentPadding = PaddingValues( + vertical = paddingVertical, + horizontal = paddingHorizontal + ), + onClick = { onButtonClick() }, + enabled = isEnabled + ) { + Text( + text = text, + color = Color.White, + style = style + ) + } + } +} \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/designsystem/component/dialog/BaseDialog.kt b/core/src/main/java/com/sopt/core/designsystem/component/dialog/BaseDialog.kt new file mode 100644 index 0000000..ab05732 --- /dev/null +++ b/core/src/main/java/com/sopt/core/designsystem/component/dialog/BaseDialog.kt @@ -0,0 +1,77 @@ +package com.sopt.core.designsystem.component.dialog + +import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Icon +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.Dialog +import androidx.compose.ui.window.DialogProperties +import com.sopt.core.R +import com.sopt.core.designsystem.theme.NoostakAndroidTheme + +@Composable +fun BaseDialog( + onDismissRequest: () -> Unit, + properties: DialogProperties = DialogProperties( + usePlatformDefaultWidth = false, + decorFitsSystemWindows = true, + dismissOnBackPress = true, + dismissOnClickOutside = true, + ), + content: @Composable () -> Unit, +) { + Dialog( + onDismissRequest = { onDismissRequest() }, + properties = properties, + ) { + Box( + modifier = Modifier + .wrapContentSize() + .padding(horizontal = 30.dp) + .background( + color = Color.White, + shape = RoundedCornerShape(20.dp) + ), + ) { + Row( + modifier = Modifier + .fillMaxWidth() + .padding(top = 18.dp, bottom = 16.dp) + .padding(horizontal = 16.dp), + horizontalArrangement = Arrangement.End + ) { + Icon( + painter = painterResource(id = R.drawable.ic_back), + contentDescription = null, + tint = Color.Gray, + modifier = Modifier + .clickable { onDismissRequest() } + ) + } + content() + } + } +} + +@Preview +@Composable +fun BaseDialogPreview() { + NoostakAndroidTheme { + BaseDialog( + onDismissRequest = {}, + content = {} + ) + } +} \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/designsystem/component/snackbar/BaseSnackBar.kt b/core/src/main/java/com/sopt/core/designsystem/component/snackbar/BaseSnackBar.kt new file mode 100644 index 0000000..d13e851 --- /dev/null +++ b/core/src/main/java/com/sopt/core/designsystem/component/snackbar/BaseSnackBar.kt @@ -0,0 +1,23 @@ +package com.sopt.core.designsystem.component.snackbar + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp + +@Composable +fun BaseSnackBar(content: @Composable () -> Unit) { + Box( + modifier = Modifier + .clip(CircleShape) + .background(color = Color.LightGray) + .padding(vertical = 7.dp, horizontal = 20.dp) + ) { + content() + } +} \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/designsystem/component/textfield/BaseTextField.kt b/core/src/main/java/com/sopt/core/designsystem/component/textfield/BaseTextField.kt new file mode 100644 index 0000000..1825574 --- /dev/null +++ b/core/src/main/java/com/sopt/core/designsystem/component/textfield/BaseTextField.kt @@ -0,0 +1,44 @@ +package com.sopt.core.designsystem.component.textfield + +import androidx.compose.material3.Text +import androidx.compose.material3.TextField +import androidx.compose.material3.TextFieldDefaults +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.tooling.preview.Preview +import com.sopt.core.designsystem.theme.NoostakAndroidTheme + +@Composable +fun BaseTextField( + value: String, + onValueChange: (String) -> Unit, + label: String, + placeholder: String, + isEnabled: Boolean = true, + modifier: Modifier +) { + TextField( + modifier = modifier, + value = value, + onValueChange = { onValueChange(it) }, + label = { + Text( + text = label, + color = Color.Black + ) + }, + placeholder = { + Text( + text = placeholder, + color = Color.LightGray + ) + }, + enabled = isEnabled, + colors = TextFieldDefaults.colors( + focusedContainerColor = Color.Transparent, + unfocusedContainerColor = Color.Transparent, + disabledContainerColor = Color.Transparent, + ) + ) +} diff --git a/core/src/main/java/com/sopt/core/designsystem/component/topappbar/BaseTopAppBar.kt b/core/src/main/java/com/sopt/core/designsystem/component/topappbar/BaseTopAppBar.kt new file mode 100644 index 0000000..52d842c --- /dev/null +++ b/core/src/main/java/com/sopt/core/designsystem/component/topappbar/BaseTopAppBar.kt @@ -0,0 +1,57 @@ +package com.sopt.core.designsystem.component.topappbar + +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.CenterAlignedTopAppBar +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color.Companion.White +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.unit.dp +import com.sopt.core.R + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun BaseTopAppBar( + title: String = "", + modifier: Modifier, + onBackButtonClick: () -> Unit = {}, +) { + CenterAlignedTopAppBar( + modifier = modifier, + title = { + Text( + text = title, + textAlign = TextAlign.Center, + ) + }, + navigationIcon = { + IconButton( + onClick = { + onBackButtonClick() + } + ) { + Icon( + painter = painterResource(id = R.drawable.ic_back), + contentDescription = stringResource(id = R.string.ic_back), + modifier = Modifier + .padding(start = 8.dp) + ) + } + }, + colors = TopAppBarDefaults.topAppBarColors(White), + windowInsets = WindowInsets( + left = 0, + top = 0, + right = 0, + bottom = 0 + ), + ) +} \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/designsystem/theme/Color.kt b/core/src/main/java/com/sopt/core/designsystem/theme/Color.kt new file mode 100644 index 0000000..2b182c3 --- /dev/null +++ b/core/src/main/java/com/sopt/core/designsystem/theme/Color.kt @@ -0,0 +1,11 @@ +package com.sopt.core.designsystem.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/designsystem/theme/Theme.kt b/core/src/main/java/com/sopt/core/designsystem/theme/Theme.kt new file mode 100644 index 0000000..90cdfba --- /dev/null +++ b/core/src/main/java/com/sopt/core/designsystem/theme/Theme.kt @@ -0,0 +1,27 @@ +package com.sopt.core.designsystem.theme + +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.Color + +private val LightColorScheme = lightColorScheme( + background = Color.White, +) + +@Composable +fun NoostakAndroidTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = LightColorScheme + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/designsystem/theme/Type.kt b/core/src/main/java/com/sopt/core/designsystem/theme/Type.kt new file mode 100644 index 0000000..86f7dbe --- /dev/null +++ b/core/src/main/java/com/sopt/core/designsystem/theme/Type.kt @@ -0,0 +1,34 @@ +package com.sopt.core.designsystem.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/extension/ContextExt.kt b/core/src/main/java/com/sopt/core/extension/ContextExt.kt new file mode 100644 index 0000000..9fc13f8 --- /dev/null +++ b/core/src/main/java/com/sopt/core/extension/ContextExt.kt @@ -0,0 +1,17 @@ +package com.sopt.core.extension + +import android.content.Context +import android.widget.Toast +import androidx.annotation.StringRes + +fun Context.toast(@StringRes message: Int) { + Toast.makeText(this, getString(message), Toast.LENGTH_SHORT).show() +} + +fun Context.stringToast(message: String) { + Toast.makeText(this, message, Toast.LENGTH_SHORT).show() +} + +fun Context.longToast(@StringRes message: Int) { + Toast.makeText(this, getString(message), Toast.LENGTH_SHORT).show() +} \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/extension/Extension.kt b/core/src/main/java/com/sopt/core/extension/Extension.kt new file mode 100644 index 0000000..cdaa8d1 --- /dev/null +++ b/core/src/main/java/com/sopt/core/extension/Extension.kt @@ -0,0 +1,4 @@ +package com.sopt.core.extension + +fun String?.isJsonObject(): Boolean = this?.startsWith("{") == true && this.endsWith("}") +fun String?.isJsonArray(): Boolean = this?.startsWith("[") == true && this.endsWith("]") \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/extension/ModifierExt.kt b/core/src/main/java/com/sopt/core/extension/ModifierExt.kt new file mode 100644 index 0000000..880021b --- /dev/null +++ b/core/src/main/java/com/sopt/core/extension/ModifierExt.kt @@ -0,0 +1,89 @@ +package com.sopt.core.extension + +import android.annotation.SuppressLint +import android.graphics.BlurMaskFilter +import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectTapGestures +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.composed +import androidx.compose.ui.draw.drawBehind +import androidx.compose.ui.focus.FocusManager +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Paint +import androidx.compose.ui.graphics.drawscope.drawIntoCanvas +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp + +@SuppressLint("ModifierFactoryUnreferencedReceiver") +inline fun Modifier.noRippleClickable(crossinline onClick: () -> Unit): Modifier = composed { + clickable(indication = null, + interactionSource = remember { MutableInteractionSource() }) { + onClick() + } +} + +fun Modifier.addFocusCleaner(focusManager: FocusManager): Modifier { + return this.pointerInput(Unit) { + detectTapGestures(onTap = { + focusManager.clearFocus() + }) + } +} + +@Composable +fun Modifier.customShadow( + color: Color = Color.Gray, + shadowRadius: Dp = 0.dp, + shadowWidth: Dp = 2.dp, + offsetX: Dp = 0.dp, + offsetY: Dp = 0.dp, +) = composed { + val paint: Paint = remember { Paint() } + val density = LocalDensity.current + val radius = shadowRadius + shadowWidth + val blurRadiusPx = with(density) { radius.toPx() } + val maskFilter = remember { + BlurMaskFilter(blurRadiusPx, BlurMaskFilter.Blur.NORMAL) + } + drawBehind { + drawIntoCanvas { canvas -> + val frameworkPaint = paint.asFrameworkPaint() + if (radius != 0.dp) { + frameworkPaint.maskFilter = maskFilter + } + frameworkPaint.color = color.toArgb() + + val leftPixel = offsetX.toPx() + val topPixel = offsetY.toPx() + val rightPixel = size.width + leftPixel + val bottomPixel = size.height + topPixel + + if (radius > 0.dp) { + val radiusPx = radius.toPx() + canvas.drawRoundRect( + left = leftPixel, + top = topPixel, + right = rightPixel, + bottom = bottomPixel, + radiusX = radiusPx, + radiusY = radiusPx, + paint = paint, + ) + } else { + canvas.drawRect( + left = leftPixel, + top = topPixel, + right = rightPixel, + bottom = bottomPixel, + paint = paint, + ) + } + } + } +} \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/navigation/MainTabRoute.kt b/core/src/main/java/com/sopt/core/navigation/MainTabRoute.kt new file mode 100644 index 0000000..1c659f5 --- /dev/null +++ b/core/src/main/java/com/sopt/core/navigation/MainTabRoute.kt @@ -0,0 +1,3 @@ +package com.sopt.core.navigation + +interface MainTabRoute : Route \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/navigation/Route.kt b/core/src/main/java/com/sopt/core/navigation/Route.kt new file mode 100644 index 0000000..e506cd7 --- /dev/null +++ b/core/src/main/java/com/sopt/core/navigation/Route.kt @@ -0,0 +1,3 @@ +package com.sopt.core.navigation + +interface Route \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/state/UiState.kt b/core/src/main/java/com/sopt/core/state/UiState.kt new file mode 100644 index 0000000..6691b75 --- /dev/null +++ b/core/src/main/java/com/sopt/core/state/UiState.kt @@ -0,0 +1,15 @@ +package com.sopt.core.state + +sealed interface UiState { + data object Empty : UiState + + data object Loading : UiState + + data class Success( + val data: T, + ) : UiState + + data class Failure( + val msg: String, + ) : UiState +} diff --git a/core/src/main/java/com/sopt/core/util/NoRippleConfiguration.kt b/core/src/main/java/com/sopt/core/util/NoRippleConfiguration.kt new file mode 100644 index 0000000..846500f --- /dev/null +++ b/core/src/main/java/com/sopt/core/util/NoRippleConfiguration.kt @@ -0,0 +1,17 @@ +package com.sopt.core.util + +import androidx.compose.material.ripple.RippleAlpha +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.RippleConfiguration +import androidx.compose.ui.graphics.Color + +@OptIn(ExperimentalMaterial3Api::class) +val NoRippleConfiguration = RippleConfiguration( + color = Color.Unspecified, + rippleAlpha = RippleAlpha( + draggedAlpha = 0.0f, + focusedAlpha = 0.0f, + hoveredAlpha = 0.0f, + pressedAlpha = 0.0f + ) +) \ No newline at end of file diff --git a/core/src/main/java/com/sopt/core/util/NoRippleInteractionSource.kt b/core/src/main/java/com/sopt/core/util/NoRippleInteractionSource.kt new file mode 100644 index 0000000..7f75d48 --- /dev/null +++ b/core/src/main/java/com/sopt/core/util/NoRippleInteractionSource.kt @@ -0,0 +1,15 @@ +package com.sopt.core.util + +import androidx.compose.foundation.interaction.Interaction +import androidx.compose.foundation.interaction.MutableInteractionSource +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.emptyFlow + +object NoRippleInteractionSource : MutableInteractionSource { + + override val interactions: Flow = emptyFlow() + + override suspend fun emit(interaction: Interaction) {} + + override fun tryEmit(interaction: Interaction) = true +} \ No newline at end of file diff --git a/core/src/main/res/drawable/ic_back.xml b/core/src/main/res/drawable/ic_back.xml new file mode 100644 index 0000000..951bd9f --- /dev/null +++ b/core/src/main/res/drawable/ic_back.xml @@ -0,0 +1,9 @@ + + + diff --git a/core/src/main/res/font/pretendard_light.otf b/core/src/main/res/font/pretendard_light.otf new file mode 100644 index 0000000..228679e Binary files /dev/null and b/core/src/main/res/font/pretendard_light.otf differ diff --git a/core/src/main/res/font/pretendard_medium.otf b/core/src/main/res/font/pretendard_medium.otf new file mode 100644 index 0000000..0575069 Binary files /dev/null and b/core/src/main/res/font/pretendard_medium.otf differ diff --git a/core/src/main/res/font/pretendard_regular.otf b/core/src/main/res/font/pretendard_regular.otf new file mode 100644 index 0000000..08bf4cf Binary files /dev/null and b/core/src/main/res/font/pretendard_regular.otf differ diff --git a/core/src/main/res/font/pretendard_semibold.otf b/core/src/main/res/font/pretendard_semibold.otf new file mode 100644 index 0000000..e7e36ab Binary files /dev/null and b/core/src/main/res/font/pretendard_semibold.otf differ diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml new file mode 100644 index 0000000..6bf9423 --- /dev/null +++ b/core/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + 뒤로가기 버튼 + \ No newline at end of file diff --git a/core/src/test/java/com/sopt/core/ExampleUnitTest.kt b/core/src/test/java/com/sopt/core/ExampleUnitTest.kt new file mode 100644 index 0000000..8ff044c --- /dev/null +++ b/core/src/test/java/com/sopt/core/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.sopt.core + +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) + } +} \ No newline at end of file diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/data/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/data/build.gradle.kts b/data/build.gradle.kts new file mode 100644 index 0000000..e3d5004 --- /dev/null +++ b/data/build.gradle.kts @@ -0,0 +1,67 @@ +plugins { + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.serialization) +} + +android { + namespace = "com.sopt.data" + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + minSdk = libs.versions.minSdk.get().toInt() + + 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 = libs.versions.jvmTarget.get() + } + buildFeatures { + buildConfig = true + } +} + +dependencies { + implementation(project(":domain")) + + // Kotlin + implementation(libs.kotlinx.coroutines.android) + implementation(libs.kotlinx.coroutines.core) + implementation(libs.kotlinx.serialization.json) + implementation(libs.kotlinx.coroutines.test) + + // AndroidX Core + implementation(libs.core.ktx) + + // Hilt (Dependency Injection) + implementation(libs.hilt.android) + implementation(libs.javax.inject) + + // Retrofit (Networking) + implementation(libs.retrofit.core) + implementation(libs.retrofit.kotlin.serialization) + implementation(libs.okhttp.logging) + + // Logging + implementation(libs.timber) + + // Testing + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.espresso.core) +} \ No newline at end of file diff --git a/data/consumer-rules.pro b/data/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/data/proguard-rules.pro b/data/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/data/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/data/src/androidTest/java/com/sopt/data/ExampleInstrumentedTest.kt b/data/src/androidTest/java/com/sopt/data/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..93a0b66 --- /dev/null +++ b/data/src/androidTest/java/com/sopt/data/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.sopt.data + +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.sopt.data.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/data/src/main/AndroidManifest.xml b/data/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a5918e6 --- /dev/null +++ b/data/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/data/src/main/java/com/sopt/data/datasource/ExampleDataSource.kt b/data/src/main/java/com/sopt/data/datasource/ExampleDataSource.kt new file mode 100644 index 0000000..507ece2 --- /dev/null +++ b/data/src/main/java/com/sopt/data/datasource/ExampleDataSource.kt @@ -0,0 +1,8 @@ +package com.sopt.data.datasource + +import com.sopt.data.dto.ExampleBaseResponse +import com.sopt.data.dto.response.ResponseGetExampleDto + +interface ExampleDataSource { + suspend fun getUsers(page: Int): ExampleBaseResponse> +} \ No newline at end of file diff --git a/data/src/main/java/com/sopt/data/datasourceimpl/ExampleDataSourceImpl.kt b/data/src/main/java/com/sopt/data/datasourceimpl/ExampleDataSourceImpl.kt new file mode 100644 index 0000000..4b835b6 --- /dev/null +++ b/data/src/main/java/com/sopt/data/datasourceimpl/ExampleDataSourceImpl.kt @@ -0,0 +1,15 @@ +package com.sopt.data.datasourceimpl + +import com.sopt.data.datasource.ExampleDataSource +import com.sopt.data.dto.ExampleBaseResponse +import com.sopt.data.dto.response.ResponseGetExampleDto +import com.sopt.data.service.ExampleApiService +import javax.inject.Inject + +class ExampleDataSourceImpl @Inject constructor( + private val exampleApiService: ExampleApiService +) : ExampleDataSource { + override suspend fun getUsers(page: Int): ExampleBaseResponse> { + return exampleApiService.getUsers(page) + } +} \ No newline at end of file diff --git a/data/src/main/java/com/sopt/data/dto/ExampleBaseResponse.kt b/data/src/main/java/com/sopt/data/dto/ExampleBaseResponse.kt new file mode 100644 index 0000000..bd3504f --- /dev/null +++ b/data/src/main/java/com/sopt/data/dto/ExampleBaseResponse.kt @@ -0,0 +1,20 @@ +package com.sopt.data.dto + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ExampleBaseResponse( + @SerialName("page") val page: Int, + @SerialName("per_page") val perPage: Int, + @SerialName("total") val total: Int, + @SerialName("total_pages") val totalPages: Int, + @SerialName("data") val data: T? = null, + @SerialName("support") val support: Support, +) + +@Serializable +data class Support( + @SerialName("url") val url: String, + @SerialName("text") val text: String, +) \ No newline at end of file diff --git a/data/src/main/java/com/sopt/data/dto/request/gitkeep b/data/src/main/java/com/sopt/data/dto/request/gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/data/src/main/java/com/sopt/data/dto/response/ResponseGetExampleDto.kt b/data/src/main/java/com/sopt/data/dto/response/ResponseGetExampleDto.kt new file mode 100644 index 0000000..95d88e0 --- /dev/null +++ b/data/src/main/java/com/sopt/data/dto/response/ResponseGetExampleDto.kt @@ -0,0 +1,13 @@ +package com.sopt.data.dto.response + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ResponseGetExampleDto ( + @SerialName("id") val id: Int, + @SerialName("email") val email: String, + @SerialName("first_name") val firstName: String, + @SerialName("last_name") val lastName: String, + @SerialName("avatar") val avatar: String, +) \ No newline at end of file diff --git a/data/src/main/java/com/sopt/data/mapper/ResponseExampleDtoMapper.kt b/data/src/main/java/com/sopt/data/mapper/ResponseExampleDtoMapper.kt new file mode 100644 index 0000000..d047b11 --- /dev/null +++ b/data/src/main/java/com/sopt/data/mapper/ResponseExampleDtoMapper.kt @@ -0,0 +1,8 @@ +package com.sopt.data.mapper + +import com.sopt.data.dto.response.ResponseGetExampleDto +import com.sopt.domain.entity.ExampleEntity + +fun ResponseGetExampleDto.toExampleEntity() = ExampleEntity( + email, firstName, avatar +) \ No newline at end of file diff --git a/data/src/main/java/com/sopt/data/repositoryimpl/ExampleRepositoryImpl.kt b/data/src/main/java/com/sopt/data/repositoryimpl/ExampleRepositoryImpl.kt new file mode 100644 index 0000000..186bc2b --- /dev/null +++ b/data/src/main/java/com/sopt/data/repositoryimpl/ExampleRepositoryImpl.kt @@ -0,0 +1,17 @@ +package com.sopt.data.repositoryimpl + +import com.sopt.data.datasource.ExampleDataSource +import com.sopt.data.mapper.toExampleEntity +import com.sopt.domain.entity.ExampleEntity +import com.sopt.domain.repository.ExampleRepository +import javax.inject.Inject + +class ExampleRepositoryImpl @Inject constructor( + private val exampleDataSource: ExampleDataSource +) : ExampleRepository { + override suspend fun getUsers(page: Int): Result> { + return runCatching { + exampleDataSource.getUsers(page).data?.map { it.toExampleEntity() } ?: emptyList() + } + } +} \ No newline at end of file diff --git a/data/src/main/java/com/sopt/data/service/ApiKeyStorage.kt b/data/src/main/java/com/sopt/data/service/ApiKeyStorage.kt new file mode 100644 index 0000000..00af9ac --- /dev/null +++ b/data/src/main/java/com/sopt/data/service/ApiKeyStorage.kt @@ -0,0 +1,8 @@ +package com.sopt.data.service + +object ApiKeyStorage { + const val API = "api" + const val V1 = "v1" + const val USERS = "users" + const val PAGE = "page" +} \ No newline at end of file diff --git a/data/src/main/java/com/sopt/data/service/ExampleApiService.kt b/data/src/main/java/com/sopt/data/service/ExampleApiService.kt new file mode 100644 index 0000000..eede4f7 --- /dev/null +++ b/data/src/main/java/com/sopt/data/service/ExampleApiService.kt @@ -0,0 +1,15 @@ +package com.sopt.data.service + +import com.sopt.data.dto.ExampleBaseResponse +import com.sopt.data.dto.response.ResponseGetExampleDto +import com.sopt.data.service.ApiKeyStorage.API +import com.sopt.data.service.ApiKeyStorage.USERS +import retrofit2.http.GET +import retrofit2.http.Query + +interface ExampleApiService { + @GET("/$API/$USERS") + suspend fun getUsers( + @Query("page") page: Int + ): ExampleBaseResponse> +} \ No newline at end of file diff --git a/data/src/test/java/com/sopt/data/ExampleUnitTest.kt b/data/src/test/java/com/sopt/data/ExampleUnitTest.kt new file mode 100644 index 0000000..a0e31d4 --- /dev/null +++ b/data/src/test/java/com/sopt/data/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.sopt.data + +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) + } +} \ No newline at end of file diff --git a/domain/.gitignore b/domain/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/domain/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts new file mode 100644 index 0000000..e0bfbb3 --- /dev/null +++ b/domain/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + id("java-library") + alias(libs.plugins.ksp) + alias(libs.plugins.kotlin.jvm) +} + +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +dependencies { + // KotlinDependencies + implementation(libs.kotlin) + implementation(libs.kotlinx.coroutines.android) + + // Hilt + ksp(libs.hilt.compiler) + implementation(libs.javax.inject) + implementation(libs.hilt.core) +} \ No newline at end of file diff --git a/domain/src/main/java/com/sopt/domain/entity/ExampleEntity.kt b/domain/src/main/java/com/sopt/domain/entity/ExampleEntity.kt new file mode 100644 index 0000000..fae4538 --- /dev/null +++ b/domain/src/main/java/com/sopt/domain/entity/ExampleEntity.kt @@ -0,0 +1,7 @@ +package com.sopt.domain.entity + +data class ExampleEntity( + val email: String, + val firstName: String, + val avatar: String, +) \ No newline at end of file diff --git a/domain/src/main/java/com/sopt/domain/repository/ExampleRepository.kt b/domain/src/main/java/com/sopt/domain/repository/ExampleRepository.kt new file mode 100644 index 0000000..865125b --- /dev/null +++ b/domain/src/main/java/com/sopt/domain/repository/ExampleRepository.kt @@ -0,0 +1,7 @@ +package com.sopt.domain.repository + +import com.sopt.domain.entity.ExampleEntity + +interface ExampleRepository { + suspend fun getUsers(page: Int): Result> +} \ No newline at end of file diff --git a/domain/src/main/java/com/sopt/domain/usecase/GetExampleUseCase.kt b/domain/src/main/java/com/sopt/domain/usecase/GetExampleUseCase.kt new file mode 100644 index 0000000..f293e34 --- /dev/null +++ b/domain/src/main/java/com/sopt/domain/usecase/GetExampleUseCase.kt @@ -0,0 +1,10 @@ +package com.sopt.domain.usecase + +import com.sopt.domain.repository.ExampleRepository +import javax.inject.Inject + +class GetExampleUseCase @Inject constructor( + private val exampleRepository: ExampleRepository +) { + suspend operator fun invoke(page: Int) = exampleRepository.getUsers(page) +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..20e2a01 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,23 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. For more details, visit +# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official +# Enables namespacing of each library's R class so that its R class includes only the +# resources declared in the library itself and none from the library's dependencies, +# thereby reducing the size of the R class for that library +android.nonTransitiveRClass=true \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..a1eb413 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,172 @@ +[versions] +compileSdk = "34" +minSdk = "28" +targetSdk = "34" +versionCode = "1" +versionName = "1.0" +kotlinCompilerExtensionVersion = "1.5.3" +jvmTarget = "1.8" +accompanist = "0.28.0" + +# Compose +compose-compiler = "1.5.15" +compose-bom = "2024.09.02" +compose-material3 = "1.3.0" +activity-compose = "1.9.2" +androidx-hilt-navigation-compose = "1.2.0" +constraintlayout-compose = "1.0.1" + +# Kotlin +kotlin = "2.0.0" +kotlinx-coroutines = "1.8.1" +kotlinx-serialization-json = "1.7.0" +kotlinx-datetime = "0.4.0" +kotlinx-collections = "0.3.7" +ktlint = "11.5.1" +ksp = "2.0.0-1.0.21" + +# AndroidX +core-ktx = "1.13.1" +androidx-core = "1.12.0" +androidx-lifecycle = "2.8.6" +androidx-navigation = "2.8.1" +androidx-activity-ktx = "1.9.2" +androidx-splash-screen = "1.0.1" +androidx-datastore = "1.1.0" +androidx-paging = "3.2.1" +androidx-paging-compose = "3.3.2" +activity = "1.9.2" +accompanist-insets = "0.28.0" + +# Third-Party Libraries +retrofit = "2.11.0" +retrofit-kotlinx-serialization-json = "1.0.0" +okhttp = "4.12.0" +timber = "5.0.1" +encrypted-datastore = "1.7.21-1.0.8-1.1.0-alpha01" +coil = "2.7.0" +lottie-compose = "6.4.1" + +# Kakao +kakao = "2.20.1" + +viewpager-indicator = "5.0" + +# Hilt +hilt = "2.52" + +# Javax +javax = "1" + +# Testing +junit = "4.13.2" +androidx-test-ext-junit = "1.1.5" +androidx-test-runner = "1.5.2" +androidx-test = "1.5.0" +espresso-core = "3.5.1" + +#agp +android-gradle-plugin = "8.5.0" +constraintlayout = "2.1.4" + +# Process Phoenix +phoenix = "3.0.0" + +# Room +room = "2.6.1" +appcompat = "1.7.0" +material = "1.12.0" + + +[plugins] +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } # Kotlin Symbol Processing (KSP) 플러그인 +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } # Kotlin Android 플러그인 +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } # Kotlin JVM 플러그인 +kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } # Kotlin Serialization 플러그인 +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } # Kotlin 코드 스타일 검사 플러그인 +android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" } # Android 애플리케이션 플러그인 +android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" } # Android 라이브러리 플러그인 +hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" } # Hilt DI 플러그인 +compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } + +[libraries] +# Compose +compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" } # Compose BOM +compose-compiler = { group = "androidx.compose.compiler", name = "compiler", version.ref = "compose-compiler" } # Compose 컴파일러 +material3-compose = { group = "androidx.compose.material3", name = "material3", version.ref = "compose-material3" } # Material Design 3 Compose 라이브러리 +ui = { group = "androidx.compose.ui", name = "ui" } # Compose UI 라이브러리 +ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } # Compose 그래픽 라이브러리 +ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } # Compose UI 도구 라이브러리 +ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } # Compose UI 미리보기 도구 라이브러리 +ui-foundation = { group = "androidx.compose.foundation", name = "foundation" } # Compose 기초 라이브러리 +coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coil" } # 이미지 로딩 라이브러리 (Compose용) +activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" } # Compose용 Activity 라이브러리 +lifecycle-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidx-lifecycle" } # Compose용 Lifecycle 라이브러리 +navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "androidx-navigation" } # Compose용 Navigation 라이브러리 +hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "androidx-hilt-navigation-compose" } # Compose용 Hilt Navigation 라이브러리 +constraintlayout-compose = { group = "androidx.constraintlayout", name = "constraintlayout-compose", version.ref = "constraintlayout-compose" } # Compose용 ConstraintLayout 라이브러리 +accompanist-systemuicontroller = { group = "com.google.accompanist", name = "accompanist-systemuicontroller", version.ref = "accompanist" } + +# Kotlin +kotlin = {group = "org.jetbrains.kotlin" , name = "kotlin-stdlib", version.ref = "kotlin"} # Kotlin 표준 라이브러리 +kotlinx-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" } # Android용 Kotlin Coroutines +kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } # Kotlin Coroutines 핵심 라이브러리 +kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" } # Kotlinx JSON 직렬화 라이브러리 +kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" } # Kotlin Coroutines 테스트 라이브러리 +kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-datetime" } # Kotlinx 날짜/시간 라이브러리 +kotlinx-collections = { group = "org.jetbrains.kotlinx", name = "kotlinx-collections-immutable", version.ref = "kotlinx-collections" } # Kotlinx 불변 컬렉션 라이브러리 + +# AndroidX +core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" } # AndroidX Core KTX 라이브러리 +androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "androidx-lifecycle" } # AndroidX Lifecycle Runtime KTX 라이브러리 +androidx-lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "androidx-lifecycle" } # AndroidX Lifecycle ViewModel KTX 라이브러리 +androidx-activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "androidx-activity-ktx" } # AndroidX Activity KTX 라이브러리 +androidx-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "androidx-splash-screen" } # AndroidX SplashScreen 라이브러리 +androidx-paging = { group = "androidx.paging", name = "paging-runtime", version.ref = "androidx-paging" } # AndroidX Paging 라이브러리 +androidx-paging-common = { group = "androidx.paging", name = "paging-common", version.ref = "androidx-paging" } # AndroidX Paging 공용 라이브러리 +androidx-paging-compose = { group = "androidx.paging", name = "paging-compose", version.ref = "androidx-paging-compose" } # Compose용 AndroidX Paging 라이브러리 +accompanist-insets = { group = "com.google.accompanist", name = "accompanist-insets", version.ref = "accompanist-insets" } # + +# Third-Party Libraries +retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" } # Retrofit 네트워킹 라이브러리 +retrofit-kotlin-serialization = { group = "com.jakewharton.retrofit", name = "retrofit2-kotlinx-serialization-converter", version.ref = "retrofit-kotlinx-serialization-json" } # Retrofit Kotlinx Serialization 변환기 +okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" } # OkHttp 로깅 인터셉터 +timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" } # Timber 로깅 라이브러리 +androidx-datastore-core = { group = "androidx.datastore", name = "datastore", version.ref = "androidx-datastore" } # AndroidX DataStore 핵심 라이브러리 +androidx-datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "androidx-datastore" } # AndroidX DataStore Preferences 라이브러리 +encrypted-datastore-preference-ksp = { group = "tech.thdev", name = "useful-encrypted-data-store-preferences-ksp", version.ref = "encrypted-datastore" } # 암호화된 DataStore Preferences KSP +encrypted-datastore-preference-ksp-annotations = { group = "tech.thdev", name = "useful-encrypted-data-store-preferences-ksp-annotations", version.ref = "encrypted-datastore" } # 암호화된 DataStore Preferences KSP 어노테이션 +encrypted-datastore-preference-security = { group = "tech.thdev", name = "useful-encrypted-data-store-preferences-security", version.ref = "encrypted-datastore" } # 암호화된 DataStore Preferences 보안 라이브러리 +lottie-compose = { group = "com.airbnb.android", name = "lottie-compose", version.ref = "lottie-compose" } # Lottie Compose 라이브러리 +viewpager-indicator = { group = "com.tbuonomo", name = "dotsindicator", version.ref = "viewpager-indicator" } # ViewPager 인디케이터 라이브러리 +androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } # AndroidX Activity 라이브러리 +process-phoenix = { group = "com.jakewharton", name = "process-phoenix", version.ref = "phoenix" } # Process Phoenix 라이브러리 + +# Kakao +kakao-all = { group = "com.kakao.sdk", name = "v2-all", version.ref = "kakao" } # Kakao SDK 라이브러리 +kakao-user = { group = "com.kakao.sdk", name = "v2-user", version.ref = "kakao" } # Kakao 로그인 라이브러리 + +# Hilt +hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" } # Hilt Android 라이브러리 +hilt-core = { group = "com.google.dagger", name = "hilt-core", version.ref = "hilt" } # Hilt Core 라이브러리 +hilt-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" } # Hilt Android 컴파일러 +hilt-testing = { module = "com.google.dagger:hilt-android-testing", version.ref = "hilt" } # Hilt Android 테스트 라이브러리 + +# Javax +javax-inject = { group = "javax.inject", name = "javax.inject", version.ref = "javax" } # Javax Inject 라이브러리 + +# Room +room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" } # Room 런타임 라이브러리 +room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" } # Room 컴파일러 라이브러리 +room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" } # Room KTX 라이브러리 + +# Test +junit = { group = "junit", name = "junit", version.ref = "junit" } # JUnit 테스트 라이브러리 +ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } # Compose UI 테스트 매니페스트 라이브러리 +ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } # Compose UI JUnit4 테스트 라이브러리 +androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" } # AndroidX Test JUnit 확장 라이브러리 +androidx-test-runner = { group = "androidx.test", name = "runner", version.ref = "androidx-test-runner" } # AndroidX Test Runner 라이브러리 +androidx-test-core = { group = "androidx.test", name = "core", version.ref = "androidx-test" } # AndroidX Test Core 라이브러리 +espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" } +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } +material = { group = "com.google.android.material", name = "material", version.ref = "material" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..26f93f1 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Oct 04 12:32:41 KST 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..ac1b06f --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/presentation/.gitignore b/presentation/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/presentation/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/presentation/build.gradle.kts b/presentation/build.gradle.kts new file mode 100644 index 0000000..f55c412 --- /dev/null +++ b/presentation/build.gradle.kts @@ -0,0 +1,116 @@ +plugins { + alias(libs.plugins.android.library) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.ksp) + alias(libs.plugins.hilt) + alias(libs.plugins.kotlin.serialization) + alias(libs.plugins.compose.compiler) +} + +android { + namespace = "com.sopt.presentation" + compileSdk = libs.versions.compileSdk.get().toInt() + + defaultConfig { + minSdk = libs.versions.minSdk.get().toInt() + + 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 = libs.versions.jvmTarget.get() + } + buildFeatures { + compose = true + buildConfig = true + } + composeOptions { + kotlinCompilerExtensionVersion = libs.versions.kotlinCompilerExtensionVersion.get() + } +} + +dependencies { + implementation(project(":core")) + implementation(project(":domain")) + + // Compose + implementation(libs.activity.compose) + implementation(libs.ui) + implementation(libs.ui.tooling.preview) + implementation(libs.material3.compose) + + // Kotlin + implementation(libs.kotlinx.coroutines.android) + implementation(libs.kotlinx.coroutines.core) + implementation(libs.kotlinx.serialization.json) + implementation(libs.kotlinx.coroutines.test) + + // AndroidX Core + implementation(libs.core.ktx) + implementation(libs.androidx.activity.ktx) + implementation(libs.androidx.splashscreen) + implementation(libs.androidx.paging) + implementation(libs.androidx.paging.common) + implementation(libs.androidx.paging.compose) + implementation(libs.accompanist.insets) + implementation(libs.navigation.compose) + implementation(libs.lifecycle.compose) + + // Hilt (Dependency Injection) + implementation(libs.hilt.android) + ksp(libs.hilt.compiler) + implementation(libs.javax.inject) + implementation(libs.hilt.navigation.compose) + + // Retrofit (Networking) + implementation(libs.retrofit.core) + implementation(libs.retrofit.kotlin.serialization) + implementation(libs.okhttp.logging) + + // Image Loading + implementation(libs.coil.compose) + implementation(libs.lottie.compose) + + // Logging + implementation(libs.timber) + + // DataStore (Local Storage) + implementation(libs.androidx.datastore.core) + implementation(libs.androidx.datastore.preferences) + implementation(libs.encrypted.datastore.preference.ksp) + implementation(libs.encrypted.datastore.preference.ksp.annotations) + implementation(libs.encrypted.datastore.preference.security) + + // ViewPager Indicator + implementation(libs.viewpager.indicator) + + // Testing + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.espresso.core) + androidTestImplementation(platform(libs.compose.bom)) + androidTestImplementation(libs.ui.test.junit4) + debugImplementation(libs.ui.tooling) + debugImplementation(libs.ui.test.manifest) + + // Accompanist System UI Controller + implementation(libs.accompanist.systemuicontroller) + + // Kakao + implementation(libs.kakao.all) + implementation(libs.kakao.user) +} \ No newline at end of file diff --git a/presentation/consumer-rules.pro b/presentation/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/presentation/proguard-rules.pro b/presentation/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/presentation/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/presentation/src/androidTest/java/com/sopt/presentation/ExampleInstrumentedTest.kt b/presentation/src/androidTest/java/com/sopt/presentation/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..4f7d879 --- /dev/null +++ b/presentation/src/androidTest/java/com/sopt/presentation/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.sopt.presentation + +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.sopt.presentation.test", appContext.packageName) + } +} \ No newline at end of file diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a5918e6 --- /dev/null +++ b/presentation/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/calendar/CalendarRoute.kt b/presentation/src/main/java/com/sopt/presentation/calendar/CalendarRoute.kt new file mode 100644 index 0000000..7082965 --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/calendar/CalendarRoute.kt @@ -0,0 +1,43 @@ +package com.sopt.presentation.calendar + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import com.sopt.core.designsystem.theme.NoostakAndroidTheme + +@Composable +fun CalendarRoute( + paddingValues: PaddingValues +) { + CalendarScreen(paddingValues = paddingValues) +} + +@Composable +fun CalendarScreen( + paddingValues: PaddingValues = PaddingValues() +) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center + ) { + Text(text = "Calendar Screen") + } +} + +@Preview(showBackground = true) +@Composable +fun CalendarScreenPreview() { + NoostakAndroidTheme { + CalendarScreen() + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/calendar/navigation/CalendarNavigation.kt b/presentation/src/main/java/com/sopt/presentation/calendar/navigation/CalendarNavigation.kt new file mode 100644 index 0000000..e3a2d45 --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/calendar/navigation/CalendarNavigation.kt @@ -0,0 +1,31 @@ +package com.sopt.presentation.calendar.navigation + +import androidx.compose.foundation.layout.PaddingValues +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavOptions +import androidx.navigation.compose.composable +import com.sopt.core.navigation.MainTabRoute +import com.sopt.presentation.calendar.CalendarRoute +import kotlinx.serialization.Serializable + +fun NavController.navigateCalendar(navOptions: NavOptions? = null) { + navigate( + route = Calendar, + navOptions = navOptions + ) +} + +fun NavGraphBuilder.calendarNavGraph( + paddingValues: PaddingValues, + navHostController: NavController +) { + composable { + CalendarRoute( + paddingValues = paddingValues, + ) + } +} + +@Serializable +data object Calendar : MainTabRoute \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/example/ExampleItem.kt b/presentation/src/main/java/com/sopt/presentation/example/ExampleItem.kt new file mode 100644 index 0000000..67d3b2a --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/example/ExampleItem.kt @@ -0,0 +1,68 @@ +package com.sopt.presentation.example + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +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.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color.Companion.White +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import coil.compose.AsyncImage +import com.sopt.domain.entity.ExampleEntity + +@Composable +fun ExampleItem( + data: ExampleEntity +) { + Box( + modifier = Modifier + .fillMaxSize() + ) { + Row( + modifier = Modifier + .fillMaxWidth() + .background(White) + .padding(vertical = 10.dp, horizontal = 18.dp), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween + ) { + Column { + Text(text = data.firstName) + Spacer(modifier = Modifier.height(4.dp)) + Text(text = data.email) + } + AsyncImage( + modifier = Modifier + .size(60.dp) + .clip(RoundedCornerShape(12.dp)), + model = data.avatar, + contentDescription = null, + ) + } + } +} + +@Preview(showBackground = true) +@Composable +fun ExampleItemPreview() { + ExampleItem( + data = ExampleEntity( + firstName = "John", + email = "", + avatar = "" + ) + ) +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/example/ExampleRoute.kt b/presentation/src/main/java/com/sopt/presentation/example/ExampleRoute.kt new file mode 100644 index 0000000..215638d --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/example/ExampleRoute.kt @@ -0,0 +1,151 @@ +package com.sopt.presentation.example + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.statusBarsPadding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.items +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.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import com.sopt.core.designsystem.component.topappbar.BaseTopAppBar +import com.sopt.core.designsystem.component.button.BaseButton +import com.sopt.core.designsystem.theme.NoostakAndroidTheme +import com.sopt.core.extension.toast +import com.sopt.core.state.UiState +import com.sopt.domain.entity.ExampleEntity +import com.sopt.presentation.R + +@Composable +fun ExampleRoute( + text: String, + navigateUp: () -> Unit, + exampleViewModel: ExampleViewModel = hiltViewModel() +) { + val context = LocalContext.current + val state by exampleViewModel.state.collectAsStateWithLifecycle() + + LaunchedEffect(Unit) { + exampleViewModel.getFollowers(2) + } + + LaunchedEffect(exampleViewModel.sideEffects) { + exampleViewModel.sideEffects.collect { sideEffect -> + when (sideEffect) { + is ExampleSideEffect.ShowToast -> { + context.toast(sideEffect.message) + } + + is ExampleSideEffect.NavigateUp -> navigateUp() + } + } + } + + when (state.followers) { + is UiState.Empty -> { + // Show empty + } + + is UiState.Loading -> { + Box(modifier = Modifier.fillMaxSize()) { + CircularProgressIndicator( + modifier = Modifier.align(Alignment.Center), + color = Color.Gray + ) + } + } + + is UiState.Success -> { + ExampleScreen( + text = text, + followers = (state.followers as UiState.Success>).data, + onBackButtonClick = exampleViewModel::navigateUp + ) + } + + is UiState.Failure -> { + Column( + modifier = Modifier.fillMaxSize(), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center + ) { + Text( + modifier = Modifier.padding(top = 10.dp), + text = "서버 연결에 실패했어요 ㅠ" + ) + } + } + } +} + +@Composable +fun ExampleScreen( + text: String = "", + followers: List, + onBackButtonClick: () -> Unit, +) { + Column( + modifier = Modifier + .fillMaxSize() + .statusBarsPadding() + .navigationBarsPadding() + ) { + BaseTopAppBar( + title = stringResource(R.string.appbar_example_title), + modifier = Modifier.fillMaxWidth(), + onBackButtonClick = { onBackButtonClick() }, + ) + if (text.isNotBlank()) { + Text( + text = text, + modifier = Modifier.padding(16.dp) + ) + } + LazyColumn( + modifier = Modifier.weight(1f) + ) { + items(followers) { follower -> + ExampleItem(follower) + } + } + BaseButton( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp), + shape = RoundedCornerShape(30.dp), + style = TextStyle.Default, + paddingVertical = 10.dp, + text = stringResource(R.string.btn_example_back), + onButtonClick = { onBackButtonClick() } + ) + } +} + +@Preview(showBackground = true) +@Composable +fun ExampleRoutePreview() { + NoostakAndroidTheme { + ExampleScreen( + followers = emptyList(), + onBackButtonClick = {} + ) + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/example/ExampleSideEffect.kt b/presentation/src/main/java/com/sopt/presentation/example/ExampleSideEffect.kt new file mode 100644 index 0000000..3670036 --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/example/ExampleSideEffect.kt @@ -0,0 +1,8 @@ +package com.sopt.presentation.example + +import androidx.annotation.StringRes + +sealed class ExampleSideEffect { + data object NavigateUp : ExampleSideEffect() + data class ShowToast (@StringRes val message: Int) : ExampleSideEffect() +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/example/ExampleState.kt b/presentation/src/main/java/com/sopt/presentation/example/ExampleState.kt new file mode 100644 index 0000000..7b0bfcb --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/example/ExampleState.kt @@ -0,0 +1,8 @@ +package com.sopt.presentation.example + +import com.sopt.core.state.UiState +import com.sopt.domain.entity.ExampleEntity + +data class ExampleState( + var followers: UiState> = UiState.Empty, +) \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/example/ExampleViewModel.kt b/presentation/src/main/java/com/sopt/presentation/example/ExampleViewModel.kt new file mode 100644 index 0000000..d3733ea --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/example/ExampleViewModel.kt @@ -0,0 +1,50 @@ +package com.sopt.presentation.example + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.sopt.core.state.UiState +import com.sopt.domain.usecase.GetExampleUseCase +import com.sopt.presentation.R +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class ExampleViewModel @Inject constructor( + private val getExampleUseCase: GetExampleUseCase +) : ViewModel() { + private val _state: MutableStateFlow = MutableStateFlow(ExampleState()) + val state: StateFlow get() = _state.asStateFlow() + + private val _sideEffects: MutableSharedFlow = MutableSharedFlow() + val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() + + fun getFollowers(page: Int) { + viewModelScope.launch { + _state.value = _state.value.copy(followers = UiState.Loading) + getExampleUseCase(page).fold( + onSuccess = { + _state.value = _state.value.copy(followers = UiState.Success(it)) + _sideEffects.emit(ExampleSideEffect.ShowToast(R.string.server_success)) + }, + onFailure = { + _state.value = + _state.value.copy(followers = UiState.Failure(it.message.toString())) + _sideEffects.emit(ExampleSideEffect.ShowToast(R.string.server_failure)) + } + ) + } + } + + fun navigateUp() { + viewModelScope.launch { + _sideEffects.emit(ExampleSideEffect.NavigateUp) + } + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/example/navigation/ExampleNavigation.kt b/presentation/src/main/java/com/sopt/presentation/example/navigation/ExampleNavigation.kt new file mode 100644 index 0000000..7d7ae9c --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/example/navigation/ExampleNavigation.kt @@ -0,0 +1,38 @@ +package com.sopt.presentation.example.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavHostController +import androidx.navigation.NavOptions +import androidx.navigation.compose.composable +import androidx.navigation.toRoute +import com.sopt.core.navigation.Route +import com.sopt.presentation.example.ExampleRoute +import kotlinx.serialization.Serializable + +fun NavController.navigateExample( + text: String, + navOptions: NavOptions? = null +) { + navigate( + route = Example(text = text), + navOptions = navOptions + ) +} + +fun NavGraphBuilder.exampleNavGraph( + navHostController: NavHostController +) { + composable { + val args = it.toRoute() // 이전 화면에서 데이터 전달 받기 + ExampleRoute( + text = args.text, + navigateUp = navHostController::navigateUp + ) + } +} + +@Serializable +data class Example( + val text: String +) : Route \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/group/GroupRoute.kt b/presentation/src/main/java/com/sopt/presentation/group/GroupRoute.kt new file mode 100644 index 0000000..38118d9 --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/group/GroupRoute.kt @@ -0,0 +1,43 @@ +package com.sopt.presentation.group + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import com.sopt.core.designsystem.theme.NoostakAndroidTheme + +@Composable +fun GroupRoute( + paddingValues: PaddingValues +) { + GroupScreen(paddingValues = paddingValues) +} + +@Composable +fun GroupScreen( + paddingValues: PaddingValues = PaddingValues() +) { + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center + ) { + Text(text = "Appointment Screen") + } +} + +@Preview(showBackground = true) +@Composable +fun GroupScreenPreview() { + NoostakAndroidTheme { + GroupScreen() + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/group/navigation/GroupNavigation.kt b/presentation/src/main/java/com/sopt/presentation/group/navigation/GroupNavigation.kt new file mode 100644 index 0000000..f015ec3 --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/group/navigation/GroupNavigation.kt @@ -0,0 +1,31 @@ +package com.sopt.presentation.group.navigation + +import androidx.compose.foundation.layout.PaddingValues +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavOptions +import androidx.navigation.compose.composable +import com.sopt.core.navigation.MainTabRoute +import com.sopt.presentation.group.GroupRoute +import kotlinx.serialization.Serializable + +fun NavController.navigateGroup(navOptions: NavOptions? = null) { + navigate( + route = Group, + navOptions = navOptions + ) +} + +fun NavGraphBuilder.groupNavGraph( + paddingValues: PaddingValues, + navHostController: NavController +) { + composable { + GroupRoute( + paddingValues = paddingValues, + ) + } +} + +@Serializable +data object Group : MainTabRoute \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/main/MainActivity.kt b/presentation/src/main/java/com/sopt/presentation/main/MainActivity.kt new file mode 100644 index 0000000..4d55e86 --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/main/MainActivity.kt @@ -0,0 +1,24 @@ +package com.sopt.presentation.main + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen +import com.sopt.core.designsystem.theme.NoostakAndroidTheme +import dagger.hilt.android.AndroidEntryPoint + +@AndroidEntryPoint +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + installSplashScreen() + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + val navigator: MainNavigator = rememberMainNavigator() + NoostakAndroidTheme { + MainScreen(navigator) + } + } + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/main/MainNavigator.kt b/presentation/src/main/java/com/sopt/presentation/main/MainNavigator.kt new file mode 100644 index 0000000..d610b04 --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/main/MainNavigator.kt @@ -0,0 +1,62 @@ +package com.sopt.presentation.main + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.navigation.NavDestination +import androidx.navigation.NavDestination.Companion.hasRoute +import androidx.navigation.NavGraph.Companion.findStartDestination +import androidx.navigation.NavHostController +import androidx.navigation.compose.currentBackStackEntryAsState +import androidx.navigation.compose.rememberNavController +import androidx.navigation.navOptions +import com.sopt.presentation.calendar.navigation.Calendar +import com.sopt.presentation.calendar.navigation.navigateCalendar +import com.sopt.presentation.group.navigation.navigateGroup +import com.sopt.presentation.mypage.navigation.navigateMyPage + +class MainNavigator( + val navController: NavHostController +) { + private val currentDestination: NavDestination? + @Composable get() = navController + .currentBackStackEntryAsState().value?.destination + + val startDestination = Calendar + + val currentTab: MainTab? + @Composable get() = MainTab.find { tab -> + currentDestination?.hasRoute(tab::class) == true + } + + fun navigate(tab: MainTab) { + val navOptions = navOptions { + popUpTo(navController.graph.findStartDestination().id) { + saveState = true + } + launchSingleTop = true + restoreState = true + } + + when (tab) { + MainTab.CALENDAR -> navController.navigateCalendar(navOptions) + MainTab.APPOINTMENT -> navController.navigateGroup(navOptions) + MainTab.MY_PAGE -> navController.navigateMyPage(navOptions) + } + } + + private fun navigateUp() { + navController.navigateUp() + } + + @Composable + fun showBottomBar() = MainTab.contains { + currentDestination?.hasRoute(it::class) == true + } +} + +@Composable +fun rememberMainNavigator( + navController: NavHostController = rememberNavController(), +): MainNavigator = remember(navController) { + MainNavigator(navController) +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/main/MainScreen.kt b/presentation/src/main/java/com/sopt/presentation/main/MainScreen.kt new file mode 100644 index 0000000..865633a --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/main/MainScreen.kt @@ -0,0 +1,191 @@ +package com.sopt.presentation.main + +import android.app.Activity +import androidx.activity.compose.BackHandler +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.EnterTransition +import androidx.compose.animation.ExitTransition +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Icon +import androidx.compose.material3.NavigationBar +import androidx.compose.material3.NavigationBarItem +import androidx.compose.material3.NavigationBarItemDefaults +import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarDuration +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect +import androidx.compose.runtime.SideEffect +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.graphics.Color +import androidx.compose.ui.graphics.Color.Companion.White +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.navigation.compose.NavHost +import com.google.accompanist.systemuicontroller.rememberSystemUiController +import com.sopt.core.designsystem.component.snackbar.BaseSnackBar +import com.sopt.core.util.NoRippleInteractionSource +import com.sopt.presentation.calendar.navigation.calendarNavGraph +import com.sopt.presentation.example.navigation.exampleNavGraph +import com.sopt.presentation.group.navigation.groupNavGraph +import com.sopt.presentation.mypage.navigation.myPageNavGraph +import kotlinx.coroutines.launch + +@Composable +fun MainScreen( + navigator: MainNavigator = rememberMainNavigator(), +) { + val context = LocalContext.current + val systemUiController = rememberSystemUiController() + val lifecycleOwner = LocalLifecycleOwner.current + var backPressedState by remember { mutableStateOf(true) } + var backPressedTime = 0L + val coroutineScope = rememberCoroutineScope() + val snackBarHostState = remember { SnackbarHostState() } + + SideEffect { + systemUiController.setStatusBarColor( + color = White + ) + } + + DisposableEffect(key1 = lifecycleOwner) { + onDispose { + systemUiController.setStatusBarColor( + color = Color.Transparent + ) + } + } + + BackHandler(enabled = backPressedState) { + if (System.currentTimeMillis() - backPressedTime <= 3000) { + (context as Activity).finish() + } else { + backPressedState = true + coroutineScope.launch { + snackBarHostState.showSnackbar( + message = "버튼을 한 번 더 누르면 종료돼요", + duration = SnackbarDuration.Short + ) + } + } + backPressedTime = System.currentTimeMillis() + } + + Scaffold( + snackbarHost = { + SnackbarHost( + hostState = snackBarHostState, + modifier = Modifier.padding(bottom = 10.dp) + ) { snackBarData -> + BaseSnackBar { + Text( + text = snackBarData.visuals.message, + ) + } + } + }, + bottomBar = { + MainBottomBar( + isVisible = navigator.showBottomBar(), + tabs = MainTab.entries.toList(), + currentTab = navigator.currentTab, + onTabSelected = navigator::navigate + ) + }, + ) { paddingValues -> + Column( + modifier = Modifier + .fillMaxSize() + ) { + NavHost( + enterTransition = { + EnterTransition.None + }, + exitTransition = { + ExitTransition.None + }, + popEnterTransition = { + EnterTransition.None + }, + popExitTransition = { + ExitTransition.None + }, + navController = navigator.navController, + startDestination = navigator.startDestination + ) { + exampleNavGraph(navHostController = navigator.navController) + calendarNavGraph( + paddingValues = paddingValues, + navHostController = navigator.navController + ) + groupNavGraph( + paddingValues = paddingValues, + navHostController = navigator.navController + ) + myPageNavGraph( + paddingValues = paddingValues, + navHostController = navigator.navController + ) + } + } + } +} + +@Composable +private fun MainBottomBar( + isVisible: Boolean, + tabs: List, + currentTab: MainTab?, + onTabSelected: (MainTab) -> Unit, +) { + AnimatedVisibility( + visible = isVisible, + ) { + NavigationBar( + containerColor = White + ) { + tabs.forEach { itemType -> + NavigationBarItem( + interactionSource = NoRippleInteractionSource, + selected = currentTab == itemType, + onClick = { + onTabSelected(itemType) + }, + icon = { + Icon( + painter = painterResource(id = (itemType.icon)), + contentDescription = stringResource(id = itemType.contentDescription) + ) + }, + label = { + Text( + text = stringResource(id = itemType.contentDescription), + fontSize = 9.sp + ) + }, + colors = NavigationBarItemDefaults.colors( + selectedIconColor = Color.Black, + selectedTextColor = Color.Black, + unselectedIconColor = Color.Gray, + unselectedTextColor = Color.Gray, + indicatorColor = White + ) + ) + } + } + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/main/MainTab.kt b/presentation/src/main/java/com/sopt/presentation/main/MainTab.kt new file mode 100644 index 0000000..200294d --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/main/MainTab.kt @@ -0,0 +1,45 @@ +package com.sopt.presentation.main + +import androidx.annotation.DrawableRes +import androidx.annotation.StringRes +import androidx.compose.runtime.Composable +import com.sopt.core.navigation.MainTabRoute +import com.sopt.core.navigation.Route +import com.sopt.presentation.R +import com.sopt.presentation.calendar.navigation.Calendar +import com.sopt.presentation.group.navigation.Group +import com.sopt.presentation.mypage.navigation.MyPage + +enum class MainTab( + @DrawableRes val icon: Int, + @StringRes val contentDescription: Int, + val route: MainTabRoute, +) { + CALENDAR( + icon = R.drawable.ic_android_black_24dp, + contentDescription = R.string.bottom_nav_calendar, + route = Calendar + ), + APPOINTMENT( + icon = R.drawable.ic_android_black_24dp, + contentDescription = R.string.bottom_nav_group, + route = Group + ), + MY_PAGE( + icon = R.drawable.ic_android_black_24dp, + contentDescription = R.string.bottom_nav_my_page, + route = MyPage + ); + + companion object { + @Composable + fun find(predicate: @Composable (MainTabRoute) -> Boolean): MainTab? { + return entries.find { predicate(it.route) } + } + + @Composable + fun contains(predicate: @Composable (Route) -> Boolean): Boolean { + return entries.map { it.route }.any { predicate(it) } + } + } +} diff --git a/presentation/src/main/java/com/sopt/presentation/mypage/MyPageRoute.kt b/presentation/src/main/java/com/sopt/presentation/mypage/MyPageRoute.kt new file mode 100644 index 0000000..e86d8dc --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/mypage/MyPageRoute.kt @@ -0,0 +1,95 @@ +package com.sopt.presentation.mypage + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Text +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.setValue +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import com.sopt.core.designsystem.component.button.BaseButton +import com.sopt.core.designsystem.component.textfield.BaseTextField +import com.sopt.core.designsystem.theme.NoostakAndroidTheme +import com.sopt.presentation.R + +@Composable +fun MyPageRoute( + paddingValues: PaddingValues, + navigateToExample: (String) -> Unit, + myPageViewModel: MyPageViewModel = hiltViewModel(), +) { + val context = LocalContext.current + + LaunchedEffect(myPageViewModel.sideEffects) { + myPageViewModel.sideEffects.collect { sideEffect -> + when (sideEffect) { + is MyPageSideEffect.NavigateToExample -> { + navigateToExample(sideEffect.text) + } + } + } + + } + + MyPageScreen( + paddingValues = paddingValues, + onExampleClick = myPageViewModel::navigateToExample + ) +} + +@Composable +fun MyPageScreen( + paddingValues: PaddingValues = PaddingValues(), + onExampleClick: (String) -> Unit, +) { + var text by remember { mutableStateOf("") } + + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues), + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.Center + ) { + Text(text = "MyPage Screen") + BaseTextField( + value = text, + onValueChange = { text = it }, + label = "텍스트 입력칸", + placeholder = "텍스트를 적어주세요", + modifier = Modifier.padding(bottom = 10.dp) + ) + BaseButton( + shape = RoundedCornerShape(30.dp), + style = TextStyle.Default, + paddingVertical = 9.dp, + paddingHorizontal = 20.dp, + text = stringResource(R.string.btn_my_page), + onButtonClick = { onExampleClick(text) } + ) + } +} + +@Preview(showBackground = true) +@Composable +fun MyPageScreenPreview() { + NoostakAndroidTheme { + MyPageScreen( + onExampleClick = {} + ) + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/mypage/MyPageSideEffect.kt b/presentation/src/main/java/com/sopt/presentation/mypage/MyPageSideEffect.kt new file mode 100644 index 0000000..228555f --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/mypage/MyPageSideEffect.kt @@ -0,0 +1,5 @@ +package com.sopt.presentation.mypage + +sealed class MyPageSideEffect { + data class NavigateToExample(val text: String) : MyPageSideEffect() +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/mypage/MyPageViewModel.kt b/presentation/src/main/java/com/sopt/presentation/mypage/MyPageViewModel.kt new file mode 100644 index 0000000..c3cd827 --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/mypage/MyPageViewModel.kt @@ -0,0 +1,22 @@ +package com.sopt.presentation.mypage + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class MyPageViewModel @Inject constructor() : ViewModel() { + private val _sideEffects = MutableSharedFlow() + val sideEffects: SharedFlow get() = _sideEffects.asSharedFlow() + + fun navigateToExample(text: String) { + viewModelScope.launch { + _sideEffects.emit(MyPageSideEffect.NavigateToExample(text)) + } + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/sopt/presentation/mypage/navigation/MyPageNavigation.kt b/presentation/src/main/java/com/sopt/presentation/mypage/navigation/MyPageNavigation.kt new file mode 100644 index 0000000..eb9259f --- /dev/null +++ b/presentation/src/main/java/com/sopt/presentation/mypage/navigation/MyPageNavigation.kt @@ -0,0 +1,36 @@ +package com.sopt.presentation.mypage.navigation + +import androidx.compose.foundation.layout.PaddingValues +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavHostController +import androidx.navigation.NavOptions +import androidx.navigation.compose.composable +import com.sopt.core.navigation.MainTabRoute +import com.sopt.presentation.example.navigation.navigateExample +import com.sopt.presentation.mypage.MyPageRoute +import kotlinx.serialization.Serializable + +fun NavController.navigateMyPage(navOptions: NavOptions? = null) { + navigate( + route = MyPage, + navOptions = navOptions + ) +} + +fun NavGraphBuilder.myPageNavGraph( + paddingValues: PaddingValues, + navHostController: NavHostController +) { + composable { + MyPageRoute( + paddingValues = paddingValues, + navigateToExample = { text -> + navHostController.navigateExample(text = text) + } + ) + } +} + +@Serializable +data object MyPage : MainTabRoute \ No newline at end of file diff --git a/presentation/src/main/res/drawable/ic_android_black_24dp.xml b/presentation/src/main/res/drawable/ic_android_black_24dp.xml new file mode 100644 index 0000000..171b390 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_android_black_24dp.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/presentation/src/main/res/drawable/ic_launcher_background.xml b/presentation/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/presentation/src/main/res/drawable/ic_launcher_foreground.xml b/presentation/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/presentation/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/mipmap-hdpi/ic_launcher.webp b/presentation/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/presentation/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/presentation/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/presentation/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/presentation/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/presentation/src/main/res/mipmap-mdpi/ic_launcher.webp b/presentation/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/presentation/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/presentation/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/presentation/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/presentation/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/presentation/src/main/res/mipmap-xhdpi/ic_launcher.webp b/presentation/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/presentation/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/presentation/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/presentation/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/presentation/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/presentation/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/presentation/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/presentation/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/presentation/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/presentation/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/presentation/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/presentation/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml new file mode 100644 index 0000000..e567367 --- /dev/null +++ b/presentation/src/main/res/values/strings.xml @@ -0,0 +1,15 @@ + + Noostak-Android + + + 캘린더 + 그룹 + 내정보 + + + Server Success + Server Error + 팔로워 목록 + 예제 화면으로 이동하기 + 뒤로 돌아가기 + \ No newline at end of file diff --git a/presentation/src/main/res/values/themes.xml b/presentation/src/main/res/values/themes.xml new file mode 100644 index 0000000..149593b --- /dev/null +++ b/presentation/src/main/res/values/themes.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/xml/backup_rules.xml b/presentation/src/main/res/xml/backup_rules.xml new file mode 100644 index 0000000..fa0f996 --- /dev/null +++ b/presentation/src/main/res/xml/backup_rules.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/presentation/src/main/res/xml/data_extraction_rules.xml b/presentation/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 0000000..9ee9997 --- /dev/null +++ b/presentation/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/presentation/src/test/java/com/sopt/presentation/ExampleUnitTest.kt b/presentation/src/test/java/com/sopt/presentation/ExampleUnitTest.kt new file mode 100644 index 0000000..f37d2f2 --- /dev/null +++ b/presentation/src/test/java/com/sopt/presentation/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package com.sopt.presentation + +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) + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..25f0448 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,28 @@ +pluginManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + gradlePluginPortal() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + maven ("https://devrepo.kakao.com/nexus/content/groups/public/") + } +} + +rootProject.name = "Noostak-Android" +include(":app") +include(":domain") +include(":core") +include(":data") +include(":presentation")