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/album detail] bottomSheet와 사진 디테일 추가 #85

Closed
wants to merge 7 commits into from
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ obj/
.idea/gradle.xml
.idea/jarRepositories.xml
.idea/navEditor.xml
.idea/codeStyles

# Legacy Eclipse project files
.classpath
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ android {

buildTypes {
debug {
//appDistribution upload debug
firebaseAppDistribution {
artifactType = "APK"
releaseNotesFile = "firebase/releaseNote.txt"
Expand Down
19 changes: 10 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@
android:exported="false" />
<activity
android:name=".feature.home.HomeActivity"
android:exported="false" />
<activity
android:name=".feature.signup.SignUpActivity"
android:exported="false" />
<activity
android:name=".feature.onboarding.OnBoardingActivity"
android:exported="true"
android:theme="@style/Theme.App.Popopopo.Starting">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".feature.signup.SignUpActivity"
android:exported="false" />
<activity
android:name=".feature.onboarding.OnBoardingActivity"
android:exported="true"
android:theme="@style/Theme.App.Popopopo.Starting" />
<activity
android:name=".feature.setting.SettingActivity"
android:exported="true" />
Expand All @@ -100,7 +100,8 @@
</intent-filter>
</activity>
<activity
android:name=".feature.album.AlbumListActivity"
android:name=".feature.album.list.AlbumListActivity"
android:exported="false" />
<activity android:name=".feature.album.detail.AlbumDetailActivity" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.teampophory.pophory.albumsort

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.activityViewModels
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.teampophory.pophory.databinding.BottomSheetAlbumSortBinding
import com.teampophory.pophory.feature.album.list.AlbumListViewModel

class AlbumSortBottomSheet : BottomSheetDialogFragment() {

private var _binding: BottomSheetAlbumSortBinding? = null
private val binding get() = _binding!!

private val viewModel by activityViewModels<AlbumListViewModel>()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
_binding = BottomSheetAlbumSortBinding.inflate(inflater, container, false)
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initListMenuViews()
}

private fun initListMenuViews() {
with(binding) {
tvSortNewest.setOnClickListener {
viewModel.sortPhotoList(AlbumSortType.NEWEST)
dismissAllowingStateLoss()
}
tvSortOldest.setOnClickListener {
viewModel.sortPhotoList(AlbumSortType.OLDEST)
dismissAllowingStateLoss()
}
}
}

override fun onDestroyView() {
_binding = null
super.onDestroyView()
}

companion object {
const val TAG = "ModalBottomSheet"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.teampophory.pophory.albumsort

enum class AlbumSortType {
NEWEST,
OLDEST
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.teampophory.pophory.config.di

import com.teampophory.pophory.data.network.service.AlbumService
import com.teampophory.pophory.data.network.service.AuthService
import com.teampophory.pophory.data.repository.auth.AuthRepository
import com.teampophory.pophory.data.repository.auth.DefaultAuthRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.teampophory.pophory.config.di

import com.teampophory.pophory.data.repository.PhotoRepository
import com.teampophory.pophory.data.repository.DefaultPhotoRepository
import com.teampophory.pophory.network.PhotoNetworkDataSource
import com.teampophory.pophory.network.retrofit.album.RetrofitPhotoNetwork
import com.teampophory.pophory.network.retrofit.album.RetrofitPhotoNetworkApi
import com.teampophory.pophory.data.network.service.AlbumService
import com.teampophory.pophory.data.repository.photo.AlbumRepository
import com.teampophory.pophory.data.repository.photo.DefaultAlbumRepository
import dagger.Binds
import dagger.Module
import dagger.Provides
Expand All @@ -19,17 +17,13 @@ import javax.inject.Singleton
object PhotoModule {
@Provides
@Singleton
fun providePhotoNetworkService(retrofit: Retrofit): RetrofitPhotoNetworkApi = retrofit.create()
fun providePhotoNetworkService(retrofit: Retrofit): AlbumService = retrofit.create()

@Module
@InstallIn(SingletonComponent::class)
interface Binder {
@Binds
@Singleton
fun bindPhotoRepository(defaultPhotoRepository: DefaultPhotoRepository): PhotoRepository

@Binds
@Singleton
fun bindPhotoNwtworkDataSource(retrofitPhotoNetwork: RetrofitPhotoNetwork): PhotoNetworkDataSource
fun bindPhotoRepository(defaultPhotoRepository: DefaultAlbumRepository): AlbumRepository
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.teampophory.pophory.data.network.model.album

import com.teampophory.pophory.feature.album.model.OrientType
import com.teampophory.pophory.feature.album.model.PhotoDetail
import com.teampophory.pophory.feature.album.model.PhotoItem
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class PhotoListResponse(
@SerialName("photos") val photos: List<Photo>? = null
) {
@Serializable
data class Photo(
@SerialName("id")
val id: Int? = null,
@SerialName("studio")
val studio: String? = null,
@SerialName("takenAt")
val takenAt: String? = null,
@SerialName("imageUrl")
val imageUrl: String? = null,
@SerialName("width")
val width: Int? = null,
@SerialName("height")
val height: Int? = null
)

fun mapPhotosToPhotoItems(): List<PhotoDetail> {
val photoDetails = mutableListOf<PhotoDetail>()
photos.orEmpty().forEach { photo ->
val id = photo.id ?: return photoDetails
val studio = photo.studio ?: return photoDetails
val takenAt = photo.takenAt ?: return photoDetails
val imageUrl = photo.imageUrl ?: return photoDetails
val width = photo.width ?: return photoDetails
val height = photo.height ?: return photoDetails
val orientationType = when {
(width >= height) -> OrientType.HORIZONTAL
else -> OrientType.VERTICAL
}
photoDetails.add(
PhotoDetail(id, studio, takenAt, imageUrl, width, height, orientationType)
)
}
return photoDetails
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.teampophory.pophory.data.network.service

import com.teampophory.pophory.data.network.model.album.PhotoListResponse
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.Path

interface AlbumService {
@GET("api/v1/albums/{albumId}/photos")
suspend fun getPhotos(
@Path("albumId") albumId: Int
): PhotoListResponse

@DELETE("/api/v1/photo/{photoId}")
suspend fun deletePhoto(
@Path("photoId") photoId: Long
): Unit
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.teampophory.pophory.data.repository.fake

import com.teampophory.pophory.data.repository.PhotoRepository
import com.teampophory.pophory.network.model.PhotoListResponse
import com.teampophory.pophory.data.repository.photo.AlbumRepository
import com.teampophory.pophory.data.network.model.album.PhotoListResponse
import kotlinx.coroutines.delay

class FakePhotoRepository : PhotoRepository {
private val fakeImageUrl =
"https://images.unsplash.com/photo-1687023956422-117d5c47029d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=3432&q=80"
class FakePhotoRepository : AlbumRepository {
private val fakeImageUrl = "https://images.unsplash.com/photo-1687023956422-117d5c47029d?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=3432&q=80"

override suspend fun getPhotos(): Result<PhotoListResponse> {
override suspend fun getPhotos(id: Int): Result<PhotoListResponse> {
delay(300)
return runCatching {
PhotoListResponse(
Expand Down Expand Up @@ -41,4 +40,9 @@ class FakePhotoRepository : PhotoRepository {
)
}
}

override suspend fun deletePhoto(photoId: Long): Result<Unit> {
delay(300)
return runCatching { }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.teampophory.pophory.data.repository.photo

import com.teampophory.pophory.data.network.model.album.PhotoListResponse

interface AlbumRepository {
suspend fun getPhotos(id: Int): Result<PhotoListResponse>

suspend fun deletePhoto(photoId: Long): Result<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.teampophory.pophory.data.repository.photo

import com.teampophory.pophory.data.network.model.album.PhotoListResponse
import com.teampophory.pophory.data.network.service.AlbumService
import javax.inject.Inject

class DefaultAlbumRepository @Inject constructor(
private val networkApi: AlbumService
) : AlbumRepository {
override suspend fun getPhotos(id:Int): Result<PhotoListResponse> {
return runCatching { networkApi.getPhotos(id) }
}

override suspend fun deletePhoto(photoId: Long): Result<Unit> {
return runCatching { networkApi.deletePhoto(photoId) }
}

}

This file was deleted.

Loading