Change trending people

This commit is contained in:
Marcin Czachurski 2023-10-09 16:47:20 +02:00
parent c5bcbfeb42
commit fc3b4d1296
5 changed files with 50 additions and 19 deletions

View File

@ -1348,7 +1348,7 @@
CODE_SIGN_ENTITLEMENTS = VernissageWidget/VernissageWidgetExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 256;
CURRENT_PROJECT_VERSION = 301;
DEVELOPMENT_TEAM = B2U9FEKYP8;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = VernissageWidget/Info.plist;
@ -1360,7 +1360,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.12.0;
MARKETING_VERSION = 1.13.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.mczachurski.vernissage.widget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
@ -1379,7 +1379,7 @@
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
CODE_SIGN_ENTITLEMENTS = VernissageWidget/VernissageWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 256;
CURRENT_PROJECT_VERSION = 301;
DEVELOPMENT_TEAM = B2U9FEKYP8;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = VernissageWidget/Info.plist;
@ -1391,7 +1391,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.12.0;
MARKETING_VERSION = 1.13.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.mczachurski.vernissage.widget;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
@ -1409,7 +1409,7 @@
CODE_SIGN_ENTITLEMENTS = VernissageShare/VernissageShareExtension.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 256;
CURRENT_PROJECT_VERSION = 301;
DEVELOPMENT_TEAM = B2U9FEKYP8;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = VernissageShare/Info.plist;
@ -1421,7 +1421,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.12.0;
MARKETING_VERSION = 1.13.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.mczachurski.vernissage.share;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
@ -1438,7 +1438,7 @@
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = NO;
CODE_SIGN_ENTITLEMENTS = VernissageShare/VernissageShareExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 256;
CURRENT_PROJECT_VERSION = 301;
DEVELOPMENT_TEAM = B2U9FEKYP8;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = VernissageShare/Info.plist;
@ -1450,7 +1450,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.12.0;
MARKETING_VERSION = 1.13.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.mczachurski.vernissage.share;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
@ -1592,7 +1592,7 @@
CODE_SIGN_ENTITLEMENTS = Vernissage/Vernissage.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 256;
CURRENT_PROJECT_VERSION = 301;
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
DEVELOPMENT_TEAM = B2U9FEKYP8;
ENABLE_PREVIEWS = YES;
@ -1611,7 +1611,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.12.0;
MARKETING_VERSION = 1.13.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.mczachurski.vernissage;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -1635,7 +1635,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Vernissage/Vernissage.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 256;
CURRENT_PROJECT_VERSION = 301;
DEVELOPMENT_ASSET_PATHS = "\"Vernissage/Preview Content\"";
DEVELOPMENT_TEAM = B2U9FEKYP8;
ENABLE_PREVIEWS = YES;
@ -1654,7 +1654,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.12.0;
MARKETING_VERSION = 1.13.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.mczachurski.vernissage;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";

View File

@ -114,8 +114,28 @@ struct AccountsPhotoView: View {
switch self.listType {
case .trending:
do {
let accountsFromApi = try await self.client.trends?.accounts()
return accountsFromApi ?? []
// TODO: Trending accounts API is returning almost always the same set of accounts. Thus we can take accounts from trending statuses.
async let trendingStatusesDaily = self.client.trends?.statuses(range: .daily)
async let trendingStatusesMonthly = self.client.trends?.statuses(range: .monthly)
async let trendingStatusesYearly = self.client.trends?.statuses(range: .yearly)
async let accountsFromApi = self.client.trends?.accounts()
let trendingStatuses = try await (dailyStatuses: trendingStatusesDaily,
monthlyStatuses: trendingStatusesMonthly,
yearlyStatuses: trendingStatusesYearly)
let allTrendingStatuses = (trendingStatuses.dailyStatuses ?? []) + (trendingStatuses.monthlyStatuses ?? []) + (trendingStatuses.yearlyStatuses ?? [])
var allTrendingAccounts: [Account] = []
for trendingStatus in allTrendingStatuses where allTrendingAccounts.contains(where: { $0.id == trendingStatus.account.id }) == false {
allTrendingAccounts.append(trendingStatus.account)
}
let trendingAccounts = try await accountsFromApi ?? []
for account in trendingAccounts where allTrendingAccounts.contains(where: { $0.id == account.id }) == false {
allTrendingAccounts.append(account)
}
return allTrendingAccounts
} catch NetworkError.notSuccessResponse(let response) {
// TODO: This code can be removed when other Pixelfed server will support trending accounts.
if response.statusCode() == HTTPStatusCode.notFound {

View File

@ -14,7 +14,12 @@ struct ImageGrid: View {
@EnvironmentObject var routerPath: RouterPath
@StateObject var photoUrl: PhotoUrl
@State var maxHeight = 120.0
@Binding var maxHeight: Double
init(photoUrl: PhotoUrl, maxHeight: Binding<Double>) {
self._photoUrl = StateObject(wrappedValue: photoUrl)
self._maxHeight = maxHeight
}
var body: some View {
if self.photoUrl.sensitive && !self.applicationState.showSensitive {

View File

@ -20,9 +20,9 @@ struct ImagesGrid: View {
@EnvironmentObject var routerPath: RouterPath
private let maxImages = 5
private let maxHeight = UIDevice.isIPad ? 240.0 : 120.0
@State public var gridType: GridType
@State public var maxHeight = UIDevice.isIPhone ? 120.0 : 240.0
@State private var photoUrls: [PhotoUrl] = [
PhotoUrl(id: UUID().uuidString),
@ -36,7 +36,7 @@ struct ImagesGrid: View {
ScrollView(.horizontal) {
LazyHGrid(rows: [GridItem(.fixed(self.maxHeight))]) {
ForEach(self.photoUrls) { photoUrl in
ImageGrid(photoUrl: photoUrl, maxHeight: self.maxHeight)
ImageGrid(photoUrl: photoUrl, maxHeight: $maxHeight)
}
Text("more...")
@ -48,6 +48,9 @@ struct ImagesGrid: View {
}
}
}
.gallery { properties in
self.maxHeight = properties.horizontalSize == .compact ? 120.0 : 240.0
}
.frame(height: self.maxHeight)
.onFirstAppear {
Task {

View File

@ -29,6 +29,7 @@ public struct GalleryProperties {
public let imageColumns: Int
public let containerWidth: Double
public let containerHeight: Double
public let horizontalSize: UserInterfaceSizeClass
}
struct DeviceImageGallery: ViewModifier {
@ -66,7 +67,8 @@ struct DeviceImageGallery: ViewModifier {
// View like on iPhone.
return GalleryProperties(imageColumns: 1,
containerWidth: geometry.size.width,
containerHeight: geometry.size.height)
containerHeight: geometry.size.height,
horizontalSize: horizontalSize)
} else {
// View like on iPad.
let imageColumns = geometry.size.width > geometry.size.height ? 3 : 2
@ -74,7 +76,8 @@ struct DeviceImageGallery: ViewModifier {
return GalleryProperties(imageColumns: imageColumns,
containerWidth: (geometry.size.width - Double(marginSpacing)) / Double(imageColumns),
containerHeight: (geometry.size.height - Double(marginSpacing)) / Double(imageColumns))
containerHeight: (geometry.size.height - Double(marginSpacing)) / Double(imageColumns),
horizontalSize: horizontalSize)
}
}
}