Skip to content

Commit

Permalink
Fix thumbnail links not working with deeplinks (LemmyNet#1023)
Browse files Browse the repository at this point in the history
* Fix nav not working with deeplinks

* Fix formatting

---------

Co-authored-by: Kevin Phoenix <[email protected]>
  • Loading branch information
MV-GH and twizmwazin authored Jul 12, 2023
1 parent 4d55ee0 commit deffc88
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ fun CommunityActivity(
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
openImageViewer = navController::toView,
navController = navController,
)
}
else -> {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ fun MainPostListingsContent(
useCustomTabs = useCustomTabs,
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
navController = navController,
openImageViewer = navController::toView,
)
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/jerboa/ui/components/login/Login.kt
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ fun LoginFormPreview() {

@Composable
fun LoginHeader(
navController: NavController = rememberNavController(),
navController: NavController,
accounts: List<Account>? = null,
) {
TopAppBar(
Expand Down Expand Up @@ -284,5 +284,5 @@ fun LoginHeader(
@Preview
@Composable
fun LoginHeaderPreview() {
LoginHeader()
LoginHeader(navController = rememberNavController())
}
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ fun UserTabs(
useCustomTabs = useCustomTabs,
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
navController = navController,
openImageViewer = openImageViewer,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ fun PostActivity(
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
openImageViewer = openImageViewer,
navController = navController,
)
}

Expand Down
27 changes: 25 additions & 2 deletions app/src/main/java/com/jerboa/ui/components/post/PostListing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.jerboa.InstantScores
import com.jerboa.PostViewMode
Expand Down Expand Up @@ -272,6 +273,7 @@ fun PostTitleBlock(
useCustomTabs: Boolean,
usePrivateTabs: Boolean,
blurNSFW: Boolean,
navController: NavController,
openImageViewer: (url: String) -> Unit,
) {
val imagePost = postView.post.url?.let { isImage(it) } ?: run { false }
Expand All @@ -289,6 +291,7 @@ fun PostTitleBlock(
useCustomTabs = useCustomTabs,
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
navController = navController,
openImageViewer = openImageViewer,
)
}
Expand Down Expand Up @@ -356,6 +359,7 @@ fun PostTitleAndThumbnail(
useCustomTabs: Boolean,
usePrivateTabs: Boolean,
blurNSFW: Boolean,
navController: NavController,
openImageViewer: (url: String) -> Unit,
) {
Column(
Expand Down Expand Up @@ -388,6 +392,7 @@ fun PostTitleAndThumbnail(
useCustomTabs = useCustomTabs,
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
navController = navController,
openImageViewer = openImageViewer,
)
}
Expand All @@ -405,6 +410,7 @@ fun PostBody(
usePrivateTabs: Boolean,
blurNSFW: Boolean,
openImageViewer: (url: String) -> Unit,
navController: NavController,
clickBody: () -> Unit = {},
) {
val post = postView.post
Expand All @@ -419,6 +425,7 @@ fun PostBody(
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
openImageViewer = openImageViewer,
navController = navController,
)

// The metadata card
Expand Down Expand Up @@ -486,6 +493,7 @@ fun PreviewStoryTitleAndMetadata() {
usePrivateTabs = false,
blurNSFW = true,
openImageViewer = {},
navController = rememberNavController(),
)
}

Expand All @@ -502,6 +510,7 @@ fun PreviewSourcePost() {
usePrivateTabs = false,
blurNSFW = true,
openImageViewer = {},
navController = rememberNavController(),
)
}

Expand Down Expand Up @@ -763,6 +772,7 @@ fun PreviewPostListingCard() {
showAvatar = true,
blurNSFW = true,
openImageViewer = {},
navController = rememberNavController(),
)
}

Expand Down Expand Up @@ -795,6 +805,7 @@ fun PreviewLinkPostListing() {
showAvatar = true,
blurNSFW = true,
openImageViewer = {},
navController = rememberNavController(),
)
}

Expand Down Expand Up @@ -827,6 +838,7 @@ fun PreviewImagePostListingCard() {
showAvatar = true,
blurNSFW = true,
openImageViewer = {},
navController = rememberNavController(),
)
}

Expand Down Expand Up @@ -859,6 +871,7 @@ fun PreviewImagePostListingSmallCard() {
showAvatar = true,
blurNSFW = true,
openImageViewer = {},
navController = rememberNavController(),
)
}

Expand Down Expand Up @@ -891,6 +904,7 @@ fun PreviewLinkNoThumbnailPostListing() {
showAvatar = true,
blurNSFW = true,
openImageViewer = {},
navController = rememberNavController(),
)
}

Expand Down Expand Up @@ -922,6 +936,7 @@ fun PostListing(
enableDownVotes: Boolean,
showAvatar: Boolean,
blurNSFW: Boolean,
navController: NavController,
openImageViewer: (url: String) -> Unit,
) {
// This stores vote data
Expand Down Expand Up @@ -982,6 +997,7 @@ fun PostListing(
useCustomTabs = useCustomTabs,
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
navController = navController,
openImageViewer = openImageViewer,
)

Expand Down Expand Up @@ -1028,6 +1044,7 @@ fun PostListing(
useCustomTabs = useCustomTabs,
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
navController = navController,
openImageViewer = openImageViewer,
)

Expand Down Expand Up @@ -1058,6 +1075,7 @@ fun PostListing(
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
openImageViewer = openImageViewer,
navController = navController,
)
}
}
Expand Down Expand Up @@ -1124,6 +1142,7 @@ fun PostListingList(
useCustomTabs: Boolean,
usePrivateTabs: Boolean,
blurNSFW: Boolean,
navController: NavController,
openImageViewer: (url: String) -> Unit,
) {
Column(
Expand Down Expand Up @@ -1229,6 +1248,7 @@ fun PostListingList(
useCustomTabs = useCustomTabs,
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
navController = navController,
openImageViewer = openImageViewer,
)
}
Expand All @@ -1241,11 +1261,10 @@ private fun ThumbnailTile(
useCustomTabs: Boolean,
usePrivateTabs: Boolean,
blurNSFW: Boolean,
navController: NavController,
openImageViewer: (url: String) -> Unit,
) {
postView.post.url?.also { url ->
// TODO weird performance issues with using a previously rendered navcontroller
val navController = rememberNavController()

val postLinkPicMod = Modifier
.size(POST_LINK_PIC_SIZE)
Expand Down Expand Up @@ -1314,6 +1333,7 @@ fun PostListingListPreview() {
usePrivateTabs = false,
blurNSFW = true,
openImageViewer = {},
navController = rememberNavController(),
)
}

Expand Down Expand Up @@ -1342,6 +1362,7 @@ fun PostListingListWithThumbPreview() {
usePrivateTabs = false,
blurNSFW = true,
openImageViewer = {},
navController = rememberNavController(),
)
}

Expand Down Expand Up @@ -1375,6 +1396,7 @@ fun PostListingCard(
useCustomTabs: Boolean,
usePrivateTabs: Boolean,
blurNSFW: Boolean,
navController: NavController,
openImageViewer: (url: String) -> Unit,
) {
Column(
Expand Down Expand Up @@ -1410,6 +1432,7 @@ fun PostListingCard(
blurNSFW = blurNSFW,
openImageViewer = openImageViewer,
clickBody = { onPostClick(postView) },
navController = navController,
)

// Footer bar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.jerboa.PostViewMode
import com.jerboa.datatypes.sampleLinkPostView
import com.jerboa.datatypes.samplePostView
Expand Down Expand Up @@ -59,6 +61,7 @@ fun PostListings(
usePrivateTabs: Boolean,
blurNSFW: Boolean,
openImageViewer: (url: String) -> Unit,
navController: NavController,
) {
LazyColumn(
state = listState,
Expand Down Expand Up @@ -105,6 +108,7 @@ fun PostListings(
usePrivateTabs = usePrivateTabs,
blurNSFW = blurNSFW,
openImageViewer = openImageViewer,
navController = navController,
)
Divider(modifier = Modifier.padding(bottom = SMALL_PADDING))
}
Expand Down Expand Up @@ -153,5 +157,6 @@ fun PreviewPostListings() {
usePrivateTabs = false,
blurNSFW = true,
openImageViewer = {},
navController = rememberNavController(),
)
}

0 comments on commit deffc88

Please sign in to comment.