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

fix: empty placeholder strings #12

Merged
merged 1 commit into from
Jan 6, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ import com.github.whitescent.mastify.ui.component.drawVerticalScrollbar
import com.github.whitescent.mastify.ui.component.status.StatusListItem
import com.github.whitescent.mastify.ui.component.status.StatusSnackBar
import com.github.whitescent.mastify.ui.component.status.paging.EmptyStatusListPlaceholder
import com.github.whitescent.mastify.ui.component.status.paging.PageType
import com.github.whitescent.mastify.ui.component.status.paging.PagePlaceholderType
import com.github.whitescent.mastify.ui.component.status.paging.StatusListLoadError
import com.github.whitescent.mastify.ui.component.status.paging.StatusListLoading
import com.github.whitescent.mastify.ui.component.status.rememberStatusSnackBarState
Expand Down Expand Up @@ -197,7 +197,7 @@ fun Home(
StatusListLoadError { viewModel.refreshTimeline() }
uiState.timelineLoadState == NotLoading && uiState.endReached ->
EmptyStatusListPlaceholder(
pageType = PageType.Timeline,
pagePlaceholderType = PagePlaceholderType.Home,
modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())
)
else -> StatusListLoading(Modifier.fillMaxSize())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.github.whitescent.mastify.network.model.status.Status
import com.github.whitescent.mastify.network.model.status.Status.Attachment
import com.github.whitescent.mastify.paging.autoAppend
import com.github.whitescent.mastify.ui.component.status.StatusCommonList
import com.github.whitescent.mastify.ui.component.status.paging.PagePlaceholderType
import com.github.whitescent.mastify.viewModel.ExplorerViewModel
import com.github.whitescent.mastify.viewModel.ProfileKind
import com.github.whitescent.mastify.viewModel.ProfileViewModel
Expand Down Expand Up @@ -65,6 +66,7 @@ fun ProfilePager(
0 -> StatusCommonList(
statusCommonListData = statusList,
statusListState = statusListState,
pagePlaceholderType = PagePlaceholderType.Profile(isSelf = viewModel.uiState.isSelf!!),
action = { action, status ->
viewModel.onStatusAction(action, context, status)
},
Expand All @@ -74,9 +76,11 @@ fun ProfilePager(
navigateToProfile = navigateToProfile,
navigateToMedia = navigateToMedia,
)

1 -> StatusCommonList(
statusCommonListData = statusListWithReply,
statusListState = statusListWithReplyState,
pagePlaceholderType = PagePlaceholderType.Profile(isSelf = viewModel.uiState.isSelf!!),
action = { action, status ->
viewModel.onStatusAction(action, context, status)
},
Expand All @@ -89,6 +93,7 @@ fun ProfilePager(
2 -> StatusCommonList(
statusCommonListData = statusListWithMedia,
statusListState = statusListWithMediaState,
pagePlaceholderType = PagePlaceholderType.Profile(isSelf = viewModel.uiState.isSelf!!),
action = { action, status ->
viewModel.onStatusAction(action, context, status)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import com.github.whitescent.mastify.ui.component.StatusAppendingIndicator
import com.github.whitescent.mastify.ui.component.StatusEndIndicator
import com.github.whitescent.mastify.ui.component.drawVerticalScrollbar
import com.github.whitescent.mastify.ui.component.status.paging.EmptyStatusListPlaceholder
import com.github.whitescent.mastify.ui.component.status.paging.PageType
import com.github.whitescent.mastify.ui.component.status.paging.PagePlaceholderType
import com.github.whitescent.mastify.ui.component.status.paging.StatusListLoadError
import com.github.whitescent.mastify.ui.component.status.paging.StatusListLoading
import com.github.whitescent.mastify.utils.StatusAction
Expand All @@ -71,6 +71,7 @@ import kotlinx.coroutines.launch
fun StatusCommonList(
statusCommonListData: StatusCommonListData<StatusUiData>,
statusListState: LazyListState,
pagePlaceholderType: PagePlaceholderType,
modifier: Modifier = Modifier,
enablePullRefresh: Boolean = false,
action: (StatusAction, Status) -> Unit,
Expand Down Expand Up @@ -114,7 +115,7 @@ fun StatusCommonList(
loadState == Error -> StatusListLoadError { refreshList() }
loadState == NotLoading && statusCommonListData.endReached ->
EmptyStatusListPlaceholder(
pageType = PageType.Timeline,
pagePlaceholderType = pagePlaceholderType,
modifier = Modifier.fillMaxSize().verticalScroll(rememberScrollState())
)
else -> StatusListLoading(Modifier.fillMaxSize())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

package com.github.whitescent.mastify.ui.component.status.paging

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -37,10 +37,13 @@ import com.airbnb.lottie.compose.animateLottieCompositionAsState
import com.airbnb.lottie.compose.rememberLottieComposition
import com.github.whitescent.R
import com.github.whitescent.mastify.ui.theme.AppTheme
import com.github.whitescent.mastify.viewModel.ExplorerKind
import com.github.whitescent.mastify.viewModel.ExplorerKind.PublicTimeline
import com.github.whitescent.mastify.viewModel.ExplorerKind.Trending

@Composable
fun EmptyStatusListPlaceholder(
pageType: PageType,
pagePlaceholderType: PagePlaceholderType,
modifier: Modifier = Modifier,
alignment: Alignment = Alignment.Center,
) {
Expand All @@ -50,19 +53,28 @@ fun EmptyStatusListPlaceholder(
modifier = modifier,
contentAlignment = alignment
) {
Column(Modifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally) {
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center) {
LottieAnimation(
composition = composition,
progress = { progress },
contentScale = ContentScale.Fit,
modifier = Modifier
.size(360.dp)
contentScale = ContentScale.Crop,
modifier = Modifier.size(300.dp),
alignment = Alignment.TopCenter
)
Text(
text = stringResource(
id = when (pageType) {
PageType.Timeline -> R.string.empty_timeline
PageType.Profile -> R.string.empty_status
id = when (pagePlaceholderType) {
is PagePlaceholderType.Home -> R.string.empty_timeline
is PagePlaceholderType.Profile -> {
if (pagePlaceholderType.isSelf) R.string.empty_status_self
else R.string.empty_status
}
is PagePlaceholderType.Explore -> {
when (pagePlaceholderType.explorerKind) {
PublicTimeline, Trending -> R.string.timeline_is_empty
ExplorerKind.News -> R.string.news_is_empty
}
}
}
),
fontWeight = FontWeight.Medium,
Expand All @@ -73,6 +85,8 @@ fun EmptyStatusListPlaceholder(
}
}

enum class PageType {
Timeline, Profile
sealed class PagePlaceholderType {
data object Home : PagePlaceholderType()
data class Profile(val isSelf: Boolean) : PagePlaceholderType()
data class Explore(val explorerKind: ExplorerKind) : PagePlaceholderType()
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ class ProfileViewModel @Inject constructor(

init {
viewModelScope.launch {
statusPager.refresh()
uiState = uiState.copy(
isSelf = navArgs.account.id == accountDao.getActiveAccount()!!.accountId
)
statusPager.refresh()
getRelationship(navArgs.account.id)
fetchAccount(navArgs.account.id)
launch {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
<string name="media_title">媒体</string>
<string name="edit_profile">编辑个人资料</string>
<string name="empty_status">"这个家伙还没有发布过任何嘟文"</string>
<string name="empty_status_self">你还没有发布过嘟文哦</string>
<string name="empty_timeline">"你还没有关注其他人哦"</string>


Expand Down Expand Up @@ -133,4 +134,6 @@
<string name="public_timeline">公共时间轴</string>
<string name="news_title">新闻</string>
<string name="search_title">搜索</string>
<string name="timeline_is_empty">这里现在还没有帖子</string>
<string name="news_is_empty">这个实例现在还没有新闻</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<string name="media_title">Media</string>
<string name="edit_profile">Edit Profile</string>
<string name="empty_status">This guy hasn\'t yet made a post</string>
<string name="empty_status_self">You haven\'t posted yet</string>
<string name="empty_timeline">"You haven't followed anyone else yet"</string>

<!--These are for timestamps on posts. For example: "16s" or "2d"-->
Expand Down Expand Up @@ -136,5 +137,7 @@
<string name="public_timeline">Public Timeline</string>
<string name="news_title">News</string>
<string name="search_title">Search</string>
<string name="timeline_is_empty">There are no posts here yet</string>
<string name="news_is_empty">There is no news about this instance yet</string>

</resources>