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

Feature/jaino/#35 #36

Merged
merged 32 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8c6050b
[CHORE] #17 : safe args plugin ์ถ”๊ฐ€
jeongjaino Oct 18, 2023
7762d60
[CHORE] #17 : safe args custom plugin ๊ตฌํ˜„ ๋ฐ ๋“ฑ๋ก
jeongjaino Oct 18, 2023
3673ed6
[FEATURE] #17 : ์‚ฌ์šฉ์ž uid ๊ฐ€์ ธ์˜ค๋Š” ๋กœ์ง ๊ตฌํ˜„
jeongjaino Oct 19, 2023
51574b6
[STYLE] #17 : Hilt binds ํ•จ์ˆ˜๋“ค ๋ฉ”์†Œ๋“œ ๋„ค์ด๋ฐ provides -> binds๋กœ ๋ณ€๊ฒฝ
jeongjaino Oct 19, 2023
439ea81
[CHORE] #17 : NetworkModule -> FirebaseModule rename
jeongjaino Oct 19, 2023
51d168e
[FEATURE] #17 : DataSource Module ๊ตฌํ˜„
jeongjaino Oct 19, 2023
830e4fa
[CHORE] #17 : Compose Navigation ์ถ”๊ฐ€
jeongjaino Oct 19, 2023
7fc195e
[CHORE] #17 : kotlin jvmToolChain ์†Œ๊ฑฐ in build-logics
jeongjaino Oct 19, 2023
b7fbe78
[FEATURE] #17 : userId ๊ฐ€์ ธ์™€, DataSource Argument์— ํ•ด๋‹น userId ์‚ฝ์ž… ๋กœ์ง ๊ตฌํ˜„
jeongjaino Oct 19, 2023
8b99f10
[FIX] #17 : ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ Equal -> Instance ๋น„๊ต๋กœ ์ˆ˜์ •
jeongjaino Oct 19, 2023
f7e13c3
[CHORE] #17 : Argument naming ๋ฐ ๊ฐ„๊ฒฉ ์ˆ˜์ •
jeongjaino Oct 19, 2023
37a5c7a
[FEATURE] #17 : SignInUseCase ์ˆ˜ํ–‰ ๋ฐ ์ฒ˜๋ฆฌ ๋กœ์ง ๊ตฌํ˜„
jeongjaino Oct 19, 2023
7e53c6e
[FEATURE] #17 : SignInScreen์ด ์˜ฌ๋ ค์ง€๋Š” SignInFragment ๊ตฌํ˜„
jeongjaino Oct 19, 2023
75ce27a
[FEATURE] #17 : StateFul -> StateLess Field๋กœ ์ˆ˜์ •
jeongjaino Oct 19, 2023
520fa2c
[FEATURE] #17 : SignUpViewModel ๊ตฌํ˜„
jeongjaino Oct 19, 2023
0829da8
[FEATURE] #17 : Screen State ๋ชจ๋‘ ViewModel hoisting ๊ตฌํ˜„
jeongjaino Oct 19, 2023
997ec44
[FEATURE] #17 : Selected Item State ๋ชจ๋‘ ViewModel hoisting ๊ตฌํ˜„
jeongjaino Oct 19, 2023
84b63e1
[FEATURE] #17 : SignUpFragment ๋ฐ Navigation ๊ตฌํ˜„
jeongjaino Oct 19, 2023
8c19a23
[FEATURE] #17 : auth_nav ๊ตฌํ˜„ํ•˜๊ธฐ
jeongjaino Oct 19, 2023
ae4f680
[FEATURE] #17 : auth_nav ๋“ฑ๋ก ๋ฐ hide bottom bar ๋กœ์ง๊ตฌํ˜„
jeongjaino Oct 19, 2023
20f69df
[STYLE] #17 : Convention์— ๋งž๊ฒŒ ํฌ๋งทํŒ… ์ˆ˜์ •(์ธ๋ดํŠธ, ํŠธ๋ ˆ์ธ ํฌ๋ž˜์‰ฌ)
jeongjaino Oct 19, 2023
c4f75c4
[CHORE] #17 : ์ ‘๊ทผ ์ œํ•œ์ž ์ˆ˜์ • Composable -> internal / private
jeongjaino Oct 20, 2023
a246ba7
[CHORE] #17 : 1ํ•™๊ธฐ, 2ํ•™๊ธฐ String Resource ์ถ”๊ฐ€
jeongjaino Oct 20, 2023
6c10d3a
[CHORE] #17 : 1ํ•™๊ธฐ Const ๋“ฑ๋ก
jeongjaino Oct 20, 2023
5418b19
[CHORE] #35 : base Module -> common Module renaming
jeongjaino Oct 20, 2023
9c09787
[CHORE] #35 : base Module -> common Module renaming
jeongjaino Oct 20, 2023
c0b4214
[CHORE] #35 : Firebase ์ข…์†์„ฑ ์ถ”๊ฐ€
jeongjaino Oct 20, 2023
b7bd047
[CHORE] #35 : RepeatOnLifeCycle -> CoroutinesExtensions Rename
jeongjaino Oct 20, 2023
2dac9f6
[CHORE] #35 : ์˜ˆ์™ธ์— ๋”ฐ๋ผ Text ๋ณ€ํ™˜ ์ต์Šคํ…์…˜ ๊ตฌํ˜„
jeongjaino Oct 20, 2023
b67b922
[FEATURE] #35 : ModalBottomSheet -> BottomSheetScaffold ์ „ํ™˜, ์˜ˆ์™ธ ์‚ฌํ•ญ Snaโ€ฆ
jeongjaino Oct 20, 2023
e08ea2c
[FEATURE] #35 : Failure Event Exception -> SnackBar ๋…ธ์ถœ ๊ตฌํ˜„
jeongjaino Oct 20, 2023
d4309fc
[CHORE] #35 : SignInBottomSheet -> SignInScreen, SignInScreen -> Signโ€ฆ
jeongjaino Oct 21, 2023
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
2 changes: 1 addition & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id("com.wap.wapp.firebase")
id("com.wap.wapp.compose")
id("com.wap.wapp.hilt")
id("com.wap.wapp.navigation")
}

