diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomMessageCompose.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomMessageCompose.kt index 1294cf883..290988501 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomMessageCompose.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ChatroomMessageCompose.kt @@ -113,6 +113,8 @@ fun ChatroomMessageCompose( var alignment: Arrangement.Horizontal var shape: Shape + val grayTint = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + if (note.author == accountUser) { backgroundBubbleColor = MaterialTheme.colors.primary.copy(alpha = 0.32f) alignment = Arrangement.End @@ -333,11 +335,11 @@ fun ChatroomMessageCompose( } Row() { - LikeReaction(baseNote, accountViewModel) + LikeReaction(baseNote, grayTint, accountViewModel) Spacer(modifier = Modifier.width(5.dp)) - ZapReaction(baseNote, accountViewModel) + ZapReaction(baseNote, grayTint, accountViewModel) Spacer(modifier = Modifier.width(5.dp)) - ReplyReaction(baseNote, accountViewModel, showCounter = false) { + ReplyReaction(baseNote, grayTint, accountViewModel, showCounter = false) { onWantsToReply(baseNote) } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt index 310c2c7df..21c839669 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/note/ReactionsRow.kt @@ -71,6 +71,8 @@ fun ReactionsRow(baseNote: Note, accountViewModel: AccountViewModel, navControll val accountState by accountViewModel.accountLiveData.observeAsState() val account = accountState?.account ?: return + val grayTint = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + var wantsToReplyTo by remember { mutableStateOf(null) } @@ -91,23 +93,23 @@ fun ReactionsRow(baseNote: Note, accountViewModel: AccountViewModel, navControll Row(verticalAlignment = CenterVertically) { Row(verticalAlignment = CenterVertically, modifier = Modifier.weight(1f)) { - ReplyReaction(baseNote, accountViewModel) { + ReplyReaction(baseNote, grayTint, accountViewModel) { wantsToReplyTo = baseNote } } Row(verticalAlignment = CenterVertically, modifier = Modifier.weight(1f)) { - BoostReaction(baseNote, accountViewModel) { + BoostReaction(baseNote, grayTint, accountViewModel) { wantsToQuote = baseNote } } Row(verticalAlignment = CenterVertically, modifier = Modifier.weight(1f)) { - LikeReaction(baseNote, accountViewModel) + LikeReaction(baseNote, grayTint, accountViewModel) } Row(verticalAlignment = CenterVertically, modifier = Modifier.weight(1f)) { - ZapReaction(baseNote, accountViewModel) + ZapReaction(baseNote, grayTint, accountViewModel) } Row(verticalAlignment = CenterVertically, modifier = Modifier.weight(1f)) { - ViewCountReaction(baseNote.idHex) + ViewCountReaction(baseNote.idHex, grayTint) } } } @@ -115,6 +117,7 @@ fun ReactionsRow(baseNote: Note, accountViewModel: AccountViewModel, navControll @Composable fun ReplyReaction( baseNote: Note, + grayTint: Color, accountViewModel: AccountViewModel, showCounter: Boolean = true, iconSize: Dp = 20.dp, @@ -142,39 +145,33 @@ fun ReplyReaction( } } ) { - ReplyIcon(iconSize) + Icon( + painter = painterResource(R.drawable.ic_comment), + null, + modifier = Modifier.size(iconSize), + tint = grayTint + ) } if (showCounter) { Text( " ${showCount(replies.size)}", fontSize = 14.sp, - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + color = grayTint ) } } -@Composable -private fun ReplyIcon(iconSize: Dp = 15.dp) { - Icon( - painter = painterResource(R.drawable.ic_comment), - null, - modifier = Modifier.size(iconSize), - tint = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) - ) -} - @Composable public fun BoostReaction( baseNote: Note, + grayTint: Color, accountViewModel: AccountViewModel, iconSize: Dp = 20.dp, onQuotePress: () -> Unit ) { val boostsState by baseNote.live().boosts.observeAsState() val boostedNote = boostsState?.note - - val grayTint = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) val context = LocalContext.current val scope = rememberCoroutineScope() @@ -234,13 +231,14 @@ public fun BoostReaction( Text( " ${showCount(boostedNote?.boosts?.size)}", fontSize = 14.sp, - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + color = grayTint ) } @Composable fun LikeReaction( baseNote: Note, + grayTint: Color, accountViewModel: AccountViewModel, iconSize: Dp = 20.dp, heartSize: Dp = 16.dp @@ -248,7 +246,6 @@ fun LikeReaction( val reactionsState by baseNote.live().reactions.observeAsState() val reactedNote = reactionsState?.note ?: return - val grayTint = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) val context = LocalContext.current val scope = rememberCoroutineScope() @@ -292,7 +289,7 @@ fun LikeReaction( Text( " ${showCount(reactedNote.reactions.size)}", fontSize = 14.sp, - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) + color = grayTint ) } @@ -300,6 +297,7 @@ fun LikeReaction( @OptIn(ExperimentalFoundationApi::class) fun ZapReaction( baseNote: Note, + grayTint: Color, accountViewModel: AccountViewModel, textModifier: Modifier = Modifier, iconSize: Dp = 20.dp, @@ -315,7 +313,6 @@ fun ZapReaction( var wantsToZap by remember { mutableStateOf(false) } var wantsToChangeZapAmount by remember { mutableStateOf(false) } var wantsToSetCustomZap by remember { mutableStateOf(false) } - val grayTint = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) val context = LocalContext.current val scope = rememberCoroutineScope() @@ -466,15 +463,20 @@ fun ZapReaction( Text( showAmount(zapAmount), fontSize = 14.sp, - color = MaterialTheme.colors.onSurface.copy(alpha = 0.32f), + color = grayTint, modifier = textModifier ) } @Composable -public fun ViewCountReaction(idHex: String, iconSize: Dp = 20.dp, barChartSize: Dp = 19.dp, numberSize: Dp = 24.dp) { +public fun ViewCountReaction( + idHex: String, + grayTint: Color, + iconSize: Dp = 20.dp, + barChartSize: Dp = 19.dp, + numberSize: Dp = 24.dp +) { val uri = LocalUriHandler.current - val grayTint = MaterialTheme.colors.onSurface.copy(alpha = 0.32f) IconButton( modifier = Modifier.size(iconSize), diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt index dcf3f2a4f..1b78c427c 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/FeedView.kt @@ -42,7 +42,8 @@ fun FeedView( navController: NavController, routeForLastRead: String?, scrollStateKey: String? = null, - scrollToTop: Boolean = false + scrollToTop: Boolean = false, + enablePullRefresh: Boolean = true ) { val feedState by viewModel.feedContent.collectAsState() @@ -50,7 +51,13 @@ fun FeedView( val refresh = { refreshing = true; viewModel.invalidateData(); refreshing = false } val pullRefreshState = rememberPullRefreshState(refreshing, onRefresh = refresh) - Box(Modifier.pullRefresh(pullRefreshState)) { + val modifier = if (enablePullRefresh) { + Modifier.pullRefresh(pullRefreshState) + } else { + Modifier + } + + Box(modifier) { Column { Crossfade( targetState = feedState, @@ -88,7 +95,9 @@ fun FeedView( } } - PullRefreshIndicator(refreshing, pullRefreshState, Modifier.align(Alignment.TopCenter)) + if (enablePullRefresh) { + PullRefreshIndicator(refreshing, pullRefreshState, Modifier.align(Alignment.TopCenter)) + } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/LnZapFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/LnZapFeedView.kt index c13e23f53..ab8e591a2 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/LnZapFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/LnZapFeedView.kt @@ -27,14 +27,25 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @OptIn(ExperimentalMaterialApi::class) @Composable -fun LnZapFeedView(viewModel: LnZapFeedViewModel, accountViewModel: AccountViewModel, navController: NavController) { +fun LnZapFeedView( + viewModel: LnZapFeedViewModel, + accountViewModel: AccountViewModel, + navController: NavController, + enablePullRefresh: Boolean = true +) { val feedState by viewModel.feedContent.collectAsState() var refreshing by remember { mutableStateOf(false) } val refresh = { refreshing = true; viewModel.invalidateData(); refreshing = false } val pullRefreshState = rememberPullRefreshState(refreshing, onRefresh = refresh) - Box(Modifier.pullRefresh(pullRefreshState)) { + val modifier = if (enablePullRefresh) { + Modifier.pullRefresh(pullRefreshState) + } else { + Modifier + } + + Box(modifier) { Column() { Crossfade(targetState = feedState, animationSpec = tween(durationMillis = 100)) { state -> when (state) { @@ -59,7 +70,9 @@ fun LnZapFeedView(viewModel: LnZapFeedViewModel, accountViewModel: AccountViewMo } } - PullRefreshIndicator(refreshing, pullRefreshState, Modifier.align(Alignment.TopCenter)) + if (enablePullRefresh) { + PullRefreshIndicator(refreshing, pullRefreshState, Modifier.align(Alignment.TopCenter)) + } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/RelayFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/RelayFeedView.kt index e24453a3f..cee08ccf8 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/RelayFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/RelayFeedView.kt @@ -96,7 +96,11 @@ class RelayFeedViewModel : ViewModel() { @OptIn(ExperimentalMaterialApi::class) @Composable -fun RelayFeedView(viewModel: RelayFeedViewModel, accountViewModel: AccountViewModel) { +fun RelayFeedView( + viewModel: RelayFeedViewModel, + accountViewModel: AccountViewModel, + enablePullRefresh: Boolean = true +) { val accountState by accountViewModel.accountLiveData.observeAsState() val account = accountState?.account ?: return @@ -114,7 +118,13 @@ fun RelayFeedView(viewModel: RelayFeedViewModel, accountViewModel: AccountViewMo val refresh = { refreshing = true; viewModel.refresh(); refreshing = false } val pullRefreshState = rememberPullRefreshState(refreshing, onRefresh = refresh) - Box(Modifier.pullRefresh(pullRefreshState)) { + val modifier = if (enablePullRefresh) { + Modifier.pullRefresh(pullRefreshState) + } else { + Modifier + } + + Box(modifier) { Column() { val listState = rememberLazyListState() @@ -136,6 +146,8 @@ fun RelayFeedView(viewModel: RelayFeedViewModel, accountViewModel: AccountViewMo } } - PullRefreshIndicator(refreshing, pullRefreshState, Modifier.align(Alignment.TopCenter)) + if (enablePullRefresh) { + PullRefreshIndicator(refreshing, pullRefreshState, Modifier.align(Alignment.TopCenter)) + } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt index 79da216b4..d2f8078cd 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/UserFeedView.kt @@ -27,14 +27,25 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @OptIn(ExperimentalMaterialApi::class) @Composable -fun UserFeedView(viewModel: UserFeedViewModel, accountViewModel: AccountViewModel, navController: NavController) { +fun UserFeedView( + viewModel: UserFeedViewModel, + accountViewModel: AccountViewModel, + navController: NavController, + enablePullRefresh: Boolean = true +) { val feedState by viewModel.feedContent.collectAsState() var refreshing by remember { mutableStateOf(false) } val refresh = { refreshing = true; viewModel.invalidateData(); refreshing = false } val pullRefreshState = rememberPullRefreshState(refreshing, onRefresh = refresh) - Box(Modifier.pullRefresh(pullRefreshState)) { + val modifier = if (enablePullRefresh) { + Modifier.pullRefresh(pullRefreshState) + } else { + Modifier + } + + Box(modifier) { Column() { Crossfade(targetState = feedState, animationSpec = tween(durationMillis = 100)) { state -> when (state) { @@ -59,7 +70,9 @@ fun UserFeedView(viewModel: UserFeedViewModel, accountViewModel: AccountViewMode } } - PullRefreshIndicator(refreshing, pullRefreshState, Modifier.align(Alignment.TopCenter)) + if (enablePullRefresh) { + PullRefreshIndicator(refreshing, pullRefreshState, Modifier.align(Alignment.TopCenter)) + } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt index b23bb3623..4a9ab3c11 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt @@ -760,7 +760,7 @@ fun TabNotesNewThreads(accountViewModel: AccountViewModel, navController: NavCon Column( modifier = Modifier.padding(vertical = 0.dp) ) { - FeedView(feedViewModel, accountViewModel, navController, null) + FeedView(feedViewModel, accountViewModel, navController, null, enablePullRefresh = false) } } } @@ -780,7 +780,7 @@ fun TabNotesConversations(accountViewModel: AccountViewModel, navController: Nav Column( modifier = Modifier.padding(vertical = 0.dp) ) { - FeedView(feedViewModel, accountViewModel, navController, null) + FeedView(feedViewModel, accountViewModel, navController, null, enablePullRefresh = false) } } } @@ -801,7 +801,7 @@ fun TabBookmarks(baseUser: User, accountViewModel: AccountViewModel, navControll Column( modifier = Modifier.padding(vertical = 0.dp) ) { - FeedView(feedViewModel, accountViewModel, navController, null) + FeedView(feedViewModel, accountViewModel, navController, null, enablePullRefresh = false) } } } @@ -821,7 +821,7 @@ fun TabFollows(baseUser: User, accountViewModel: AccountViewModel, navController Column( modifier = Modifier.padding(vertical = 0.dp) ) { - UserFeedView(feedViewModel, accountViewModel, navController) + UserFeedView(feedViewModel, accountViewModel, navController, enablePullRefresh = false) } } } @@ -840,7 +840,7 @@ fun TabFollowers(baseUser: User, accountViewModel: AccountViewModel, navControll Column( modifier = Modifier.padding(vertical = 0.dp) ) { - UserFeedView(feedViewModel, accountViewModel, navController) + UserFeedView(feedViewModel, accountViewModel, navController, enablePullRefresh = false) } } } @@ -859,7 +859,7 @@ fun TabReceivedZaps(baseUser: User, accountViewModel: AccountViewModel, navContr Column( modifier = Modifier.padding(vertical = 0.dp) ) { - LnZapFeedView(feedViewModel, accountViewModel, navController) + LnZapFeedView(feedViewModel, accountViewModel, navController, enablePullRefresh = false) } } } @@ -878,7 +878,7 @@ fun TabReports(baseUser: User, accountViewModel: AccountViewModel, navController Column( modifier = Modifier.padding(vertical = 0.dp) ) { - FeedView(feedViewModel, accountViewModel, navController, null) + FeedView(feedViewModel, accountViewModel, navController, null, enablePullRefresh = false) } } } @@ -913,7 +913,7 @@ fun TabRelays(user: User, accountViewModel: AccountViewModel) { Column( modifier = Modifier.padding(vertical = 0.dp) ) { - RelayFeedView(feedViewModel, accountViewModel) + RelayFeedView(feedViewModel, accountViewModel, enablePullRefresh = false) } } } diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt index 401c48435..adba2b7ea 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/VideoScreen.kt @@ -367,9 +367,9 @@ fun ReactionsColumn(baseNote: Note, accountViewModel: AccountViewModel, navContr BoostReaction(baseNote, accountViewModel, iconSize = 40.dp) { wantsToQuote = baseNote }*/ - LikeReaction(baseNote, accountViewModel, iconSize = 40.dp, heartSize = 35.dp) - ZapReaction(baseNote, accountViewModel, iconSize = 40.dp, animationSize = 35.dp) - ViewCountReaction(baseNote.idHex, iconSize = 40.dp, barChartSize = 39.dp) + LikeReaction(baseNote, grayTint = MaterialTheme.colors.onBackground, accountViewModel, iconSize = 40.dp, heartSize = 35.dp) + ZapReaction(baseNote, grayTint = MaterialTheme.colors.onBackground, accountViewModel, iconSize = 40.dp, animationSize = 35.dp) + ViewCountReaction(baseNote.idHex, grayTint = MaterialTheme.colors.onBackground, iconSize = 40.dp, barChartSize = 39.dp) } }