Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] 밈 등록 Register 모듈 추가 #241

Merged
merged 6 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ dependencies {
implementation(project(":feature:search"))
implementation(project(":feature:setting"))
implementation(project(":feature:splash"))
implementation(project(":feature:register"))

implementation(libs.core.ktx)
implementation(libs.lifecycle)
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
android:exported="false"
android:theme="@style/Theme.PPAC" />

<activity
android:name=".register.RegisterActivity"
android:exported="false"
android:theme="@style/Theme.PPAC" />

<activity
android:name=".splash.SplashActivity"
android:exported="true"
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/team/ppac/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import team.ppac.navigation.FarmemeNavHost
import team.ppac.navigation.component.FarmemeBottomBar
import team.ppac.navigation.navigateToTopLevelDestination
import team.ppac.navigator.DetailNavigator
import team.ppac.navigator.RegisterNavigator
import team.ppac.navigator.SettingNavigator
import javax.inject.Inject

Expand All @@ -29,6 +30,9 @@ class MainActivity : ComponentActivity() {
@Inject
lateinit var settingNavigator: SettingNavigator

@Inject
lateinit var registerNavigator: RegisterNavigator

@Inject
lateinit var analyticsHelper: AnalyticsHelper

Expand Down Expand Up @@ -73,6 +77,9 @@ class MainActivity : ComponentActivity() {
navigateToSetting = {
settingNavigator.navigateFrom(this@MainActivity)
},
navigateToRegister = {
registerNavigator.navigateFrom(this@MainActivity)
}
)
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/team/ppac/navigation/FarmemeNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fun FarmemeNavHost(
navController: NavHostController,
navigateToDetail: (String) -> Unit,
navigateToSetting: () -> Unit,
navigateToRegister: () -> Unit,
) {
NavHost(
modifier = modifier,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package team.ppac.navigator

import team.ppac.navigator.base.Navigator

interface RegisterNavigator : Navigator
1 change: 1 addition & 0 deletions feature/register/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
48 changes: 48 additions & 0 deletions feature/register/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.dagger.hilt)
alias(libs.plugins.kotlin.kapt)
}

android {
namespace = "team.ppac.feature.register"
compileSdk = libs.versions.compileSdk.get().toInt()
defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}
}

dependencies {
implementation(project(":core:analytics"))
implementation(project(":core:common:android"))
implementation(project(":core:common:kotlin"))
implementation(project(":core:domain"))
implementation(project(":core:designsystem"))
implementation(project(":core:navigator"))
implementation(project(":core:error-handling"))

implementation(platform(libs.compose.bom))
implementation(libs.bundles.compose)
implementation(libs.bundles.lifecycle)
implementation(libs.appcompat)
implementation(libs.core.ktx)
implementation(libs.kotlin.coroutines.android)
implementation(libs.timber)
implementation(libs.hilt.android)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.paging.runtime)
implementation(libs.paging.compose)
implementation(libs.compose.lottie)
kapt(libs.hilt.compiler)
}
4 changes: 4 additions & 0 deletions feature/register/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package team.ppac.register

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.core.view.WindowCompat
import dagger.hilt.android.AndroidEntryPoint
import team.ppac.common.android.util.noTransitionAnimation
import team.ppac.designsystem.FarmemeTheme

@AndroidEntryPoint
class RegisterActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
FarmemeTheme {
RegisterRoute()
}
}
noTransitionAnimation()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package team.ppac.register

import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.hilt.navigation.compose.hiltViewModel
import team.ppac.common.android.base.BaseComposable