android {
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/com/wap/wapp/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.wap.wapp

import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import androidx.navigation.NavController
Expand Down Expand Up @@ -39,7 +37,7 @@ class MainActivity : AppCompatActivity() {
val typedArray = resources.obtainTypedArray(R.array.hide_bottomNavigation_fragments)

for (index in 0..typedArray.length()) {
hideBottomNavigationFragments.add(typedArray.getResourceId(index, 0,))
hideBottomNavigationFragments.add(typedArray.getResourceId(index, 0))
}

typedArray.recycle()
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/navigation/nav_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
android:id="@+id/main_nav"
app:startDestination="@id/nav_splash">

<include app:graph="@navigation/nav_auth" />
<include app:graph="@navigation/nav_manage" />
<include app:graph="@navigation/nav_notice" />
<include app:graph="@navigation/nav_profile" />
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
<resources>
<array name="hide_bottomNavigation_fragments">
<item>@id/splashFragment</item>
<item>@id/signInFragment</item>
<item>@id/signUpFragment</item>
</array>
</resources>
8 changes: 4 additions & 4 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ plugins{
`kotlin-dsl`
}

kotlin {
jvmToolchain(17)
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -42,5 +38,9 @@ gradlePlugin {
id = "com.wap.wapp.hilt"
implementationClass = "com.wap.wapp.plugin.AndroidHiltPlugin"
}
create("androidNavigation") {
id = "com.wap.wapp.navigation"
implementationClass = "com.wap.wapp.plugin.AndroidNavigationPlugin"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class AndroidFeatureConventionPlugin: Plugin<Project>{
apply("com.wap.wapp.library")
apply("com.wap.wapp.compose")
apply("com.wap.wapp.hilt")
apply("com.wap.wapp.navigation")
}
configureBinding()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.wap.wapp.plugin

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType

class AndroidNavigationPlugin: Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("androidx.navigation.safeargs")
}

val libs = extensions.getByType<VersionCatalogsExtension>().named("libs")

dependencies{
"implementation"(libs.findLibrary("androidx-navigation-fragment-ktx").get())
"implementation"(libs.findLibrary("androidx-navigation-ui-ktx").get())
"implementation"(libs.findLibrary("androidx-navigation-compose").get())
}
}
}
}
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ buildscript {
dependencies {
classpath(libs.android.build)
classpath(libs.kotlin.gradle)
classpath(libs.androidx.navigation.safeargs)
classpath(libs.hilt.gradle)
classpath(libs.google.services.gradle)
classpath(libs.firebase.crashlytics.gradle)
Expand All @@ -16,6 +17,7 @@ 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.androidx.navigation.safeargs) apply false
alias(libs.plugins.dagger.hilt) apply false
alias(libs.plugins.google.services) apply false
alias(libs.plugins.firebase.crashlytics) apply false
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ android {

dependencies {
implementation(libs.bundles.androidx)
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.auth)
implementation(libs.firebase.firestore)
implementation(libs.material)

testImplementation(libs.junit)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.android.mediproject.core.ui.base
package com.wap.wapp.core.commmon.base

import android.os.Bundle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ•˜ํ•˜ ์ฝ”๋“œ ๋ฆฌ๋ทฐ ๋•Œ ๊ฒ€์‚ฌํ•˜์ง€ ๋ชปํ•œ ์™€ํƒ€์‹œ๋„ ์ฑ…์ž„์ด ์žˆ์Šต๋‹ˆ๋‹ค ํ•˜ํ•˜

import android.util.Log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.wap.wapp.core.base.util
package com.wap.wapp.core.commmon.extensions

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.wap.wapp.core.commmon.extensions

import com.google.firebase.auth.FirebaseAuthException
import com.google.firebase.firestore.FirebaseFirestoreException
import java.net.UnknownHostException

fun Throwable.toSupportingText(): String {
return when (this) {
is UnknownHostException -> {
"๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ์ด ์›ํ™œํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."
}
is FirebaseAuthException -> {
this.toSupportingText()
}
is FirebaseFirestoreException -> {
this.toSupportingText()
}
else -> {
"์•Œ ์ˆ˜ ์—†๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค."
}
}
}
Comment on lines +7 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—ฌ๊ธฐ์„œ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ๋ฐ›๊ณ  ์ž‡์—ˆ๊พผ์š”.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„น๋„น๋„น๋„น๋„น

https://firebase.google.com/docs/reference/unity/namespace/firebase/firestore#namespace_firebase_1_1_firestore_1a24804fae11b868e5f88ba5d44d1500a8

์—ฌ๊ธฐ์— ์˜ˆ์™ธ ๋ ˆํผ๋Ÿฐ์Šค ์žˆ์–ด์šฉ


fun FirebaseAuthException.toSupportingText(): String {
return when (this.errorCode) {
"ERROR_WEB_CONTEXT_CANCELED", "ERROR_USER_CANCELLED" -> {
"๋‹ค์‹œ ์‹œ๋„ํ•ด ์ฃผ์„ธ์š”."
}
else -> {
"์•Œ ์ˆ˜ ์—†๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค."
}
}
}

fun FirebaseFirestoreException.toSupportingText(): String {
return when (this.code.value()) {
7 -> {
"์ ‘๊ทผ ๊ถŒํ•œ์ด ์—†์Šต๋‹ˆ๋‹ค."
}
16 -> {
"ํšŒ์›์ด ๋งŒ๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์‹œ ๋กœ๊ทธ์ธ ํ•ด์ฃผ์„ธ์š”."
}
else -> {
"์•Œ ์ˆ˜ ์—†๋Š” ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค."
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import dagger.hilt.android.scopes.ActivityScoped
abstract class AuthRepositoryModule {
@Binds
@ActivityScoped
abstract fun providesAuthRepository(
abstract fun bindsAuthRepository(
authRepositoryImpl: AuthRepositoryImpl,
): AuthRepository
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import javax.inject.Singleton
abstract class DataModule {
@Binds
@Singleton
abstract fun providesUserRepository(
abstract fun bindsUserRepository(
userRepositoryImpl: UserRepositoryImpl,
): UserRepository
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.wap.wapp.core.model.user.UserProfile
interface UserRepository {
suspend fun getUserProfile(userId: String): Result<UserProfile>

suspend fun getUserId(): Result<String>

suspend fun postUserProfile(
userId: String,
userName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class UserRepositoryImpl @Inject constructor(
}
}

override suspend fun getUserId(): Result<String> {
return userDataSource.getUserId()
}

override suspend fun postUserProfile(
userId: String,
userName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.wap.wapp.core.domain.model.AuthState
import com.wap.wapp.core.domain.model.AuthState.SIGN_IN
import com.wap.wapp.core.domain.model.AuthState.SIGN_UP
import dagger.hilt.android.scopes.ActivityScoped
import java.lang.IllegalStateException
import javax.inject.Inject

@ActivityScoped
Expand All @@ -21,13 +22,15 @@ class SignInUseCase @Inject constructor(
userRepository.getUserProfile(userId)
.fold(
onFailure = { exception ->
// ์‚ฌ์šฉ์ž๋ฅผ ์กฐํšŒํ•  ์ˆ˜ ์—†๋Š” ์˜ˆ์™ธ์ธ ๊ฒฝ์šฐ
val userNotFoundException = IllegalStateException()
if (exception == userNotFoundException) {
SIGN_UP
when (exception) {
// ์‚ฌ์šฉ์ž๋ฅผ ์กฐํšŒํ•  ์ˆ˜ ์—†๋Š” ์˜ˆ์™ธ์ธ ๊ฒฝ์šฐ
is IllegalStateException -> {
SIGN_UP
}
else -> {
throw (exception)
}
}
// ์ด์™ธ์˜ ์˜ˆ์™ธ๋ผ๋ฉด,
throw (exception)
},
onSuccess = {
SIGN_IN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ class PostUserProfileUseCase @Inject constructor(
private val userRepository: UserRepository,
) {
suspend operator fun invoke(
userId: String,
userName: String,
studentId: String,
registeredAt: String,
): Result<Unit> {
return userRepository.postUserProfile(
userId = userId,
userName = userName,
studentId = studentId,
registeredAt = registeredAt,
)
return runCatching {
val userId = userRepository.getUserId().getOrThrow()

userRepository.postUserProfile(
userId = userId,
userName = userName,
studentId = studentId,
registeredAt = registeredAt,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import dagger.hilt.android.scopes.ActivityScoped
abstract class AuthDataSourceModule {
@Binds
@ActivityScoped
abstract fun providesAuthDataSource(
abstract fun bindsAuthDataSource(
authDataSourceImpl: AuthDataSourceImpl,
): AuthDataSource
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.wap.wapp.core.network.di

import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.ktx.auth
import com.google.firebase.firestore.FirebaseFirestore
import com.google.firebase.firestore.ktx.firestore
import com.google.firebase.ktx.Firebase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object FirebaseModule {
@Provides
@Singleton
fun providesFirebaseAuth(): FirebaseAuth = Firebase.auth

@Provides
@Singleton
fun providesFirestore(): FirebaseFirestore = Firebase.firestore
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package com.wap.wapp.core.network.di

import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.ktx.auth
import com.google.firebase.firestore.FirebaseFirestore
import com.google.firebase.firestore.ktx.firestore
import com.google.firebase.ktx.Firebase
import com.wap.wapp.core.network.source.user.UserDataSource
import com.wap.wapp.core.network.source.user.UserDataSourceImpl
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {
@Provides
@Singleton
fun providesFirebaseAuth(): FirebaseAuth = Firebase.auth
abstract class NetworkModule {

@Provides
@Binds
@Singleton
fun providesFirestore(): FirebaseFirestore = Firebase.firestore
abstract fun bindsUserDataSource(
userDataSourceImpl: UserDataSourceImpl,
): UserDataSource
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ interface UserDataSource {
suspend fun postUserProfile(userProfileRequest: UserProfileRequest): Result<Unit>

suspend fun getUserProfile(userId: String): Result<UserProfileResponse>

suspend fun getUserId(): Result<String>
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.wap.wapp.core.network.source.user

import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.firestore.FirebaseFirestore
import com.google.firebase.firestore.SetOptions
import com.wap.wapp.core.network.constant.USER_COLLECTION
Expand All @@ -10,6 +11,7 @@ import javax.inject.Inject

class UserDataSourceImpl @Inject constructor(
private val firebaseFirestore: FirebaseFirestore,
private val firebaseAuth: FirebaseAuth,
) : UserDataSource {
override suspend fun postUserProfile(
userProfileRequest: UserProfileRequest,
Expand All @@ -28,6 +30,12 @@ class UserDataSourceImpl @Inject constructor(
}
}

override suspend fun getUserId(): Result<String> {
return runCatching {
checkNotNull(firebaseAuth.uid)
}
}

override suspend fun getUserProfile(
userId: String,
): Result<UserProfileResponse> {
Expand Down
Loading