Skip to content

Commit

Permalink
Merge pull request #86 from everymeals/feature/school_auth_screen
Browse files Browse the repository at this point in the history
[Feature/school_auth_screen]: 학교 이메일 인증 작업
  • Loading branch information
kez-lab authored Nov 15, 2023
2 parents 1bc3d35 + e72050b commit b38640b
Show file tree
Hide file tree
Showing 21 changed files with 581 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.everymeal.everymeal_android.di

import com.everymeal.data.service.auth.AuthApi
import com.everymeal.data.service.onboarding.OnboardingApi
import com.everymeal.everymeal_android.BuildConfig
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
Expand All @@ -24,7 +25,7 @@ object NetworkModule {

@Provides
@Singleton
fun provideClient(): OkHttpClient {
fun provideClient(): OkHttpClient {
return OkHttpClient.Builder()
.connectTimeout(100, TimeUnit.SECONDS)
.readTimeout(100, TimeUnit.SECONDS)
Expand All @@ -46,4 +47,10 @@ object NetworkModule {
fun provideOnboardingApi(retrofit: Retrofit): OnboardingApi {
return retrofit.create(OnboardingApi::class.java)
}
}

@Provides
@Singleton
fun provideAuthApi(retrofit: Retrofit): AuthApi {
return retrofit.create(AuthApi::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.everymeal.everymeal_android.di

import com.everymeal.data.datasource.auth.AuthRemoteDataSource
import com.everymeal.data.datasource.auth.AuthRemoteRemoteDataSourceImpl
import com.everymeal.data.datasource.onboarding.OnboardingDataSource
import com.everymeal.data.datasource.onboarding.OnboardingDataSourceImpl
import com.everymeal.data.repository.DefaultAuthRepository
import com.everymeal.data.repository.onboarding.OnboardingRepositoryImpl
import com.everymeal.domain.repository.auth.AuthRepository
import com.everymeal.domain.repository.onboarding.OnboardingRepository
import dagger.Binds
import dagger.Module
Expand All @@ -25,4 +29,16 @@ abstract class RepositoryModule {
abstract fun bindOnboardingDataSource(
onboardingDataSourceImpl: OnboardingDataSourceImpl
): OnboardingDataSource
}

@Singleton
@Binds
abstract fun bindAuthRemoteDataSource(
authRemoteDataSourceImpl: AuthRemoteRemoteDataSourceImpl
): AuthRemoteDataSource

@Singleton
@Binds
abstract fun bindAuthRepository(
defaultAuthRepository: DefaultAuthRepository
): AuthRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.everymeal.data.datasource.auth

import com.everymeal.domain.model.auth.Email

interface AuthRemoteDataSource {
suspend fun postEmail(email: Email): Result<String>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.everymeal.data.datasource.auth

import com.everymeal.data.model.auth.toEmailRequest
import com.everymeal.data.model.unwrapData
import com.everymeal.data.service.auth.AuthApi
import com.everymeal.domain.model.auth.Email
import javax.inject.Inject

class AuthRemoteRemoteDataSourceImpl @Inject constructor(
private val authApi: AuthApi
) : AuthRemoteDataSource {

override suspend fun postEmail(email: Email): Result<String> = runCatching {
authApi.postEmail(email.toEmailRequest())
}.unwrapData()
}
20 changes: 20 additions & 0 deletions data/src/main/java/com/everymeal/data/model/auth/EmailRequest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.everymeal.data.model.auth


import com.everymeal.domain.model.auth.Email
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class EmailRequest(
@SerialName("email")
val email: String? = null
)

fun EmailRequest.toEmail() = Email(
email = email ?: ""
)

fun Email.toEmailRequest() = EmailRequest(
email = email
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.everymeal.data.repository

import com.everymeal.data.datasource.auth.AuthRemoteDataSource
import com.everymeal.domain.model.auth.Email
import com.everymeal.domain.repository.auth.AuthRepository
import javax.inject.Inject

class DefaultAuthRepository @Inject constructor(
private val authRemoteDataSource: AuthRemoteDataSource
) : AuthRepository {
override suspend fun postEmail(email: Email): Result<String> {
return authRemoteDataSource.postEmail(email)
}
}
10 changes: 10 additions & 0 deletions data/src/main/java/com/everymeal/data/service/auth/AuthApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.everymeal.data.service.auth

import com.everymeal.data.model.BaseResponse
import com.everymeal.data.model.auth.EmailRequest
import retrofit2.http.POST

interface AuthApi {
@POST("/api/v1/users/email")
suspend fun postEmail(emailRequest: EmailRequest): BaseResponse<String>
}
5 changes: 5 additions & 0 deletions domain/src/main/java/com/everymeal/domain/model/auth/Email.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.everymeal.domain.model.auth

data class Email(
val email: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.everymeal.domain.repository.auth

import com.everymeal.domain.model.auth.Email

interface AuthRepository {
suspend fun postEmail(email: Email): Result<String>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.everymeal.domain.usecase.auth

import com.everymeal.domain.model.auth.Email
import com.everymeal.domain.repository.auth.AuthRepository
import javax.inject.Inject

class PostEmailUseCase @Inject constructor(
private val authRepository: AuthRepository
) {
suspend operator fun invoke(
email: Email
): Result<String> {
return authRepository.postEmail(email)
}
}
8 changes: 3 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ espresso-core = "3.5.1"
lifecycle-runtime-ktx = "2.6.2"
activity = "1.7.2"
compose-bom = "2023.10.01"

dagger-hilt = "2.46.1"
hilt-compose = "1.0.0"

okhttp = "4.11.0"
retrofit = "2.9.0"
serialization = "1.6.0"
kotlin-serilization = "1.0.0"

lottie = "6.1.0"

compose-navigation = "2.7.4"
accompanist = "0.33.0-alpha"

[libraries]
agp = { module = "com.android.tools.build:gradle", version.ref = "agp" }
Expand All @@ -41,6 +38,7 @@ ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview
ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
material3 = { group = "androidx.compose.material3", name = "material3" }
accompanist-webview = { group = "com.google.accompanist", name = "accompanist-webview", version.ref = "accompanist" }

# Kotlin
kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }
Expand All @@ -57,7 +55,7 @@ hilt-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref =

# Retrofit
okhttp-bom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttp" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp"}
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
okhttp-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }

Expand Down
4 changes: 4 additions & 0 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ dependencies {
implementation(libs.ui.graphics)
implementation(libs.ui.tooling.preview)
implementation(libs.material3)
implementation(libs.accompanist.webview)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.espresso.core)
Expand All @@ -75,6 +76,9 @@ dependencies {
implementation(libs.hilt.compose)
kapt(libs.hilt.testing.compiler)

// Retrofit
implementation(libs.retrofit)

// Lottie
implementation(libs.compose.lottie)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
Expand All @@ -34,9 +36,11 @@ import com.everymeal.presentation.R
import com.everymeal.presentation.ui.detail.ReportCategoryType
import com.everymeal.presentation.ui.home.HomeCategoryList
import com.everymeal.presentation.ui.theme.EveryMealTypo
import com.everymeal.presentation.ui.theme.EveryMealTypography
import com.everymeal.presentation.ui.theme.Gray200
import com.everymeal.presentation.ui.theme.Gray400
import com.everymeal.presentation.ui.theme.Gray600
import com.everymeal.presentation.ui.theme.Gray700
import com.everymeal.presentation.ui.theme.Gray800
import com.everymeal.presentation.ui.theme.Gray900
import com.everymeal.presentation.ui.theme.Grey2
Expand All @@ -49,7 +53,7 @@ import com.everymeal.presentation.ui.theme.Typography
fun EveryMealMainBottomSheetDialog(
title: String,
content: String,
onClick : () -> Unit,
onClick: () -> Unit,
onDismiss: () -> Unit
) {
ModalBottomSheet(
Expand Down Expand Up @@ -148,7 +152,7 @@ fun SortCategoryItem(
color = Gray900,
style = EveryMealTypo.displayMedium,
)
if(title == category) {
if (title == category) {
Image(
modifier = Modifier.size(24.dp),
imageVector = ImageVector.vectorResource(R.drawable.icon_check_mono),
Expand Down Expand Up @@ -266,6 +270,7 @@ fun RatingItem(
}
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EveryMealReportBottomSheetDialog(
Expand Down Expand Up @@ -305,6 +310,74 @@ fun EveryMealReportBottomSheetDialog(
}
}

data class EveryMealConditionAgreeDialogItem(
val title: String,
val isAgreed: Boolean,
val isEssential: Boolean = false,
)

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EveryMealConditionAgreeDialog(
onItemClicked: (Int) -> Unit,
onNextButtonClicked: () -> Unit,
onDismiss: () -> Unit,
conditionItems: List<EveryMealConditionAgreeDialogItem>
) {
ModalBottomSheet(
onDismissRequest = { onDismiss() },
containerColor = Color.White,
) {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 20.dp)
) {
Text(
text = stringResource(R.string.condition_agree_title),
style = EveryMealTypography.Heading2,
color = Gray900,
)
Spacer(modifier = Modifier.size(13.dp))
LazyColumn(content = {
itemsIndexed(conditionItems) {index, item ->
Row(
modifier = Modifier
.clickable(onClick = {
onItemClicked(index)
})
.padding(vertical = 7.dp),
) {
Image(
painter = if (item.isAgreed) painterResource(
id = R.drawable.icon_check_mono
) else painterResource(id = R.drawable.icon_check_gray_mono),
contentDescription = "check"
)
Text(
modifier = Modifier.padding(start = 6.dp),
text = item.title,
style = EveryMealTypography.Subtitle3,
color = Gray700,
)
Spacer(modifier = Modifier.weight(1f))
Image(
painter = painterResource(id = R.drawable.icon_arrow_right),
contentDescription = null
)
}
}
})
EveryMealMainButton(
text = stringResource(R.string.ok),
enabled = true,
onClick = onNextButtonClicked,
)
Spacer(modifier = Modifier.size(24.dp))
}
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EveryMealDetailReportBottomSheetDialog(
Expand Down Expand Up @@ -385,7 +458,7 @@ fun ReportCategoryItem(
modifier = Modifier.size(24.dp),
imageVector = ImageVector.vectorResource(R.drawable.icon_check_gray_mono),
contentDescription = null,
colorFilter = if(title == category) {
colorFilter = if (title == category) {
ColorFilter.tint(Main100)
} else {
ColorFilter.tint(Gray400)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ fun EveryMealTextField(
modifier: Modifier = Modifier,
value: String,
onValueChange: (String) -> Unit,
placeholderText: String,
placeholderText: String = "",
isError: Boolean = false,
supportingText: (@Composable () -> Unit)? = null,
leadingIcon: (@Composable () -> Unit)? = null,
otherCustomization: (@Composable () -> Unit)? = null
) {
Expand All @@ -28,6 +30,8 @@ fun EveryMealTextField(
value = value,
onValueChange = onValueChange,
leadingIcon = leadingIcon,
isError = isError,
supportingText = supportingText,
placeholder = {
Text(
text = placeholderText,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ fun MainScreen(
@Composable
fun MainScreenPreview() {
MainScreen()
}
}
Loading

0 comments on commit b38640b

Please sign in to comment.