@Composable
internal fun RegisterRoute(
viewModel: RegisterViewModel = hiltViewModel(),
) {
BaseComposable(viewModel = viewModel) { uiState ->
LaunchedEffect(key1 = viewModel) {
viewModel.sideEffect.collect { sideEffect ->
// when (sideEffect) {
//
// }
}
}

RegisterScreen(
uiState = uiState,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package team.ppac.register

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import team.ppac.designsystem.component.scaffold.FarmemeScaffold
import team.ppac.register.mvi.RegisterUiState

@Composable
internal fun RegisterScreen(
uiState: RegisterUiState,
) {
FarmemeScaffold(
modifier = Modifier.fillMaxSize(),
) {
LazyColumn(
modifier = Modifier.fillMaxSize(),
) {
item {
Text(text = "RegisterScreen")
}
}
}
}

@Preview
@Composable
private fun RegisterScreenPreview() {
RegisterScreen(
uiState = RegisterUiState.INITIAL_STATE,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package team.ppac.register

import androidx.lifecycle.SavedStateHandle
import dagger.hilt.android.lifecycle.HiltViewModel
import team.ppac.common.android.base.BaseViewModel
import team.ppac.errorhandling.FarmemeNetworkException
import team.ppac.register.mvi.RegisterIntent
import team.ppac.register.mvi.RegisterSideEffect
import team.ppac.register.mvi.RegisterUiState
import javax.inject.Inject

@HiltViewModel
class RegisterViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
) : BaseViewModel<RegisterUiState, RegisterSideEffect, RegisterIntent>(savedStateHandle) {

override fun createInitialState(savedStateHandle: SavedStateHandle): RegisterUiState {
return RegisterUiState.INITIAL_STATE
}

override fun handleClientException(throwable: Throwable) {
if (throwable is FarmemeNetworkException) {
reduce {
copy(isError = true)
}
}
}

override suspend fun handleIntent(intent: RegisterIntent) {
// when (intent) {
//
// }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package team.ppac.register.di

import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import dagger.hilt.android.scopes.ActivityScoped
import team.ppac.navigator.RegisterNavigator
import team.ppac.register.navigator.RegisterNavigatorImpl

@Module
@InstallIn(ActivityComponent::class)
internal abstract class RegisterNavigatorModule {
@Binds
@ActivityScoped
abstract fun bindRegisterNavigator(impl: RegisterNavigatorImpl): RegisterNavigator
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package team.ppac.register.mvi

import team.ppac.common.android.base.UiIntent

sealed interface RegisterIntent : UiIntent {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package team.ppac.register.mvi

import team.ppac.common.android.base.UiSideEffect

sealed class RegisterSideEffect : UiSideEffect {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package team.ppac.register.mvi

import team.ppac.common.android.base.UiState

data class RegisterUiState(
val isLoading: Boolean,
val isError: Boolean,
) : UiState {

companion object {
val INITIAL_STATE = RegisterUiState(
isLoading = false,
isError = false,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package team.ppac.register.navigator

import android.app.Activity
import android.content.Context
import android.content.Intent
import androidx.activity.result.ActivityResultLauncher
import team.ppac.common.android.extension.getIntent
import team.ppac.navigator.RegisterNavigator
import team.ppac.register.RegisterActivity
import javax.inject.Inject

class RegisterNavigatorImpl @Inject constructor() : RegisterNavigator {
override fun navigateFrom(
activity: Activity,
intentBuilder: Intent.() -> Intent,
withFinish: Boolean
) {
activity.startActivity(activity.getIntent<RegisterActivity>(intentBuilder))
if (withFinish) activity.finish()
}

override fun navigateResultLauncher(
launcher: ActivityResultLauncher<Intent>,
activity: Activity,
intentBuilder: Intent.() -> Intent
) {
launcher.launch(activity.getIntent<RegisterActivity>(intentBuilder))
}

override fun navigateResultLauncher(
launcher: ActivityResultLauncher<Intent>,
context: Context,
intentBuilder: Intent.() -> Intent
) {
launcher.launch(context.getIntent<RegisterActivity>(intentBuilder))
}
}
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ include(":feature:mypage")
include(":feature:detail")
include(":feature:setting")
include(":feature:splash")
include(":feature:register")