-
Notifications
You must be signed in to change notification settings - Fork 0
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
Settings #27
Settings #27
Changes from all commits
4b925d5
647457c
688bb5b
f10a8d5
f3ce863
669624c
8e2a050
873bb9b
99018cf
acaaea3
86b7f65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
package com.example.data.di | ||
|
||
import com.example.data.BuildConfig | ||
import com.example.data.retrofit.AddInterceptor | ||
import com.example.data.retrofit.UserService | ||
import com.google.gson.GsonBuilder | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import okhttp3.Interceptor | ||
import okhttp3.OkHttpClient | ||
import okhttp3.Request | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:no-unused-imports reported by reviewdog 🐶 |
||
import retrofit2.Retrofit | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
|
||
|
@@ -16,9 +19,10 @@ import retrofit2.converter.gson.GsonConverterFactory | |
class RetrofitModule { | ||
|
||
@Provides | ||
fun provideOkHttp(): OkHttpClient { | ||
fun provideOkHttp(interceptor: AddInterceptor): OkHttpClient { | ||
return OkHttpClient | ||
.Builder() | ||
.addInterceptor(interceptor) | ||
.build() | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,13 @@ import com.example.data.usecase.GetTokenUseCaseImpl | |
import com.example.data.usecase.LoginUseCaseImpl | ||
import com.example.data.usecase.SetTokenUseCaseImpl | ||
import com.example.data.usecase.SignUpUseCaseImpl | ||
import com.example.data.usecase.main.setting.GetMyUserUseCaseImpl | ||
import com.example.domain.usecase.login.ClearTokenUseCase | ||
import com.example.domain.usecase.login.GetTokenUseCase | ||
import com.example.domain.usecase.login.LoginUseCase | ||
import com.example.domain.usecase.login.SetTokenUseCase | ||
import com.example.domain.usecase.login.SignUpUseCase | ||
import com.example.domain.usecase.main.setting.GetMyUserUseCase | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
|
@@ -33,4 +35,7 @@ abstract class UserModule { | |
|
||
@Binds | ||
abstract fun bindClearUseCase(clearTokenUseCaseImpl: ClearTokenUseCaseImpl) : ClearTokenUseCase | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:no-trailing-spaces reported by reviewdog 🐶 |
||
@Binds | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:blank-line-before-declaration reported by reviewdog 🐶 |
||
abstract fun bindGetMyUserUseCase(getMyUserUseCaseImpl: GetMyUserUseCaseImpl) : GetMyUserUseCase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:function-return-type-spacing reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:colon-spacing reported by reviewdog 🐶 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.data.model | ||
|
||
import com.example.domain.model.User | ||
import com.google.gson.annotations.SerializedName | ||
|
||
data class UserDto( | ||
@SerializedName("id") | ||
val id: Long, | ||
@SerializedName("loginId") | ||
val loginId: String, | ||
@SerializedName("userName") | ||
val userName: String, | ||
@SerializedName("extraUserInfo") | ||
val extraUserInfo: String, | ||
@SerializedName("profileFilePath") | ||
val profileFilePath: String?, | ||
) { | ||
fun toUser() = User( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:multiline-expression-wrapping reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:function-signature reported by reviewdog 🐶 |
||
id = id, | ||
loginId = loginId, | ||
profileImageUrl = profileFilePath, | ||
username = userName | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:trailing-comma-on-call-site reported by reviewdog 🐶 |
||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.example.data.retrofit | ||
|
||
import com.example.data.UserDataStore | ||
import javax.inject.Inject | ||
import kotlinx.coroutines.runBlocking | ||
import okhttp3.Interceptor | ||
import okhttp3.Response | ||
|
||
class AddInterceptor @Inject constructor( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:annotation reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:annotation reported by reviewdog 🐶 |
||
private val userDataStore: UserDataStore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶 |
||
) : Interceptor { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:no-empty-first-line-in-class-body reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:no-trailing-spaces reported by reviewdog 🐶 |
||
override fun intercept(chain: Interceptor.Chain): Response { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:no-empty-first-line-in-method-block reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:no-trailing-spaces reported by reviewdog 🐶 |
||
val token: String? = runBlocking { userDataStore.getToken() } | ||
return chain.proceed( | ||
chain.request() | ||
.newBuilder() | ||
.run { | ||
token?.let { | ||
this.addHeader("Token", token) | ||
} ?: this | ||
} | ||
.addHeader("Content-Type", "application/json; charset=UTF-8") | ||
.build() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:trailing-comma-on-call-site reported by reviewdog 🐶 |
||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.example.data.retrofit | ||
|
||
import com.example.data.model.CommonResponse | ||
import com.example.data.model.UserDto | ||
import okhttp3.RequestBody | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.Headers | ||
import retrofit2.http.POST | ||
|
||
|
@@ -18,4 +20,8 @@ interface UserService { | |
suspend fun signUp( | ||
@Body requestBody: RequestBody | ||
): CommonResponse<Int> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:no-trailing-spaces reported by reviewdog 🐶 |
||
@GET("users/my-page") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:blank-line-before-declaration reported by reviewdog 🐶 |
||
@Headers("Content-Type:application/json; charset=UTF-8") | ||
suspend fun myPage(): CommonResponse<UserDto> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ class ClearTokenUseCaseImpl @Inject constructor( | |
private val userDataStore: UserDataStore | ||
) : ClearTokenUseCase { | ||
|
||
override suspend fun invoke() { | ||
override suspend fun invoke(): Result<Unit> = runCatching { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:multiline-expression-wrapping reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:function-signature reported by reviewdog 🐶 |
||
userDataStore.clear() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.example.data.usecase.main.setting | ||
|
||
import android.util.Log | ||
import com.example.data.retrofit.UserService | ||
import com.example.domain.model.User | ||
import com.example.domain.usecase.main.setting.GetMyUserUseCase | ||
import javax.inject.Inject | ||
|
||
class GetMyUserUseCaseImpl @Inject constructor( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:annotation reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:annotation reported by reviewdog 🐶 |
||
private val userService: UserService | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶 |
||
) : GetMyUserUseCase { | ||
override suspend fun invoke(): Result<User> = runCatching { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:multiline-expression-wrapping reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:function-signature reported by reviewdog 🐶 |
||
val userDto = userService.myPage().data | ||
Log.e("GetMyUserUseCaseImpl", "userDto: $userDto") | ||
userDto.toUser() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.example.domain.model | ||
|
||
data class User( | ||
val id: Long, | ||
val loginId: String, | ||
val username: String, | ||
val profileImageUrl: String? = null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶 |
||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.example.domain.usecase.login | ||
|
||
interface ClearTokenUseCase { | ||
suspend operator fun invoke() | ||
suspend operator fun invoke() : Result<Unit> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:function-return-type-spacing reported by reviewdog 🐶 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:colon-spacing reported by reviewdog 🐶 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.example.domain.usecase.main.setting | ||
|
||
import com.example.domain.model.User | ||
|
||
interface GetMyUserUseCase { | ||
suspend operator fun invoke() : Result<User> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [ktlint] standard:function-return-type-spacing reported by reviewdog 🐶 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.example.presentation.component | ||
|
||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.filled.Person | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Brush | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.ColorFilter | ||
import androidx.compose.ui.graphics.vector.rememberVectorPainter | ||
import androidx.compose.ui.layout.ContentScale | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import coil.compose.rememberAsyncImagePainter | ||
|
||
@Composable | ||
fun ProfileImage( | ||
modifier: Modifier, | ||
profileImageUrl: String? = null, | ||
borderWidth: Dp = 4.dp, | ||
) { | ||
val rainbowColorsBrush = | ||
remember { | ||
Brush.sweepGradient( | ||
listOf( | ||
Color(0xFF9575CD), | ||
Color(0xFFBA68C8), | ||
Color(0xFFE57373), | ||
Color(0xFFFFB74D), | ||
Color(0xFFFFF176), | ||
Color(0xFFAED581), | ||
Color(0xFF4DD0E1), | ||
Color(0xFF9575CD), | ||
), | ||
) | ||
} | ||
Image( | ||
painter = | ||
profileImageUrl?.let { url -> | ||
rememberAsyncImagePainter(model = url, contentScale = ContentScale.Crop) | ||
} ?: rememberVectorPainter(image = Icons.Default.Person), | ||
contentDescription = "프로필 사진", | ||
colorFilter = if (profileImageUrl == null) ColorFilter.tint(Color.White) else null, | ||
contentScale = ContentScale.Crop, | ||
modifier = | ||
modifier | ||
.border( | ||
BorderStroke(borderWidth, rainbowColorsBrush), | ||
CircleShape, | ||
) | ||
.padding(borderWidth) | ||
.clip(CircleShape), | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [ktlint] standard:no-unused-imports reported by reviewdog 🐶
Unused import