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/register-photo-ui] 사진 등록 UI 구성 #82

Merged
merged 34 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9580ab8
공통 모듈에 BindingActivity/Fragment 넣기
l2hyunwoo Jul 6, 2023
ee9c3e4
Add Photo 화면 생성
l2hyunwoo Jul 6, 2023
2d06d6e
데이터 바인딩 허용
l2hyunwoo Jul 6, 2023
360d5ee
Background 이미지 넣기
l2hyunwoo Jul 6, 2023
eea42a2
사진 새롭게 등록
l2hyunwoo Jul 6, 2023
666e936
기존 toolbar 레이아웃에 텍스트도 넣을 수 있게 설정
l2hyunwoo Jul 6, 2023
b57e2ce
사진 등록 UI 구현
l2hyunwoo Jul 6, 2023
a6ae753
캘린더 구현
l2hyunwoo Jul 6, 2023
15cf511
일정 변경 범위 설정
l2hyunwoo Jul 6, 2023
3f47475
사진찍은 날짜 관련 QA
l2hyunwoo Jul 6, 2023
3c85299
auth data 모델을 network에서 옮기기
l2hyunwoo Jul 6, 2023
ce8eb4c
스튜디오 fetch 로직에 사용할 데이터 모델 구축
l2hyunwoo Jul 6, 2023
59169b7
Repository 레이어 단 패키지 변경
l2hyunwoo Jul 6, 2023
10e586c
사진관 Fetch 로직 구현 + 사진관 추가 로직 구현
l2hyunwoo Jul 6, 2023
ae939a6
바텀시트 아이템 background + 프래그먼트 클래스 설정
l2hyunwoo Jul 6, 2023
8587ad1
필요없는 파일 삭제
l2hyunwoo Jul 6, 2023
eacfe3c
StudioUiModel 구축
l2hyunwoo Jul 6, 2023
1a7c865
Fix Typo
l2hyunwoo Jul 6, 2023
20b1801
바텀시트 구현
l2hyunwoo Jul 6, 2023
f930ae2
클릭 연동
l2hyunwoo Jul 6, 2023
fec2f6f
Uri에서 사진 이미지 정보 가져오기
l2hyunwoo Jul 6, 2023
63d3b63
오타 수정
l2hyunwoo Jul 6, 2023
59516fc
AddPhotoActivity에 보낼 데이터 정의
l2hyunwoo Jul 6, 2023
c40f7b7
데이터 받아오고 이미지 세팅하는 로직 추가
l2hyunwoo Jul 6, 2023
90d3a55
오타 수정
l2hyunwoo Jul 6, 2023
da08ac8
Uri에서 Image 가져오는 Utils 생성
l2hyunwoo Jul 7, 2023
4876955
사진 배경 이미지 맞추기
l2hyunwoo Jul 7, 2023
0915d54
AlbumCover id에 맞춰서 앨범커버 drawable 제공해주는 함수 만들어주기
l2hyunwoo Jul 7, 2023
2163b22
AlbumItem parcelable로 만들기
l2hyunwoo Jul 7, 2023
d207620
typo fix
l2hyunwoo Jul 7, 2023
ca28a3e
사진 AddPhotoActivity로 넘겨주기
l2hyunwoo Jul 7, 2023
3fd5fd7
사진 post 요청에 필요한 Util 제작
l2hyunwoo Jul 7, 2023
7078723
사진 POST 데이터 레이어 작업
l2hyunwoo Jul 7, 2023
925312f
사진 추가 기능 구현 완료
l2hyunwoo Jul 7, 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
32 changes: 32 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

4 changes: 4 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ android {
}
}

buildFeatures {
dataBinding = true
}
l2hyunwoo marked this conversation as resolved.
Show resolved Hide resolved

