From de3f9e70a8a3b6ac186cfc98e2f1d09fced02a25 Mon Sep 17 00:00:00 2001 From: ChuYong Date: Wed, 21 Feb 2024 17:04:04 +0900 Subject: [PATCH 1/9] =?UTF-8?q?feat:=20Play=EC=8A=A4=ED=86=A0=EC=96=B4=20?= =?UTF-8?q?=ED=83=80=EC=9D=B4=ED=8B=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastlane/metadata/android/ko-KR/title.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/metadata/android/ko-KR/title.txt b/fastlane/metadata/android/ko-KR/title.txt index a608909..7349f1b 100644 --- a/fastlane/metadata/android/ko-KR/title.txt +++ b/fastlane/metadata/android/ko-KR/title.txt @@ -1 +1 @@ -삐삐 - 가족 일상 위젯 \ No newline at end of file +삐삐 - 하루 한 번, 가족에게 보내는 생존신고 \ No newline at end of file From 803a44b7ba36c8228adde43790722f8b170454f9 Mon Sep 17 00:00:00 2001 From: ChuYong Date: Wed, 21 Feb 2024 17:10:26 +0900 Subject: [PATCH 2/9] =?UTF-8?q?fix:=20pagingsource=20=EC=9E=AC=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EA=B4=80=EB=A0=A8=20=EC=9D=B4=EC=8A=88=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/repository/post/GetCommentsRepository.kt | 10 +++++++--- .../bbibbi/data/repository/post/GetFeedsRepository.kt | 10 +++++++--- .../feature/view_model/post/MainPostFeedViewModel.kt | 4 +--- .../feature/view_model/post/PostCommentViewModel.kt | 4 +--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/no5ing/bbibbi/data/repository/post/GetCommentsRepository.kt b/app/src/main/java/com/no5ing/bbibbi/data/repository/post/GetCommentsRepository.kt index 35c1b83..65fafdc 100644 --- a/app/src/main/java/com/no5ing/bbibbi/data/repository/post/GetCommentsRepository.kt +++ b/app/src/main/java/com/no5ing/bbibbi/data/repository/post/GetCommentsRepository.kt @@ -22,7 +22,7 @@ import javax.inject.Singleton class GetCommentsRepository @Inject constructor( private val memberCacheProvider: MemberCacheProvider, ) : BaseRepository>() { - lateinit var pagingSource: GetCommentsPageSource + private lateinit var pagingSource: GetCommentsPageSource override fun fetch(arguments: Arguments): Flow> { return Pager( config = PagingConfig( @@ -36,11 +36,15 @@ class GetCommentsRepository @Inject constructor( }.flow } - override fun closeResources() { - super.closeResources() + fun invalidateSource() { if (::pagingSource.isInitialized) pagingSource.invalidate() } + + override fun closeResources() { + super.closeResources() + this.invalidateSource() + } } class GetCommentsPageSource @Inject constructor( diff --git a/app/src/main/java/com/no5ing/bbibbi/data/repository/post/GetFeedsRepository.kt b/app/src/main/java/com/no5ing/bbibbi/data/repository/post/GetFeedsRepository.kt index 4383fca..ae7058d 100644 --- a/app/src/main/java/com/no5ing/bbibbi/data/repository/post/GetFeedsRepository.kt +++ b/app/src/main/java/com/no5ing/bbibbi/data/repository/post/GetFeedsRepository.kt @@ -23,7 +23,7 @@ import javax.inject.Singleton class GetFeedsRepository @Inject constructor( private val memberCacheProvider: MemberCacheProvider, ) : BaseRepository>() { - lateinit var pagingSource: GetFeedPageSource + private lateinit var pagingSource: GetFeedPageSource override fun fetch(arguments: Arguments): Flow> { return Pager( config = PagingConfig( @@ -37,11 +37,15 @@ class GetFeedsRepository @Inject constructor( }.flow } - override fun closeResources() { - super.closeResources() + fun invalidateSource() { if (::pagingSource.isInitialized) pagingSource.invalidate() } + + override fun closeResources() { + super.closeResources() + this.invalidateSource() + } } class GetFeedPageSource @Inject constructor( diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/MainPostFeedViewModel.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/MainPostFeedViewModel.kt index ff0789a..3378556 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/MainPostFeedViewModel.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/MainPostFeedViewModel.kt @@ -37,9 +37,7 @@ class MainPostFeedViewModel @Inject constructor( } } - fun refresh() { - getPostsRepository.pagingSource.invalidate() - } + fun refresh() = getPostsRepository.invalidateSource() override fun release() { super.release() diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/PostCommentViewModel.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/PostCommentViewModel.kt index 8b91d34..64c63cd 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/PostCommentViewModel.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/PostCommentViewModel.kt @@ -22,9 +22,7 @@ class PostCommentViewModel @Inject constructor( return PagingData.empty() } - fun refresh() { - getCommentsRepository.pagingSource.invalidate() - } + fun refresh() = getCommentsRepository.invalidateSource() override fun invoke(arguments: Arguments) { withMutexScope(Dispatchers.IO) { From 8bd53f6f372ebb2ec1c86cf9eb922994e31a5eae Mon Sep 17 00:00:00 2001 From: ChuYong Date: Wed, 21 Feb 2024 17:11:02 +0900 Subject: [PATCH 3/9] =?UTF-8?q?feat:=20=EB=B2=84=EC=A0=84=20=EB=B2=88?= =?UTF-8?q?=ED=98=B8=201.1.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 42df43a..5b7b425 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -47,7 +47,7 @@ android { minSdk = 26 targetSdk = 34 versionCode = 11011 - versionName = "1.1.1" + versionName = "1.1.2" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { From d0c0ad3e6b1ef60f72498f8ab0238b2f22fe904d Mon Sep 17 00:00:00 2001 From: ChuYong Date: Wed, 21 Feb 2024 17:20:46 +0900 Subject: [PATCH 4/9] =?UTF-8?q?fix:=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?= =?UTF-8?q?=EB=B0=B0=EA=B2=BD=20=EC=A1=B0=ED=9A=8C=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=9D=B4=EC=8A=88=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/view/main/post_view/PostViewPage.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt index 065f0ed..949e89a 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt @@ -145,7 +145,13 @@ fun PostViewPage( modifier = Modifier.fillMaxSize() ) { AsyncImage( - model = asyncImagePainter(source = postState.data.post.imageUrl), + model = asyncImagePainter( + source = + if(postState.isReady()) + if (siblingPostState.isReady()) siblingPostState.data[pagerState.currentPage].post.imageUrl + else postState.data.post.imageUrl + else null + ), contentDescription = null, modifier = Modifier .fillMaxSize() From 6f4477ae22d2f6b2aacb4ca4d1a1bfbce48a47c3 Mon Sep 17 00:00:00 2001 From: ChuYong Date: Wed, 21 Feb 2024 17:34:25 +0900 Subject: [PATCH 5/9] =?UTF-8?q?fix:=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?= =?UTF-8?q?=EC=9D=B4=EC=9B=83=20=EC=A1=B0=ED=9A=8C=20=EA=B4=80=EB=A0=A8=20?= =?UTF-8?q?=EC=9D=B4=EC=8A=88=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/feature/view/main/post_view/PostViewPage.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt index 949e89a..46bf27a 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt @@ -82,7 +82,7 @@ fun PostViewPage( var isPagerReady by remember { mutableStateOf(false) } val postState by postViewPageState.uiState.collectAsState() val siblingPostState by familyPostsViewModel.uiState.collectAsState() - val pagerState = key(siblingPostState.isReady()) { + val pagerState = key(siblingPostState) { rememberPagerState( initialPage = if (siblingPostState.isReady()) siblingPostState.data .indexOfFirst { it.post.postId == postId } else 0, @@ -123,7 +123,8 @@ fun PostViewPage( LaunchedEffect(postState, pagerState.currentPage) { if (postState.isReady()) { val currentPost = - if (siblingPostState.isReady()) siblingPostState.data[pagerState.currentPage] else postState.data + (if (siblingPostState.isReady()) siblingPostState.data.getOrNull(pagerState.currentPage) else postState.data) + ?: return@LaunchedEffect familyPostReactionBarViewModel.invoke( Arguments( arguments = mapOf( From 47c425de4beb2c18d83aa8ffcbf73d9354a7b52c Mon Sep 17 00:00:00 2001 From: ChuYong Date: Wed, 21 Feb 2024 17:47:18 +0900 Subject: [PATCH 6/9] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=98=A4=EB=A5=98=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EA=B4=80=EB=A0=A8=20=EB=A1=9C=EC=A7=81=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/no5ing/bbibbi/di/NetworkModule.kt | 7 +++---- .../view_model/post/CreatePostViewModel.kt | 2 +- .../com/no5ing/bbibbi/util/ImageUploader.kt | 21 ++----------------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/no5ing/bbibbi/di/NetworkModule.kt b/app/src/main/java/com/no5ing/bbibbi/di/NetworkModule.kt index b6f70bb..e92339f 100644 --- a/app/src/main/java/com/no5ing/bbibbi/di/NetworkModule.kt +++ b/app/src/main/java/com/no5ing/bbibbi/di/NetworkModule.kt @@ -32,9 +32,9 @@ import javax.inject.Singleton @Module @InstallIn(SingletonComponent::class) object NetworkModule { - private const val timeout_read = 10L - private const val timeout_connect = 10L - private const val timeout_write = 10L + private const val timeout_read = 20L + private const val timeout_connect = 20L + private const val timeout_write = 20L val requireUpdateState = MutableStateFlow(false) val requireTokenInvalidRestart = MutableStateFlow(false) @@ -144,7 +144,6 @@ object NetworkModule { // HttpLoggingInterceptor { message -> Timber.d("%s", message) } // httpLoggingInterceptor.level = HttpLoggingInterceptor.Level.BODY return client - // .addInterceptor(httpLoggingInterceptor) .connectTimeout(timeout_connect, TimeUnit.SECONDS) .readTimeout(timeout_read, TimeUnit.SECONDS) .writeTimeout(timeout_write, TimeUnit.SECONDS) diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/CreatePostViewModel.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/CreatePostViewModel.kt index 394bb60..d858dd1 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/CreatePostViewModel.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/CreatePostViewModel.kt @@ -59,7 +59,7 @@ class CreatePostViewModel @Inject constructor( data.url ) if (imageUploadResult == null) { - //TODO: SOME KIND + setState(APIResponse.unknownError()) return@suspendOnSuccess } val postResult = restAPI.getPostApi().createPost( diff --git a/app/src/main/java/com/no5ing/bbibbi/util/ImageUploader.kt b/app/src/main/java/com/no5ing/bbibbi/util/ImageUploader.kt index 6a5779b..e5d8dfe 100644 --- a/app/src/main/java/com/no5ing/bbibbi/util/ImageUploader.kt +++ b/app/src/main/java/com/no5ing/bbibbi/util/ImageUploader.kt @@ -16,25 +16,8 @@ fun OkHttpClient.uploadImage( .url(targetUrl) .put(targetFile.asRequestBody("image/jpeg".toMediaType())) .build() - val response = newCall(request).execute() - return if (response.isSuccessful) { - destinationUrl - } else { - null - } -} - -fun OkHttpClient.upload( - body: RequestBody, - targetUrl: String -): String? { - val destinationUrl = removeQueryParams(targetUrl) - val request = Request.Builder() - .url(targetUrl) - .put(body) - .build() - val response = newCall(request).execute() - return if (response.isSuccessful) { + val response = runCatching { newCall(request).execute() }.getOrNull() + return if (response?.isSuccessful == true) { destinationUrl } else { null From f552f52fa36fc9aa341c41ceb3a7b7886c5b44f6 Mon Sep 17 00:00:00 2001 From: ChuYong Date: Wed, 21 Feb 2024 22:58:10 +0900 Subject: [PATCH 7/9] =?UTF-8?q?fix:=20=EB=A9=94=EC=9D=B8=20=ED=94=BC?= =?UTF-8?q?=EB=93=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90=20=EC=88=9C=EC=9C=84=20?= =?UTF-8?q?=EC=9D=B4=EC=8A=88=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../family/MainFeedStoryElementUiState.kt | 10 +++++ .../feature/view/main/home/HomePage.kt | 7 +--- .../feature/view/main/home/HomePageContent.kt | 14 +++---- .../view/main/home/HomePageStoryBar.kt | 37 +++++++++-------- .../post/DailyFamilyTopViewModel.kt | 41 +++++++++++++++---- 5 files changed, 71 insertions(+), 38 deletions(-) create mode 100644 app/src/main/java/com/no5ing/bbibbi/presentation/feature/uistate/family/MainFeedStoryElementUiState.kt diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/uistate/family/MainFeedStoryElementUiState.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/uistate/family/MainFeedStoryElementUiState.kt new file mode 100644 index 0000000..ed0618a --- /dev/null +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/uistate/family/MainFeedStoryElementUiState.kt @@ -0,0 +1,10 @@ +package com.no5ing.bbibbi.presentation.feature.uistate.family + +import com.no5ing.bbibbi.data.model.BaseModel +import com.no5ing.bbibbi.data.model.member.Member +import com.no5ing.bbibbi.data.model.post.Post + +data class MainFeedStoryElementUiState( + val member: Member, + val isUploadedToday: Boolean, +) : BaseModel() diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePage.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePage.kt index 2e3444c..fb39159 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePage.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePage.kt @@ -43,7 +43,6 @@ fun HomePage( retrieveMeViewModel: RetrieveMeViewModel = hiltViewModel(), isMeUploadedTodayViewModel: IsMeUploadedTodayViewModel = hiltViewModel(), familyPostsViewModel: MainPostFeedViewModel = hiltViewModel(), - familyMembersViewModel: FamilyMembersViewModel = hiltViewModel(), familyPostTopViewModel: DailyFamilyTopViewModel = hiltViewModel(), onTapLeft: () -> Unit = {}, onTapRight: () -> Unit = {}, @@ -81,7 +80,7 @@ fun HomePage( } if (familyPostsViewModel.isInitialize()) { - familyMembersViewModel.invoke(Arguments()) + // familyMembersViewModel.invoke(Arguments()) retrieveMeViewModel.invoke(Arguments()) familyPostTopViewModel.invoke(Arguments())// TODO familyPostsViewModel.invoke( @@ -114,7 +113,6 @@ fun HomePage( ) HomePageContent( contentState = familyPostsViewModel.uiState, - familyListState = familyMembersViewModel.uiState, postTopState = familyPostTopViewModel.uiState, meState = retrieveMeViewModel.uiState, onTapContent = onTapContent, @@ -152,8 +150,7 @@ fun HomePagePreview() { HomePageTopBar() HomePageContent( contentState = MutableStateFlow(PagingData.empty()), - familyListState = MutableStateFlow(PagingData.empty()), - postTopState = MutableStateFlow(emptyMap()), + postTopState = MutableStateFlow(APIResponse.idle()), meState = MutableStateFlow(APIResponse.success(Member.unknown())) ) } diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageContent.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageContent.kt index 326a0ae..7892a23 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageContent.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageContent.kt @@ -30,6 +30,7 @@ import com.no5ing.bbibbi.R import com.no5ing.bbibbi.data.model.APIResponse import com.no5ing.bbibbi.data.model.member.Member import com.no5ing.bbibbi.data.model.post.Post +import com.no5ing.bbibbi.presentation.feature.uistate.family.MainFeedStoryElementUiState import com.no5ing.bbibbi.presentation.feature.uistate.family.MainFeedUiState import com.no5ing.bbibbi.presentation.theme.bbibbiScheme import com.no5ing.bbibbi.util.gapBetweenNow @@ -39,8 +40,8 @@ import kotlinx.coroutines.flow.StateFlow @Composable fun HomePageContent( contentState: StateFlow>, - familyListState: StateFlow>, - postTopState: StateFlow>, + //familyListState: StateFlow>, + postTopState: StateFlow>>, meState: StateFlow>, onTapContent: (Post) -> Unit = {}, onTapProfile: (Member) -> Unit = {}, @@ -48,12 +49,11 @@ fun HomePageContent( onRefresh: () -> Unit = {}, ) { val postItems = contentState.collectAsLazyPagingItems() - val memberItems = familyListState.collectAsLazyPagingItems() + // val memberItems = familyListState.collectAsLazyPagingItems() var isRefreshing by remember { mutableStateOf(false) } - LaunchedEffect(postItems.loadState.refresh, memberItems.loadState.refresh) { + LaunchedEffect(postItems.loadState.refresh) { if (isRefreshing && - postItems.loadState.refresh is LoadState.NotLoading && - memberItems.loadState.refresh is LoadState.NotLoading + postItems.loadState.refresh is LoadState.NotLoading ) { isRefreshing = false } @@ -64,7 +64,6 @@ fun HomePageContent( onRefresh = { if (isRefreshing) return@HomePageFeedGrid isRefreshing = true - memberItems.refresh() postItems.refresh() onRefresh() } @@ -76,7 +75,6 @@ fun HomePageContent( HomePageStoryBar( postTopStateFlow = postTopState, meStateFlow = meState, - familyListStateFlow = familyListState, onTapProfile = onTapProfile, onTapInvite = onTapInvite, ) diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageStoryBar.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageStoryBar.kt index bb5236f..793abea 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageStoryBar.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageStoryBar.kt @@ -35,6 +35,7 @@ import com.no5ing.bbibbi.R import com.no5ing.bbibbi.data.model.APIResponse import com.no5ing.bbibbi.data.model.member.Member import com.no5ing.bbibbi.presentation.component.CircleProfileImage +import com.no5ing.bbibbi.presentation.feature.uistate.family.MainFeedStoryElementUiState import com.no5ing.bbibbi.presentation.theme.bbibbiScheme import com.no5ing.bbibbi.presentation.theme.bbibbiTypo import com.no5ing.bbibbi.util.LocalSessionState @@ -42,18 +43,17 @@ import kotlinx.coroutines.flow.StateFlow @Composable fun HomePageStoryBar( - postTopStateFlow: StateFlow>, + postTopStateFlow: StateFlow>>, meStateFlow: StateFlow>, - familyListStateFlow: StateFlow>, onTapProfile: (Member) -> Unit = {}, onTapInvite: () -> Unit = {}, ) { val meId = LocalSessionState.current.memberId val postTopState by postTopStateFlow.collectAsState() val meState by meStateFlow.collectAsState() - val items = familyListStateFlow.collectAsLazyPagingItems() + //val items = familyListStateFlow.collectAsLazyPagingItems() - if (items.itemCount == 1) { + if (postTopState.isReady() && postTopState.data.size == 1) { HomePageNoFamilyBar( modifier = Modifier .fillMaxWidth() @@ -61,7 +61,7 @@ fun HomePageStoryBar( .padding(horizontal = 16.dp), onTap = onTapInvite, ) - } else { + } else if(postTopState.isReady()) { LazyRow( modifier = Modifier .fillMaxWidth() @@ -71,8 +71,9 @@ fun HomePageStoryBar( Spacer(modifier = Modifier.width(20.dp)) } - if (meState.isReady()) { + if (meState.isReady() && postTopState.isReady()) { val item = meState.data + val meData = postTopState.data.indexOfFirst { it.member.memberId == meId } item { StoryBarIcon( member = item, @@ -80,28 +81,28 @@ fun HomePageStoryBar( onTapProfile(item) }, isMe = true, - isUploaded = postTopState.containsKey(item.memberId), - rank = postTopState[item.memberId] ?: -1, + isUploaded = postTopState.data[meData].isUploadedToday, + rank = meData, ) } } items( - count = items.itemCount, - key = { items[it]!!.memberId } + count = postTopState.data.size, + key = { postTopState.data[it].member.memberId } ) { index -> - val item = items[index] ?: throw RuntimeException() - if (item.memberId != meId) { + val item = postTopState.data[index] + if (item.member.memberId != meId) { Row { Spacer(modifier = Modifier.width(12.dp)) StoryBarIcon( - member = item, + member = item.member, onTap = { - onTapProfile(item) + onTapProfile(item.member) }, - isUploaded = postTopState.containsKey(item.memberId), - rank = postTopState[item.memberId] ?: -1, + isUploaded = item.isUploadedToday, + rank = index, ) } } @@ -132,8 +133,8 @@ fun StoryBarIcon( horizontalAlignment = Alignment.CenterHorizontally ) { Box { - val rankColor = getRankColor(rank = rank) - val rankBadge = getRankBadge(rank = rank) + val rankColor = if(isUploaded) getRankColor(rank = rank) else null + val rankBadge = if(isUploaded) getRankBadge(rank = rank) else null if (rankColor != null) { Box( modifier = Modifier diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/DailyFamilyTopViewModel.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/DailyFamilyTopViewModel.kt index 893be95..8fbdf59 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/DailyFamilyTopViewModel.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/DailyFamilyTopViewModel.kt @@ -1,25 +1,39 @@ package com.no5ing.bbibbi.presentation.feature.view_model.post import com.no5ing.bbibbi.data.datasource.network.RestAPI +import com.no5ing.bbibbi.data.model.APIResponse +import com.no5ing.bbibbi.data.model.member.Member import com.no5ing.bbibbi.data.repository.Arguments +import com.no5ing.bbibbi.presentation.feature.uistate.family.MainFeedStoryElementUiState import com.no5ing.bbibbi.presentation.feature.view_model.BaseViewModel import com.no5ing.bbibbi.util.todayAsString +import com.skydoves.sandwich.getOrNull +import com.skydoves.sandwich.isSuccess +import com.skydoves.sandwich.suspendOnFailure import com.skydoves.sandwich.suspendOnSuccess import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.async import javax.inject.Inject @HiltViewModel class DailyFamilyTopViewModel @Inject constructor( private val restAPI: RestAPI, -) : BaseViewModel>() { - override fun initState(): Map { - return emptyMap() +) : BaseViewModel>>() { + override fun initState(): APIResponse> { + return APIResponse.idle() } override fun invoke(arguments: Arguments) { withMutexScope(Dispatchers.IO) { - val newMap = HashMap() + val newList = ArrayList() + val members = async { + restAPI.getMemberApi() + .getMembers( + page = 1, + size = 100 + ) + } restAPI .getPostApi() .getPosts( @@ -29,10 +43,23 @@ class DailyFamilyTopViewModel @Inject constructor( date = todayAsString(), sort = "ASC" ).suspendOnSuccess { - data.results.forEachIndexed { index, post -> - newMap[post.authorId] = index + val response = members.await() + if (response.isSuccess) { + val memberMap = (response.getOrNull()?.results?.associateBy { it.memberId } ?: emptyMap()) + .toMutableMap() + data.results.forEachIndexed { index, post -> + val currentMember = memberMap.remove(post.authorId) ?: return@forEachIndexed + newList.add(MainFeedStoryElementUiState(currentMember, true)) + } + memberMap.forEach { + newList.add(MainFeedStoryElementUiState(it.value, false)) + } + setState(APIResponse.success(newList)) + } else { + setState(APIResponse.unknownError()) } - setState(newMap) + }.suspendOnFailure { + setState(APIResponse.unknownError()) } } } From 84729fbbcd253e4bccaa37ccbebef72540633aa8 Mon Sep 17 00:00:00 2001 From: ChuYong Date: Wed, 21 Feb 2024 23:00:29 +0900 Subject: [PATCH 8/9] =?UTF-8?q?style:=20=EC=BD=94=EB=93=9C=20=EB=A6=AC?= =?UTF-8?q?=ED=8F=AC=EB=A7=A4=ED=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/no5ing/bbibbi/FirebaseService.kt | 6 ++++-- .../uistate/family/MainFeedStoryElementUiState.kt | 1 - .../feature/view/common/CustomAlertDialog.kt | 3 ++- .../feature/view/common/PostCommentDialog.kt | 7 +++++-- .../feature/view/main/family/FamilyPage.kt | 12 +++++++++--- .../presentation/feature/view/main/home/HomePage.kt | 3 +-- .../feature/view/main/home/HomePageContent.kt | 6 +++--- .../feature/view/main/home/HomePageStoryBar.kt | 8 +++----- .../feature/view/main/home/TryWidgetPopup.kt | 3 ++- .../feature/view/main/post_view/PostViewPage.kt | 8 ++++---- .../view/main/profile/ProfilePageMemberBar.kt | 7 +++++-- .../view_model/post/DailyFamilyTopViewModel.kt | 7 ++++--- .../java/com/no5ing/bbibbi/util/ImageUploader.kt | 1 - 13 files changed, 42 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/com/no5ing/bbibbi/FirebaseService.kt b/app/src/main/java/com/no5ing/bbibbi/FirebaseService.kt index fd67c43..6cc8f77 100644 --- a/app/src/main/java/com/no5ing/bbibbi/FirebaseService.kt +++ b/app/src/main/java/com/no5ing/bbibbi/FirebaseService.kt @@ -29,8 +29,10 @@ class FirebaseService : FirebaseMessagingService() { } } val pendingIntent = PendingIntent - .getActivity(this@FirebaseService, 0, intent, PendingIntent.FLAG_IMMUTABLE - .or(PendingIntent.FLAG_CANCEL_CURRENT)) + .getActivity( + this@FirebaseService, 0, intent, PendingIntent.FLAG_IMMUTABLE + .or(PendingIntent.FLAG_CANCEL_CURRENT) + ) val builder = NotificationCompat .Builder(this@FirebaseService, channel_id) .setSmallIcon(R.drawable.notification_icon) diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/uistate/family/MainFeedStoryElementUiState.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/uistate/family/MainFeedStoryElementUiState.kt index ed0618a..cfd2b53 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/uistate/family/MainFeedStoryElementUiState.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/uistate/family/MainFeedStoryElementUiState.kt @@ -2,7 +2,6 @@ package com.no5ing.bbibbi.presentation.feature.uistate.family import com.no5ing.bbibbi.data.model.BaseModel import com.no5ing.bbibbi.data.model.member.Member -import com.no5ing.bbibbi.data.model.post.Post data class MainFeedStoryElementUiState( val member: Member, diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/common/CustomAlertDialog.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/common/CustomAlertDialog.kt index 0296d43..bf9c200 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/common/CustomAlertDialog.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/common/CustomAlertDialog.kt @@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.AlertDialog import androidx.compose.material3.AlertDialogDefaults +import androidx.compose.material3.BasicAlertDialog import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ExperimentalMaterial3Api @@ -60,7 +61,7 @@ fun CustomAlertDialog( hasCancel: Boolean = true, ) { if (enabledState.value) { - AlertDialog( + BasicAlertDialog( onDismissRequest = cancelRequest, modifier = Modifier, properties = DialogProperties() diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/common/PostCommentDialog.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/common/PostCommentDialog.kt index b2f5a97..f38c232 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/common/PostCommentDialog.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/common/PostCommentDialog.kt @@ -25,8 +25,8 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.material3.Divider import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -217,7 +217,10 @@ fun PostCommentDialog( style = MaterialTheme.bbibbiTypo.bodyOneBold, ) Spacer(modifier = Modifier.height(16.dp)) - Divider(thickness = 1.dp, color = MaterialTheme.bbibbiScheme.gray600) + HorizontalDivider( + thickness = 1.dp, + color = MaterialTheme.bbibbiScheme.gray600 + ) } } ) { diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/family/FamilyPage.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/family/FamilyPage.kt index b3c2b7c..4e079ed 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/family/FamilyPage.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/family/FamilyPage.kt @@ -4,7 +4,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -77,7 +77,10 @@ fun FamilyPage( onTapShare = onTapShare, uiState = inviteLinkState, ) - Divider(thickness = 1.dp, color = MaterialTheme.bbibbiScheme.backgroundSecondary) + HorizontalDivider( + thickness = 1.dp, + color = MaterialTheme.bbibbiScheme.backgroundSecondary + ) FamilyPageMemberList( meId = meId, meState = meState, @@ -110,7 +113,10 @@ fun FamilyPagePreview() { mutableStateOf(APIResponse.success(DeepLink.mock())) }, ) - Divider(thickness = 1.dp, color = MaterialTheme.bbibbiScheme.backgroundSecondary) + HorizontalDivider( + thickness = 1.dp, + color = MaterialTheme.bbibbiScheme.backgroundSecondary + ) FamilyPageMemberList( meId = Member.unknown().memberId, meState = remember { mutableStateOf(APIResponse.success(Member.unknown())) }, diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePage.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePage.kt index fb39159..b713cc5 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePage.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePage.kt @@ -28,7 +28,6 @@ import com.no5ing.bbibbi.presentation.component.BBiBBiSurface import com.no5ing.bbibbi.presentation.component.BackToExitHandler import com.no5ing.bbibbi.presentation.feature.view.common.CustomAlertDialog import com.no5ing.bbibbi.presentation.feature.view_model.auth.RetrieveMeViewModel -import com.no5ing.bbibbi.presentation.feature.view_model.members.FamilyMembersViewModel import com.no5ing.bbibbi.presentation.feature.view_model.post.DailyFamilyTopViewModel import com.no5ing.bbibbi.presentation.feature.view_model.post.IsMeUploadedTodayViewModel import com.no5ing.bbibbi.presentation.feature.view_model.post.MainPostFeedViewModel @@ -80,7 +79,7 @@ fun HomePage( } if (familyPostsViewModel.isInitialize()) { - // familyMembersViewModel.invoke(Arguments()) + // familyMembersViewModel.invoke(Arguments()) retrieveMeViewModel.invoke(Arguments()) familyPostTopViewModel.invoke(Arguments())// TODO familyPostsViewModel.invoke( diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageContent.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageContent.kt index 7892a23..643d50b 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageContent.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageContent.kt @@ -10,7 +10,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.lazy.grid.GridItemSpan -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -49,7 +49,7 @@ fun HomePageContent( onRefresh: () -> Unit = {}, ) { val postItems = contentState.collectAsLazyPagingItems() - // val memberItems = familyListState.collectAsLazyPagingItems() + // val memberItems = familyListState.collectAsLazyPagingItems() var isRefreshing by remember { mutableStateOf(false) } LaunchedEffect(postItems.loadState.refresh) { if (isRefreshing && @@ -79,7 +79,7 @@ fun HomePageContent( onTapInvite = onTapInvite, ) Spacer(modifier = Modifier.height(24.dp)) - Divider( + HorizontalDivider( thickness = 1.dp, color = MaterialTheme.bbibbiScheme.backgroundSecondary ) diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageStoryBar.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageStoryBar.kt index 793abea..7f14ff7 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageStoryBar.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/HomePageStoryBar.kt @@ -29,8 +29,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import androidx.paging.PagingData -import androidx.paging.compose.collectAsLazyPagingItems import com.no5ing.bbibbi.R import com.no5ing.bbibbi.data.model.APIResponse import com.no5ing.bbibbi.data.model.member.Member @@ -61,7 +59,7 @@ fun HomePageStoryBar( .padding(horizontal = 16.dp), onTap = onTapInvite, ) - } else if(postTopState.isReady()) { + } else if (postTopState.isReady()) { LazyRow( modifier = Modifier .fillMaxWidth() @@ -133,8 +131,8 @@ fun StoryBarIcon( horizontalAlignment = Alignment.CenterHorizontally ) { Box { - val rankColor = if(isUploaded) getRankColor(rank = rank) else null - val rankBadge = if(isUploaded) getRankBadge(rank = rank) else null + val rankColor = if (isUploaded) getRankColor(rank = rank) else null + val rankBadge = if (isUploaded) getRankBadge(rank = rank) else null if (rankColor != null) { Box( modifier = Modifier diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/TryWidgetPopup.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/TryWidgetPopup.kt index 52663a6..e9b8bab 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/TryWidgetPopup.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/home/TryWidgetPopup.kt @@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.AlertDialog import androidx.compose.material3.AlertDialogDefaults +import androidx.compose.material3.BasicAlertDialog import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.ExperimentalMaterial3Api @@ -38,7 +39,7 @@ import com.no5ing.bbibbi.presentation.theme.bbibbiTypo fun TryWidgetPopup() { val enabledState = remember { mutableStateOf(true) } if (enabledState.value) { - AlertDialog( + BasicAlertDialog( onDismissRequest = { enabledState.value = false }, diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt index 46bf27a..2b596cf 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/post_view/PostViewPage.kt @@ -148,10 +148,10 @@ fun PostViewPage( AsyncImage( model = asyncImagePainter( source = - if(postState.isReady()) - if (siblingPostState.isReady()) siblingPostState.data[pagerState.currentPage].post.imageUrl - else postState.data.post.imageUrl - else null + if (postState.isReady()) + if (siblingPostState.isReady()) siblingPostState.data[pagerState.currentPage].post.imageUrl + else postState.data.post.imageUrl + else null ), contentDescription = null, modifier = Modifier diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/profile/ProfilePageMemberBar.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/profile/ProfilePageMemberBar.kt index 0fb54c0..391bdf0 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/profile/ProfilePageMemberBar.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view/main/profile/ProfilePageMemberBar.kt @@ -11,7 +11,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width -import androidx.compose.material3.Divider +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -126,7 +126,10 @@ fun ProfilePageMemberBar( ) } Spacer(modifier = Modifier.height(24.dp)) - Divider(thickness = 1.dp, color = MaterialTheme.bbibbiScheme.backgroundSecondary) + HorizontalDivider( + thickness = 1.dp, + color = MaterialTheme.bbibbiScheme.backgroundSecondary + ) Spacer(modifier = Modifier.height(24.dp)) } } diff --git a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/DailyFamilyTopViewModel.kt b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/DailyFamilyTopViewModel.kt index 8fbdf59..40e5573 100644 --- a/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/DailyFamilyTopViewModel.kt +++ b/app/src/main/java/com/no5ing/bbibbi/presentation/feature/view_model/post/DailyFamilyTopViewModel.kt @@ -2,7 +2,6 @@ package com.no5ing.bbibbi.presentation.feature.view_model.post import com.no5ing.bbibbi.data.datasource.network.RestAPI import com.no5ing.bbibbi.data.model.APIResponse -import com.no5ing.bbibbi.data.model.member.Member import com.no5ing.bbibbi.data.repository.Arguments import com.no5ing.bbibbi.presentation.feature.uistate.family.MainFeedStoryElementUiState import com.no5ing.bbibbi.presentation.feature.view_model.BaseViewModel @@ -45,10 +44,12 @@ class DailyFamilyTopViewModel @Inject constructor( ).suspendOnSuccess { val response = members.await() if (response.isSuccess) { - val memberMap = (response.getOrNull()?.results?.associateBy { it.memberId } ?: emptyMap()) + val memberMap = (response.getOrNull()?.results?.associateBy { it.memberId } + ?: emptyMap()) .toMutableMap() data.results.forEachIndexed { index, post -> - val currentMember = memberMap.remove(post.authorId) ?: return@forEachIndexed + val currentMember = + memberMap.remove(post.authorId) ?: return@forEachIndexed newList.add(MainFeedStoryElementUiState(currentMember, true)) } memberMap.forEach { diff --git a/app/src/main/java/com/no5ing/bbibbi/util/ImageUploader.kt b/app/src/main/java/com/no5ing/bbibbi/util/ImageUploader.kt index e5d8dfe..05f40f8 100644 --- a/app/src/main/java/com/no5ing/bbibbi/util/ImageUploader.kt +++ b/app/src/main/java/com/no5ing/bbibbi/util/ImageUploader.kt @@ -3,7 +3,6 @@ package com.no5ing.bbibbi.util import okhttp3.MediaType.Companion.toMediaType import okhttp3.OkHttpClient import okhttp3.Request -import okhttp3.RequestBody import okhttp3.RequestBody.Companion.asRequestBody import java.io.File From 1e078e57051ff7f8de2e3a36ce9dda7505a3cf36 Mon Sep 17 00:00:00 2001 From: ChuYong Date: Thu, 22 Feb 2024 00:54:14 +0900 Subject: [PATCH 9/9] =?UTF-8?q?feat:=20bibbi.app=20=EB=94=A5=EB=A7=81?= =?UTF-8?q?=ED=81=AC=20=EC=8A=A4=ED=82=A4=EB=A7=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 11 +++++++++++ .../join_family_with_link/JoinFamilyWithLinkPage.kt | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c076d67..e6b9efa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -61,6 +61,17 @@ + + + + + + + + + + +