mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-30 06:43:00 +00:00 
			
		
		
		
	Improve previews, display date of comment
This commit is contained in:
		| @@ -33,6 +33,7 @@ import org.schabi.newpipe.R | |||||||
| import org.schabi.newpipe.extractor.comments.CommentsInfoItem | import org.schabi.newpipe.extractor.comments.CommentsInfoItem | ||||||
| import org.schabi.newpipe.extractor.stream.Description | import org.schabi.newpipe.extractor.stream.Description | ||||||
| import org.schabi.newpipe.ui.theme.AppTheme | import org.schabi.newpipe.ui.theme.AppTheme | ||||||
|  | import org.schabi.newpipe.util.Localization | ||||||
| import org.schabi.newpipe.util.NavigationHelper | import org.schabi.newpipe.util.NavigationHelper | ||||||
| import org.schabi.newpipe.util.image.ImageStrategy | import org.schabi.newpipe.util.image.ImageStrategy | ||||||
|  |  | ||||||
| @@ -68,8 +69,11 @@ fun Comment(comment: CommentsInfoItem) { | |||||||
|                 modifier = Modifier.clickable { isExpanded = !isExpanded }, |                 modifier = Modifier.clickable { isExpanded = !isExpanded }, | ||||||
|                 verticalArrangement = Arrangement.spacedBy(4.dp) |                 verticalArrangement = Arrangement.spacedBy(4.dp) | ||||||
|             ) { |             ) { | ||||||
|  |                 val date = Localization.relativeTimeOrTextual( | ||||||
|  |                     context, comment.uploadDate, comment.textualUploadDate | ||||||
|  |                 ) | ||||||
|                 Text( |                 Text( | ||||||
|                     text = comment.uploaderName, |                     text = Localization.concatenateStrings(comment.uploaderName, date), | ||||||
|                     color = MaterialTheme.colorScheme.secondary |                     color = MaterialTheme.colorScheme.secondary | ||||||
|                 ) |                 ) | ||||||
|  |  | ||||||
| @@ -118,9 +122,9 @@ fun CommentsInfoItem( | |||||||
|     commentText: Description, |     commentText: Description, | ||||||
|     uploaderName: String, |     uploaderName: String, | ||||||
|     textualUploadDate: String = "5 months ago", |     textualUploadDate: String = "5 months ago", | ||||||
|     likeCount: Int = 100, |     likeCount: Int = 0, | ||||||
|     isHeartedByUploader: Boolean = true, |     isHeartedByUploader: Boolean = false, | ||||||
|     isPinned: Boolean = true, |     isPinned: Boolean = false, | ||||||
| ) = CommentsInfoItem(serviceId, url, name).apply { | ) = CommentsInfoItem(serviceId, url, name).apply { | ||||||
|     this.commentText = commentText |     this.commentText = commentText | ||||||
|     this.uploaderName = uploaderName |     this.uploaderName = uploaderName | ||||||
| @@ -137,6 +141,9 @@ private fun CommentPreview() { | |||||||
|     val comment = CommentsInfoItem( |     val comment = CommentsInfoItem( | ||||||
|         commentText = Description("Hello world!\n\nThis line should be hidden by default.", Description.PLAIN_TEXT), |         commentText = Description("Hello world!\n\nThis line should be hidden by default.", Description.PLAIN_TEXT), | ||||||
|         uploaderName = "Test", |         uploaderName = "Test", | ||||||
|  |         likeCount = 100, | ||||||
|  |         isPinned = true, | ||||||
|  |         isHeartedByUploader = true | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|     AppTheme { |     AppTheme { | ||||||
|   | |||||||
| @@ -42,6 +42,9 @@ private fun CommentRepliesPreview() { | |||||||
|     val comment = CommentsInfoItem( |     val comment = CommentsInfoItem( | ||||||
|         commentText = Description("Hello world!", Description.PLAIN_TEXT), |         commentText = Description("Hello world!", Description.PLAIN_TEXT), | ||||||
|         uploaderName = "Test", |         uploaderName = "Test", | ||||||
|  |         likeCount = 100, | ||||||
|  |         isPinned = true, | ||||||
|  |         isHeartedByUploader = true | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|     val reply1 = CommentsInfoItem( |     val reply1 = CommentsInfoItem( | ||||||
|   | |||||||
| @@ -140,16 +140,15 @@ fun CommentRepliesHeader(comment: CommentsInfoItem, disposables: CompositeDispos | |||||||
| @Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) | @Preview(name = "Dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES) | ||||||
| @Composable | @Composable | ||||||
| fun CommentRepliesHeaderPreview() { | fun CommentRepliesHeaderPreview() { | ||||||
|     val disposables = CompositeDisposable() |     val comment = CommentsInfoItem( | ||||||
|     val comment = CommentsInfoItem(1, "", "") |         commentText = Description("Hello world!", Description.PLAIN_TEXT), | ||||||
|     comment.commentText = Description("Hello world!", Description.PLAIN_TEXT) |         uploaderName = "Test", | ||||||
|     comment.uploaderName = "Test" |         likeCount = 100, | ||||||
|     comment.textualUploadDate = "5 months ago" |         isPinned = true, | ||||||
|     comment.likeCount = 100 |         isHeartedByUploader = true | ||||||
|     comment.isPinned = true |     ) | ||||||
|     comment.isHeartedByUploader = true |  | ||||||
|  |  | ||||||
|     AppTheme { |     AppTheme { | ||||||
|         CommentRepliesHeader(comment, disposables) |         CommentRepliesHeader(comment, CompositeDisposable()) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Isira Seneviratne
					Isira Seneviratne