buildTypes {
debug {
firebaseAppDistribution {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,8 @@
<activity
android:name=".feature.album.AlbumListActivity"
android:exported="false" />
<activity
android:name=".feature.home.photo.AddPhotoActivity"
android:exported="true" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.teampophory.pophory.config.di

import com.teampophory.pophory.data.repository.DefaultMyPageRepository
import com.teampophory.pophory.data.repository.MyPageRepository
import com.teampophory.pophory.data.repository.my.DefaultMyPageRepository
import com.teampophory.pophory.data.repository.my.MyPageRepository
import com.teampophory.pophory.network.MyPageNetworkDataSource
import com.teampophory.pophory.network.retrofit.mypage.RetrofitMyPageNetwork
import com.teampophory.pophory.network.retrofit.mypage.RetrofitMyPageNetworkApi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.teampophory.pophory.config.di

import com.teampophory.pophory.data.repository.PhotoRepository
import com.teampophory.pophory.data.repository.DefaultPhotoRepository
import com.teampophory.pophory.data.repository.photo.PhotoRepository
import com.teampophory.pophory.data.repository.photo.DefaultPhotoRepository
import com.teampophory.pophory.network.PhotoNetworkDataSource
import com.teampophory.pophory.network.retrofit.album.RetrofitPhotoNetwork
import com.teampophory.pophory.network.retrofit.album.RetrofitPhotoNetworkApi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.teampophory.pophory.config.di

import com.teampophory.pophory.data.repository.DefaultStoreRepository
import com.teampophory.pophory.data.repository.StoreRepository
import com.teampophory.pophory.data.repository.store.DefaultStoreRepository
import com.teampophory.pophory.data.repository.store.StoreRepository
import com.teampophory.pophory.network.StoreNetworkDataSource
import com.teampophory.pophory.network.retrofit.store.RetrofitStoreNetwork
import com.teampophory.pophory.network.retrofit.store.RetrofitStoreNetworkApi
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.teampophory.pophory.data.network.model.auth
package com.teampophory.pophory.data.model.auth

data class Token(
val accessToken: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.teampophory.pophory.data.network.model.auth
package com.teampophory.pophory.data.model.auth

enum class UserAccountState(val value: Boolean) {
REGISTERED(true),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.teampophory.pophory.data.network.model.auth
package com.teampophory.pophory.data.model.auth

data class UserAuthentication(
val token: Token,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.teampophory.pophory.data.model.photo

data class Studio(
val id: Long,
val name: String,
val imageUrl: String?
)
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.teampophory.pophory.data.network.model.auth

import com.teampophory.pophory.data.model.auth.Token
import com.teampophory.pophory.data.model.auth.UserAuthentication
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.teampophory.pophory.data.network.model.photo

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

typealias StudioEntity = com.teampophory.pophory.data.model.photo.Studio

@Serializable
data class StudioResponse(
@SerialName("studios")
val studios: List<Studio>
) {
@Serializable
data class Studio(
@SerialName("id")
val id: Long,
@SerialName("name")
val name: String,
@SerialName("imageUrl")
val imageUrl: String? = null
) {
fun toStudio() = StudioEntity(
id = id,
name = name,
imageUrl = imageUrl
)
}

fun toStudios() = studios.map { it.toStudio() }
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.teampophory.pophory.data.repository.auth

import com.teampophory.pophory.data.network.model.auth.Token
import com.teampophory.pophory.data.network.model.auth.UserAuthentication
import com.teampophory.pophory.data.model.auth.Token
import com.teampophory.pophory.data.model.auth.UserAuthentication

interface AuthRepository {
suspend fun login(socialToken: String): UserAuthentication
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.teampophory.pophory.data.repository.auth

import com.teampophory.pophory.data.local.PophoryDataStore
import com.teampophory.pophory.data.network.model.auth.Token
import com.teampophory.pophory.data.network.model.auth.UserAuthentication
import com.teampophory.pophory.data.model.auth.Token
import com.teampophory.pophory.data.model.auth.UserAuthentication
import com.teampophory.pophory.data.network.service.AuthService
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.teampophory.pophory.data.repository.fake

import com.teampophory.pophory.data.repository.MyPageRepository
import com.teampophory.pophory.data.repository.my.MyPageRepository
import com.teampophory.pophory.network.model.MyPageResponse
import kotlinx.coroutines.delay

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.teampophory.pophory.data.repository.fake

import com.teampophory.pophory.data.repository.PhotoRepository
import com.teampophory.pophory.common.image.ContentUriRequestBody
import com.teampophory.pophory.data.model.photo.Studio
import com.teampophory.pophory.data.repository.photo.PhotoRepository
import com.teampophory.pophory.network.model.PhotoListResponse
import kotlinx.coroutines.delay

Expand Down Expand Up @@ -41,4 +43,17 @@ class FakePhotoRepository : PhotoRepository {
)
}
}

override suspend fun getStudios(): Result<List<Studio>> {
TODO("Not yet implemented")
}

override suspend fun addPhoto(
albumId: Int,
takenAt: String,
studioId: Long,
photo: ContentUriRequestBody
): Result<Unit> {
TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.teampophory.pophory.data.repository
package com.teampophory.pophory.data.repository.my

import com.teampophory.pophory.network.MyPageNetworkDataSource
import com.teampophory.pophory.network.model.MyPageResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.teampophory.pophory.data.repository
package com.teampophory.pophory.data.repository.my

import com.teampophory.pophory.network.model.MyPageResponse

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.teampophory.pophory.data.repository.photo

import com.teampophory.pophory.common.image.ContentUriRequestBody
import com.teampophory.pophory.data.model.photo.Studio
import com.teampophory.pophory.network.PhotoNetworkDataSource
import com.teampophory.pophory.network.model.PhotoListResponse
import javax.inject.Inject

class DefaultPhotoRepository @Inject constructor(
private val retrofitPhotoNetwork: PhotoNetworkDataSource
) : PhotoRepository {
override suspend fun getPhotos(): Result<PhotoListResponse> {
return runCatching { retrofitPhotoNetwork.getAlbums() }
}

override suspend fun getStudios(): Result<List<Studio>> {
return runCatching { retrofitPhotoNetwork.getStudios().toStudios() }
}

override suspend fun addPhoto(
albumId: Int,
takenAt: String,
studioId: Long,
photo: ContentUriRequestBody
): Result<Unit> {
return runCatching {
retrofitPhotoNetwork.addPhoto(
albumId,
takenAt,
studioId,
photo
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.teampophory.pophory.data.repository.photo

import com.teampophory.pophory.common.image.ContentUriRequestBody
import com.teampophory.pophory.data.model.photo.Studio
import com.teampophory.pophory.network.model.PhotoListResponse

interface PhotoRepository {
suspend fun getPhotos(): Result<PhotoListResponse>
suspend fun getStudios(): Result<List<Studio>>
suspend fun addPhoto(
albumId: Int,
takenAt: String,
studioId: Long,
photo: ContentUriRequestBody
): Result<Unit>
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.teampophory.pophory.data.repository
package com.teampophory.pophory.data.repository.store

import com.teampophory.pophory.network.StoreNetworkDataSource
import com.teampophory.pophory.network.model.StoreResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.teampophory.pophory.data.repository
package com.teampophory.pophory.data.repository.store

import com.teampophory.pophory.network.model.StoreResponse

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.teampophory.pophory.domain

import com.teampophory.pophory.data.network.model.auth.UserAccountState
import com.teampophory.pophory.data.model.auth.UserAccountState
import com.teampophory.pophory.data.repository.auth.AuthRepository
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.teampophory.pophory.feature

import androidx.lifecycle.ViewModel
import com.teampophory.pophory.feature.home.store.model.AlbumItem

class HomeViewModel : ViewModel() {
var currentAlbum: AlbumItem? = null
private set

fun onUpdateAlbum(album: AlbumItem?) {
currentAlbum = album
}
Comment on lines +6 to +12
Copy link
Member

Choose a reason for hiding this comment

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

currentAlbum을 observalbe한 변수가 아닌 nullable한 변수로 지정한 이유가 있을까요?!

Copy link
Member Author

Choose a reason for hiding this comment

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

얘를 변경감지해서 사용할 수 있는 부분이 딱히 없어서 collect 하는 걸 제외했습니다.

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.teampophory.pophory.data.repository.PhotoRepository
import com.teampophory.pophory.data.repository.photo.PhotoRepository
import com.teampophory.pophory.network.model.toPhotoList
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
package com.teampophory.pophory.feature.home

import android.os.Bundle
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.commit
import com.teampophory.pophory.R
import com.teampophory.pophory.common.view.viewBinding
import com.teampophory.pophory.databinding.ActivityHomeBinding
import com.teampophory.pophory.feature.HomeViewModel
import com.teampophory.pophory.feature.home.mypage.MyPageFragment
import com.teampophory.pophory.feature.home.photo.AddPhotoActivity
import com.teampophory.pophory.feature.home.store.StoreFragment
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class HomeActivity : AppCompatActivity() {
private val binding: ActivityHomeBinding by viewBinding(ActivityHomeBinding::inflate)
private val viewModel by viewModels<HomeViewModel>()
private val imagePicker = registerForActivityResult(ActivityResultContracts.PickVisualMedia()) {
it?.let { uri ->
val currentAlbum = viewModel.currentAlbum
currentAlbum?.let { album ->
startActivity(AddPhotoActivity.getIntent(this, uri.toString(), album))
}
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -32,6 +46,9 @@ class HomeActivity : AppCompatActivity() {
selectedFragment?.let { changeFragment(it) }
return@setOnItemSelectedListener selectedFragment != null
}
binding.bottomNavFav.setOnClickListener {
imagePicker.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
}
Comment on lines +49 to +51
Copy link
Member

Choose a reason for hiding this comment

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

jpg, png만 따로 처리하는 부분이 ImageOnly 상수인가요?

Copy link
Member Author

Choose a reason for hiding this comment

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

넵넵

}

private fun initializeDefaultFragment(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.teampophory.pophory.data.repository.MyPageRepository
import com.teampophory.pophory.data.repository.my.MyPageRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject
Expand Down
Loading