#43 Open user profile from timelines

This commit is contained in:
Marcin Czachurski 2023-04-18 13:45:48 +02:00
parent 209fa0969d
commit 341aae5496
3 changed files with 43 additions and 19 deletions

View File

@ -47,7 +47,11 @@ struct ImageRowItem: View {
} blurred: {
ZStack {
BlurredImage(blurhash: attachmentData.blurhash)
ImageAvatar(displayName: self.status.accountDisplayName, avatarUrl: self.status.accountAvatar)
ImageAvatar(displayName: self.status.accountDisplayName, avatarUrl: self.status.accountAvatar) {
self.routerPath.navigate(to: .userProfile(accountId: self.status.accountId,
accountDisplayName: self.status.accountDisplayName,
accountUserName: self.status.accountUsername))
}
}
.onTapGesture {
self.navigateToStatus()
@ -102,7 +106,12 @@ struct ImageRowItem: View {
ZStack {
self.imageView(uiImage: uiImage)
ImageAvatar(displayName: self.status.accountDisplayName, avatarUrl: self.status.accountAvatar)
ImageAvatar(displayName: self.status.accountDisplayName, avatarUrl: self.status.accountAvatar) {
self.routerPath.navigate(to: .userProfile(accountId: self.status.accountId,
accountDisplayName: self.status.accountDisplayName,
accountUserName: self.status.accountUsername))
}
ImageFavourite(isFavourited: $isFavourited)
ImageAlternativeText(text: self.attachmentData.text) { text in
self.routerPath.presentedAlert = .alternativeText(text: text)

View File

@ -50,7 +50,11 @@ struct ImageRowItemAsync: View {
ZStack {
BlurredImage(blurhash: attachment.blurhash)
ImageAvatar(displayName: self.statusViewModel.account.displayNameWithoutEmojis,
avatarUrl: self.statusViewModel.account.avatar)
avatarUrl: self.statusViewModel.account.avatar) {
self.routerPath.navigate(to: .userProfile(accountId: self.statusViewModel.account.id,
accountDisplayName: self.statusViewModel.account.displayNameWithoutEmojis,
accountUserName: self.statusViewModel.account.acct))
}
}
.onTapGesture {
self.navigateToStatus()
@ -115,7 +119,11 @@ struct ImageRowItemAsync: View {
if self.showAvatar {
ImageAvatar(displayName: self.statusViewModel.account.displayNameWithoutEmojis,
avatarUrl: self.statusViewModel.account.avatar)
avatarUrl: self.statusViewModel.account.avatar) {
self.routerPath.navigate(to: .userProfile(accountId: self.statusViewModel.account.id,
accountDisplayName: self.statusViewModel.account.displayNameWithoutEmojis,
accountUserName: self.statusViewModel.account.acct))
}
}
ImageAlternativeText(text: self.attachment.description) { text in

View File

@ -14,38 +14,45 @@ public struct ImageAvatar: View {
private let displayName: String?
private let avatarUrl: URL?
private let onTap: () -> Void
public init(displayName: String?, avatarUrl: URL?) {
public init(displayName: String?, avatarUrl: URL?, onTap: @escaping () -> Void) {
self.displayName = displayName
self.avatarUrl = avatarUrl
self.onTap = onTap
}
public var body: some View {
if self.applicationState.showAvatarsOnTimeline {
VStack(alignment: .leading) {
HStack(alignment: .center) {
LazyImage(url: avatarUrl) { state in
if let image = state.image {
self.buildAvatar(image: image)
} else if state.isLoading {
self.buildAvatar()
} else {
self.buildAvatar()
HStack(alignment: .center) {
LazyImage(url: avatarUrl) { state in
if let image = state.image {
self.buildAvatar(image: image)
} else if state.isLoading {
self.buildAvatar()
} else {
self.buildAvatar()
}
}
Text(displayName ?? "")
.font(.system(size: 15))
.foregroundColor(.white.opacity(0.8))
.fontWeight(.semibold)
.shadow(color: .black, radius: 2)
}
.padding(8)
.onTapGesture {
self.onTap()
}
Text(displayName ?? "")
.font(.system(size: 15))
.foregroundColor(.white.opacity(0.8))
.fontWeight(.semibold)
.shadow(color: .black, radius: 2)
Spacer()
}
Spacer()
}
.padding(.leading, 8)
.padding(.top, 8)
}
}