Improve tags/accounts trendings

This commit is contained in:
Marcin Czachursk 2023-03-04 19:35:59 +01:00
parent 613628d0cc
commit 0a0619f8da
16 changed files with 104 additions and 53 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1115,7 +1115,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 47;
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
DEVELOPMENT_TEAM = B2U9FEKYP8;
ENABLE_PREVIEWS = YES;
@ -1152,7 +1152,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 47;
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
DEVELOPMENT_TEAM = B2U9FEKYP8;
ENABLE_PREVIEWS = YES;

View File

@ -0,0 +1,56 @@
{
"images" : [
{
"filename" : "ImagePlaceholderLight.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "ImagePlaceholder.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ImagePlaceholderLight@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "ImagePlaceholder@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ImagePlaceholderLight@3x.png",
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "ImagePlaceholder@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -13,28 +13,26 @@ struct AccountImagesGridView: View {
@EnvironmentObject var routerPath: RouterPath
private let account: Account
private var photoUrls: [PhotoUrl]
@State private var photoUrls: [PhotoUrl] = [
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString)
]
init(account: Account) {
self.account = account
self.photoUrls = [
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString)
]
}
var body: some View {
LazyVGrid(columns: [GridItem(.adaptive(minimum:140))]) {
ForEach(self.photoUrls) { photoUrl in
ImageGrid(photoUrl: photoUrl)
.clipShape(RoundedRectangle(cornerRadius: 10))
.frame(width: 140, height: 140)
.id(photoUrl.id)
}
Text("more...")
.foregroundColor(.accentColor)
.fontWeight(.bold)
.padding(10)
.onTapGesture {
self.routerPath.navigate(to: .userProfile(accountId: account.id,

View File

@ -37,6 +37,7 @@ struct TrendingAccountsView: View {
ForEach(self.accounts, id: \.id) { account in
Section {
AccountImagesGridView(account: account)
// .id(UUID().uuidString)
} header: {
HStack {
UsernameRow(
@ -46,7 +47,8 @@ struct TrendingAccountsView: View {
accountUsername: account.acct)
Spacer()
}
.padding(.horizontal, 8)
.listRowInsets(EdgeInsets())
.padding(.vertical, 12)
}
}
}

View File

@ -13,30 +13,28 @@ struct TagImagesGridView: View {
@EnvironmentObject var routerPath: RouterPath
private let hashtag: String
private let photoUrls: [PhotoUrl]
@State private var photoUrls: [PhotoUrl] = [
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString)
]
init(hashtag: String) {
self.hashtag = hashtag
self.photoUrls = [
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString),
PhotoUrl(id: UUID().uuidString)
]
}
var body: some View {
LazyVGrid(columns: [GridItem(.adaptive(minimum:80))]) {
ForEach(self.photoUrls) { photoUrl in
ImageGrid(photoUrl: photoUrl)
.clipShape(RoundedRectangle(cornerRadius: 10))
.frame(width: 80, height: 80)
.id(photoUrl.id)
}
Text("more...")
.foregroundColor(.accentColor)
.fontWeight(.bold)
.padding(10)
.onTapGesture {
self.routerPath.navigate(to: .tag(hashTag: hashtag))
@ -58,24 +56,26 @@ struct TagImagesGridView: View {
limit: 10) ?? []
let statusesWithImages = statusesFromApi.getStatusesWithImagesOnly()
var index = 0
for status in statusesWithImages {
if let mediaAttachment = status.getAllImageMediaAttachments().first {
self.photoUrls[index].statusId = status.id
self.photoUrls[index].url = mediaAttachment.url
self.photoUrls[index].blurhash = mediaAttachment.blurhash
index = index + 1
}
if index == 5 {
break;
}
}
self.updatePhotos(statusesWithImages: statusesWithImages)
} catch {
ErrorService.shared.handle(error, message: "Loading tags failed.", showToastr: !Task.isCancelled)
}
}
private func updatePhotos(statusesWithImages: [Status]) {
var index = 0
for status in statusesWithImages {
if let mediaAttachment = status.getAllImageMediaAttachments().first {
self.photoUrls[index].statusId = status.id
self.photoUrls[index].url = mediaAttachment.url
self.photoUrls[index].blurhash = mediaAttachment.blurhash
index = index + 1
}
if index == 5 {
break;
}
}
}
}

View File

@ -37,7 +37,7 @@ struct TrendingTagsView: View {
ForEach(self.tags, id: \.id) { tag in
Section(header: Text(tag.name).font(.headline)) {
TagImagesGridView(hashtag: tag.hashtag)
.id(UUID().uuidString)
// .id(UUID().uuidString)
}
}
}

View File

@ -10,22 +10,23 @@ import NukeUI
struct ImageGrid: View {
@EnvironmentObject var routerPath: RouterPath
@StateObject var photoUrl: PhotoUrl
var body: some View {
if let url = photoUrl.url {
LazyImage(url: url) { state in
if let image = state.image {
image
.aspectRatio(contentMode: .fit)
.clipShape(RoundedRectangle(cornerRadius: 10))
.onTapGesture {
if let statusId = self.photoUrl.statusId {
self.routerPath.navigate(to: .status(id: statusId))
}
}
} else if state.isLoading {
placeholder()
self.placeholder()
} else {
placeholder()
self.placeholder()
}
}
.priority(.high)
@ -36,15 +37,9 @@ struct ImageGrid: View {
@ViewBuilder
private func placeholder() -> some View {
if let imageBlurhash = photoUrl.blurhash, let uiImage = UIImage(blurHash: imageBlurhash, size: CGSize(width: 32, height: 32)) {
Image(uiImage: uiImage)
.resizable()
.animatePlaceholder(isLoading: .constant(true))
} else {
Rectangle()
.fill(Color.placeholderText)
.redacted(reason: .placeholder)
.animatePlaceholder(isLoading: .constant(true))
}
Image("ImagePlaceholder")
.resizable()
.aspectRatio(contentMode: .fit)
.clipShape(RoundedRectangle(cornerRadius: 10))
}
}