diff --git a/core/data/src/main/java/com/wei/picquest/core/data/model/ImageDetail.kt b/core/data/src/main/java/com/wei/picquest/core/data/model/ImageDetail.kt index c188c9c..4b17c16 100644 --- a/core/data/src/main/java/com/wei/picquest/core/data/model/ImageDetail.kt +++ b/core/data/src/main/java/com/wei/picquest/core/data/model/ImageDetail.kt @@ -1,33 +1,8 @@ package com.wei.picquest.core.data.model +import com.wei.picquest.core.model.data.ImageDetail import com.wei.picquest.core.network.model.NetworkImageDetail -data class ImageDetail( - val id: Int, - val pageURL: String, - val type: String, - val tags: String, - val previewURL: String, - val previewWidth: Int, - val previewHeight: Int, - val webformatURL: String, - val webformatWidth: Int, - val webformatHeight: Int, - val largeImageURL: String, - val imageWidth: Int, - val imageHeight: Int, - val imageSize: Long, - val views: Int, - val downloads: Int, - val likes: Int, - val comments: Int, - val userId: Int, - val user: String, - val userImageURL: String, -) { - val aspectRatio get() = imageWidth.toFloat() / imageHeight.toFloat() -} - fun NetworkImageDetail.asExternalModel() = ImageDetail( id = this.id, pageURL = this.pageURL, diff --git a/core/data/src/main/java/com/wei/picquest/core/data/model/VideoDetail.kt b/core/data/src/main/java/com/wei/picquest/core/data/model/VideoDetail.kt index d45241d..81ae809 100644 --- a/core/data/src/main/java/com/wei/picquest/core/data/model/VideoDetail.kt +++ b/core/data/src/main/java/com/wei/picquest/core/data/model/VideoDetail.kt @@ -1,40 +1,12 @@ package com.wei.picquest.core.data.model +import com.wei.picquest.core.model.data.VideoDetail +import com.wei.picquest.core.model.data.VideoDetailSize +import com.wei.picquest.core.model.data.VideoStreams import com.wei.picquest.core.network.model.NetworkVideoDetail import com.wei.picquest.core.network.model.NetworkVideoDetailSize import com.wei.picquest.core.network.model.NetworkVideoStreams -data class VideoDetail( - val id: Int, - val pageURL: String, - val type: String, - val tags: String, - val duration: Int, - val pictureId: String, - val videos: VideoStreams, - val views: Int, - val downloads: Int, - val likes: Int, - val comments: Int, - val userId: Int, - val user: String, - val userImageURL: String, -) - -data class VideoStreams( - val large: VideoDetailSize, - val medium: VideoDetailSize, - val small: VideoDetailSize, - val tiny: VideoDetailSize, -) - -data class VideoDetailSize( - val url: String, - val width: Int, - val height: Int, - val size: Long, -) - fun NetworkVideoDetail.asExternalModel() = VideoDetail( id = this.id, pageURL = this.pageURL, diff --git a/core/data/src/main/java/com/wei/picquest/core/data/repository/DefaultSearchImagesRepository.kt b/core/data/src/main/java/com/wei/picquest/core/data/repository/DefaultSearchImagesRepository.kt index 1df7232..37fdd3b 100644 --- a/core/data/src/main/java/com/wei/picquest/core/data/repository/DefaultSearchImagesRepository.kt +++ b/core/data/src/main/java/com/wei/picquest/core/data/repository/DefaultSearchImagesRepository.kt @@ -4,8 +4,8 @@ import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.PagingData import androidx.paging.map -import com.wei.picquest.core.data.model.ImageDetail import com.wei.picquest.core.data.model.asExternalModel +import com.wei.picquest.core.model.data.ImageDetail import com.wei.picquest.core.network.PqNetworkDataSource import com.wei.picquest.core.network.pagingsource.PixabayImagePagingSource import kotlinx.coroutines.flow.Flow diff --git a/core/data/src/main/java/com/wei/picquest/core/data/repository/DefaultSearchVideosRepository.kt b/core/data/src/main/java/com/wei/picquest/core/data/repository/DefaultSearchVideosRepository.kt index 4c11b2a..fecf5fc 100644 --- a/core/data/src/main/java/com/wei/picquest/core/data/repository/DefaultSearchVideosRepository.kt +++ b/core/data/src/main/java/com/wei/picquest/core/data/repository/DefaultSearchVideosRepository.kt @@ -4,8 +4,8 @@ import androidx.paging.Pager import androidx.paging.PagingConfig import androidx.paging.PagingData import androidx.paging.map -import com.wei.picquest.core.data.model.VideoDetail import com.wei.picquest.core.data.model.asExternalModel +import com.wei.picquest.core.model.data.VideoDetail import com.wei.picquest.core.network.PqNetworkDataSource import com.wei.picquest.core.network.pagingsource.PixabayVideoPagingSource import kotlinx.coroutines.flow.Flow diff --git a/core/data/src/main/java/com/wei/picquest/core/data/repository/SearchImagesRepository.kt b/core/data/src/main/java/com/wei/picquest/core/data/repository/SearchImagesRepository.kt index 436a903..5c77d7b 100644 --- a/core/data/src/main/java/com/wei/picquest/core/data/repository/SearchImagesRepository.kt +++ b/core/data/src/main/java/com/wei/picquest/core/data/repository/SearchImagesRepository.kt @@ -1,7 +1,7 @@ package com.wei.picquest.core.data.repository import androidx.paging.PagingData -import com.wei.picquest.core.data.model.ImageDetail +import com.wei.picquest.core.model.data.ImageDetail import kotlinx.coroutines.flow.Flow interface SearchImagesRepository { diff --git a/core/data/src/main/java/com/wei/picquest/core/data/repository/SearchVideosRepository.kt b/core/data/src/main/java/com/wei/picquest/core/data/repository/SearchVideosRepository.kt index 9255245..a50cc5e 100644 --- a/core/data/src/main/java/com/wei/picquest/core/data/repository/SearchVideosRepository.kt +++ b/core/data/src/main/java/com/wei/picquest/core/data/repository/SearchVideosRepository.kt @@ -1,7 +1,7 @@ package com.wei.picquest.core.data.repository import androidx.paging.PagingData -import com.wei.picquest.core.data.model.VideoDetail +import com.wei.picquest.core.model.data.VideoDetail import kotlinx.coroutines.flow.Flow interface SearchVideosRepository { diff --git a/core/model/src/main/java/com/wei/picquest/core/model/data/ImageDetail.kt b/core/model/src/main/java/com/wei/picquest/core/model/data/ImageDetail.kt new file mode 100644 index 0000000..4ff5a51 --- /dev/null +++ b/core/model/src/main/java/com/wei/picquest/core/model/data/ImageDetail.kt @@ -0,0 +1,27 @@ +package com.wei.picquest.core.model.data + +data class ImageDetail( + val id: Int, + val pageURL: String, + val type: String, + val tags: String, + val previewURL: String, + val previewWidth: Int, + val previewHeight: Int, + val webformatURL: String, + val webformatWidth: Int, + val webformatHeight: Int, + val largeImageURL: String, + val imageWidth: Int, + val imageHeight: Int, + val imageSize: Long, + val views: Int, + val downloads: Int, + val likes: Int, + val comments: Int, + val userId: Int, + val user: String, + val userImageURL: String, +) { + val aspectRatio get() = imageWidth.toFloat() / imageHeight.toFloat() +} diff --git a/core/model/src/main/java/com/wei/picquest/core/model/data/VideoDetail.kt b/core/model/src/main/java/com/wei/picquest/core/model/data/VideoDetail.kt new file mode 100644 index 0000000..866e78e --- /dev/null +++ b/core/model/src/main/java/com/wei/picquest/core/model/data/VideoDetail.kt @@ -0,0 +1,32 @@ +package com.wei.picquest.core.model.data + +data class VideoDetail( + val id: Int, + val pageURL: String, + val type: String, + val tags: String, + val duration: Int, + val pictureId: String, + val videos: VideoStreams, + val views: Int, + val downloads: Int, + val likes: Int, + val comments: Int, + val userId: Int, + val user: String, + val userImageURL: String, +) + +data class VideoStreams( + val large: VideoDetailSize, + val medium: VideoDetailSize, + val small: VideoDetailSize, + val tiny: VideoDetailSize, +) + +data class VideoDetailSize( + val url: String, + val width: Int, + val height: Int, + val size: Long, +) diff --git a/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/PhotoLibraryScreen.kt b/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/PhotoLibraryScreen.kt index 0763a60..e7e6f4d 100644 --- a/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/PhotoLibraryScreen.kt +++ b/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/PhotoLibraryScreen.kt @@ -55,13 +55,13 @@ import androidx.paging.compose.collectAsLazyPagingItems import coil.compose.AsyncImagePainter import coil.compose.SubcomposeAsyncImage import coil.compose.SubcomposeAsyncImageContent -import com.wei.picquest.core.data.model.ImageDetail import com.wei.picquest.core.designsystem.component.coilImagePainter import com.wei.picquest.core.designsystem.icon.PqIcons import com.wei.picquest.core.designsystem.theme.PqTheme import com.wei.picquest.core.designsystem.theme.SPACING_LARGE import com.wei.picquest.core.designsystem.theme.SPACING_MEDIUM import com.wei.picquest.core.designsystem.theme.SPACING_SMALL +import com.wei.picquest.core.model.data.ImageDetail import com.wei.picquest.feature.photo.R import com.wei.picquest.feature.photo.photolibrary.component.LayoutSwitchWarningDialog import com.wei.picquest.feature.photo.photolibrary.data.fake.fakeImageDetails diff --git a/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/PhotoLibraryViewModel.kt b/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/PhotoLibraryViewModel.kt index 32b6fb7..0db3bbe 100644 --- a/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/PhotoLibraryViewModel.kt +++ b/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/PhotoLibraryViewModel.kt @@ -5,8 +5,8 @@ import androidx.lifecycle.viewModelScope import androidx.paging.PagingData import androidx.paging.cachedIn import com.wei.picquest.core.base.BaseViewModel -import com.wei.picquest.core.data.model.ImageDetail import com.wei.picquest.core.data.repository.SearchImagesRepository +import com.wei.picquest.core.model.data.ImageDetail import com.wei.picquest.feature.photo.photolibrary.navigation.PhotoLibraryArgs import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow diff --git a/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/data/fake/FakeImageDetails.kt b/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/data/fake/FakeImageDetails.kt index 274ba01..d167bbb 100644 --- a/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/data/fake/FakeImageDetails.kt +++ b/feature/photo/src/main/java/com/wei/picquest/feature/photo/photolibrary/data/fake/FakeImageDetails.kt @@ -1,6 +1,6 @@ package com.wei.picquest.feature.photo.photolibrary.data.fake -import com.wei.picquest.core.data.model.ImageDetail +import com.wei.picquest.core.model.data.ImageDetail val fakeImageDetails = listOf( ImageDetail( diff --git a/feature/video/src/main/java/com/wei/picquest/feature/video/videolibrary/VideoLibraryScreen.kt b/feature/video/src/main/java/com/wei/picquest/feature/video/videolibrary/VideoLibraryScreen.kt index d4a6124..c875c63 100644 --- a/feature/video/src/main/java/com/wei/picquest/feature/video/videolibrary/VideoLibraryScreen.kt +++ b/feature/video/src/main/java/com/wei/picquest/feature/video/videolibrary/VideoLibraryScreen.kt @@ -63,15 +63,15 @@ import androidx.paging.compose.LazyPagingItems import androidx.paging.compose.collectAsLazyPagingItems import coil.compose.AsyncImage import coil.request.ImageRequest -import com.wei.picquest.core.data.model.VideoDetail -import com.wei.picquest.core.data.model.VideoDetailSize -import com.wei.picquest.core.data.model.VideoStreams import com.wei.picquest.core.designsystem.component.ThemePreviews import com.wei.picquest.core.designsystem.component.coilImagePainter import com.wei.picquest.core.designsystem.icon.PqIcons import com.wei.picquest.core.designsystem.theme.PqTheme import com.wei.picquest.core.designsystem.theme.SPACING_MEDIUM import com.wei.picquest.core.designsystem.theme.SPACING_SMALL +import com.wei.picquest.core.model.data.VideoDetail +import com.wei.picquest.core.model.data.VideoDetailSize +import com.wei.picquest.core.model.data.VideoStreams import com.wei.picquest.core.pip.enterPictureInPicture import com.wei.picquest.core.pip.isInPictureInPictureMode import com.wei.picquest.core.pip.updatedPipParams diff --git a/feature/video/src/main/java/com/wei/picquest/feature/video/videolibrary/VideoLibraryViewModel.kt b/feature/video/src/main/java/com/wei/picquest/feature/video/videolibrary/VideoLibraryViewModel.kt index 9dde68a..26e2c74 100644 --- a/feature/video/src/main/java/com/wei/picquest/feature/video/videolibrary/VideoLibraryViewModel.kt +++ b/feature/video/src/main/java/com/wei/picquest/feature/video/videolibrary/VideoLibraryViewModel.kt @@ -5,8 +5,8 @@ import androidx.lifecycle.viewModelScope import androidx.paging.PagingData import androidx.paging.cachedIn import com.wei.picquest.core.base.BaseViewModel -import com.wei.picquest.core.data.model.VideoDetail import com.wei.picquest.core.data.repository.SearchVideosRepository +import com.wei.picquest.core.model.data.VideoDetail import com.wei.picquest.feature.video.videolibrary.navigation.VideoLibraryArgs import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow