Skip to content

Commit

Permalink
Merge pull request #137 from Team-Recordy/feat/#134-profile-edit
Browse files Browse the repository at this point in the history
Feature/#134 profile edit
  • Loading branch information
cacaocoffee authored Oct 28, 2024
2 parents 449954c + bfbecd8 commit 7f6afb5
Show file tree
Hide file tree
Showing 22 changed files with 541 additions and 28 deletions.
9 changes: 9 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_camera.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="12dp"
android:height="11dp"
android:viewportWidth="12"
android:viewportHeight="11">
<path
android:pathData="M5.833,8.458C6.563,8.458 7.182,8.203 7.693,7.693C8.203,7.182 8.458,6.563 8.458,5.833C8.458,5.104 8.203,4.484 7.693,3.974C7.182,3.464 6.563,3.208 5.833,3.208C5.104,3.208 4.484,3.464 3.974,3.974C3.464,4.484 3.208,5.104 3.208,5.833C3.208,6.563 3.464,7.182 3.974,7.693C4.484,8.203 5.104,8.458 5.833,8.458ZM5.833,7.292C5.425,7.292 5.08,7.151 4.798,6.869C4.516,6.587 4.375,6.242 4.375,5.833C4.375,5.425 4.516,5.08 4.798,4.798C5.08,4.516 5.425,4.375 5.833,4.375C6.242,4.375 6.587,4.516 6.869,4.798C7.151,5.08 7.292,5.425 7.292,5.833C7.292,6.242 7.151,6.587 6.869,6.869C6.587,7.151 6.242,7.292 5.833,7.292ZM1.167,10.5C0.846,10.5 0.571,10.386 0.343,10.157C0.114,9.929 0,9.654 0,9.333V2.333C0,2.013 0.114,1.738 0.343,1.509C0.571,1.281 0.846,1.167 1.167,1.167H3.004L3.733,0.379C3.84,0.262 3.969,0.17 4.12,0.102C4.27,0.034 4.428,0 4.594,0H7.073C7.238,0 7.396,0.034 7.547,0.102C7.698,0.17 7.826,0.262 7.933,0.379L8.663,1.167H10.5C10.821,1.167 11.095,1.281 11.324,1.509C11.552,1.738 11.667,2.013 11.667,2.333V9.333C11.667,9.654 11.552,9.929 11.324,10.157C11.095,10.386 10.821,10.5 10.5,10.5H1.167Z"
android:fillColor="#131318"/>
</vector>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/user/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ android {
dependencies {
implementation(projects.domain.user)
implementation(projects.core.datastore)
implementation(projects.data.video)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.record.user.model.remote.request

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class RequestUpdateProfileDto(
@SerialName("nickname")
var nickname: String,
@SerialName("profileImageUrl")
var profileImageUrl: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import kotlinx.serialization.Serializable

@Serializable
data class ResponseGetUserProfileDto(
@SerialName("followerCount")
val followerCount: Int,
@SerialName("followingCount")
val followingCount: Int,
@SerialName("id")
val id: Int,
@SerialName("isFollowing")
val isFollowing: Boolean,
@SerialName("nickname")
val nickname: String,
@SerialName("profileImageUrl")
val profileImageUrl: String,
@SerialName("recordCount")
val recordCount: Int,
@SerialName("followerCount")
val followerCount: Int,
@SerialName("followingCount")
val followingCount: Int,
@SerialName("isFollowing")
val isFollowing: Boolean,
)

fun ResponseGetUserProfileDto.toDomain() = Profile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ import com.record.user.model.remote.response.toCore
import com.record.user.model.remote.response.toDomain
import com.record.user.source.local.UserLocalDataSource
import com.record.user.source.remote.RemoteUserDataSource
import com.record.video.source.remote.RemoteUploadDataSource
import kotlinx.coroutines.flow.first
import retrofit2.HttpException
import java.io.File
import javax.inject.Inject

class UserRepositoryImpl @Inject constructor(
private val userLocalDataSource: UserLocalDataSource,
private val remoteUserDataSource: RemoteUserDataSource,
private val remoteUploadDataSource: RemoteUploadDataSource,
) : UserRepository {

override suspend fun getFollowingList(cursorId: Long, size: Int): Result<Cursor<User>> = runCatching {
remoteUserDataSource.getFollowingList(cursorId, size)
}.mapCatching {
Expand Down Expand Up @@ -129,4 +133,22 @@ class UserRepositoryImpl @Inject constructor(
}
}
}

override suspend fun updateUser(nickname: String, filePath: String): Result<Unit> = runCatching {
var urls = remoteUploadDataSource.getUploadUrl()
val previewUrl = urls.thumbnailUrl
remoteUploadDataSource.uploadProfileImgToS3Bucket(previewUrl, File(filePath)).let { imgurl ->
remoteUserDataSource.updateUserProfile(nickname, imgurl)
}
}.recoverCatching { exception ->
when (exception) {
is HttpException -> {
throw ApiError(exception.message())
}

else -> {
throw exception
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ interface RemoteUserDataSource {
): ResponseGetUserProfileDto

suspend fun getUserPreference(): ResponseGetUserPreferenceDto

suspend fun updateUserProfile(
nickname: String,
profileImageUrl: String,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.io.File

interface RemoteUploadDataSource {
suspend fun getUploadUrl(): ResponseGetPresignedUrlDto
suspend fun uploadProfileImgToS3Bucket(url: String, file: File): String
suspend fun uploadRecord(requestPostVideoDto: RequestPostVideoDto)
suspend fun uploadVideoToS3Bucket(url: String, file: File, listener: ProgressListener): String
suspend fun uploadThumbnailToS3Bucket(url: String, file: File): String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ interface UserRepository {
suspend fun saveUserId(userId: Long): Result<Unit>

suspend fun getUserId(): Result<Long>

suspend fun updateUser(
nickname: String,
profileImg: String,
): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.record.mypage.navigation.navigateToFollowing
import com.record.profile.navigation.ProfileRoute
import com.record.profile.navigation.navigateProfile
import com.record.search.navigation.navigateSearch
import com.record.setting.navigate.navigateProfileEdit
import com.record.setting.navigate.navigateSetting
import com.record.upload.navigation.UploadRoute
import com.record.upload.navigation.UploadRouteObject
Expand Down Expand Up @@ -146,6 +147,9 @@ internal class MainNavigator(
navController.navigateSetting(navOptions { })
}

fun navigateProfileEdit() {
navController.navigateProfileEdit(navOptions { })
}
fun navigateDetail(id: Long) {
navController.navigateDetail(placeId = id, navOptions { })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ internal fun MainScreen(

settingNavGraph(
padding = innerPadding,
navigateToLogin = { navigator.navigateLogin() },
popBackStack = navigator::popBackStackIfNotHome,
navigateToLogin = navigator::navigateLogin,
navigateToProfileEdit = navigator::navigateProfileEdit,
)

searchNavGraph(
Expand Down
3 changes: 3 additions & 0 deletions feature/setting/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ android {

dependencies {
implementation(projects.domain.auth)
implementation(projects.domain.user)
implementation(projects.domain.video)
implementation(projects.domain.upload)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ data class SettingState(

sealed interface SettingSideEffect : SideEffect {
data object Restart : SettingSideEffect
data object ProfileEdit : SettingSideEffect
}
Loading

0 comments on commit 7f6afb5

Please sign in to comment.