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

Settings #27

Merged
merged 11 commits into from
Apr 20, 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
3 changes: 0 additions & 3 deletions app/src/main/res/values/strings.xml

This file was deleted.

6 changes: 5 additions & 1 deletion data/src/main/java/com/example/data/di/RetrofitModule.kt
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

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

import okhttp3.OkHttpClient
import okhttp3.Request

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

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

Expand All @@ -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()
}

Expand Down
5 changes: 5 additions & 0 deletions data/src/main/java/com/example/data/di/UserModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,4 +35,7 @@ abstract class UserModule {

@Binds
abstract fun bindClearUseCase(clearTokenUseCaseImpl: ClearTokenUseCaseImpl) : ClearTokenUseCase

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:no-trailing-spaces reported by reviewdog 🐶
Trailing space(s)

@Binds

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:blank-line-before-declaration reported by reviewdog 🐶
Expected a blank line for this declaration

abstract fun bindGetMyUserUseCase(getMyUserUseCaseImpl: GetMyUserUseCaseImpl) : GetMyUserUseCase

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-return-type-spacing reported by reviewdog 🐶
Unexpected whitespace

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:colon-spacing reported by reviewdog 🐶
Unexpected spacing before ":"

}
24 changes: 24 additions & 0 deletions data/src/main/java/com/example/data/model/UserDto.kt
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(

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:multiline-expression-wrapping reported by reviewdog 🐶
A multiline expression should start on a new line

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
Newline expected before expression body

id = id,
loginId = loginId,
profileImageUrl = profileFilePath,
username = userName

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-call-site reported by reviewdog 🐶
Missing trailing comma before ")"

)
}
28 changes: 28 additions & 0 deletions data/src/main/java/com/example/data/retrofit/AddInterceptor.kt
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(

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:annotation reported by reviewdog 🐶
Expected newline before annotation

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:annotation reported by reviewdog 🐶
Expected newline after last annotation

private val userDataStore: UserDataStore

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶
Missing trailing comma before ")"

) : Interceptor {

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:no-empty-first-line-in-class-body reported by reviewdog 🐶
Class body should not start with blank line

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:no-trailing-spaces reported by reviewdog 🐶
Trailing space(s)

override fun intercept(chain: Interceptor.Chain): Response {

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:no-empty-first-line-in-method-block reported by reviewdog 🐶
First line in a method block should not be empty

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:no-trailing-spaces reported by reviewdog 🐶
Trailing space(s)

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()

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-call-site reported by reviewdog 🐶
Missing trailing comma before ")"

)
}
}
6 changes: 6 additions & 0 deletions data/src/main/java/com/example/data/retrofit/UserService.kt
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

Expand All @@ -18,4 +20,8 @@ interface UserService {
suspend fun signUp(
@Body requestBody: RequestBody
): CommonResponse<Int>

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:no-trailing-spaces reported by reviewdog 🐶
Trailing space(s)

@GET("users/my-page")

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:blank-line-before-declaration reported by reviewdog 🐶
Expected a blank line for this declaration

@Headers("Content-Type:application/json; charset=UTF-8")
suspend fun myPage(): CommonResponse<UserDto>
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ClearTokenUseCaseImpl @Inject constructor(
private val userDataStore: UserDataStore
) : ClearTokenUseCase {

override suspend fun invoke() {
override suspend fun invoke(): Result<Unit> = runCatching {

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:multiline-expression-wrapping reported by reviewdog 🐶
A multiline expression should start on a new line

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
Newline expected before expression body

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(

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:annotation reported by reviewdog 🐶
Expected newline before annotation

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:annotation reported by reviewdog 🐶
Expected newline after last annotation

private val userService: UserService

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶
Missing trailing comma before ")"

) : GetMyUserUseCase {
override suspend fun invoke(): Result<User> = runCatching {

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:multiline-expression-wrapping reported by reviewdog 🐶
A multiline expression should start on a new line

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-signature reported by reviewdog 🐶
Newline expected before expression body

val userDto = userService.myPage().data
Log.e("GetMyUserUseCaseImpl", "userDto: $userDto")
userDto.toUser()
}
}
8 changes: 8 additions & 0 deletions domain/src/main/java/com/example/domain/model/User.kt
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

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:trailing-comma-on-declaration-site reported by reviewdog 🐶
Missing trailing comma before ")"

)
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>

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-return-type-spacing reported by reviewdog 🐶
Unexpected whitespace

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:colon-spacing reported by reviewdog 🐶
Unexpected spacing before ":"

}
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>

Choose a reason for hiding this comment

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

🚫 [ktlint] standard:function-return-type-spacing reported by reviewdog 🐶
Unexpected whitespace

}
3 changes: 3 additions & 0 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@ dependencies {
implementation(libs.orbit.viewmodel)
implementation(libs.orbit.compose)
testImplementation(libs.orbit.test)

// coil
implementation(libs.coil.compose)
}
4 changes: 3 additions & 1 deletion presentation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<activity
android:name=".login.LoginActivity"/>

<activity android:name=".MainActivity"/>
<activity android:name=".main.MainActivity"/>
<activity android:name=".SplashActivity"
android:exported="true"
>
Expand All @@ -15,6 +15,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".main.writing.WritingActivity"/>

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.example.domain.usecase.login.GetTokenUseCase
import com.example.presentation.login.LoginActivity
import com.example.presentation.main.MainActivity
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import kotlinx.coroutines.launch
Expand Down
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),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.example.presentation.MainActivity
import com.example.presentation.component.LoginTextField
import com.example.presentation.component.SubmitButton
import com.example.presentation.main.MainActivity
import com.example.presentation.ui.theme.SnsProjectTheme
import org.orbitmvi.orbit.compose.collectAsState
import org.orbitmvi.orbit.compose.collectSideEffect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.presentation
package com.example.presentation.main

import android.os.Bundle
import androidx.activity.compose.setContent
Expand All @@ -12,6 +12,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContent {
SnsProjectTheme {
MainNavHost()
}
}
}
Expand Down
Loading