diff --git a/feature/post/src/main/java/caios/android/fanbox/feature/post/detail/PostDetailScreen.kt b/feature/post/src/main/java/caios/android/fanbox/feature/post/detail/PostDetailScreen.kt index effd1d2d..d6329bf0 100644 --- a/feature/post/src/main/java/caios/android/fanbox/feature/post/detail/PostDetailScreen.kt +++ b/feature/post/src/main/java/caios/android/fanbox/feature/post/detail/PostDetailScreen.kt @@ -7,7 +7,6 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.fillMaxSize @@ -19,10 +18,7 @@ import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.InsertDriveFile -import androidx.compose.material.icons.filled.Bookmark -import androidx.compose.material.icons.outlined.BookmarkBorder import androidx.compose.material3.Icon -import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.material3.surfaceColorAtElevation @@ -31,6 +27,7 @@ import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -250,6 +247,7 @@ private fun PostDetailScreen( modifier: Modifier = Modifier, ) { var isShowMenu by remember { mutableStateOf(false) } + var isPostLiked by rememberSaveable(postDetail.isLiked) { mutableStateOf(postDetail.isLiked) } var isBookmarked by remember(postDetail.isBookmarked) { mutableStateOf(postDetail.isBookmarked) } val isShowCoordinateHeader = when (val content = postDetail.body) { @@ -316,32 +314,23 @@ private fun PostDetailScreen( } item { - Row( + PostDetailCommentLikeButton( modifier = Modifier .padding(horizontal = 16.dp) .fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(16.dp), - ) { - PostDetailCommentLikeButton( - modifier = Modifier.weight(1f), - likeCount = postDetail.likeCount, - commentCount = postDetail.commentCount, - ) - - IconButton( - onClick = { - isBookmarked = !isBookmarked - onClickPostBookmark.invoke(postDetail.asPost(), isBookmarked) - }, - ) { - Icon( - imageVector = if (isBookmarked) Icons.Default.Bookmark else Icons.Outlined.BookmarkBorder, - tint = if (isBookmarked) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurface, - contentDescription = null, - ) - } - } + isLiked = isPostLiked, + isBookmarked = isBookmarked, + likeCount = postDetail.likeCount, + commentCount = postDetail.commentCount, + onClickLike = { + isPostLiked = true + onClickPostLike.invoke(postDetail.id) + }, + onClickBookmark = { + isBookmarked = it + onClickPostBookmark.invoke(postDetail.asPost(), isBookmarked) + }, + ) } if (postDetail.isRestricted) { diff --git a/feature/post/src/main/java/caios/android/fanbox/feature/post/detail/items/PostDetailCommentLikeSection.kt b/feature/post/src/main/java/caios/android/fanbox/feature/post/detail/items/PostDetailCommentLikeSection.kt index d6f09c7a..ad09e25e 100644 --- a/feature/post/src/main/java/caios/android/fanbox/feature/post/detail/items/PostDetailCommentLikeSection.kt +++ b/feature/post/src/main/java/caios/android/fanbox/feature/post/detail/items/PostDetailCommentLikeSection.kt @@ -1,36 +1,52 @@ package caios.android.fanbox.feature.post.detail.items +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.Comment +import androidx.compose.material.icons.filled.Bookmark import androidx.compose.material.icons.filled.Favorite +import androidx.compose.material.icons.outlined.BookmarkBorder import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp @Composable internal fun PostDetailCommentLikeButton( commentCount: Int, likeCount: Int, + isBookmarked: Boolean, + isLiked: Boolean, + onClickLike: () -> Unit, + onClickBookmark: (Boolean) -> Unit, modifier: Modifier = Modifier, ) { + val likeColor = if (isLiked) Color(0xffe0405e) else MaterialTheme.colorScheme.onSurfaceVariant + val bookmarkColor = if (isBookmarked) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant + Row( modifier = modifier, verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(12.dp), + horizontalArrangement = Arrangement.spacedBy(16.dp), ) { Row( verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(6.dp), + horizontalArrangement = Arrangement.spacedBy(8.dp), ) { Icon( - modifier = Modifier.size(18.dp), + modifier = Modifier.size(20.dp), imageVector = Icons.AutoMirrored.Filled.Comment, tint = MaterialTheme.colorScheme.onSurfaceVariant, contentDescription = null, @@ -38,26 +54,47 @@ internal fun PostDetailCommentLikeButton( Text( text = commentCount.toString(), - style = MaterialTheme.typography.bodyMedium, + style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant, ) } Row( + modifier = Modifier + .clip(CircleShape) + .clickable { + if (!isLiked) { + onClickLike.invoke() + } + onClickBookmark.invoke(true) + } + .padding(4.dp), verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(6.dp), + horizontalArrangement = Arrangement.spacedBy(8.dp), ) { Icon( - modifier = Modifier.size(18.dp), + modifier = Modifier.size(20.dp), imageVector = Icons.Default.Favorite, - tint = MaterialTheme.colorScheme.onSurfaceVariant, + tint = likeColor, contentDescription = null, ) Text( text = likeCount.toString(), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.onSurfaceVariant, + style = MaterialTheme.typography.bodySmall, + color = likeColor, + ) + } + + Spacer(modifier = Modifier.weight(1f)) + + IconButton( + onClick = { onClickBookmark.invoke(!isBookmarked) }, + ) { + Icon( + imageVector = if (isBookmarked) Icons.Default.Bookmark else Icons.Outlined.BookmarkBorder, + tint = bookmarkColor, + contentDescription = null, ) } } diff --git a/feature/welcome/src/main/java/caios/android/fanbox/feature/welcome/login/activity/LoginScreen.kt b/feature/welcome/src/main/java/caios/android/fanbox/feature/welcome/login/activity/LoginScreen.kt index 84828e32..10350646 100644 --- a/feature/welcome/src/main/java/caios/android/fanbox/feature/welcome/login/activity/LoginScreen.kt +++ b/feature/welcome/src/main/java/caios/android/fanbox/feature/welcome/login/activity/LoginScreen.kt @@ -61,7 +61,10 @@ internal fun LoginScreen( cookieManager.acceptCookie() cookieManager.acceptThirdPartyCookies(it) + it.settings.loadWithOverviewMode = true + it.settings.domStorageEnabled = true it.settings.javaScriptEnabled = true + it.settings.javaScriptCanOpenWindowsAutomatically = true }, client = object : AccompanistWebViewClient() { override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {