Compare commits
No commits in common. "47318018936c3abd17faaad303fe6440dc1b886e" and "afed69e43ea03ccd32de6b4fc03076f7eeb6be60" have entirely different histories.
4731801893
...
afed69e43e
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,17 +1,5 @@
|
|||
# Changelog
|
||||
|
||||
## 2023.4 (73)
|
||||
Features/Improvements:
|
||||
- Add preference for non-pure-black dark mode
|
||||
- Add Jump to Present button to timelines
|
||||
- Improve status collapse animation in search results screen
|
||||
- Add more trending links/hashtags/profiles buttons to Trends screen
|
||||
- Add infinite scrolling to trending links/hashtags screens
|
||||
- Add Share action to trending link context menu
|
||||
|
||||
Bugfixes:
|
||||
- Fix icon in suggested profile popover not adjusting to dark mode
|
||||
|
||||
## 2023.4 (72)
|
||||
Features/Improvements:
|
||||
- Consolidate Trends into a single screen
|
||||
|
|
|
@ -417,46 +417,32 @@ public class Client {
|
|||
}
|
||||
|
||||
// MARK: - Instance
|
||||
public static func getTrendingHashtagsDeprecated(limit: Int? = nil, offset: Int? = nil) -> Request<[Hashtag]> {
|
||||
var parameters: [Parameter] = []
|
||||
if let limit {
|
||||
parameters.append("limit" => limit)
|
||||
}
|
||||
if let offset {
|
||||
parameters.append("offset" => offset)
|
||||
public static func getTrendingHashtags(limit: Int? = nil) -> Request<[Hashtag]> {
|
||||
let parameters: [Parameter]
|
||||
if let limit = limit {
|
||||
parameters = ["limit" => limit]
|
||||
} else {
|
||||
parameters = []
|
||||
}
|
||||
return Request<[Hashtag]>(method: .get, path: "/api/v1/trends", queryParameters: parameters)
|
||||
}
|
||||
|
||||
public static func getTrendingHashtags(limit: Int? = nil, offset: Int? = nil) -> Request<[Hashtag]> {
|
||||
var parameters: [Parameter] = []
|
||||
if let limit {
|
||||
parameters.append("limit" => limit)
|
||||
}
|
||||
if let offset {
|
||||
parameters.append("offset" => offset)
|
||||
}
|
||||
return Request<[Hashtag]>(method: .get, path: "/api/v1/trends/tags", queryParameters: parameters)
|
||||
}
|
||||
|
||||
public static func getTrendingStatuses(limit: Int? = nil, offset: Int? = nil) -> Request<[Status]> {
|
||||
var parameters: [Parameter] = []
|
||||
if let limit {
|
||||
parameters.append("limit" => limit)
|
||||
}
|
||||
if let offset {
|
||||
parameters.append("offset" => offset)
|
||||
public static func getTrendingStatuses(limit: Int? = nil) -> Request<[Status]> {
|
||||
let parameters: [Parameter]
|
||||
if let limit = limit {
|
||||
parameters = ["limit" => limit]
|
||||
} else {
|
||||
parameters = []
|
||||
}
|
||||
return Request(method: .get, path: "/api/v1/trends/statuses", queryParameters: parameters)
|
||||
}
|
||||
|
||||
public static func getTrendingLinks(limit: Int? = nil, offset: Int? = nil) -> Request<[Card]> {
|
||||
var parameters: [Parameter] = []
|
||||
if let limit {
|
||||
parameters.append("limit" => limit)
|
||||
}
|
||||
if let offset {
|
||||
parameters.append("offset" => offset)
|
||||
public static func getTrendingLinks(limit: Int? = nil) -> Request<[Card]> {
|
||||
let parameters: [Parameter]
|
||||
if let limit = limit {
|
||||
parameters = ["limit" => limit]
|
||||
} else {
|
||||
parameters = []
|
||||
}
|
||||
return Request(method: .get, path: "/api/v1/trends/links", queryParameters: parameters)
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ extension Account: CustomDebugStringConvertible {
|
|||
}
|
||||
|
||||
extension Account {
|
||||
public struct Field: Codable, Equatable {
|
||||
public struct Field: Codable {
|
||||
public let name: String
|
||||
public let value: String
|
||||
public let verifiedAt: Date?
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
D6114E1127F899B30080E273 /* TrendingLinksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6114E1027F899B30080E273 /* TrendingLinksViewController.swift */; };
|
||||
D6114E1327F89B440080E273 /* TrendingLinkTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6114E1227F89B440080E273 /* TrendingLinkTableViewCell.swift */; };
|
||||
D6114E1727F8BB210080E273 /* VersionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6114E1627F8BB210080E273 /* VersionTests.swift */; };
|
||||
D611C2CF232DC61100C86A49 /* HashtagTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D611C2CD232DC61100C86A49 /* HashtagTableViewCell.swift */; };
|
||||
D611C2D0232DC61100C86A49 /* HashtagTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D611C2CE232DC61100C86A49 /* HashtagTableViewCell.xib */; };
|
||||
D61A45E628DC0F2F002BE511 /* ConfirmLoadMoreCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D61A45E528DC0F2F002BE511 /* ConfirmLoadMoreCollectionViewCell.swift */; };
|
||||
D61A45E828DF477D002BE511 /* LoadingCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D61A45E728DF477D002BE511 /* LoadingCollectionViewCell.swift */; };
|
||||
D61A45EA28DF51EE002BE511 /* TimelineLikeCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D61A45E928DF51EE002BE511 /* TimelineLikeCollectionViewController.swift */; };
|
||||
|
@ -200,7 +202,6 @@
|
|||
D681E4D7246E32290053414F /* StatusActivityItemSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = D681E4D6246E32290053414F /* StatusActivityItemSource.swift */; };
|
||||
D681E4D9246E346E0053414F /* AccountActivityItemSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = D681E4D8246E346E0053414F /* AccountActivityItemSource.swift */; };
|
||||
D68232F72464F4FD00325FB8 /* ComposeDrawingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D68232F62464F4FD00325FB8 /* ComposeDrawingViewController.swift */; };
|
||||
D68329EF299540050026EB24 /* MoreTrendsFooterCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D68329EE299540050026EB24 /* MoreTrendsFooterCollectionViewCell.swift */; };
|
||||
D686BBE324FBF8110068E6AA /* WrappedProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D686BBE224FBF8110068E6AA /* WrappedProgressView.swift */; };
|
||||
D6895DC228D65274006341DA /* CustomAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6895DC128D65274006341DA /* CustomAlertController.swift */; };
|
||||
D6895DC428D65342006341DA /* ConfirmReblogStatusPreviewView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6895DC328D65342006341DA /* ConfirmReblogStatusPreviewView.swift */; };
|
||||
|
@ -298,8 +299,6 @@
|
|||
D6C3F4F7298ED7F70009FCFF /* FavoritesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4F6298ED7F70009FCFF /* FavoritesViewController.swift */; };
|
||||
D6C3F4F9298EDBF20009FCFF /* ConversationTree.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4F8298EDBF20009FCFF /* ConversationTree.swift */; };
|
||||
D6C3F4FB299035650009FCFF /* TrendsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F4FA299035650009FCFF /* TrendsViewController.swift */; };
|
||||
D6C3F5172991C1A00009FCFF /* View+AppListStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F5162991C1A00009FCFF /* View+AppListStyle.swift */; };
|
||||
D6C3F5192991F5D60009FCFF /* TimelineJumpButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3F5182991F5D60009FCFF /* TimelineJumpButton.swift */; };
|
||||
D6C693EF216192C2007D6A6D /* TuskerNavigationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */; };
|
||||
D6C693FC2162FE6F007D6A6D /* LoadingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693FB2162FE6F007D6A6D /* LoadingViewController.swift */; };
|
||||
D6C693FE2162FEEA007D6A6D /* UIViewController+Children.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */; };
|
||||
|
@ -326,8 +325,6 @@
|
|||
D6D4DDF0212518A200E1C4BB /* TuskerUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D4DDEF212518A200E1C4BB /* TuskerUITests.swift */; };
|
||||
D6D706A029466649000827ED /* ScrollingSegmentedControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D7069F29466649000827ED /* ScrollingSegmentedControl.swift */; };
|
||||
D6D706A72948D4D0000827ED /* TimlineState.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D706A62948D4D0000827ED /* TimlineState.swift */; };
|
||||
D6D94955298963A900C59229 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D94954298963A900C59229 /* Colors.swift */; };
|
||||
D6D9498D298CBB4000C59229 /* TrendingStatusCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D9498C298CBB4000C59229 /* TrendingStatusCollectionViewCell.swift */; };
|
||||
D6D9498F298EB79400C59229 /* CopyableLable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D9498E298EB79400C59229 /* CopyableLable.swift */; };
|
||||
D6DD2A3F273C1F4900386A6C /* ComposeAttachmentImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD2A3E273C1F4900386A6C /* ComposeAttachmentImage.swift */; };
|
||||
D6DD2A45273D6C5700386A6C /* GIFImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD2A44273D6C5700386A6C /* GIFImageView.swift */; };
|
||||
|
@ -335,7 +332,6 @@
|
|||
D6DD353F22F502EC00A9563A /* Preferences+Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD353E22F502EC00A9563A /* Preferences+Notification.swift */; };
|
||||
D6DD8FFD298495A8002AD3FD /* LogoutService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD8FFC298495A8002AD3FD /* LogoutService.swift */; };
|
||||
D6DD8FFF2984D327002AD3FD /* BookmarksViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD8FFE2984D327002AD3FD /* BookmarksViewController.swift */; };
|
||||
D6DD996B2998611A0015C962 /* SuggestedProfilesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD996A2998611A0015C962 /* SuggestedProfilesViewController.swift */; };
|
||||
D6DF95C12533F5DE0027A9B6 /* RelationshipMO.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DF95C02533F5DE0027A9B6 /* RelationshipMO.swift */; };
|
||||
D6DFC69E242C490400ACC392 /* TrackpadScrollGestureRecognizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DFC69D242C490400ACC392 /* TrackpadScrollGestureRecognizer.swift */; };
|
||||
D6DFC6A0242C4CCC00ACC392 /* Weak.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DFC69F242C4CCC00ACC392 /* Weak.swift */; };
|
||||
|
@ -455,6 +451,8 @@
|
|||
D6114E1027F899B30080E273 /* TrendingLinksViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrendingLinksViewController.swift; sourceTree = "<group>"; };
|
||||
D6114E1227F89B440080E273 /* TrendingLinkTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrendingLinkTableViewCell.swift; sourceTree = "<group>"; };
|
||||
D6114E1627F8BB210080E273 /* VersionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionTests.swift; sourceTree = "<group>"; };
|
||||
D611C2CD232DC61100C86A49 /* HashtagTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashtagTableViewCell.swift; sourceTree = "<group>"; };
|
||||
D611C2CE232DC61100C86A49 /* HashtagTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = HashtagTableViewCell.xib; sourceTree = "<group>"; };
|
||||
D61A45E528DC0F2F002BE511 /* ConfirmLoadMoreCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmLoadMoreCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
D61A45E728DF477D002BE511 /* LoadingCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
D61A45E928DF51EE002BE511 /* TimelineLikeCollectionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineLikeCollectionViewController.swift; sourceTree = "<group>"; };
|
||||
|
@ -614,7 +612,6 @@
|
|||
D681E4D6246E32290053414F /* StatusActivityItemSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusActivityItemSource.swift; sourceTree = "<group>"; };
|
||||
D681E4D8246E346E0053414F /* AccountActivityItemSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountActivityItemSource.swift; sourceTree = "<group>"; };
|
||||
D68232F62464F4FD00325FB8 /* ComposeDrawingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeDrawingViewController.swift; sourceTree = "<group>"; };
|
||||
D68329EE299540050026EB24 /* MoreTrendsFooterCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoreTrendsFooterCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
D686BBE224FBF8110068E6AA /* WrappedProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WrappedProgressView.swift; sourceTree = "<group>"; };
|
||||
D6895DC128D65274006341DA /* CustomAlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomAlertController.swift; sourceTree = "<group>"; };
|
||||
D6895DC328D65342006341DA /* ConfirmReblogStatusPreviewView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmReblogStatusPreviewView.swift; sourceTree = "<group>"; };
|
||||
|
@ -713,8 +710,6 @@
|
|||
D6C3F4F6298ED7F70009FCFF /* FavoritesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoritesViewController.swift; sourceTree = "<group>"; };
|
||||
D6C3F4F8298EDBF20009FCFF /* ConversationTree.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationTree.swift; sourceTree = "<group>"; };
|
||||
D6C3F4FA299035650009FCFF /* TrendsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrendsViewController.swift; sourceTree = "<group>"; };
|
||||
D6C3F5162991C1A00009FCFF /* View+AppListStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+AppListStyle.swift"; sourceTree = "<group>"; };
|
||||
D6C3F5182991F5D60009FCFF /* TimelineJumpButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineJumpButton.swift; sourceTree = "<group>"; };
|
||||
D6C693EE216192C2007D6A6D /* TuskerNavigationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TuskerNavigationDelegate.swift; sourceTree = "<group>"; };
|
||||
D6C693FB2162FE6F007D6A6D /* LoadingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingViewController.swift; sourceTree = "<group>"; };
|
||||
D6C693FD2162FEEA007D6A6D /* UIViewController+Children.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Children.swift"; sourceTree = "<group>"; };
|
||||
|
@ -748,8 +743,6 @@
|
|||
D6D7069F29466649000827ED /* ScrollingSegmentedControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollingSegmentedControl.swift; sourceTree = "<group>"; };
|
||||
D6D706A62948D4D0000827ED /* TimlineState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimlineState.swift; sourceTree = "<group>"; };
|
||||
D6D706A829498C82000827ED /* Tusker.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Tusker.xcconfig; sourceTree = "<group>"; };
|
||||
D6D94954298963A900C59229 /* Colors.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Colors.swift; sourceTree = "<group>"; };
|
||||
D6D9498C298CBB4000C59229 /* TrendingStatusCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrendingStatusCollectionViewCell.swift; sourceTree = "<group>"; };
|
||||
D6D9498E298EB79400C59229 /* CopyableLable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopyableLable.swift; sourceTree = "<group>"; };
|
||||
D6DD2A3E273C1F4900386A6C /* ComposeAttachmentImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeAttachmentImage.swift; sourceTree = "<group>"; };
|
||||
D6DD2A44273D6C5700386A6C /* GIFImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GIFImageView.swift; sourceTree = "<group>"; };
|
||||
|
@ -757,7 +750,6 @@
|
|||
D6DD353E22F502EC00A9563A /* Preferences+Notification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Preferences+Notification.swift"; sourceTree = "<group>"; };
|
||||
D6DD8FFC298495A8002AD3FD /* LogoutService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogoutService.swift; sourceTree = "<group>"; };
|
||||
D6DD8FFE2984D327002AD3FD /* BookmarksViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksViewController.swift; sourceTree = "<group>"; };
|
||||
D6DD996A2998611A0015C962 /* SuggestedProfilesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SuggestedProfilesViewController.swift; sourceTree = "<group>"; };
|
||||
D6DF95C02533F5DE0027A9B6 /* RelationshipMO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelationshipMO.swift; sourceTree = "<group>"; };
|
||||
D6DFC69D242C490400ACC392 /* TrackpadScrollGestureRecognizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackpadScrollGestureRecognizer.swift; sourceTree = "<group>"; };
|
||||
D6DFC69F242C4CCC00ACC392 /* Weak.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Weak.swift; sourceTree = "<group>"; };
|
||||
|
@ -861,6 +853,8 @@
|
|||
D611C2CC232DC5FC00C86A49 /* Hashtag Cell */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D611C2CD232DC61100C86A49 /* HashtagTableViewCell.swift */,
|
||||
D611C2CE232DC61100C86A49 /* HashtagTableViewCell.xib */,
|
||||
D6E77D08286D25FA00D8B732 /* TrendingHashtagCollectionViewCell.swift */,
|
||||
);
|
||||
path = "Hashtag Cell";
|
||||
|
@ -949,8 +943,6 @@
|
|||
D693A72D25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.swift */,
|
||||
D693A72E25CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib */,
|
||||
D6C3F4FA299035650009FCFF /* TrendsViewController.swift */,
|
||||
D68329EE299540050026EB24 /* MoreTrendsFooterCollectionViewCell.swift */,
|
||||
D6DD996A2998611A0015C962 /* SuggestedProfilesViewController.swift */,
|
||||
);
|
||||
path = Explore;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1058,7 +1050,6 @@
|
|||
D66C900A28DAB7FD00217BF2 /* TimelineViewController.swift */,
|
||||
D6ADB6E728E8C878009924AB /* PublicTimelineDescriptionCollectionViewCell.swift */,
|
||||
D6D12B2E2925D66500D528E1 /* TimelineGapCollectionViewCell.swift */,
|
||||
D6C3F5182991F5D60009FCFF /* TimelineJumpButton.swift */,
|
||||
);
|
||||
path = Timeline;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1190,7 +1181,6 @@
|
|||
D6ADB6E928E91C30009924AB /* TimelineStatusCollectionViewCell.swift */,
|
||||
D601FA60297B539E00A8E8B5 /* ConversationMainStatusCollectionViewCell.swift */,
|
||||
D6ADB6EB28EA73CB009924AB /* StatusContentContainer.swift */,
|
||||
D6D9498C298CBB4000C59229 /* TrendingStatusCollectionViewCell.swift */,
|
||||
);
|
||||
path = Status;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1284,7 +1274,6 @@
|
|||
D6DD353E22F502EC00A9563A /* Preferences+Notification.swift */,
|
||||
D6BC9DB4232D4CE3002CA326 /* NotificationsMode.swift */,
|
||||
D61F75872932DB6000C0B37F /* StatusSwipeAction.swift */,
|
||||
D6D94954298963A900C59229 /* Colors.swift */,
|
||||
);
|
||||
path = Preferences;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1314,7 +1303,6 @@
|
|||
D63CC70F2911F1E4000E19DE /* UIScrollView+Top.swift */,
|
||||
D61F758F29353B4300C0B37F /* FileManager+Size.swift */,
|
||||
D61F75AC293AF39000C0B37F /* Filter+Helpers.swift */,
|
||||
D6C3F5162991C1A00009FCFF /* View+AppListStyle.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1855,6 +1843,7 @@
|
|||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D611C2D0232DC61100C86A49 /* HashtagTableViewCell.xib in Resources */,
|
||||
D6E77D0D286E6B7300D8B732 /* TrendingLinkCardCollectionViewCell.xib in Resources */,
|
||||
D693A73025CF91C6003A14E2 /* FeaturedProfileCollectionViewCell.xib in Resources */,
|
||||
D61AC1D9232EA42D00C54D2D /* InstanceTableViewCell.xib in Resources */,
|
||||
|
@ -1971,7 +1960,6 @@
|
|||
D6093FB725BE0CF3004811E6 /* TrendHistoryView.swift in Sources */,
|
||||
D6EBF01723C55E0D00AE061B /* UISceneSession+MastodonController.swift in Sources */,
|
||||
D61F759229365C6C00C0B37F /* CollectionViewController.swift in Sources */,
|
||||
D6DD996B2998611A0015C962 /* SuggestedProfilesViewController.swift in Sources */,
|
||||
D6DD8FFD298495A8002AD3FD /* LogoutService.swift in Sources */,
|
||||
04DACE8C212CB14B009840C4 /* MainTabBarViewController.swift in Sources */,
|
||||
D68E525D24A3E8F00054355A /* InlineTrendsViewController.swift in Sources */,
|
||||
|
@ -2005,6 +1993,7 @@
|
|||
0411610022B442870030A9B7 /* LoadingLargeImageViewController.swift in Sources */,
|
||||
D6A4DCE525537C7A00D9DE31 /* FastSwitchingAccountView.swift in Sources */,
|
||||
D6A4DCCC2553667800D9DE31 /* FastAccountSwitcherViewController.swift in Sources */,
|
||||
D611C2CF232DC61100C86A49 /* HashtagTableViewCell.swift in Sources */,
|
||||
D627944F23A9C99800D38C68 /* EditListAccountsViewController.swift in Sources */,
|
||||
D6945C3423AC6431005C403C /* AddSavedHashtagViewController.swift in Sources */,
|
||||
D6F6A552291F098700F496A8 /* RenameListService.swift in Sources */,
|
||||
|
@ -2013,7 +2002,6 @@
|
|||
D6AC956723C4347E008C9946 /* MainSceneDelegate.swift in Sources */,
|
||||
D6311C5025B3765B00B27539 /* ImageDataCache.swift in Sources */,
|
||||
D6BC9DD7232D7811002CA326 /* TimelinesPageViewController.swift in Sources */,
|
||||
D6D9498D298CBB4000C59229 /* TrendingStatusCollectionViewCell.swift in Sources */,
|
||||
D60E2F2E244248BF005F8713 /* MastodonCachePersistentStore.swift in Sources */,
|
||||
D620483623D38075008A63EF /* ContentTextView.swift in Sources */,
|
||||
D651C5B42915B00400236EF6 /* ProfileFieldsView.swift in Sources */,
|
||||
|
@ -2023,7 +2011,6 @@
|
|||
D6A3BC802321B7E600FD64D5 /* FollowNotificationGroupTableViewCell.swift in Sources */,
|
||||
D627944D23A9A03D00D38C68 /* ListTimelineViewController.swift in Sources */,
|
||||
D6D12B2F2925D66500D528E1 /* TimelineGapCollectionViewCell.swift in Sources */,
|
||||
D6D94955298963A900C59229 /* Colors.swift in Sources */,
|
||||
D6945C3823AC739F005C403C /* InstanceTimelineViewController.swift in Sources */,
|
||||
D625E4822588262A0074BB2B /* DraggableTableViewCell.swift in Sources */,
|
||||
D68E525B24A3D77E0054355A /* TuskerRootViewController.swift in Sources */,
|
||||
|
@ -2079,7 +2066,6 @@
|
|||
D6A00B1D26379FC900316AD4 /* PollOptionsView.swift in Sources */,
|
||||
D6DF95C12533F5DE0027A9B6 /* RelationshipMO.swift in Sources */,
|
||||
D6ADB6EE28EA74E8009924AB /* UIView+Configure.swift in Sources */,
|
||||
D68329EF299540050026EB24 /* MoreTrendsFooterCollectionViewCell.swift in Sources */,
|
||||
D623A5412635FB3C0095BD04 /* PollOptionView.swift in Sources */,
|
||||
D61F75B1293BD85300C0B37F /* CreateFilterService.swift in Sources */,
|
||||
D65C6BF525478A9C00A6E89C /* BackgroundableViewController.swift in Sources */,
|
||||
|
@ -2101,7 +2087,6 @@
|
|||
D6CA8CDE296387310050C433 /* SaveToPhotosActivity.swift in Sources */,
|
||||
D6B936712829F72900237D0E /* NSManagedObjectContext+Helpers.swift in Sources */,
|
||||
D68A76EE295369C7001DA1B3 /* AcknowledgementsView.swift in Sources */,
|
||||
D6C3F5192991F5D60009FCFF /* TimelineJumpButton.swift in Sources */,
|
||||
D63CC7102911F1E4000E19DE /* UIScrollView+Top.swift in Sources */,
|
||||
D6F6A557291F4F1600F496A8 /* MuteAccountView.swift in Sources */,
|
||||
D65B4B8B297879E900DABDFB /* AccountFollowsViewController.swift in Sources */,
|
||||
|
@ -2253,7 +2238,6 @@
|
|||
D6E426B325337C7000C02E1C /* CustomEmojiImageView.swift in Sources */,
|
||||
D6D4DDD0212518A000E1C4BB /* AppDelegate.swift in Sources */,
|
||||
D61F75B3293BD89C00C0B37F /* UpdateFilterService.swift in Sources */,
|
||||
D6C3F5172991C1A00009FCFF /* View+AppListStyle.swift in Sources */,
|
||||
D65B4B6A297777D900DABDFB /* StatusNotFoundView.swift in Sources */,
|
||||
D6412B0924B0291E00F5412E /* MyProfileViewController.swift in Sources */,
|
||||
D601FA5D297B2E6F00A8E8B5 /* ConversationCollectionViewController.swift in Sources */,
|
||||
|
@ -2424,7 +2408,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = Tusker/Tusker.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 73;
|
||||
CURRENT_PROJECT_VERSION = 72;
|
||||
INFOPLIST_FILE = Tusker/Info.plist;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
|
@ -2489,7 +2473,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = OpenInTusker/OpenInTusker.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 73;
|
||||
CURRENT_PROJECT_VERSION = 72;
|
||||
INFOPLIST_FILE = OpenInTusker/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
|
||||
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.3;
|
||||
|
@ -2640,7 +2624,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = Tusker/Tusker.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 73;
|
||||
CURRENT_PROJECT_VERSION = 72;
|
||||
INFOPLIST_FILE = Tusker/Info.plist;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
|
@ -2668,7 +2652,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = Tusker/Tusker.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 73;
|
||||
CURRENT_PROJECT_VERSION = 72;
|
||||
INFOPLIST_FILE = Tusker/Info.plist;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
|
||||
|
@ -2773,7 +2757,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = OpenInTusker/OpenInTusker.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 73;
|
||||
CURRENT_PROJECT_VERSION = 72;
|
||||
INFOPLIST_FILE = OpenInTusker/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
|
||||
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.3;
|
||||
|
@ -2799,7 +2783,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = OpenInTusker/OpenInTusker.entitlements;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 73;
|
||||
CURRENT_PROJECT_VERSION = 72;
|
||||
INFOPLIST_FILE = OpenInTusker/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
|
||||
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.3;
|
||||
|
|
|
@ -20,7 +20,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
configureSentry()
|
||||
swizzleStatusBar()
|
||||
swizzlePresentationController()
|
||||
|
||||
AppShortcutItem.createItems(for: application)
|
||||
|
||||
|
@ -155,24 +154,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||
Logging.general.error("Unable to swizzle status bar manager")
|
||||
}
|
||||
}
|
||||
|
||||
private func swizzlePresentationController() {
|
||||
var originalIMP: IMP?
|
||||
let imp = imp_implementationWithBlock({ (self: UIPresentationController) in
|
||||
let new = UITraitCollection(pureBlackDarkMode: self.presentingViewController.traitCollection.pureBlackDarkMode)
|
||||
if let existing = self.overrideTraitCollection {
|
||||
self.overrideTraitCollection = UITraitCollection(traitsFrom: [existing, new])
|
||||
} else {
|
||||
self.overrideTraitCollection = new
|
||||
}
|
||||
let original = unsafeBitCast(originalIMP!, to: (@convention(c) (UIPresentationController) -> Void).self)
|
||||
original(self)
|
||||
} as (@convention(block) (UIPresentationController) -> Void))
|
||||
let sel = Selector(["Necessary", "If", "Traits", "update", "_"].reversed().joined())
|
||||
originalIMP = class_replaceMethod(UIPresentationController.self, sel, imp, "v@:")
|
||||
if originalIMP == nil {
|
||||
Logging.general.error("Unable to swizzle presentation controller")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
//
|
||||
// View+AppListStyle.swift
|
||||
// Tusker
|
||||
//
|
||||
// Created by Shadowfacts on 2/6/23.
|
||||
// Copyright © 2023 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import Combine
|
||||
|
||||
extension View {
|
||||
@ViewBuilder
|
||||
func appGroupedListBackground(container: UIAppearanceContainer.Type, applyBackground: Bool = true) -> some View {
|
||||
if #available(iOS 16.0, *) {
|
||||
if applyBackground {
|
||||
self
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(Color.appGroupedBackground.edgesIgnoringSafeArea(.all))
|
||||
} else {
|
||||
self
|
||||
.scrollContentBackground(.hidden)
|
||||
}
|
||||
} else {
|
||||
self
|
||||
.onAppear {
|
||||
UITableView.appearance(whenContainedInInstancesOf: [container]).backgroundColor = .appGroupedBackground
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func appGroupedListRowBackground() -> some View {
|
||||
self.modifier(AppGroupedListRowBackground())
|
||||
}
|
||||
}
|
||||
|
||||
private struct AppGroupedListRowBackground: ViewModifier {
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
if colorScheme == .dark, !Preferences.shared.pureBlackDarkMode {
|
||||
content
|
||||
.listRowBackground(Color.appGroupedCellBackground)
|
||||
} else {
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,104 +0,0 @@
|
|||
//
|
||||
// Colors.swift
|
||||
// Tusker
|
||||
//
|
||||
// Created by Shadowfacts on 1/31/23.
|
||||
// Copyright © 2023 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SwiftUI
|
||||
|
||||
extension UIColor {
|
||||
static let appBackground = UIColor { traitCollection in
|
||||
if case .dark = traitCollection.userInterfaceStyle,
|
||||
!traitCollection.pureBlackDarkMode {
|
||||
return UIColor(hue: 230/360, saturation: 23/100, brightness: 10/100, alpha: 1)
|
||||
} else {
|
||||
return .systemBackground
|
||||
}
|
||||
}
|
||||
|
||||
static let appSecondaryBackground = UIColor { traitCollection in
|
||||
if case .dark = traitCollection.userInterfaceStyle,
|
||||
!traitCollection.pureBlackDarkMode {
|
||||
if traitCollection.userInterfaceLevel == .elevated {
|
||||
return UIColor(hue: 230/360, saturation: 23/100, brightness: 10/100, alpha: 1)
|
||||
} else {
|
||||
return UIColor(hue: 230/360, saturation: 23/100, brightness: 5/100, alpha: 1)
|
||||
}
|
||||
} else {
|
||||
return .secondarySystemBackground
|
||||
}
|
||||
}
|
||||
|
||||
static let appGroupedBackground = UIColor { traitCollection in
|
||||
if case .dark = traitCollection.userInterfaceStyle,
|
||||
!traitCollection.pureBlackDarkMode {
|
||||
return .appSecondaryBackground
|
||||
} else {
|
||||
return .systemGroupedBackground
|
||||
}
|
||||
}
|
||||
|
||||
static let appSelectedCellBackground = UIColor { traitCollection in
|
||||
if case .dark = traitCollection.userInterfaceStyle,
|
||||
!traitCollection.pureBlackDarkMode {
|
||||
return UIColor(hue: 230/360, saturation: 20/100, brightness: 27/100, alpha: 1)
|
||||
} else {
|
||||
return .systemFill
|
||||
}
|
||||
}
|
||||
|
||||
static let appGroupedCellBackground = UIColor { traitCollection in
|
||||
if case .dark = traitCollection.userInterfaceStyle {
|
||||
if traitCollection.pureBlackDarkMode {
|
||||
return .secondarySystemBackground
|
||||
} else {
|
||||
return .appFill
|
||||
}
|
||||
} else {
|
||||
return .systemBackground
|
||||
}
|
||||
}
|
||||
|
||||
static let appFill = UIColor { traitCollection in
|
||||
if case .dark = traitCollection.userInterfaceStyle,
|
||||
!traitCollection.pureBlackDarkMode {
|
||||
return UIColor(hue: 230/360, saturation: 20/100, brightness: 17/100, alpha: 1)
|
||||
} else {
|
||||
return .systemFill
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Color {
|
||||
static let appBackground = Color(uiColor: .appBackground)
|
||||
static let appGroupedBackground = Color(uiColor: .appGroupedBackground)
|
||||
static let appSecondaryBackground = Color(uiColor: .appSecondaryBackground)
|
||||
static let appSelectedCellBackground = Color(uiColor: .appGroupedCellBackground)
|
||||
static let appGroupedCellBackground = Color(uiColor: .appGroupedCellBackground)
|
||||
static let appFill = Color(uiColor: .appFill)
|
||||
}
|
||||
|
||||
private let traitsKey: String = ["Traits", "Defined", "client", "_"].reversed().joined()
|
||||
private let key = "tusker_usePureBlackDarkMode"
|
||||
|
||||
extension UITraitCollection {
|
||||
var pureBlackDarkMode: Bool {
|
||||
get {
|
||||
// default to true to mach OS behavior
|
||||
(value(forKey: traitsKey) as? [String: Any])?[key] as? Bool ?? true
|
||||
}
|
||||
set {
|
||||
var dict = value(forKey: traitsKey) as? [String: Any] ?? [:]
|
||||
dict[key] = newValue
|
||||
setValue(dict, forKey: traitsKey)
|
||||
}
|
||||
}
|
||||
|
||||
convenience init(pureBlackDarkMode: Bool) {
|
||||
self.init()
|
||||
self.pureBlackDarkMode = pureBlackDarkMode
|
||||
}
|
||||
}
|
|
@ -38,7 +38,6 @@ class Preferences: Codable, ObservableObject {
|
|||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
self.theme = try container.decode(UIUserInterfaceStyle.self, forKey: .theme)
|
||||
self.pureBlackDarkMode = try container.decodeIfPresent(Bool.self, forKey: .pureBlackDarkMode) ?? true
|
||||
self.accentColor = try container.decodeIfPresent(AccentColor.self, forKey: .accentColor) ?? .default
|
||||
self.avatarStyle = try container.decode(AvatarStyle.self, forKey: .avatarStyle)
|
||||
self.hideCustomEmojiInUsernames = try container.decode(Bool.self, forKey: .hideCustomEmojiInUsernames)
|
||||
|
@ -93,7 +92,6 @@ class Preferences: Codable, ObservableObject {
|
|||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
|
||||
try container.encode(theme, forKey: .theme)
|
||||
try container.encode(pureBlackDarkMode, forKey: .pureBlackDarkMode)
|
||||
try container.encode(accentColor, forKey: .accentColor)
|
||||
try container.encode(avatarStyle, forKey: .avatarStyle)
|
||||
try container.encode(hideCustomEmojiInUsernames, forKey: .hideCustomEmojiInUsernames)
|
||||
|
@ -142,7 +140,6 @@ class Preferences: Codable, ObservableObject {
|
|||
|
||||
// MARK: Appearance
|
||||
@Published var theme = UIUserInterfaceStyle.unspecified
|
||||
@Published var pureBlackDarkMode = true
|
||||
@Published var accentColor = AccentColor.default
|
||||
@Published var avatarStyle = AvatarStyle.roundRect
|
||||
@Published var hideCustomEmojiInUsernames = false
|
||||
|
@ -205,7 +202,6 @@ class Preferences: Codable, ObservableObject {
|
|||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case theme
|
||||
case pureBlackDarkMode
|
||||
case accentColor
|
||||
case avatarStyle
|
||||
case hideCustomEmojiInUsernames
|
||||
|
|
|
@ -243,13 +243,8 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate, TuskerSceneDelegate
|
|||
}
|
||||
|
||||
@objc func themePrefChanged() {
|
||||
guard let window else { return }
|
||||
window.overrideUserInterfaceStyle = Preferences.shared.theme
|
||||
window.tintColor = Preferences.shared.accentColor.color
|
||||
let key = ["Controller", "Presentation", "root", "_"].reversed().joined()
|
||||
if let rootPresentationController = window.value(forKey: key) as? UIPresentationController {
|
||||
rootPresentationController.overrideTraitCollection = UITraitCollection(pureBlackDarkMode: Preferences.shared.pureBlackDarkMode)
|
||||
}
|
||||
window?.overrideUserInterfaceStyle = Preferences.shared.theme
|
||||
window?.tintColor = Preferences.shared.accentColor.color
|
||||
}
|
||||
|
||||
func showAddAccount() {
|
||||
|
|
|
@ -41,8 +41,7 @@ class AccountFollowsListViewController: UIViewController, CollectionViewControll
|
|||
}
|
||||
|
||||
override func loadView() {
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .plain)
|
||||
config.backgroundColor = .appBackground
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
config.itemSeparatorHandler = { [unowned self] indexPath, sectionConfig in
|
||||
guard let item = self.dataSource.itemIdentifier(for: indexPath) else {
|
||||
return sectionConfig
|
||||
|
@ -66,16 +65,6 @@ class AccountFollowsListViewController: UIViewController, CollectionViewControll
|
|||
let accountCell = UICollectionView.CellRegistration<AccountCollectionViewCell, String> { [unowned self] cell, indexPath, item in
|
||||
cell.delegate = self
|
||||
cell.updateUI(accountID: item)
|
||||
|
||||
cell.configurationUpdateHandler = { cell, state in
|
||||
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appBackground
|
||||
}
|
||||
cell.backgroundConfiguration = config
|
||||
}
|
||||
}
|
||||
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, item in
|
||||
cell.indicator.startAnimating()
|
||||
|
|
|
@ -31,8 +31,7 @@ class AccountListViewController: UIViewController, CollectionViewController {
|
|||
}
|
||||
|
||||
override func loadView() {
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
config.backgroundColor = .appGroupedBackground
|
||||
let config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
let layout = UICollectionViewCompositionalLayout.list(using: config)
|
||||
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
collectionView.delegate = self
|
||||
|
|
|
@ -72,8 +72,7 @@ class AssetCollectionViewController: UIViewController, UICollectionViewDelegate
|
|||
// bottom ignores safe area because we want cells to underflow bottom of the screen on notched iPhones
|
||||
view.bottomAnchor.constraint(equalTo: collectionView.bottomAnchor),
|
||||
])
|
||||
view.backgroundColor = .appBackground
|
||||
collectionView.backgroundColor = .appBackground
|
||||
view.backgroundColor = .systemBackground
|
||||
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(donePressed))
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ class AssetCollectionsListViewController: UITableViewController {
|
|||
tableView.register(UINib(nibName: "AlbumTableViewCell", bundle: .main), forCellReuseIdentifier: "albumCell")
|
||||
|
||||
tableView.allowsFocus = true
|
||||
tableView.backgroundColor = .appGroupedBackground
|
||||
|
||||
dataSource = DataSource(tableView: tableView, cellProvider: { (tableView, indexPath, item) -> UITableViewCell? in
|
||||
switch item {
|
||||
|
|
|
@ -112,7 +112,7 @@ struct ComposeAttachmentsList: View {
|
|||
self.isShowingAssetPickerPopover = false
|
||||
}
|
||||
// on iPadOS 16, this is necessary to show the dark color in the popover arrow
|
||||
.background(Color(.appBackground))
|
||||
.background(Color(.systemBackground))
|
||||
.environment(\.colorScheme, .dark)
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
.withSheetDetentsIfAvailable()
|
||||
|
|
|
@ -111,7 +111,7 @@ struct ComposePollView: View {
|
|||
|
||||
private var backgroundColor: Color {
|
||||
// in light mode, .secondarySystemBackground has a blue-ish hue, which we don't want
|
||||
colorScheme == .dark ? Color.appFill : Color(white: 0.95)
|
||||
colorScheme == .dark ? Color(UIColor.secondarySystemBackground) : Color(white: 0.95)
|
||||
}
|
||||
|
||||
private var buttonBackgroundColor: Color {
|
||||
|
@ -191,7 +191,7 @@ struct ComposePollOption: View {
|
|||
|
||||
private var textField: some View {
|
||||
var field = ComposeEmojiTextField(text: $option.text, placeholder: "Option \(optionIndex + 1)", maxLength: mastodonController.instance?.pollsConfiguration?.maxCharactersPerOption)
|
||||
return field.backgroundColor(.appBackground)
|
||||
return field.backgroundColor(.systemBackground)
|
||||
}
|
||||
|
||||
private func removeOption() {
|
||||
|
@ -216,7 +216,7 @@ struct ComposePollOption: View {
|
|||
.cornerRadius(radiusFraction * size)
|
||||
|
||||
Rectangle()
|
||||
.foregroundColor(Color(UIColor.appBackground))
|
||||
.foregroundColor(Color(UIColor.systemBackground))
|
||||
.frame(width: innerSize, height: innerSize)
|
||||
.cornerRadius(radiusFraction * innerSize)
|
||||
}
|
||||
|
|
|
@ -94,10 +94,6 @@ struct ComposeView: View {
|
|||
|
||||
var body: some View {
|
||||
ZStack(alignment: .top) {
|
||||
// just using .background doesn't work; for some reason it gets inset immediately after the software keyboard is dismissed
|
||||
Color.appBackground
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
|
||||
mainList
|
||||
.scrollDismissesKeyboardInteractivelyIfAvailable()
|
||||
|
||||
|
@ -128,7 +124,7 @@ struct ComposeView: View {
|
|||
}
|
||||
})
|
||||
.sheet(isPresented: $uiState.isShowingDraftsList) {
|
||||
DraftsRepresentable(currentDraft: draft, mastodonController: mastodonController)
|
||||
DraftsView(currentDraft: draft, mastodonController: mastodonController)
|
||||
}
|
||||
.actionSheet(isPresented: $uiState.isShowingSaveDraftSheet, content: self.saveAndCloseSheet)
|
||||
.alert(isPresented: $isShowingPostErrorAlert) {
|
||||
|
@ -173,13 +169,11 @@ struct ComposeView: View {
|
|||
)
|
||||
.listRowInsets(EdgeInsets(top: 8, leading: 8, bottom: 4, trailing: 8))
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color.appBackground)
|
||||
}
|
||||
|
||||
header
|
||||
.listRowInsets(EdgeInsets(top: draft.inReplyToID == nil ? 8 : 4, leading: 8, bottom: 4, trailing: 8))
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color.appBackground)
|
||||
|
||||
if uiState.draft.contentWarningEnabled {
|
||||
ComposeEmojiTextField(
|
||||
|
@ -190,7 +184,6 @@ struct ComposeView: View {
|
|||
)
|
||||
.listRowInsets(EdgeInsets(top: 4, leading: 8, bottom: 4, trailing: 8))
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color.appBackground)
|
||||
}
|
||||
|
||||
MainComposeTextView(
|
||||
|
@ -199,20 +192,17 @@ struct ComposeView: View {
|
|||
)
|
||||
.listRowInsets(EdgeInsets(top: 4, leading: 8, bottom: 4, trailing: 8))
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color.appBackground)
|
||||
|
||||
if let poll = draft.poll {
|
||||
ComposePollView(draft: draft, poll: poll)
|
||||
.listRowInsets(EdgeInsets(top: 4, leading: 8, bottom: 4, trailing: 8))
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color.appBackground)
|
||||
}
|
||||
|
||||
ComposeAttachmentsList(
|
||||
draft: draft
|
||||
)
|
||||
.listRowInsets(EdgeInsets(top: 4, leading: 8, bottom: 8, trailing: 8))
|
||||
.listRowBackground(Color.appBackground)
|
||||
}
|
||||
.animation(.default, value: draft.poll?.options.count)
|
||||
.scrollDismissesKeyboardInteractivelyIfAvailable()
|
||||
|
@ -329,7 +319,7 @@ struct ComposeView: View {
|
|||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
private extension View {
|
||||
@available(iOS, obsoleted: 16.0)
|
||||
@ViewBuilder
|
||||
func scrollDismissesKeyboardInteractivelyIfAvailable() -> some View {
|
||||
|
|
|
@ -8,21 +8,6 @@
|
|||
|
||||
import SwiftUI
|
||||
|
||||
@available(iOS, obsoleted: 16.0)
|
||||
struct DraftsRepresentable: UIViewControllerRepresentable {
|
||||
typealias UIViewControllerType = UIHostingController<DraftsView>
|
||||
|
||||
let currentDraft: Draft
|
||||
let mastodonController: MastodonController
|
||||
|
||||
func makeUIViewController(context: Context) -> UIHostingController<DraftsView> {
|
||||
return UIHostingController(rootView: DraftsView(currentDraft: currentDraft, mastodonController: mastodonController))
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIHostingController<DraftsView>, context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
struct DraftsView: View {
|
||||
let currentDraft: Draft
|
||||
// don't pass this in via the environment b/c it crashes on macOS (at least, in Designed for iPad mode) since the environment doesn't get propagated through the modal popup window or something
|
||||
|
@ -64,10 +49,8 @@ struct DraftsView: View {
|
|||
.map { visibleDrafts[$0] }
|
||||
.forEach { draftsManager.remove($0) }
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.appGroupedListBackground(container: DraftsRepresentable.UIViewControllerType.self)
|
||||
.navigationTitle(Text("Drafts"))
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
|
|
|
@ -38,11 +38,10 @@ struct MainComposeTextView: View {
|
|||
@Binding var becomeFirstResponder: Bool
|
||||
@State private var hasFirstAppeared = false
|
||||
@ScaledMetric private var fontSize = 20
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .topLeading) {
|
||||
colorScheme == .dark ? Color.appFill : Color(uiColor: .secondarySystemBackground)
|
||||
Color(UIColor.secondarySystemBackground)
|
||||
|
||||
if draft.text.isEmpty {
|
||||
placeholder
|
||||
|
|
|
@ -37,7 +37,7 @@ class ConversationCollectionViewController: UIViewController, CollectionViewCont
|
|||
|
||||
override func loadView() {
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .plain)
|
||||
config.backgroundColor = .appSecondaryBackground
|
||||
config.backgroundColor = .secondarySystemBackground
|
||||
config.leadingSwipeActionsConfigurationProvider = { [unowned self] in
|
||||
(collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.leadingSwipeActions()
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ class ConversationCollectionViewController: UIViewController, CollectionViewCont
|
|||
}
|
||||
// we're not using contenetInsetsReference = .readableContent here because it always insets the cells even if
|
||||
// the collection view's actual width is narrow enough to fit in the readable width, resulting in a bit of the
|
||||
// background color always peeking through the edges
|
||||
// background color always peaking through the edges
|
||||
let layout = UICollectionViewCompositionalLayout.list(using: config)
|
||||
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
// something about the autoresizing mask breaks resizing the vc
|
||||
|
|
|
@ -94,7 +94,7 @@ class ConversationViewController: UIViewController {
|
|||
|
||||
title = NSLocalizedString("Conversation", comment: "conversation screen title")
|
||||
|
||||
view.backgroundColor = .appSecondaryBackground
|
||||
view.backgroundColor = .secondarySystemBackground
|
||||
|
||||
collapseBarButtonItem = UIBarButtonItem(image: UIImage(systemName: "eye.fill")!, style: .plain, target: self, action: #selector(toggleCollapseButtonPressed))
|
||||
updateVisibilityBarButtonItem()
|
||||
|
|
|
@ -141,13 +141,18 @@ class ExpandThreadCollectionViewCell: UICollectionViewListCell {
|
|||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state)
|
||||
var config = UIBackgroundConfiguration.listPlainCell()
|
||||
if state.isSelected || state.isHighlighted {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
var hue: CGFloat = 0
|
||||
var saturation: CGFloat = 0
|
||||
var brightness: CGFloat = 0
|
||||
UIColor.secondarySystemBackground.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: nil)
|
||||
let sign: CGFloat = traitCollection.userInterfaceStyle == .dark ? 1 : -1
|
||||
config.backgroundColor = UIColor(hue: hue, saturation: saturation, brightness: max(0, brightness + sign * 0.1), alpha: 1)
|
||||
} else {
|
||||
config.backgroundColor = .appSecondaryBackground
|
||||
config.backgroundColor = .secondarySystemBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
backgroundConfiguration = config.updated(for: state)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,20 +9,6 @@
|
|||
import SwiftUI
|
||||
import Pachyderm
|
||||
|
||||
@available(iOS, obsoleted: 16.0)
|
||||
struct AddHashtagPinnedTimelineRepresentable: UIViewControllerRepresentable {
|
||||
typealias UIViewControllerType = UIHostingController<AddHashtagPinnedTimelineView>
|
||||
|
||||
@Binding var pinnedTimelines: [PinnedTimeline]
|
||||
|
||||
func makeUIViewController(context: Context) -> UIHostingController<AddHashtagPinnedTimelineView> {
|
||||
return UIHostingController(rootView: AddHashtagPinnedTimelineView(pinnedTimelines: $pinnedTimelines))
|
||||
}
|
||||
|
||||
func updateUIViewController(_ uiViewController: UIHostingController<AddHashtagPinnedTimelineView>, context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
struct AddHashtagPinnedTimelineView: View {
|
||||
@EnvironmentObject private var mastodonController: MastodonController
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
@ -48,8 +34,6 @@ struct AddHashtagPinnedTimelineView: View {
|
|||
var body: some View {
|
||||
NavigationView {
|
||||
list
|
||||
.listStyle(.grouped)
|
||||
.appGroupedListBackground(container: AddHashtagPinnedTimelineRepresentable.UIViewControllerType.self)
|
||||
.navigationTitle("Add Hashtag")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.searchable(text: $viewModel.searchQuery, placement: .navigationBarDrawer(displayMode: .always), prompt: Text("Search for hashtags"))
|
||||
|
@ -73,9 +57,8 @@ struct AddHashtagPinnedTimelineView: View {
|
|||
})
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var list: some View {
|
||||
let list = List {
|
||||
List {
|
||||
Section {
|
||||
if viewModel.searchQuery.isEmpty {
|
||||
forEachTag(savedAndFollowedHashtags)
|
||||
|
@ -90,17 +73,8 @@ struct AddHashtagPinnedTimelineView: View {
|
|||
.listRowBackground(EmptyView())
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
.listStyle(.grouped)
|
||||
|
||||
if #available(iOS 16.0, *) {
|
||||
list
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(Color.appGroupedBackground)
|
||||
} else {
|
||||
list
|
||||
}
|
||||
}
|
||||
|
||||
private func forEachTag(_ tags: [String]) -> some View {
|
||||
|
|
|
@ -51,7 +51,6 @@ struct CustomizeTimelinesList: View {
|
|||
private var navigationBody: some View {
|
||||
List {
|
||||
PinnedTimelinesView(accountPreferences: mastodonController.accountPreferences)
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
Section {
|
||||
Toggle(isOn: $preferences.hideReblogsInTimelines) {
|
||||
|
@ -63,7 +62,6 @@ struct CustomizeTimelinesList: View {
|
|||
} header: {
|
||||
Text("Home Timeline")
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
Section {
|
||||
filtersForEach(unexpiredFilters)
|
||||
|
@ -77,7 +75,6 @@ struct CustomizeTimelinesList: View {
|
|||
} header: {
|
||||
Text("Active Filters")
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
if !expiredFilters.isEmpty {
|
||||
Section {
|
||||
|
@ -85,11 +82,8 @@ struct CustomizeTimelinesList: View {
|
|||
} header: {
|
||||
Text("Expired Filters")
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.appGroupedListBackground(container: UIHostingController<CustomizeTimelinesList>.self)
|
||||
.navigationTitle(Text("Customize Timelines"))
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
|
|
|
@ -72,7 +72,6 @@ struct EditFilterView: View {
|
|||
filter.title = newValue
|
||||
}))
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
Section {
|
||||
|
@ -97,7 +96,6 @@ struct EditFilterView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
Section {
|
||||
if mastodonController.instanceFeatures.filtersV2 {
|
||||
|
@ -122,7 +120,6 @@ struct EditFilterView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
Section {
|
||||
ForEach(FilterV1.Context.allCases, id: \.rawValue) { context in
|
||||
|
@ -144,10 +141,7 @@ struct EditFilterView: View {
|
|||
} header: {
|
||||
Text("Contexts")
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
.appGroupedListBackground(container: UIHostingController<CustomizeTimelinesList>.self)
|
||||
.scrollDismissesKeyboardInteractivelyIfAvailable()
|
||||
.navigationTitle(create ? "Add Filter" : "Edit Filter")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
|
|
|
@ -111,13 +111,7 @@ struct PinnedTimelinesView: View {
|
|||
Text("Pinned Timelines")
|
||||
}
|
||||
.sheet(isPresented: $isShowingAddHashtagSheet, content: {
|
||||
if #available(iOS 16.0, *) {
|
||||
AddHashtagPinnedTimelineView(pinnedTimelines: $pinnedTimelines)
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
} else {
|
||||
AddHashtagPinnedTimelineRepresentable(pinnedTimelines: $pinnedTimelines)
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
}
|
||||
AddHashtagPinnedTimelineView(pinnedTimelines: $pinnedTimelines)
|
||||
})
|
||||
.sheet(isPresented: $isShowingAddInstanceSheet, content: {
|
||||
AddInstancePinnedTimelineView(pinnedTimelines: $pinnedTimelines)
|
||||
|
|
|
@ -34,15 +34,15 @@ class AddSavedHashtagViewController: UIViewController {
|
|||
|
||||
title = NSLocalizedString("Search", comment: "search screen title")
|
||||
|
||||
view.backgroundColor = .systemGroupedBackground
|
||||
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
config.backgroundColor = .appGroupedBackground
|
||||
config.headerMode = .supplementary
|
||||
let layout = UICollectionViewCompositionalLayout.list(using: config)
|
||||
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
|
||||
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
collectionView.delegate = self
|
||||
collectionView.allowsFocus = true
|
||||
collectionView.backgroundColor = .appGroupedBackground
|
||||
view.addSubview(collectionView)
|
||||
|
||||
let sectionHeaderCell = UICollectionView.SupplementaryRegistration<UICollectionViewListCell>(elementKind: UICollectionView.elementKindSectionHeader) { (headerView, collectionView, indexPath) in
|
||||
|
|
|
@ -43,8 +43,7 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
|
|||
super.viewDidLoad()
|
||||
|
||||
var configuration = UICollectionLayoutListConfiguration(appearance: .insetGrouped)
|
||||
configuration.backgroundColor = .appGroupedBackground
|
||||
configuration.trailingSwipeActionsConfigurationProvider = { [unowned self] in self.trailingSwipeActionsForCell(at: $0) }
|
||||
configuration.trailingSwipeActionsConfigurationProvider = self.trailingSwipeActionsForCell(at:)
|
||||
configuration.headerMode = .supplementary
|
||||
let layout = UICollectionViewCompositionalLayout.list(using: configuration)
|
||||
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
|
||||
|
@ -101,23 +100,12 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
|
|||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
// UISearchController exists outside of the normal VC hierarchy,
|
||||
// so we manually propagate this down to the results controller
|
||||
// so that it can deselect on appear
|
||||
if searchController.isActive {
|
||||
resultsController.viewWillAppear(animated)
|
||||
}
|
||||
|
||||
clearSelectionOnAppear(animated: animated)
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
if searchController.isActive {
|
||||
resultsController.viewDidAppear(animated)
|
||||
}
|
||||
|
||||
// this is a workaround for the issue that setting isActive on a search controller that is not visible
|
||||
// does not cause it to automatically become active once it becomes visible
|
||||
// see FB7814561
|
||||
|
@ -141,16 +129,6 @@ class ExploreViewController: UIViewController, UICollectionViewDelegate, Collect
|
|||
config.text = item.label
|
||||
config.image = item.image
|
||||
cell.contentConfiguration = config
|
||||
|
||||
cell.configurationUpdateHandler = { cell, state in
|
||||
var config = UIBackgroundConfiguration.listGroupedCell()
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appGroupedCellBackground
|
||||
}
|
||||
cell.backgroundConfiguration = config
|
||||
}
|
||||
|
||||
switch item {
|
||||
case .addList, .addSavedHashtag, .findInstance:
|
||||
|
|
|
@ -39,7 +39,6 @@ class FeaturedProfileCollectionViewCell: UICollectionViewCell {
|
|||
noteTextView.textContainerInset = UIEdgeInsets(top: 16, left: 4, bottom: 16, right: 4)
|
||||
|
||||
backgroundColor = .clear
|
||||
clippingView.backgroundColor = .appBackground
|
||||
clippingView.layer.cornerRadius = 5
|
||||
clippingView.layer.borderWidth = 1
|
||||
clippingView.layer.masksToBounds = true
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
|
@ -55,6 +55,7 @@
|
|||
</label>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" verticalCompressionResistancePriority="749" scrollEnabled="NO" editable="NO" textAlignment="natural" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bvj-F0-ggC" customClass="StatusContentTextView" customModule="Tusker" customModuleProvider="target">
|
||||
<rect key="frame" x="8" y="102" width="384" height="98"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
|
||||
<color key="textColor" systemColor="labelColor"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
|
@ -101,7 +102,7 @@
|
|||
</objects>
|
||||
<resources>
|
||||
<systemColor name="labelColor">
|
||||
<color red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
</systemColor>
|
||||
<systemColor name="systemBackgroundColor">
|
||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
//
|
||||
// MoreTrendsFooterCollectionViewCell.swift
|
||||
// Tusker
|
||||
//
|
||||
// Created by Shadowfacts on 2/9/23.
|
||||
// Copyright © 2023 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class MoreTrendsFooterCollectionViewCell: UICollectionViewCell {
|
||||
|
||||
weak var delegate: TuskerNavigationDelegate?
|
||||
|
||||
private var button = UIButton()
|
||||
|
||||
private var kind: Kind!
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
button.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)
|
||||
button.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(button)
|
||||
NSLayoutConstraint.activate([
|
||||
button.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
|
||||
button.topAnchor.constraint(equalTo: contentView.topAnchor),
|
||||
button.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
|
||||
])
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func updateUI(_ kind: Kind) {
|
||||
guard self.kind != kind else {
|
||||
return
|
||||
}
|
||||
self.kind = kind
|
||||
|
||||
var config = UIButton.Configuration.plain()
|
||||
var title: AttributedString
|
||||
switch kind {
|
||||
case .hashtags:
|
||||
title = "More Trending Hashtags"
|
||||
case .links:
|
||||
title = "More Trending Links"
|
||||
case .profileSuggestions:
|
||||
title = "More Suggested Accounts"
|
||||
}
|
||||
title.font = .preferredFont(forTextStyle: .body).withTraits(.traitBold)!
|
||||
config.attributedTitle = title
|
||||
config.image = UIImage(systemName: "chevron.right")
|
||||
config.imagePlacement = .trailing
|
||||
config.buttonSize = .mini
|
||||
button.configuration = config
|
||||
}
|
||||
|
||||
@objc private func buttonPressed() {
|
||||
guard let delegate else {
|
||||
return
|
||||
}
|
||||
switch kind {
|
||||
case nil:
|
||||
return
|
||||
case .hashtags:
|
||||
delegate.show(TrendingHashtagsViewController(mastodonController: delegate.apiController))
|
||||
case .links:
|
||||
delegate.show(TrendingLinksViewController(mastodonController: delegate.apiController))
|
||||
case .profileSuggestions:
|
||||
delegate.show(SuggestedProfilesViewController(mastodonController: delegate.apiController))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension MoreTrendsFooterCollectionViewCell {
|
||||
enum Kind {
|
||||
case hashtags
|
||||
case links
|
||||
case profileSuggestions
|
||||
}
|
||||
}
|
|
@ -64,7 +64,7 @@ class ProfileDirectoryViewController: UIViewController {
|
|||
|
||||
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
|
||||
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
collectionView.backgroundColor = .appSecondaryBackground
|
||||
collectionView.backgroundColor = .secondarySystemBackground
|
||||
collectionView.register(UINib(nibName: "FeaturedProfileCollectionViewCell", bundle: .main), forCellWithReuseIdentifier: "featuredProfileCell")
|
||||
collectionView.delegate = self
|
||||
collectionView.dragDelegate = self
|
||||
|
|
|
@ -36,7 +36,6 @@ class SuggestedProfileCardCollectionViewCell: UICollectionViewCell {
|
|||
layer.shadowOffset = .zero
|
||||
layer.masksToBounds = false
|
||||
contentView.layer.cornerRadius = 12.5
|
||||
contentView.backgroundColor = .appGroupedCellBackground
|
||||
updateLayerColors()
|
||||
|
||||
headerImageView.cache = .headers
|
||||
|
@ -190,7 +189,7 @@ private struct SuggestionSourceView: View {
|
|||
var body: some View {
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
Image(uiImage: source.image.withRenderingMode(.alwaysTemplate))
|
||||
Image(uiImage: source.image)
|
||||
Text(source.title)
|
||||
Spacer()
|
||||
}
|
||||
|
|
|
@ -1,212 +0,0 @@
|
|||
//
|
||||
// SuggestedProfilesViewController.swift
|
||||
// Tusker
|
||||
//
|
||||
// Created by Shadowfacts on 2/11/23.
|
||||
// Copyright © 2023 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Pachyderm
|
||||
|
||||
class SuggestedProfilesViewController: UIViewController, CollectionViewController {
|
||||
|
||||
weak var mastodonController: MastodonController!
|
||||
|
||||
var collectionView: UICollectionView!
|
||||
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
|
||||
|
||||
private var state = State.unloaded
|
||||
|
||||
init(mastodonController: MastodonController) {
|
||||
self.mastodonController = mastodonController
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
title = "Suggested Accounts"
|
||||
|
||||
let layout = UICollectionViewCompositionalLayout { [unowned self] sectionIndex, environment in
|
||||
switch dataSource.sectionIdentifier(for: sectionIndex) {
|
||||
case nil:
|
||||
fatalError()
|
||||
|
||||
case .loadingIndicator:
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
config.backgroundColor = .appGroupedBackground
|
||||
config.showsSeparators = false
|
||||
return .list(using: config, layoutEnvironment: environment)
|
||||
|
||||
case .accounts:
|
||||
let size = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(280))
|
||||
let item = NSCollectionLayoutItem(layoutSize: size)
|
||||
let item2 = NSCollectionLayoutItem(layoutSize: size)
|
||||
let group = NSCollectionLayoutGroup.vertical(layoutSize: size, subitems: [item, item2])
|
||||
group.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)
|
||||
group.interItemSpacing = .fixed(16)
|
||||
let section = NSCollectionLayoutSection(group: group)
|
||||
section.interGroupSpacing = 16
|
||||
section.contentInsets = NSDirectionalEdgeInsets(top: 16, leading: 0, bottom: 16, trailing: 0)
|
||||
return section
|
||||
}
|
||||
}
|
||||
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
collectionView.translatesAutoresizingMaskIntoConstraints = false
|
||||
collectionView.delegate = self
|
||||
collectionView.dragDelegate = self
|
||||
collectionView.backgroundColor = .appGroupedBackground
|
||||
collectionView.allowsFocus = true
|
||||
view.addSubview(collectionView)
|
||||
NSLayoutConstraint.activate([
|
||||
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
|
||||
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||
])
|
||||
|
||||
dataSource = createDataSource()
|
||||
}
|
||||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
|
||||
cell.indicator.startAnimating()
|
||||
}
|
||||
let accountCell = UICollectionView.CellRegistration<SuggestedProfileCardCollectionViewCell, (String, Suggestion.Source)>(cellNib: UINib(nibName: "SuggestedProfileCardCollectionViewCell", bundle: .main)) { cell, indexPath, item in
|
||||
cell.delegate = self
|
||||
cell.updateUI(accountID: item.0, source: item.1)
|
||||
}
|
||||
return UICollectionViewDiffableDataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
|
||||
switch itemIdentifier {
|
||||
case .loadingIndicator:
|
||||
return collectionView.dequeueConfiguredReusableCell(using: loadingCell, for: indexPath, item: ())
|
||||
case .account(let id, let source):
|
||||
return collectionView.dequeueConfiguredReusableCell(using: accountCell, for: indexPath, item: (id, source))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
Task {
|
||||
await loadInitial()
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func loadInitial() async {
|
||||
guard case .unloaded = state else {
|
||||
return
|
||||
}
|
||||
state = .loading
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.loadingIndicator])
|
||||
snapshot.appendItems([.loadingIndicator])
|
||||
await dataSource.apply(snapshot)
|
||||
|
||||
do {
|
||||
let request = Client.getSuggestions(limit: 80)
|
||||
let (suggestions, _) = try await mastodonController.run(request)
|
||||
|
||||
await mastodonController.persistentContainer.addAll(accounts: suggestions.map(\.account))
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.accounts])
|
||||
snapshot.appendItems(suggestions.map { .account($0.account.id, $0.source) })
|
||||
await dataSource.apply(snapshot)
|
||||
|
||||
state = .loaded
|
||||
} catch {
|
||||
state = .unloaded
|
||||
let config = ToastConfiguration(from: error, with: "Error Loading Suggested Accounts", in: self) { [weak self] toast in
|
||||
toast.dismissToast(animated: true)
|
||||
await self?.loadInitial()
|
||||
}
|
||||
showToast(configuration: config, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension SuggestedProfilesViewController {
|
||||
enum State {
|
||||
case unloaded
|
||||
case loading
|
||||
case loaded
|
||||
}
|
||||
}
|
||||
|
||||
extension SuggestedProfilesViewController {
|
||||
enum Section {
|
||||
case loadingIndicator
|
||||
case accounts
|
||||
}
|
||||
enum Item: Hashable {
|
||||
case loadingIndicator
|
||||
case account(String, Suggestion.Source)
|
||||
}
|
||||
}
|
||||
|
||||
extension SuggestedProfilesViewController: UICollectionViewDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
|
||||
if case .account(_, _) = dataSource.itemIdentifier(for: indexPath) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
guard case .account(let id, _) = dataSource.itemIdentifier(for: indexPath) else {
|
||||
return
|
||||
}
|
||||
selected(account: id)
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
|
||||
guard case .account(let id, _) = dataSource.itemIdentifier(for: indexPath),
|
||||
let cell = collectionView.cellForItem(at: indexPath) else {
|
||||
return nil
|
||||
}
|
||||
return UIContextMenuConfiguration {
|
||||
ProfileViewController(accountID: id, mastodonController: self.mastodonController)
|
||||
} actionProvider: { _ in
|
||||
UIMenu(children: self.actionsForProfile(accountID: id, source: .view(cell)))
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) {
|
||||
MenuPreviewHelper.willPerformPreviewAction(animator: animator, presenter: self)
|
||||
}
|
||||
}
|
||||
|
||||
extension SuggestedProfilesViewController: UICollectionViewDragDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
|
||||
guard case .account(let id, _) = dataSource.itemIdentifier(for: indexPath),
|
||||
let account = mastodonController.persistentContainer.account(for: id) else {
|
||||
return []
|
||||
}
|
||||
let provider = NSItemProvider(object: account.url as NSURL)
|
||||
let activity = UserActivityManager.showProfileActivity(id: id, accountID: mastodonController.accountInfo!.id)
|
||||
provider.registerObject(activity, visibility: .all)
|
||||
return [UIDragItem(itemProvider: provider)]
|
||||
}
|
||||
}
|
||||
|
||||
extension SuggestedProfilesViewController: TuskerNavigationDelegate {
|
||||
var apiController: MastodonController! { mastodonController }
|
||||
}
|
||||
|
||||
extension SuggestedProfilesViewController: MenuActionProvider {
|
||||
}
|
||||
|
||||
extension SuggestedProfilesViewController: ToastableViewController {
|
||||
}
|
|
@ -9,7 +9,6 @@
|
|||
import UIKit
|
||||
import Pachyderm
|
||||
import WebURLFoundationExtras
|
||||
import Combine
|
||||
|
||||
class TrendingHashtagsViewController: UIViewController {
|
||||
|
||||
|
@ -18,9 +17,6 @@ class TrendingHashtagsViewController: UIViewController {
|
|||
private var collectionView: UICollectionView!
|
||||
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
|
||||
|
||||
private var state = State.unloaded
|
||||
private var confirmLoadMore = PassthroughSubject<Void, Never>()
|
||||
|
||||
init(mastodonController: MastodonController) {
|
||||
self.mastodonController = mastodonController
|
||||
|
||||
|
@ -36,21 +32,9 @@ class TrendingHashtagsViewController: UIViewController {
|
|||
|
||||
title = NSLocalizedString("Trending Hashtags", comment: "trending hashtags screen title")
|
||||
|
||||
view.backgroundColor = .appGroupedBackground
|
||||
view.backgroundColor = .systemGroupedBackground
|
||||
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
config.backgroundColor = .appGroupedBackground
|
||||
config.itemSeparatorHandler = { [unowned self] indexPath, sectionConfig in
|
||||
guard let item = dataSource.itemIdentifier(for: indexPath) else {
|
||||
return sectionConfig
|
||||
}
|
||||
var config = sectionConfig
|
||||
if item.hideSeparators {
|
||||
config.topSeparatorVisibility = .hidden
|
||||
config.bottomSeparatorVisibility = .hidden
|
||||
}
|
||||
return config
|
||||
}
|
||||
let config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
let layout = UICollectionViewCompositionalLayout.list(using: config)
|
||||
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
|
||||
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
|
@ -59,24 +43,14 @@ class TrendingHashtagsViewController: UIViewController {
|
|||
collectionView.allowsFocus = true
|
||||
view.addSubview(collectionView)
|
||||
|
||||
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
|
||||
cell.indicator.startAnimating()
|
||||
}
|
||||
let hashtagCell = UICollectionView.CellRegistration<TrendingHashtagCollectionViewCell, Hashtag> { cell, indexPath, hashtag in
|
||||
let registration = UICollectionView.CellRegistration<TrendingHashtagCollectionViewCell, Hashtag> { cell, indexPath, hashtag in
|
||||
cell.updateUI(hashtag: hashtag)
|
||||
}
|
||||
let confirmLoadMoreCell = UICollectionView.CellRegistration<ConfirmLoadMoreCollectionViewCell, Bool> { [unowned self] cell, indexPath, isLoading in
|
||||
cell.confirmLoadMore = self.confirmLoadMore
|
||||
cell.isLoading = isLoading
|
||||
}
|
||||
|
||||
dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { (collectionView, indexPath, item) in
|
||||
switch item {
|
||||
case .loadingIndicator:
|
||||
return collectionView.dequeueConfiguredReusableCell(using: loadingCell, for: indexPath, item: ())
|
||||
case .tag(let hashtag):
|
||||
return collectionView.dequeueConfiguredReusableCell(using: hashtagCell, for: indexPath, item: hashtag)
|
||||
case .confirmLoadMore(let loading):
|
||||
return collectionView.dequeueConfiguredReusableCell(using: confirmLoadMoreCell, for: indexPath, item: loading)
|
||||
case let .tag(hashtag):
|
||||
return collectionView.dequeueConfiguredReusableCell(using: registration, for: indexPath, item: hashtag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,150 +58,30 @@ class TrendingHashtagsViewController: UIViewController {
|
|||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
let request = Client.getTrendingHashtags(limit: 10)
|
||||
Task {
|
||||
await loadInitial()
|
||||
}
|
||||
}
|
||||
|
||||
private func request(offset: Int?) -> Request<[Hashtag]> {
|
||||
if mastodonController.instanceFeatures.hasMastodonVersion(3, 5, 0) {
|
||||
return Client.getTrendingHashtags(offset: offset)
|
||||
} else {
|
||||
return Client.getTrendingHashtagsDeprecated(offset: offset)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func loadInitial() async {
|
||||
guard case .unloaded = state else {
|
||||
return
|
||||
}
|
||||
state = .loadingInitial
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.trendingTags])
|
||||
snapshot.appendItems([.loadingIndicator])
|
||||
await dataSource.apply(snapshot)
|
||||
|
||||
do {
|
||||
let request = self.request(offset: nil)
|
||||
let (hashtags, _) = try await mastodonController.run(request)
|
||||
snapshot.deleteItems([.loadingIndicator])
|
||||
snapshot.appendItems(hashtags.map { .tag($0) })
|
||||
state = .loaded
|
||||
await dataSource.apply(snapshot)
|
||||
} catch {
|
||||
snapshot.deleteItems([.loadingIndicator])
|
||||
await dataSource.apply(snapshot)
|
||||
state = .unloaded
|
||||
|
||||
let config = ToastConfiguration(from: error, with: "Error Loading Trending Tags", in: self) { [weak self] toast in
|
||||
toast.dismissToast(animated: true)
|
||||
await self?.loadInitial()
|
||||
guard let (hashtags, _) = try? await mastodonController.run(request) else {
|
||||
return
|
||||
}
|
||||
self.showToast(configuration: config, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func loadOlder() async {
|
||||
guard case .loaded = state else {
|
||||
return
|
||||
}
|
||||
state = .loadingOlder
|
||||
|
||||
let origSnapshot = dataSource.snapshot()
|
||||
var snapshot = origSnapshot
|
||||
if Preferences.shared.disableInfiniteScrolling {
|
||||
snapshot.appendItems([.confirmLoadMore(false)])
|
||||
await dataSource.apply(snapshot)
|
||||
|
||||
for await _ in confirmLoadMore.values {
|
||||
break
|
||||
}
|
||||
|
||||
snapshot.deleteItems([.confirmLoadMore(false)])
|
||||
snapshot.appendItems([.confirmLoadMore(true)])
|
||||
await dataSource.apply(snapshot, animatingDifferences: false)
|
||||
} else {
|
||||
snapshot.appendItems([.loadingIndicator])
|
||||
await dataSource.apply(snapshot)
|
||||
}
|
||||
|
||||
do {
|
||||
let request = self.request(offset: snapshot.itemIdentifiers.count - 1)
|
||||
let (hashtags, _) = try await mastodonController.run(request)
|
||||
var snapshot = origSnapshot
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.trendingTags])
|
||||
snapshot.appendItems(hashtags.map { .tag($0) })
|
||||
await dataSource.apply(snapshot)
|
||||
} catch {
|
||||
await dataSource.apply(origSnapshot)
|
||||
|
||||
let config = ToastConfiguration(from: error, with: "Error Loading More Tags", in: self) { [weak self] toast in
|
||||
toast.dismissToast(animated: true)
|
||||
await self?.loadOlder()
|
||||
}
|
||||
self.showToast(configuration: config, animated: true)
|
||||
}
|
||||
|
||||
state = .loaded
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension TrendingHashtagsViewController {
|
||||
enum State {
|
||||
case unloaded
|
||||
case loadingInitial
|
||||
case loaded
|
||||
case loadingOlder
|
||||
}
|
||||
}
|
||||
|
||||
extension TrendingHashtagsViewController {
|
||||
enum Section {
|
||||
case trendingTags
|
||||
}
|
||||
enum Item: Hashable {
|
||||
case loadingIndicator
|
||||
case tag(Hashtag)
|
||||
case confirmLoadMore(Bool)
|
||||
|
||||
var hideSeparators: Bool {
|
||||
switch self {
|
||||
case .loadingIndicator:
|
||||
return true
|
||||
case .tag(_):
|
||||
return false
|
||||
case .confirmLoadMore(_):
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
var shouldSelect: Bool {
|
||||
if case .tag(_) = self {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension TrendingHashtagsViewController: UICollectionViewDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
||||
if indexPath.section == collectionView.numberOfSections - 1,
|
||||
indexPath.row == collectionView.numberOfItems(inSection: indexPath.section) - 1 {
|
||||
Task {
|
||||
await self.loadOlder()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
|
||||
return dataSource.itemIdentifier(for: indexPath)?.shouldSelect ?? false
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
guard let item = dataSource.itemIdentifier(for: indexPath),
|
||||
case let .tag(hashtag) = item else {
|
||||
|
|
|
@ -21,29 +21,6 @@ class TrendingLinkCardCollectionViewCell: UICollectionViewCell {
|
|||
@IBOutlet weak var providerLabel: UILabel!
|
||||
@IBOutlet weak var activityLabel: UILabel!
|
||||
@IBOutlet weak var historyView: TrendHistoryView!
|
||||
private var thumbnailAspectRatioConstraint: NSLayoutConstraint?
|
||||
|
||||
var verticalSize: VerticalSize! {
|
||||
didSet {
|
||||
guard oldValue != verticalSize else {
|
||||
return
|
||||
}
|
||||
switch verticalSize {
|
||||
case nil:
|
||||
fatalError()
|
||||
case .regular:
|
||||
thumbnailAspectRatioConstraint?.isActive = false
|
||||
thumbnailAspectRatioConstraint = thumbnailView.widthAnchor.constraint(equalTo: thumbnailView.heightAnchor, multiplier: 4/3)
|
||||
thumbnailAspectRatioConstraint!.isActive = true
|
||||
descriptionLabel.numberOfLines = 3
|
||||
case .compact:
|
||||
thumbnailAspectRatioConstraint?.isActive = false
|
||||
thumbnailAspectRatioConstraint = thumbnailView.widthAnchor.constraint(equalTo: thumbnailView.heightAnchor, multiplier: 2/1)
|
||||
thumbnailAspectRatioConstraint!.isActive = true
|
||||
descriptionLabel.numberOfLines = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var hoverGestureAnimator: UIViewPropertyAnimator?
|
||||
|
||||
|
@ -57,11 +34,8 @@ class TrendingLinkCardCollectionViewCell: UICollectionViewCell {
|
|||
layer.shadowOffset = .zero
|
||||
layer.masksToBounds = false
|
||||
contentView.layer.cornerRadius = 12.5
|
||||
contentView.backgroundColor = .appGroupedCellBackground
|
||||
updateLayerColors()
|
||||
|
||||
verticalSize = .regular
|
||||
|
||||
addGestureRecognizer(UIHoverGestureRecognizer(target: self, action: #selector(hoverRecognized)))
|
||||
}
|
||||
|
||||
|
@ -162,9 +136,3 @@ class TrendingLinkCardCollectionViewCell: UICollectionViewCell {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
extension TrendingLinkCardCollectionViewCell {
|
||||
enum VerticalSize {
|
||||
case regular, compact
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="h3b-Mf-lD6" customClass="CachedImageView" customModule="Tusker" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="300" height="225"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" secondItem="h3b-Mf-lD6" secondAttribute="height" multiplier="4:3" placeholder="YES" id="QDY-8a-LYC"/>
|
||||
<constraint firstAttribute="width" secondItem="h3b-Mf-lD6" secondAttribute="height" multiplier="4:3" id="QDY-8a-LYC"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="LpU-m4-guC">
|
||||
|
@ -56,9 +56,9 @@
|
|||
</constraints>
|
||||
</view>
|
||||
<visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cWo-9n-z42">
|
||||
<rect key="frame" x="0.0" y="196.66666666666666" width="300" height="28.333333333333343"/>
|
||||
<rect key="frame" x="0.0" y="196.33333333333334" width="300" height="28.666666666666657"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="ktv-3s-cp9">
|
||||
<rect key="frame" x="0.0" y="0.0" width="300" height="28.333333333333343"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="300" height="28.666666666666657"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsLetterSpacingToFitWidth="YES" showsExpansionTextWhenTruncated="YES" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ho3-cU-IGi">
|
||||
|
|
|
@ -79,16 +79,6 @@ class TrendingLinkTableViewCell: UITableViewCell {
|
|||
|
||||
thumbnailView.layer.cornerRadius = 0.05 * thumbnailView.bounds.width
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appGroupedCellBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
func updateUI(card: Card) {
|
||||
self.card = card
|
||||
|
|
|
@ -10,22 +10,19 @@ import UIKit
|
|||
import Pachyderm
|
||||
import WebURLFoundationExtras
|
||||
import SafariServices
|
||||
import Combine
|
||||
|
||||
class TrendingLinksViewController: UIViewController, CollectionViewController {
|
||||
class TrendingLinksViewController: EnhancedTableViewController {
|
||||
|
||||
weak var mastodonController: MastodonController!
|
||||
|
||||
var collectionView: UICollectionView!
|
||||
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
|
||||
|
||||
private var state = State.unloaded
|
||||
private let confirmLoadMore = PassthroughSubject<Void, Never>()
|
||||
private var dataSource: UITableViewDiffableDataSource<Section, Item>!
|
||||
|
||||
init(mastodonController: MastodonController) {
|
||||
self.mastodonController = mastodonController
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
super.init(style: .grouped)
|
||||
|
||||
dragEnabled = true
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
@ -37,259 +34,72 @@ class TrendingLinksViewController: UIViewController, CollectionViewController {
|
|||
|
||||
title = NSLocalizedString("Trending Links", comment: "trending links screen title")
|
||||
|
||||
let layout = UICollectionViewCompositionalLayout { [unowned self] sectionIndex, environment in
|
||||
switch dataSource.sectionIdentifier(for: sectionIndex) {
|
||||
case nil:
|
||||
fatalError()
|
||||
|
||||
case .loadingIndicator:
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
config.backgroundColor = .appGroupedBackground
|
||||
config.showsSeparators = false
|
||||
return .list(using: config, layoutEnvironment: environment)
|
||||
|
||||
case .links:
|
||||
let size = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(280))
|
||||
let item = NSCollectionLayoutItem(layoutSize: size)
|
||||
let item2 = NSCollectionLayoutItem(layoutSize: size)
|
||||
let group = NSCollectionLayoutGroup.vertical(layoutSize: size, subitems: [item, item2])
|
||||
group.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16)
|
||||
group.interItemSpacing = .fixed(16)
|
||||
let section = NSCollectionLayoutSection(group: group)
|
||||
section.interGroupSpacing = 16
|
||||
section.contentInsets = NSDirectionalEdgeInsets(top: 16, leading: 0, bottom: 16, trailing: 0)
|
||||
return section
|
||||
}
|
||||
}
|
||||
collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
collectionView.translatesAutoresizingMaskIntoConstraints = false
|
||||
collectionView.delegate = self
|
||||
collectionView.dragDelegate = self
|
||||
collectionView.backgroundColor = .appGroupedBackground
|
||||
collectionView.allowsFocus = true
|
||||
view.addSubview(collectionView)
|
||||
NSLayoutConstraint.activate([
|
||||
collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||
collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||
collectionView.topAnchor.constraint(equalTo: view.topAnchor),
|
||||
collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||
])
|
||||
tableView.register(TrendingLinkTableViewCell.self, forCellReuseIdentifier: "trendingLinkCell")
|
||||
tableView.estimatedRowHeight = 100
|
||||
tableView.allowsFocus = true
|
||||
|
||||
dataSource = createDataSource()
|
||||
}
|
||||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
|
||||
cell.indicator.startAnimating()
|
||||
}
|
||||
let linkCell = UICollectionView.CellRegistration<TrendingLinkCardCollectionViewCell, Card>(cellNib: UINib(nibName: "TrendingLinkCardCollectionViewCell", bundle: .main)) { cell, indexPath, item in
|
||||
cell.verticalSize = .compact
|
||||
cell.updateUI(card: item)
|
||||
}
|
||||
let confirmLoadMoreCell = UICollectionView.CellRegistration<ConfirmLoadMoreCollectionViewCell, Bool> { cell, indexPath, isLoading in
|
||||
cell.confirmLoadMore = self.confirmLoadMore
|
||||
cell.isLoading = isLoading
|
||||
}
|
||||
return UICollectionViewDiffableDataSource(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
|
||||
switch itemIdentifier {
|
||||
case .loadingIndicator:
|
||||
return collectionView.dequeueConfiguredReusableCell(using: loadingCell, for: indexPath, item: ())
|
||||
case .link(let card):
|
||||
return collectionView.dequeueConfiguredReusableCell(using: linkCell, for: indexPath, item: card)
|
||||
case .confirmLoadMore(let loading):
|
||||
return collectionView.dequeueConfiguredReusableCell(using: confirmLoadMoreCell, for: indexPath, item: loading)
|
||||
}
|
||||
}
|
||||
dataSource = UITableViewDiffableDataSource(tableView: tableView, cellProvider: { tableView, indexPath, item in
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "trendingLinkCell", for: indexPath) as! TrendingLinkTableViewCell
|
||||
cell.updateUI(card: item.card)
|
||||
return cell
|
||||
})
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
let request = Client.getTrendingLinks()
|
||||
Task {
|
||||
await loadInitial()
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func loadInitial() async {
|
||||
guard case .unloaded = state else {
|
||||
return
|
||||
}
|
||||
state = .loading
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.loadingIndicator])
|
||||
snapshot.appendItems([.loadingIndicator])
|
||||
await dataSource.apply(snapshot)
|
||||
|
||||
do {
|
||||
let request = Client.getTrendingLinks()
|
||||
let (links, _) = try await mastodonController.run(request)
|
||||
snapshot.deleteSections([.loadingIndicator])
|
||||
guard let (links, _) = try? await mastodonController.run(request) else {
|
||||
return
|
||||
}
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.links])
|
||||
snapshot.appendItems(links.map { .link($0) })
|
||||
state = .loaded
|
||||
snapshot.appendItems(links.map(Item.init))
|
||||
await dataSource.apply(snapshot)
|
||||
} catch {
|
||||
await dataSource.apply(NSDiffableDataSourceSnapshot())
|
||||
state = .unloaded
|
||||
let config = ToastConfiguration(from: error, with: "Error Loading Trending Links", in: self) { [weak self] toast in
|
||||
toast.dismissToast(animated: true)
|
||||
await self?.loadInitial()
|
||||
}
|
||||
self.showToast(configuration: config, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func loadOlder() async {
|
||||
guard case .loaded = state else {
|
||||
return
|
||||
}
|
||||
state = .loadingOlder
|
||||
|
||||
let origSnapshot = dataSource.snapshot()
|
||||
var snapshot = origSnapshot
|
||||
if Preferences.shared.disableInfiniteScrolling {
|
||||
snapshot.appendSections([.loadingIndicator])
|
||||
snapshot.appendItems([.confirmLoadMore(false)], toSection: .loadingIndicator)
|
||||
await dataSource.apply(snapshot)
|
||||
|
||||
for await _ in confirmLoadMore.values {
|
||||
break
|
||||
}
|
||||
|
||||
snapshot.deleteItems([.confirmLoadMore(false)])
|
||||
snapshot.appendItems([.confirmLoadMore(true)], toSection: .loadingIndicator)
|
||||
await dataSource.apply(snapshot, animatingDifferences: false)
|
||||
} else {
|
||||
snapshot.appendSections([.loadingIndicator])
|
||||
snapshot.appendItems([.loadingIndicator], toSection: .loadingIndicator)
|
||||
await dataSource.apply(snapshot)
|
||||
}
|
||||
|
||||
do {
|
||||
let request = Client.getTrendingLinks(offset: origSnapshot.itemIdentifiers.count)
|
||||
let (links, _) = try await mastodonController.run(request)
|
||||
var snapshot = origSnapshot
|
||||
snapshot.appendItems(links.map { .link($0) }, toSection: .links)
|
||||
await dataSource.apply(snapshot)
|
||||
} catch {
|
||||
await dataSource.apply(origSnapshot)
|
||||
let config = ToastConfiguration(from: error, with: "Erorr Loading More Links", in: self) { [weak self] toast in
|
||||
toast.dismissToast(animated: true)
|
||||
await self?.loadOlder()
|
||||
}
|
||||
self.showToast(configuration: config, animated: true)
|
||||
}
|
||||
}
|
||||
// MARK: - Table View Delegate
|
||||
|
||||
}
|
||||
|
||||
extension TrendingLinksViewController {
|
||||
enum State {
|
||||
case unloaded
|
||||
case loading
|
||||
case loaded
|
||||
case loadingOlder
|
||||
}
|
||||
}
|
||||
|
||||
extension TrendingLinksViewController {
|
||||
enum Section {
|
||||
case loadingIndicator
|
||||
case links
|
||||
}
|
||||
enum Item: Hashable {
|
||||
case loadingIndicator
|
||||
case link(Card)
|
||||
case confirmLoadMore(Bool)
|
||||
|
||||
static func ==(lhs: Item, rhs: Item) -> Bool {
|
||||
switch (lhs, rhs) {
|
||||
case (.loadingIndicator, .loadingIndicator):
|
||||
return true
|
||||
case (.link(let a), .link(let b)):
|
||||
return a.url == b.url
|
||||
case (.confirmLoadMore(let a), .confirmLoadMore(let b)):
|
||||
return a == b
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
switch self {
|
||||
case .loadingIndicator:
|
||||
hasher.combine(0)
|
||||
case .link(let card):
|
||||
hasher.combine(1)
|
||||
hasher.combine(card.url)
|
||||
case .confirmLoadMore(let loading):
|
||||
hasher.combine(2)
|
||||
hasher.combine(loading)
|
||||
}
|
||||
}
|
||||
|
||||
var shouldSelect: Bool {
|
||||
if case .link(_) = self {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension TrendingLinksViewController: UICollectionViewDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
||||
if indexPath.section == collectionView.numberOfSections - 1,
|
||||
indexPath.row == collectionView.numberOfItems(inSection: indexPath.section) - 1 {
|
||||
Task {
|
||||
await loadOlder()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
|
||||
return dataSource.itemIdentifier(for: indexPath)?.shouldSelect ?? false
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
guard case .link(let card) = dataSource.itemIdentifier(for: indexPath),
|
||||
let url = URL(card.url) else {
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
guard let item = dataSource.itemIdentifier(for: indexPath),
|
||||
let url = URL(item.card.url) else {
|
||||
return
|
||||
}
|
||||
selected(url: url)
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
|
||||
guard case .link(let card) = dataSource.itemIdentifier(for: indexPath),
|
||||
let url = URL(card.url),
|
||||
let cell = collectionView.cellForItem(at: indexPath) else {
|
||||
override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
|
||||
guard let item = dataSource.itemIdentifier(for: indexPath),
|
||||
let url = URL(item.card.url) else {
|
||||
return nil
|
||||
}
|
||||
return UIContextMenuConfiguration {
|
||||
return UIContextMenuConfiguration(identifier: nil) {
|
||||
let vc = SFSafariViewController(url: url)
|
||||
vc.preferredControlTintColor = Preferences.shared.accentColor.color
|
||||
return vc
|
||||
} actionProvider: { _ in
|
||||
UIMenu(children: self.actionsForTrendingLink(card: card, source: .view(cell)))
|
||||
return UIMenu(children: self.actionsForTrendingLink(card: item.card))
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) {
|
||||
MenuPreviewHelper.willPerformPreviewAction(animator: animator, presenter: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension TrendingLinksViewController: UICollectionViewDragDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
|
||||
guard case .link(let card) = dataSource.itemIdentifier(for: indexPath),
|
||||
let url = URL(card.url) else {
|
||||
return []
|
||||
extension TrendingLinksViewController {
|
||||
enum Section {
|
||||
case links
|
||||
}
|
||||
struct Item: Hashable {
|
||||
let card: Card
|
||||
|
||||
static func ==(lhs: Item, rhs: Item) -> Bool {
|
||||
return lhs.card.url == rhs.card.url
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(card.url)
|
||||
}
|
||||
return [UIDragItem(itemProvider: NSItemProvider(object: url as NSURL))]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
import UIKit
|
||||
import Pachyderm
|
||||
import SafariServices
|
||||
import Combine
|
||||
|
||||
class TrendsViewController: UIViewController, CollectionViewController {
|
||||
|
||||
|
@ -19,8 +18,6 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
|
||||
|
||||
private var loadTask: Task<Void, Never>?
|
||||
private var trendingStatusesState = TrendingStatusesState.unloaded
|
||||
private let confirmLoadMoreStatuses = PassthroughSubject<Void, Never>()
|
||||
|
||||
private var isShowingTrends = false
|
||||
private var shouldShowTrends: Bool {
|
||||
|
@ -45,17 +42,9 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
let layout = UICollectionViewCompositionalLayout { [unowned self] sectionIndex, environment in
|
||||
let sectionIdentifier = self.dataSource.snapshot().sectionIdentifiers[sectionIndex]
|
||||
switch sectionIdentifier {
|
||||
case .loadingIndicator:
|
||||
var listConfig = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
listConfig.backgroundColor = .appGroupedBackground
|
||||
listConfig.showsSeparators = false
|
||||
return .list(using: listConfig, layoutEnvironment: environment)
|
||||
|
||||
case .trendingHashtags:
|
||||
var listConfig = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
listConfig.headerMode = .supplementary
|
||||
listConfig.footerMode = .supplementary
|
||||
listConfig.backgroundColor = .appGroupedBackground
|
||||
return .list(using: listConfig, layoutEnvironment: environment)
|
||||
|
||||
case .trendingLinks:
|
||||
|
@ -67,10 +56,9 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
let section = NSCollectionLayoutSection(group: group)
|
||||
section.orthogonalScrollingBehavior = .groupPaging
|
||||
section.boundarySupplementaryItems = [
|
||||
NSCollectionLayoutBoundarySupplementaryItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(12)), elementKind: UICollectionView.elementKindSectionHeader, alignment: .topLeading),
|
||||
NSCollectionLayoutBoundarySupplementaryItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(30)), elementKind: UICollectionView.elementKindSectionFooter, alignment: .bottomLeading),
|
||||
NSCollectionLayoutBoundarySupplementaryItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(12)), elementKind: UICollectionView.elementKindSectionHeader, alignment: .topLeading)
|
||||
]
|
||||
section.contentInsets = .zero
|
||||
section.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 0, bottom: 16, trailing: 0)
|
||||
return section
|
||||
|
||||
case .profileSuggestions:
|
||||
|
@ -82,25 +70,14 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
let section = NSCollectionLayoutSection(group: group)
|
||||
section.orthogonalScrollingBehavior = .groupPaging
|
||||
section.boundarySupplementaryItems = [
|
||||
NSCollectionLayoutBoundarySupplementaryItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(12)), elementKind: UICollectionView.elementKindSectionHeader, alignment: .topLeading),
|
||||
NSCollectionLayoutBoundarySupplementaryItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(30)), elementKind: UICollectionView.elementKindSectionFooter, alignment: .bottomLeading),
|
||||
NSCollectionLayoutBoundarySupplementaryItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .estimated(12)), elementKind: UICollectionView.elementKindSectionHeader, alignment: .topLeading)
|
||||
]
|
||||
section.contentInsets = .zero
|
||||
section.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 0, bottom: 16, trailing: 0)
|
||||
return section
|
||||
|
||||
case .trendingStatuses:
|
||||
var listConfig = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
listConfig.headerMode = .supplementary
|
||||
listConfig.backgroundColor = .appGroupedBackground
|
||||
listConfig.itemSeparatorHandler = { [unowned self] indexPath, sectionConfig in
|
||||
var config = sectionConfig
|
||||
if let item = dataSource.itemIdentifier(for: indexPath),
|
||||
item.hideListSeparators {
|
||||
config.topSeparatorVisibility = .hidden
|
||||
config.bottomSeparatorVisibility = .hidden
|
||||
}
|
||||
return config
|
||||
}
|
||||
return .list(using: listConfig, layoutEnvironment: environment)
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +85,7 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
||||
collectionView.delegate = self
|
||||
collectionView.dragDelegate = self
|
||||
collectionView.backgroundColor = .appGroupedBackground
|
||||
collectionView.backgroundColor = .secondarySystemBackground
|
||||
collectionView.allowsFocus = true
|
||||
view.addSubview(collectionView)
|
||||
|
||||
|
@ -119,35 +96,19 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
let sectionHeaderCell = UICollectionView.SupplementaryRegistration<UICollectionViewListCell>(elementKind: UICollectionView.elementKindSectionHeader) { [unowned self] (headerView, collectionView, indexPath) in
|
||||
let section = self.dataSource.sectionIdentifier(for: indexPath.section)!
|
||||
let section = self.dataSource.snapshot().sectionIdentifiers[indexPath.section]
|
||||
var config = UIListContentConfiguration.groupedHeader()
|
||||
config.text = section.title
|
||||
headerView.contentConfiguration = config
|
||||
}
|
||||
let moreCell = UICollectionView.SupplementaryRegistration<MoreTrendsFooterCollectionViewCell>(elementKind: UICollectionView.elementKindSectionFooter) { [unowned self] supplementaryView, elementKind, indexPath in
|
||||
supplementaryView.delegate = self
|
||||
switch self.dataSource.sectionIdentifier(for: indexPath.section) {
|
||||
case nil, .loadingIndicator, .trendingStatuses:
|
||||
fatalError()
|
||||
case .trendingHashtags:
|
||||
supplementaryView.updateUI(.hashtags)
|
||||
case .trendingLinks:
|
||||
supplementaryView.updateUI(.links)
|
||||
case .profileSuggestions:
|
||||
supplementaryView.updateUI(.profileSuggestions)
|
||||
}
|
||||
}
|
||||
|
||||
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
|
||||
cell.indicator.startAnimating()
|
||||
}
|
||||
let trendingHashtagCell = UICollectionView.CellRegistration<TrendingHashtagCollectionViewCell, Hashtag> { (cell, indexPath, hashtag) in
|
||||
cell.updateUI(hashtag: hashtag)
|
||||
}
|
||||
let trendingLinkCell = UICollectionView.CellRegistration<TrendingLinkCardCollectionViewCell, Card>(cellNib: UINib(nibName: "TrendingLinkCardCollectionViewCell", bundle: .main)) { (cell, indexPath, card) in
|
||||
cell.updateUI(card: card)
|
||||
}
|
||||
let statusCell = UICollectionView.CellRegistration<TrendingStatusCollectionViewCell, (String, CollapseState)> { [unowned self] cell, indexPath, item in
|
||||
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, CollapseState)> { [unowned self] cell, indexPath, item in
|
||||
cell.delegate = self
|
||||
// TODO: filter trends
|
||||
cell.updateUI(statusID: item.0, state: item.1, filterResult: .allow, precomputedContent: nil)
|
||||
|
@ -156,16 +117,9 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
cell.delegate = self
|
||||
cell.updateUI(accountID: item.0, source: item.1)
|
||||
}
|
||||
let confirmLoadMoreCell = UICollectionView.CellRegistration<ConfirmLoadMoreCollectionViewCell, Bool> { [unowned self] cell, indexPath, isLoading in
|
||||
cell.confirmLoadMore = self.confirmLoadMoreStatuses
|
||||
cell.isLoading = isLoading
|
||||
}
|
||||
|
||||
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, item in
|
||||
switch item {
|
||||
case .loadingIndicator:
|
||||
return collectionView.dequeueConfiguredReusableCell(using: loadingCell, for: indexPath, item: ())
|
||||
|
||||
case let .tag(hashtag):
|
||||
return collectionView.dequeueConfiguredReusableCell(using: trendingHashtagCell, for: indexPath, item: hashtag)
|
||||
|
||||
|
@ -177,16 +131,11 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
|
||||
case let .account(id, source):
|
||||
return collectionView.dequeueConfiguredReusableCell(using: accountCell, for: indexPath, item: (id, source))
|
||||
|
||||
case let .confirmLoadMoreStatuses(loading):
|
||||
return collectionView.dequeueConfiguredReusableCell(using: confirmLoadMoreCell, for: indexPath, item: loading)
|
||||
}
|
||||
}
|
||||
dataSource.supplementaryViewProvider = { (collectionView, elementKind, indexPath) in
|
||||
if elementKind == UICollectionView.elementKindSectionHeader {
|
||||
return collectionView.dequeueConfiguredReusableSupplementary(using: sectionHeaderCell, for: indexPath)
|
||||
} else if elementKind == UICollectionView.elementKindSectionFooter {
|
||||
return collectionView.dequeueConfiguredReusableSupplementary(using: moreCell, for: indexPath)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
@ -220,11 +169,6 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
}
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.loadingIndicator])
|
||||
snapshot.appendItems([.loadingIndicator])
|
||||
await apply(snapshot: snapshot)
|
||||
|
||||
snapshot = NSDiffableDataSourceSnapshot()
|
||||
|
||||
let hashtagsReq = Client.getTrendingHashtags(limit: 5)
|
||||
let hashtags = try? await mastodonController.run(hashtagsReq).0
|
||||
|
@ -268,60 +212,9 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
|
||||
if !Task.isCancelled {
|
||||
await apply(snapshot: snapshot)
|
||||
if snapshot.sectionIdentifiers.contains(.trendingStatuses) {
|
||||
self.trendingStatusesState = .loaded
|
||||
} else {
|
||||
self.trendingStatusesState = .unloaded
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func loadOlderStatuses() async {
|
||||
guard case .loaded = trendingStatusesState else {
|
||||
return
|
||||
}
|
||||
trendingStatusesState = .loadingOlder
|
||||
|
||||
let origSnapshot = dataSource.snapshot()
|
||||
var snapshot = origSnapshot
|
||||
if Preferences.shared.disableInfiniteScrolling {
|
||||
snapshot.appendItems([.confirmLoadMoreStatuses(false)], toSection: .trendingStatuses)
|
||||
await apply(snapshot: snapshot)
|
||||
|
||||
for await _ in confirmLoadMoreStatuses.values {
|
||||
break
|
||||
}
|
||||
|
||||
snapshot.deleteItems([.confirmLoadMoreStatuses(false)])
|
||||
snapshot.appendItems([.confirmLoadMoreStatuses(true)], toSection: .trendingStatuses)
|
||||
await apply(snapshot: snapshot, animatingDifferences: false)
|
||||
} else {
|
||||
snapshot.appendItems([.loadingIndicator], toSection: .trendingStatuses)
|
||||
await apply(snapshot: snapshot)
|
||||
}
|
||||
|
||||
do {
|
||||
let request = Client.getTrendingStatuses(offset: origSnapshot.itemIdentifiers(inSection: .trendingStatuses).count)
|
||||
let (statuses, _) = try await mastodonController.run(request)
|
||||
|
||||
await mastodonController.persistentContainer.addAll(statuses: statuses)
|
||||
|
||||
var snapshot = origSnapshot
|
||||
snapshot.appendItems(statuses.map { .status($0.id, .unknown) }, toSection: .trendingStatuses)
|
||||
await apply(snapshot: snapshot)
|
||||
} catch {
|
||||
await apply(snapshot: origSnapshot)
|
||||
let config = ToastConfiguration(from: error, with: "Error Loading More Trending Statuses", in: self) { [weak self] toast in
|
||||
toast.dismissToast(animated: true)
|
||||
await self?.loadOlderStatuses()
|
||||
}
|
||||
showToast(configuration: config, animated: true)
|
||||
}
|
||||
|
||||
trendingStatusesState = .loaded
|
||||
}
|
||||
|
||||
@objc private func preferencesChanged() {
|
||||
if isShowingTrends != shouldShowTrends {
|
||||
loadTask?.cancel()
|
||||
|
@ -331,9 +224,9 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
}
|
||||
}
|
||||
|
||||
private func apply(snapshot: NSDiffableDataSourceSnapshot<Section, Item>, animatingDifferences: Bool = true) async {
|
||||
private func apply(snapshot: NSDiffableDataSourceSnapshot<Section, Item>) async {
|
||||
await Task { @MainActor in
|
||||
self.dataSource.apply(snapshot, animatingDifferences: animatingDifferences)
|
||||
self.dataSource.apply(snapshot)
|
||||
}.value
|
||||
}
|
||||
|
||||
|
@ -356,26 +249,15 @@ class TrendsViewController: UIViewController, CollectionViewController {
|
|||
}
|
||||
}
|
||||
|
||||
extension TrendsViewController {
|
||||
enum TrendingStatusesState {
|
||||
case unloaded
|
||||
case loaded
|
||||
case loadingOlder
|
||||
}
|
||||
}
|
||||
|
||||
extension TrendsViewController {
|
||||
enum Section {
|
||||
case loadingIndicator
|
||||
case trendingHashtags
|
||||
case trendingLinks
|
||||
case profileSuggestions
|
||||
case trendingStatuses
|
||||
|
||||
var title: String? {
|
||||
var title: String {
|
||||
switch self {
|
||||
case .loadingIndicator:
|
||||
return nil
|
||||
case .trendingHashtags:
|
||||
return "Trending Hashtags"
|
||||
case .trendingLinks:
|
||||
|
@ -388,17 +270,13 @@ extension TrendsViewController {
|
|||
}
|
||||
}
|
||||
enum Item: Equatable, Hashable {
|
||||
case loadingIndicator
|
||||
case status(String, CollapseState)
|
||||
case tag(Hashtag)
|
||||
case link(Card)
|
||||
case account(String, Suggestion.Source)
|
||||
case confirmLoadMoreStatuses(Bool)
|
||||
|
||||
static func == (lhs: Item, rhs: Item) -> Bool {
|
||||
switch (lhs, rhs) {
|
||||
case (.loadingIndicator, .loadingIndicator):
|
||||
return true
|
||||
case let (.status(a, _), .status(b, _)):
|
||||
return a == b
|
||||
case let (.tag(a), .tag(b)):
|
||||
|
@ -407,8 +285,6 @@ extension TrendsViewController {
|
|||
return a.url == b.url
|
||||
case let (.account(a, _), .account(b, _)):
|
||||
return a == b
|
||||
case (.confirmLoadMoreStatuses(let a), .confirmLoadMoreStatuses(let b)):
|
||||
return a == b
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
@ -416,8 +292,6 @@ extension TrendsViewController {
|
|||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
switch self {
|
||||
case .loadingIndicator:
|
||||
hasher.combine("loadingIndicator")
|
||||
case let .status(id, _):
|
||||
hasher.combine("status")
|
||||
hasher.combine(id)
|
||||
|
@ -430,54 +304,17 @@ extension TrendsViewController {
|
|||
case let .account(id, _):
|
||||
hasher.combine("account")
|
||||
hasher.combine(id)
|
||||
case let .confirmLoadMoreStatuses(loading):
|
||||
hasher.combine("confirmLoadMoreStatuses")
|
||||
hasher.combine(loading)
|
||||
}
|
||||
}
|
||||
|
||||
var shouldSelect: Bool {
|
||||
switch self {
|
||||
case .loadingIndicator, .confirmLoadMoreStatuses(_):
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
var hideListSeparators: Bool {
|
||||
switch self {
|
||||
case .loadingIndicator, .confirmLoadMoreStatuses(_):
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension TrendsViewController: UICollectionViewDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
||||
if case .trendingStatuses = dataSource.sectionIdentifier(for: indexPath.section),
|
||||
indexPath.row == collectionView.numberOfItems(inSection: indexPath.section) - 1 {
|
||||
Task {
|
||||
await self.loadOlderStatuses()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
|
||||
return dataSource.itemIdentifier(for: indexPath)?.shouldSelect ?? false
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
guard let item = dataSource.itemIdentifier(for: indexPath) else {
|
||||
return
|
||||
}
|
||||
switch item {
|
||||
case .loadingIndicator, .confirmLoadMoreStatuses(_):
|
||||
return
|
||||
|
||||
case let .tag(hashtag):
|
||||
show(HashtagTimelineViewController(for: hashtag, mastodonController: mastodonController), sender: nil)
|
||||
|
||||
|
@ -501,9 +338,6 @@ extension TrendsViewController: UICollectionViewDelegate {
|
|||
}
|
||||
|
||||
switch item {
|
||||
case .loadingIndicator, .confirmLoadMoreStatuses(_):
|
||||
return nil
|
||||
|
||||
case let .tag(hashtag):
|
||||
return UIContextMenuConfiguration(identifier: nil) {
|
||||
HashtagTimelineViewController(for: hashtag, mastodonController: self.mastodonController)
|
||||
|
@ -515,13 +349,12 @@ extension TrendsViewController: UICollectionViewDelegate {
|
|||
guard let url = URL(card.url) else {
|
||||
return nil
|
||||
}
|
||||
let cell = collectionView.cellForItem(at: indexPath)!
|
||||
return UIContextMenuConfiguration {
|
||||
let vc = SFSafariViewController(url: url)
|
||||
vc.preferredControlTintColor = Preferences.shared.accentColor.color
|
||||
return vc
|
||||
} actionProvider: { _ in
|
||||
UIMenu(children: self.actionsForTrendingLink(card: card, source: .view(cell)))
|
||||
UIMenu(children: self.actionsForTrendingLink(card: card))
|
||||
}
|
||||
|
||||
case let .status(id, state):
|
||||
|
@ -589,9 +422,6 @@ extension TrendsViewController: UICollectionViewDragDelegate {
|
|||
return []
|
||||
}
|
||||
switch item {
|
||||
case .loadingIndicator, .confirmLoadMoreStatuses(_):
|
||||
return []
|
||||
|
||||
case let .tag(hashtag):
|
||||
guard let url = URL(hashtag.url) else {
|
||||
return []
|
||||
|
|
|
@ -50,7 +50,7 @@ class FindInstanceViewController: InstanceSelectorTableViewController {
|
|||
extension FindInstanceViewController: InstanceSelectorTableViewControllerDelegate {
|
||||
func didSelectInstance(url: URL) {
|
||||
let instanceTimelineController = InstanceTimelineViewController(for: url, parentMastodonController: parentMastodonController!)
|
||||
instanceTimelineController.instanceTimelineDelegate = instanceTimelineDelegate
|
||||
instanceTimelineController.delegate = instanceTimelineDelegate
|
||||
instanceTimelineController.browsingEnabled = false
|
||||
show(instanceTimelineController, sender: self)
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ class EditListAccountsViewController: EnhancedTableViewController {
|
|||
tableView.rowHeight = UITableView.automaticDimension
|
||||
tableView.estimatedRowHeight = 66
|
||||
tableView.allowsSelection = false
|
||||
tableView.backgroundColor = .appGroupedBackground
|
||||
|
||||
dataSource = DataSource(tableView: tableView, cellProvider: { (tableView, indexPath, item) -> UITableViewCell? in
|
||||
guard case let .account(id) = item else { fatalError() }
|
||||
|
@ -62,15 +61,6 @@ class EditListAccountsViewController: EnhancedTableViewController {
|
|||
let cell = tableView.dequeueReusableCell(withIdentifier: "accountCell", for: indexPath) as! AccountTableViewCell
|
||||
cell.delegate = self
|
||||
cell.updateUI(accountID: id)
|
||||
cell.configurationUpdateHandler = { cell, state in
|
||||
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appGroupedCellBackground
|
||||
}
|
||||
cell.backgroundConfiguration = config
|
||||
}
|
||||
return cell
|
||||
})
|
||||
dataSource.editListAccountsController = self
|
||||
|
|
|
@ -45,7 +45,6 @@ class LocalPredicateStatusesViewController: UIViewController, CollectionViewCont
|
|||
|
||||
override func loadView() {
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .plain)
|
||||
config.backgroundColor = .appBackground
|
||||
config.leadingSwipeActionsConfigurationProvider = { [unowned self] in
|
||||
(collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.leadingSwipeActions()
|
||||
}
|
||||
|
|
|
@ -85,7 +85,6 @@ struct MuteAccountView: View {
|
|||
Text("This user's posts will be hidden from your timeline. You can still receive notifications from them.")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
Section {
|
||||
Picker(selection: $duration) {
|
||||
|
@ -100,7 +99,6 @@ struct MuteAccountView: View {
|
|||
Text("The mute will automatically be removed after the selected time.")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
Button(action: self.mute) {
|
||||
if isMuting {
|
||||
|
@ -115,9 +113,7 @@ struct MuteAccountView: View {
|
|||
}
|
||||
}
|
||||
.disabled(isMuting)
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
.appGroupedListBackground(container: UIHostingController<MuteAccountView>.self)
|
||||
.alertWithData("Erorr Muting", data: $error, actions: { error in
|
||||
Button("OK") {}
|
||||
}, message: { error in
|
||||
|
|
|
@ -58,7 +58,6 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
|||
|
||||
tableView.cellLayoutMarginsFollowReadableWidth = UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac
|
||||
tableView.allowsFocus = true
|
||||
tableView.backgroundColor = .appBackground
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil)
|
||||
}
|
||||
|
|
|
@ -63,7 +63,6 @@ class InstanceSelectorTableViewController: UITableViewController {
|
|||
appearance.configureWithDefaultBackground()
|
||||
navigationItem.scrollEdgeAppearance = appearance
|
||||
|
||||
tableView.backgroundColor = .appGroupedBackground
|
||||
tableView.keyboardDismissMode = .interactive
|
||||
tableView.register(UINib(nibName: "InstanceTableViewCell", bundle: .main), forCellReuseIdentifier: instanceCell)
|
||||
tableView.rowHeight = UITableView.automaticDimension
|
||||
|
@ -108,10 +107,6 @@ class InstanceSelectorTableViewController: UITableViewController {
|
|||
}
|
||||
.debounce(for: .seconds(1), scheduler: RunLoop.main)
|
||||
.sink { [weak self] in self?.updateSpecificInstance(domain: $0) }
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
loadRecommendedInstances()
|
||||
}
|
||||
|
@ -208,7 +203,7 @@ class InstanceSelectorTableViewController: UITableViewController {
|
|||
private func createActivityIndicatorHeader() {
|
||||
let header = UITableViewHeaderFooterView()
|
||||
header.translatesAutoresizingMaskIntoConstraints = false
|
||||
header.contentView.backgroundColor = .appGroupedBackground
|
||||
header.contentView.backgroundColor = .systemGroupedBackground
|
||||
|
||||
activityIndicator = UIActivityIndicatorView(style: .large)
|
||||
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
|
|
@ -42,7 +42,6 @@ struct AboutView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
Section {
|
||||
Link("Website", destination: URL(string: "https://vaccor.space/tusker")!)
|
||||
|
@ -68,10 +67,7 @@ struct AboutView: View {
|
|||
Link("Source Code", destination: URL(string: "https://git.shadowfacts.net/shadowfacts/Tusker")!)
|
||||
Link("Issue Tracker", destination: URL(string: "https://git.shadowfacts.net/shadowfacts/Tusker/issues")!)
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.appGroupedListBackground(container: PreferencesNavigationController.self)
|
||||
.sheet(isPresented: $isShowingMailSheet) {
|
||||
MailSheet(logData: logData)
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ struct AcknowledgementsView: View {
|
|||
Text(text)
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
.appGroupedListBackground(container: PreferencesNavigationController.self)
|
||||
.navigationTitle("Acknowledgements")
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@ struct AdvancedPrefsView : View {
|
|||
errorReportingSection
|
||||
cachingSection
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.appGroupedListBackground(container: PreferencesNavigationController.self)
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.navigationBarTitle(Text("Advanced"))
|
||||
}
|
||||
|
||||
|
@ -51,7 +50,6 @@ struct AdvancedPrefsView : View {
|
|||
// see FB6838291
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
var cloudKitSection: some View {
|
||||
|
@ -76,9 +74,7 @@ struct AdvancedPrefsView : View {
|
|||
Text(String(describing: cloudKitStatus!))
|
||||
}
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
.task {
|
||||
}.task {
|
||||
CKContainer.default().accountStatus { status, error in
|
||||
if let error {
|
||||
Logging.general.error("Unable to get CloudKit status: \(String(describing: error))")
|
||||
|
@ -103,7 +99,6 @@ struct AdvancedPrefsView : View {
|
|||
.lineLimit(nil)
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
var cachingSection: some View {
|
||||
|
@ -125,9 +120,7 @@ struct AdvancedPrefsView : View {
|
|||
s += AttributedString("\nMastodon cache size: \(ByteCountFormatter().string(fromByteCount: mastodonCacheSize))")
|
||||
}
|
||||
return Text(s)
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
.task {
|
||||
}.task {
|
||||
imageCacheSize = [
|
||||
ImageCache.avatars,
|
||||
.headers,
|
||||
|
|
|
@ -6,19 +6,21 @@
|
|||
//
|
||||
|
||||
import SwiftUI
|
||||
import Combine
|
||||
|
||||
struct AppearancePrefsView : View {
|
||||
@ObservedObject var preferences = Preferences.shared
|
||||
|
||||
private var appearanceChangePublisher: some Publisher<Void, Never> {
|
||||
preferences.$theme
|
||||
.map { _ in () }
|
||||
.merge(with: preferences.$pureBlackDarkMode.map { _ in () },
|
||||
preferences.$accentColor.map { _ in () }
|
||||
)
|
||||
// the prefrence publishers are all willSet, but want to notify after the change, so wait one runloop iteration
|
||||
.receive(on: DispatchQueue.main)
|
||||
private var theme: Binding<UIUserInterfaceStyle> = Binding(get: {
|
||||
Preferences.shared.theme
|
||||
}, set: {
|
||||
Preferences.shared.theme = $0
|
||||
NotificationCenter.default.post(name: .themePreferenceChanged, object: nil)
|
||||
})
|
||||
private var accentColor: Binding<Preferences.AccentColor> = Binding {
|
||||
Preferences.shared.accentColor
|
||||
} set: {
|
||||
Preferences.shared.accentColor = $0
|
||||
NotificationCenter.default.post(name: .themePreferenceChanged, object: nil)
|
||||
}
|
||||
|
||||
private var useCircularAvatars: Binding<Bool> = Binding(get: {
|
||||
|
@ -48,27 +50,19 @@ struct AppearancePrefsView : View {
|
|||
accountsSection
|
||||
postsSection
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.appGroupedListBackground(container: PreferencesNavigationController.self)
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.navigationBarTitle(Text("Appearance"))
|
||||
}
|
||||
|
||||
private var themeSection: some View {
|
||||
Section {
|
||||
Picker(selection: $preferences.theme, label: Text("Theme")) {
|
||||
Picker(selection: theme, label: Text("Theme")) {
|
||||
Text("Use System Theme").tag(UIUserInterfaceStyle.unspecified)
|
||||
Text("Light").tag(UIUserInterfaceStyle.light)
|
||||
Text("Dark").tag(UIUserInterfaceStyle.dark)
|
||||
}
|
||||
|
||||
// macOS system dark mode isn't pure black, so this isn't necessary
|
||||
if !ProcessInfo.processInfo.isMacCatalystApp && !ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
Toggle(isOn: $preferences.pureBlackDarkMode) {
|
||||
Text("Pure Black Dark Mode")
|
||||
}
|
||||
}
|
||||
|
||||
Picker(selection: $preferences.accentColor, label: Text("Accent Color")) {
|
||||
Picker(selection: accentColor, label: Text("Accent Color")) {
|
||||
ForEach(accentColorsAndImages, id: \.0.rawValue) { (color, image) in
|
||||
HStack {
|
||||
Text(color.name)
|
||||
|
@ -81,10 +75,6 @@ struct AppearancePrefsView : View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.onReceive(appearanceChangePublisher) { _ in
|
||||
NotificationCenter.default.post(name: .themePreferenceChanged, object: nil)
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
private var accountsSection: some View {
|
||||
|
@ -96,7 +86,6 @@ struct AppearancePrefsView : View {
|
|||
Text("Hide Custom Emoji in Usernames")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
private var postsSection: some View {
|
||||
|
@ -124,7 +113,6 @@ struct AppearancePrefsView : View {
|
|||
.navigationTitle("Trailing Swipe Actions")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@ struct BehaviorPrefsView: View {
|
|||
linksSection
|
||||
contentWarningsSection
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.appGroupedListBackground(container: PreferencesNavigationController.self)
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.navigationBarTitle(Text("Behavior"))
|
||||
}
|
||||
|
||||
|
@ -29,7 +28,6 @@ struct BehaviorPrefsView: View {
|
|||
Text("Require Confirmation Before Reblogging")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
private var timelineSection: some View {
|
||||
|
@ -40,7 +38,6 @@ struct BehaviorPrefsView: View {
|
|||
} header: {
|
||||
Text("Timeline")
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
private var linksSection: some View {
|
||||
|
@ -55,7 +52,6 @@ struct BehaviorPrefsView: View {
|
|||
Text("Always Use Reader Mode in In-App Safari")
|
||||
}.disabled(!preferences.useInAppSafari)
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
private var contentWarningsSection: some View {
|
||||
|
@ -72,7 +68,6 @@ struct BehaviorPrefsView: View {
|
|||
Text(preferences.expandAllContentWarnings ? "Collapse Posts with Keywords in CWs" : "Expand Posts with Keywords in CWs")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ struct ComposingPrefsView: View {
|
|||
replyingSection
|
||||
writingSection
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.appGroupedListBackground(container: PreferencesNavigationController.self)
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.navigationBarTitle("Composing")
|
||||
}
|
||||
|
||||
|
@ -52,7 +51,6 @@ struct ComposingPrefsView: View {
|
|||
} footer: {
|
||||
Text("When starting a reply, Tusker will use your preferred visibility or the visibility of the post to which you're replying, whichever is narrower.")
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
var composingSection: some View {
|
||||
|
@ -64,7 +62,6 @@ struct ComposingPrefsView: View {
|
|||
Text("Require Attachment Descriptions")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
var replyingSection: some View {
|
||||
|
@ -78,7 +75,6 @@ struct ComposingPrefsView: View {
|
|||
Text("Mention Reblogger")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
var writingSection: some View {
|
||||
|
@ -87,7 +83,6 @@ struct ComposingPrefsView: View {
|
|||
Text("Show @ and # on Keyboard")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,8 +15,7 @@ struct MediaPrefsView: View {
|
|||
List {
|
||||
viewingSection
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.appGroupedListBackground(container: PreferencesNavigationController.self)
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.navigationBarTitle("Media")
|
||||
}
|
||||
|
||||
|
@ -43,7 +42,6 @@ struct MediaPrefsView: View {
|
|||
Text("Show Uncropped Media Inline")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ struct OppositeCollapseKeywordsView: View {
|
|||
ZStack {
|
||||
// the background from the grouped ListStyle clips to the safe area, so when the keyboard is hiding/showing
|
||||
// the color behind it can be seen, which looks odd
|
||||
// Color(UIColor.secondarySystemBackground)
|
||||
// .edgesIgnoringSafeArea(.bottom)
|
||||
Color(UIColor.secondarySystemBackground)
|
||||
.edgesIgnoringSafeArea(.bottom)
|
||||
|
||||
List {
|
||||
Section(footer: Text("A post matches if its content warning contains the text of a keyword, ignoring case.")) {
|
||||
|
@ -37,11 +37,9 @@ struct OppositeCollapseKeywordsView: View {
|
|||
|
||||
FocusableTextField(placeholder: "Add Keyword", text: $valueToAdd, becomeFirstResponder: $makeAddFieldFirstResponder, onCommit: self.addKeyword)
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
.animation(.default, value: keywords.map(\.id))
|
||||
.listStyle(.grouped)
|
||||
.appGroupedListBackground(container: PreferencesNavigationController.self)
|
||||
.listStyle(GroupedListStyle())
|
||||
}
|
||||
.onAppear(perform: updateAppearance)
|
||||
.navigationBarTitle(preferences.expandAllContentWarnings ? "Collapse Post CW Keywords" : "Expand Post CW Keywords")
|
||||
|
|
|
@ -24,7 +24,6 @@ struct PreferencesView: View {
|
|||
aboutSection
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.appGroupedListBackground(container: PreferencesNavigationController.self)
|
||||
.navigationBarTitle("Preferences")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
|
@ -85,7 +84,6 @@ struct PreferencesView: View {
|
|||
} header: {
|
||||
Text("Accounts")
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
private var preferencesSection: some View {
|
||||
|
@ -109,7 +107,6 @@ struct PreferencesView: View {
|
|||
Text("Advanced")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
private var aboutSection: some View {
|
||||
|
@ -124,7 +121,6 @@ struct PreferencesView: View {
|
|||
AcknowledgementsView()
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
func logoutPressed() {
|
||||
|
|
|
@ -42,7 +42,6 @@ class SwipeActionsPrefsViewController: UIViewController, UICollectionViewDelegat
|
|||
override func loadView() {
|
||||
let layout = UICollectionViewCompositionalLayout { [unowned self] sectionIndex, environment in
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .insetGrouped)
|
||||
config.backgroundColor = .appGroupedBackground
|
||||
if dataSource.sectionIdentifier(for: sectionIndex) == .selected {
|
||||
config.headerMode = .supplementary
|
||||
}
|
||||
|
@ -60,15 +59,6 @@ class SwipeActionsPrefsViewController: UIViewController, UICollectionViewDelegat
|
|||
config.image = UIImage(systemName: item.systemImageName)
|
||||
cell.contentConfiguration = config
|
||||
cell.accessories = [.reorder(displayed: .always)]
|
||||
cell.configurationUpdateHandler = { cell, state in
|
||||
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appGroupedCellBackground
|
||||
}
|
||||
cell.backgroundConfiguration = config
|
||||
}
|
||||
}
|
||||
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
|
||||
return collectionView.dequeueConfiguredReusableCell(using: listCell, for: indexPath, item: itemIdentifier)
|
||||
|
|
|
@ -26,12 +26,8 @@ struct TipJarView: View {
|
|||
@StateObject private var observer = UbiquitousKeyValueStoreObserver()
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color.appGroupedBackground
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
|
||||
productsView
|
||||
|
||||
productsView
|
||||
.overlay {
|
||||
if showConfetti {
|
||||
ConfettiView()
|
||||
.transition(.opacity.animation(.default))
|
||||
|
|
|
@ -19,8 +19,7 @@ struct WellnessPrefsView: View {
|
|||
disableInfiniteScrolling
|
||||
hideTrends
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.appGroupedListBackground(container: PreferencesNavigationController.self)
|
||||
.listStyle(InsetGroupedListStyle())
|
||||
.navigationBarTitle(Text("Digital Wellness"))
|
||||
}
|
||||
|
||||
|
@ -30,7 +29,6 @@ struct WellnessPrefsView: View {
|
|||
Text("Favorite and Reblog Counts in Conversations")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
private var notificationsMode: some View {
|
||||
|
@ -41,7 +39,6 @@ struct WellnessPrefsView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
private var grayscaleImages: some View {
|
||||
|
@ -50,7 +47,6 @@ struct WellnessPrefsView: View {
|
|||
Text("Grayscale Images")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
private var disableInfiniteScrolling: some View {
|
||||
|
@ -59,7 +55,6 @@ struct WellnessPrefsView: View {
|
|||
Text("Disable Infinite Scrolling")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
|
||||
private var hideTrends: some View {
|
||||
|
@ -68,7 +63,6 @@ struct WellnessPrefsView: View {
|
|||
Text("Hide Trends")
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class ProfileHeaderCollectionViewCell: UICollectionViewCell {
|
|||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
contentView.backgroundColor = .appBackground
|
||||
contentView.backgroundColor = .systemBackground
|
||||
isOpaque = true
|
||||
contentView.isOpaque = true
|
||||
}
|
||||
|
|
|
@ -56,7 +56,6 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
|
||||
override func loadView() {
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .plain)
|
||||
config.backgroundColor = .appBackground
|
||||
config.leadingSwipeActionsConfigurationProvider = { [unowned self] in
|
||||
(collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.leadingSwipeActions()
|
||||
}
|
||||
|
@ -83,9 +82,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
}
|
||||
let layout = UICollectionViewCompositionalLayout { [unowned self] sectionIndex, environment in
|
||||
if case .header = dataSource.sectionIdentifier(for: sectionIndex) {
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .plain)
|
||||
config.backgroundColor = .appBackground
|
||||
return .list(using: config, layoutEnvironment: environment)
|
||||
return .list(using: .init(appearance: .plain), layoutEnvironment: environment)
|
||||
} else {
|
||||
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
|
||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
|
|
|
@ -68,7 +68,7 @@ class ProfileViewController: UIViewController {
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
view.backgroundColor = .appBackground
|
||||
view.backgroundColor = .systemBackground
|
||||
|
||||
for pageController in pageControllers {
|
||||
pageController.profileHeaderDelegate = self
|
||||
|
|
|
@ -34,57 +34,25 @@ struct ReportAddStatusView: View {
|
|||
ReportStatusView(status: status, mastodonController: mastodonController)
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
.modifier(ScrollBackgroundModifier())
|
||||
} else {
|
||||
ZStack {
|
||||
// because the background needs to fill the entire screen
|
||||
Color.appGroupedBackground
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
|
||||
ProgressView()
|
||||
.progressViewStyle(.circular)
|
||||
.alertWithData("Error Loading Posts", data: $error, actions: { _ in
|
||||
Button("OK") {}
|
||||
}, message: { error in
|
||||
Text(error.localizedDescription)
|
||||
})
|
||||
.task { @MainActor in
|
||||
do {
|
||||
let req = Account.getStatuses(report.accountID, range: .count(40), excludeReplies: false, excludeReblogs: true)
|
||||
let (statuses, _) = try await mastodonController.run(req)
|
||||
await mastodonController.persistentContainer.addAll(statuses: statuses)
|
||||
self.statuses = statuses.compactMap { mastodonController.persistentContainer.status(for: $0.id) }
|
||||
} catch {
|
||||
self.error = error
|
||||
}
|
||||
ProgressView()
|
||||
.progressViewStyle(.circular)
|
||||
.alertWithData("Error Loading Posts", data: $error, actions: { _ in
|
||||
Button("OK") {}
|
||||
}, message: { error in
|
||||
Text(error.localizedDescription)
|
||||
})
|
||||
.task { @MainActor in
|
||||
do {
|
||||
let req = Account.getStatuses(report.accountID, range: .count(40), excludeReplies: false, excludeReblogs: true)
|
||||
let (statuses, _) = try await mastodonController.run(req)
|
||||
await mastodonController.persistentContainer.addAll(statuses: statuses)
|
||||
self.statuses = statuses.compactMap { mastodonController.persistentContainer.status(for: $0.id) }
|
||||
} catch {
|
||||
self.error = error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct ScrollBackgroundModifier: ViewModifier {
|
||||
@Environment(\.colorScheme) private var colorScheme
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
if #available(iOS 16.0, *) {
|
||||
content
|
||||
.scrollContentBackground(.hidden)
|
||||
.background {
|
||||
// otherwise the pureBlackDarkMode isn't propagated, for some reason?
|
||||
// even though it is for ReportSelectRulesView??
|
||||
let traits: UITraitCollection = {
|
||||
let t = UITraitCollection(userInterfaceStyle: colorScheme == .dark ? .dark : .light)
|
||||
t.pureBlackDarkMode = true
|
||||
return t
|
||||
}()
|
||||
Color(uiColor: .appGroupedBackground.resolvedColor(with: traits))
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
}
|
||||
} else {
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,27 +47,11 @@ struct ReportSelectRulesView: View {
|
|||
.foregroundColor(selectedRuleIDs.contains(rule.id) ? .accentColor : .clear)
|
||||
}
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
.withAppBackgroundIfAvailable()
|
||||
.navigationTitle("Rules")
|
||||
}
|
||||
}
|
||||
|
||||
private extension View {
|
||||
@available(iOS, obsoleted: 16.0)
|
||||
@ViewBuilder
|
||||
func withAppBackgroundIfAvailable() -> some View {
|
||||
if #available(iOS 16.0, *) {
|
||||
self
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(Color.appGroupedBackground)
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//struct ReportSelectRulesView_Previews: PreviewProvider {
|
||||
// static var previews: some View {
|
||||
// ReportSelectRulesView()
|
||||
|
|
|
@ -32,7 +32,6 @@ struct ReportView: View {
|
|||
if #available(iOS 16.0, *) {
|
||||
NavigationStack {
|
||||
navigationViewContent
|
||||
.scrollDismissesKeyboard(.interactively)
|
||||
}
|
||||
} else {
|
||||
NavigationView {
|
||||
|
@ -94,14 +93,12 @@ struct ReportView: View {
|
|||
} header: {
|
||||
Text("Reason")
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
Section {
|
||||
ComposeTextView(text: $report.comment, placeholder: Text("Add any additional comments"))
|
||||
.backgroundColor(.clear)
|
||||
.listRowInsets(EdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 8))
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
Section {
|
||||
ForEach(report.statusIDs, id: \.self) { id in
|
||||
|
@ -119,14 +116,12 @@ struct ReportView: View {
|
|||
} footer: {
|
||||
Text("Attach posts to your report to provide additional context for moderators.")
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
Section {
|
||||
Toggle("Forward", isOn: $report.forward)
|
||||
} footer: {
|
||||
Text("You can choose to anonymously forward your report to the moderators of **\(account.url.host!)**.")
|
||||
}
|
||||
.appGroupedListRowBackground()
|
||||
|
||||
Button(action: self.sendReport) {
|
||||
if isReporting {
|
||||
|
@ -139,10 +134,7 @@ struct ReportView: View {
|
|||
}
|
||||
}
|
||||
.disabled(isReporting)
|
||||
.appGroupedListRowBackground()
|
||||
}
|
||||
.listStyle(.insetGrouped)
|
||||
.appGroupedListBackground(container: UIHostingController<ReportView>.self, applyBackground: true)
|
||||
.alertWithData("Error Reporting", data: $error, actions: { error in
|
||||
Button("OK") {}
|
||||
}, message: { error in
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
import UIKit
|
||||
import Combine
|
||||
import Pachyderm
|
||||
import WebURLFoundationExtras
|
||||
|
||||
fileprivate let accountCell = "accountCell"
|
||||
fileprivate let statusCell = "statusCell"
|
||||
|
@ -27,15 +26,17 @@ extension SearchResultsViewControllerDelegate {
|
|||
func selectedSearchResult(status statusID: String) {}
|
||||
}
|
||||
|
||||
class SearchResultsViewController: UIViewController, CollectionViewController {
|
||||
class SearchResultsViewController: EnhancedTableViewController {
|
||||
|
||||
weak var mastodonController: MastodonController!
|
||||
|
||||
weak var exploreNavigationController: UINavigationController?
|
||||
weak var delegate: SearchResultsViewControllerDelegate?
|
||||
|
||||
var collectionView: UICollectionView! { view as? UICollectionView }
|
||||
private var dataSource: UICollectionViewDiffableDataSource<Section, Item>!
|
||||
var dataSource: UITableViewDiffableDataSource<Section, Item>!
|
||||
|
||||
private var activityIndicator: UIActivityIndicatorView!
|
||||
private var errorLabel: UILabel!
|
||||
|
||||
/// Types of results to search for.
|
||||
var scope: Scope
|
||||
|
@ -49,7 +50,9 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
|
|||
self.mastodonController = mastodonController
|
||||
self.scope = scope
|
||||
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
super.init(style: .grouped)
|
||||
|
||||
dragEnabled = true
|
||||
|
||||
title = NSLocalizedString("Search", comment: "search screen title")
|
||||
}
|
||||
|
@ -58,45 +61,59 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
|
|||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func loadView() {
|
||||
let layout = UICollectionViewCompositionalLayout { [unowned self] sectionIndex, environment in
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .grouped)
|
||||
config.backgroundColor = .appGroupedBackground
|
||||
config.headerMode = .supplementary
|
||||
switch self.dataSource.sectionIdentifier(for: sectionIndex) {
|
||||
case .loadingIndicator:
|
||||
config.showsSeparators = false
|
||||
config.headerMode = .none
|
||||
case .statuses:
|
||||
config.leadingSwipeActionsConfigurationProvider = { [unowned self] in
|
||||
(self.collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.leadingSwipeActions()
|
||||
}
|
||||
config.trailingSwipeActionsConfigurationProvider = { [unowned self] in
|
||||
(self.collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.trailingSwipeActions()
|
||||
}
|
||||
config.separatorConfiguration.topSeparatorInsets = TimelineStatusCollectionViewCell.separatorInsets
|
||||
config.separatorConfiguration.bottomSeparatorInsets = TimelineStatusCollectionViewCell.separatorInsets
|
||||
default:
|
||||
break
|
||||
}
|
||||
let section = NSCollectionLayoutSection.list(using: config, layoutEnvironment: environment)
|
||||
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||
section.contentInsetsReference = .readableContent
|
||||
}
|
||||
return section
|
||||
}
|
||||
view = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
||||
collectionView.delegate = self
|
||||
collectionView.dragDelegate = self
|
||||
collectionView.allowsFocus = true
|
||||
collectionView.backgroundColor = .appGroupedBackground
|
||||
|
||||
dataSource = createDataSource()
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
errorLabel = UILabel()
|
||||
errorLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||
errorLabel.font = .preferredFont(forTextStyle: .callout)
|
||||
errorLabel.textColor = .secondaryLabel
|
||||
errorLabel.numberOfLines = 0
|
||||
errorLabel.textAlignment = .center
|
||||
errorLabel.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
||||
tableView.addSubview(errorLabel)
|
||||
NSLayoutConstraint.activate([
|
||||
errorLabel.centerYAnchor.constraint(equalTo: view.safeAreaLayoutGuide.centerYAnchor),
|
||||
errorLabel.centerXAnchor.constraint(equalTo: tableView.centerXAnchor),
|
||||
errorLabel.leadingAnchor.constraint(equalToSystemSpacingAfter: tableView.leadingAnchor, multiplier: 1),
|
||||
tableView.trailingAnchor.constraint(equalToSystemSpacingAfter: errorLabel.trailingAnchor, multiplier: 1),
|
||||
])
|
||||
|
||||
tableView.register(UINib(nibName: "AccountTableViewCell", bundle: .main), forCellReuseIdentifier: accountCell)
|
||||
tableView.register(UINib(nibName: "TimelineStatusTableViewCell", bundle: .main), forCellReuseIdentifier: statusCell)
|
||||
tableView.register(UINib(nibName: "HashtagTableViewCell", bundle: .main), forCellReuseIdentifier: hashtagCell)
|
||||
|
||||
tableView.allowsFocus = true
|
||||
|
||||
dataSource = DataSource(tableView: tableView, cellProvider: { (tableView, indexPath, item) -> UITableViewCell? in
|
||||
switch item {
|
||||
case let .account(id):
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: accountCell, for: indexPath) as! AccountTableViewCell
|
||||
cell.delegate = self
|
||||
cell.updateUI(accountID: id)
|
||||
return cell
|
||||
case let .hashtag(tag):
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: hashtagCell, for: indexPath) as! HashtagTableViewCell
|
||||
cell.delegate = self
|
||||
cell.updateUI(hashtag: tag)
|
||||
return cell
|
||||
case let .status(id, state):
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: statusCell, for: indexPath) as! TimelineStatusTableViewCell
|
||||
cell.delegate = self
|
||||
cell.updateUI(statusID: id, state: state)
|
||||
return cell
|
||||
}
|
||||
})
|
||||
|
||||
activityIndicator = UIActivityIndicatorView(style: .large)
|
||||
activityIndicator.translatesAutoresizingMaskIntoConstraints = false
|
||||
activityIndicator.isHidden = true
|
||||
view.addSubview(activityIndicator)
|
||||
NSLayoutConstraint.activate([
|
||||
activityIndicator.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
activityIndicator.topAnchor.constraint(equalTo: view.topAnchor, constant: 8)
|
||||
])
|
||||
|
||||
_ = searchSubject
|
||||
.debounce(for: .milliseconds(500), scheduler: RunLoop.main)
|
||||
.map { $0?.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||
|
@ -108,66 +125,6 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
|
|||
NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil)
|
||||
}
|
||||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
let sectionHeader = UICollectionView.SupplementaryRegistration<UICollectionViewListCell>(elementKind: UICollectionView.elementKindSectionHeader) { [unowned self] supplementaryView, elementKind, indexPath in
|
||||
let section = self.dataSource.sectionIdentifier(for: indexPath.section)!
|
||||
var config = UIListContentConfiguration.groupedHeader()
|
||||
config.text = section.displayName
|
||||
supplementaryView.contentConfiguration = config
|
||||
}
|
||||
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, itemIdentifier in
|
||||
cell.indicator.startAnimating()
|
||||
}
|
||||
let accountCell = UICollectionView.CellRegistration<AccountCollectionViewCell, String> { cell, indexPath, itemIdentifier in
|
||||
cell.delegate = self
|
||||
cell.updateUI(accountID: itemIdentifier)
|
||||
}
|
||||
let hashtagCell = UICollectionView.CellRegistration<TrendingHashtagCollectionViewCell, Hashtag> { cell, indexPath, itemIdentifier in
|
||||
cell.updateUI(hashtag: itemIdentifier)
|
||||
}
|
||||
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, CollapseState)> { [unowned self] cell, indexPath, itemIdentifier in
|
||||
cell.delegate = self
|
||||
cell.updateUI(statusID: itemIdentifier.0, state: itemIdentifier.1, filterResult: .allow, precomputedContent: nil)
|
||||
}
|
||||
let dataSource = UICollectionViewDiffableDataSource<Section, Item>(collectionView: collectionView) { collectionView, indexPath, itemIdentifier in
|
||||
let cell: UICollectionViewCell
|
||||
switch itemIdentifier {
|
||||
case .loadingIndicator:
|
||||
return collectionView.dequeueConfiguredReusableCell(using: loadingCell, for: indexPath, item: ())
|
||||
case .account(let accountID):
|
||||
cell = collectionView.dequeueConfiguredReusableCell(using: accountCell, for: indexPath, item: accountID)
|
||||
case .hashtag(let hashtag):
|
||||
cell = collectionView.dequeueConfiguredReusableCell(using: hashtagCell, for: indexPath, item: hashtag)
|
||||
case .status(let id, let state):
|
||||
cell = collectionView.dequeueConfiguredReusableCell(using: statusCell, for: indexPath, item: (id, state))
|
||||
}
|
||||
cell.configurationUpdateHandler = { cell, state in
|
||||
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appGroupedCellBackground
|
||||
}
|
||||
cell.backgroundConfiguration = config
|
||||
}
|
||||
return cell
|
||||
}
|
||||
dataSource.supplementaryViewProvider = { collectionView, elementKind, indexPath in
|
||||
if elementKind == UICollectionView.elementKindSectionHeader {
|
||||
return collectionView.dequeueConfiguredReusableSupplementary(using: sectionHeader, for: indexPath)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return dataSource
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
clearSelectionOnAppear(animated: animated)
|
||||
}
|
||||
|
||||
override func targetViewController(forAction action: Selector, sender: Any?) -> UIViewController? {
|
||||
// if we're showing a view controller, we need to go up to the explore VC's nav controller
|
||||
// the UISearchController that is our parent is not part of the normal VC hierarchy and itself doesn't have a parent
|
||||
|
@ -192,19 +149,25 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
|
|||
}
|
||||
self.currentQuery = query
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.loadingIndicator])
|
||||
snapshot.appendItems([.loadingIndicator])
|
||||
dataSource.apply(snapshot)
|
||||
activityIndicator.isHidden = false
|
||||
activityIndicator.startAnimating()
|
||||
errorLabel.isHidden = true
|
||||
|
||||
let request = Client.search(query: query, types: scope.resultTypes, resolve: true, limit: 10, following: following)
|
||||
mastodonController.run(request) { (response) in
|
||||
switch response {
|
||||
case let .success(results, _):
|
||||
guard self.currentQuery == query else { return }
|
||||
DispatchQueue.main.async {
|
||||
self.activityIndicator.isHidden = true
|
||||
self.activityIndicator.stopAnimating()
|
||||
}
|
||||
self.showSearchResults(results)
|
||||
case let .failure(error):
|
||||
DispatchQueue.main.async {
|
||||
self.activityIndicator.isHidden = true
|
||||
self.activityIndicator.stopAnimating()
|
||||
|
||||
self.showSearchError(error)
|
||||
}
|
||||
}
|
||||
|
@ -232,6 +195,7 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
|
|||
}
|
||||
}, completion: {
|
||||
DispatchQueue.main.async {
|
||||
self.errorLabel.isHidden = true
|
||||
self.dataSource.apply(snapshot)
|
||||
}
|
||||
})
|
||||
|
@ -241,11 +205,8 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
|
|||
let snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
dataSource.apply(snapshot)
|
||||
|
||||
let config = ToastConfiguration(from: error, with: "Error Searching", in: self) { [unowned self] toast in
|
||||
toast.dismissToast(animated: true)
|
||||
self.performSearch(query: self.currentQuery)
|
||||
}
|
||||
showToast(configuration: config, animated: true)
|
||||
errorLabel.isHidden = false
|
||||
errorLabel.text = error.localizedDescription
|
||||
}
|
||||
|
||||
@objc private func handleStatusDeleted(_ notification: Foundation.Notification) {
|
||||
|
@ -269,6 +230,26 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Table view delegate
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
if let delegate = delegate {
|
||||
switch dataSource.itemIdentifier(for: indexPath) {
|
||||
case nil:
|
||||
return
|
||||
case let .account(id):
|
||||
delegate.selectedSearchResult(account: id)
|
||||
case let .hashtag(hashtag):
|
||||
delegate.selectedSearchResult(hashtag: hashtag)
|
||||
case let .status(id, _):
|
||||
delegate.selectedSearchResult(status: id)
|
||||
}
|
||||
} else {
|
||||
super.tableView(tableView, didSelectRowAt: indexPath)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension SearchResultsViewController {
|
||||
|
@ -308,15 +289,12 @@ extension SearchResultsViewController {
|
|||
|
||||
extension SearchResultsViewController {
|
||||
enum Section: CaseIterable {
|
||||
case loadingIndicator
|
||||
case accounts
|
||||
case hashtags
|
||||
case statuses
|
||||
|
||||
var displayName: String? {
|
||||
var displayName: String {
|
||||
switch self {
|
||||
case .loadingIndicator:
|
||||
return nil
|
||||
case .accounts:
|
||||
return NSLocalizedString("People", comment: "accounts search results section")
|
||||
case .hashtags:
|
||||
|
@ -327,15 +305,12 @@ extension SearchResultsViewController {
|
|||
}
|
||||
}
|
||||
enum Item: Hashable {
|
||||
case loadingIndicator
|
||||
case account(String)
|
||||
case hashtag(Hashtag)
|
||||
case status(String, CollapseState)
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
switch self {
|
||||
case .loadingIndicator:
|
||||
hasher.combine("loadingIndicator")
|
||||
case let .account(id):
|
||||
hasher.combine("account")
|
||||
hasher.combine(id)
|
||||
|
@ -347,121 +322,16 @@ extension SearchResultsViewController {
|
|||
hasher.combine(id)
|
||||
}
|
||||
}
|
||||
|
||||
static func ==(lhs: Item, rhs: Item) -> Bool {
|
||||
switch (lhs, rhs) {
|
||||
case (.loadingIndicator, .loadingIndicator):
|
||||
return true
|
||||
case (.account(let a), .account(let b)):
|
||||
return a == b
|
||||
case (.hashtag(let a), .hashtag(let b)):
|
||||
return a.name == b.name
|
||||
case (.status(let a, _), .status(let b, _)):
|
||||
return a == b
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SearchResultsViewController: UICollectionViewDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
|
||||
switch dataSource.itemIdentifier(for: indexPath) {
|
||||
case .loadingIndicator:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
switch dataSource.itemIdentifier(for: indexPath) {
|
||||
case nil, .loadingIndicator:
|
||||
return
|
||||
case let .account(id):
|
||||
if let delegate {
|
||||
delegate.selectedSearchResult(account: id)
|
||||
} else {
|
||||
selected(account: id)
|
||||
class DataSource: UITableViewDiffableDataSource<Section, Item> {
|
||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection sectionIndex: Int) -> String? {
|
||||
let currentSnapshot = snapshot()
|
||||
for section in Section.allCases where currentSnapshot.indexOfSection(section) == sectionIndex {
|
||||
return section.displayName
|
||||
}
|
||||
case let .hashtag(hashtag):
|
||||
if let delegate {
|
||||
delegate.selectedSearchResult(hashtag: hashtag)
|
||||
} else {
|
||||
selected(tag: hashtag)
|
||||
}
|
||||
case let .status(id, state):
|
||||
if let delegate {
|
||||
delegate.selectedSearchResult(status: id)
|
||||
} else {
|
||||
selected(status: id, state: state.copy())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
|
||||
guard let item = dataSource.itemIdentifier(for: indexPath),
|
||||
let cell = collectionView.cellForItem(at: indexPath) else {
|
||||
return nil
|
||||
}
|
||||
switch item {
|
||||
case .loadingIndicator:
|
||||
return nil
|
||||
case .account(let id):
|
||||
return UIContextMenuConfiguration {
|
||||
ProfileViewController(accountID: id, mastodonController: self.mastodonController)
|
||||
} actionProvider: { _ in
|
||||
UIMenu(children: self.actionsForProfile(accountID: id, source: .view(cell)))
|
||||
}
|
||||
case .hashtag(let tag):
|
||||
return UIContextMenuConfiguration {
|
||||
HashtagTimelineViewController(for: tag, mastodonController: self.mastodonController)
|
||||
} actionProvider: { _ in
|
||||
UIMenu(children: self.actionsForHashtag(tag, source: .view(cell)))
|
||||
}
|
||||
case .status(_, _):
|
||||
return (cell as? TimelineStatusCollectionViewCell)?.contextMenuConfiguration()
|
||||
}
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, willPerformPreviewActionForMenuWith configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionCommitAnimating) {
|
||||
MenuPreviewHelper.willPerformPreviewAction(animator: animator, presenter: self)
|
||||
}
|
||||
}
|
||||
|
||||
extension SearchResultsViewController: UICollectionViewDragDelegate {
|
||||
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
|
||||
guard let accountInfo = mastodonController.accountInfo,
|
||||
let item = dataSource.itemIdentifier(for: indexPath) else {
|
||||
return []
|
||||
}
|
||||
let url: URL
|
||||
let activity: NSUserActivity
|
||||
switch item {
|
||||
case .loadingIndicator:
|
||||
return []
|
||||
case .account(let id):
|
||||
guard let account = mastodonController.persistentContainer.account(for: id) else {
|
||||
return []
|
||||
}
|
||||
url = account.url
|
||||
activity = UserActivityManager.showProfileActivity(id: id, accountID: accountInfo.id)
|
||||
case .hashtag(let tag):
|
||||
url = URL(tag.url)!
|
||||
activity = UserActivityManager.showTimelineActivity(timeline: .tag(hashtag: tag.name), accountID: accountInfo.id)!
|
||||
case .status(let id, _):
|
||||
guard let status = mastodonController.persistentContainer.status(for: id),
|
||||
status.url != nil else {
|
||||
return []
|
||||
}
|
||||
url = status.url!
|
||||
activity = UserActivityManager.showConversationActivity(mainStatusID: id, accountID: accountInfo.id)
|
||||
}
|
||||
activity.displaysAuxiliaryScene = true
|
||||
let provider = NSItemProvider(object: url as NSURL)
|
||||
provider.registerObject(activity, visibility: .all)
|
||||
return [UIDragItem(itemProvider: provider)]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,25 +348,8 @@ extension SearchResultsViewController: UISearchBarDelegate {
|
|||
}
|
||||
|
||||
func searchBar(_ searchBar: UISearchBar, selectedScopeButtonIndexDidChange selectedScope: Int) {
|
||||
let newQuery = searchBar.text?.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
let newScope = Scope.allCases[selectedScope]
|
||||
if self.scope == .all && currentQuery == newQuery {
|
||||
self.scope = newScope
|
||||
var snapshot = dataSource.snapshot()
|
||||
if snapshot.sectionIdentifiers.contains(.accounts) && scope != .people {
|
||||
snapshot.deleteSections([.accounts])
|
||||
}
|
||||
if snapshot.sectionIdentifiers.contains(.hashtags) && scope != .hashtags {
|
||||
snapshot.deleteSections([.hashtags])
|
||||
}
|
||||
if snapshot.sectionIdentifiers.contains(.statuses) && scope != .posts {
|
||||
snapshot.deleteSections([.statuses])
|
||||
}
|
||||
dataSource.apply(snapshot)
|
||||
} else {
|
||||
self.scope = newScope
|
||||
performSearch(query: newQuery)
|
||||
}
|
||||
self.scope = Scope.allCases[selectedScope]
|
||||
performSearch(query: searchBar.text?.trimmingCharacters(in: .whitespacesAndNewlines))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -510,16 +363,9 @@ extension SearchResultsViewController: ToastableViewController {
|
|||
extension SearchResultsViewController: MenuActionProvider {
|
||||
}
|
||||
|
||||
extension SearchResultsViewController: StatusCollectionViewCellDelegate {
|
||||
func statusCellNeedsReconfigure(_ cell: StatusCollectionViewCell, animated: Bool, completion: (() -> Void)?) {
|
||||
if let indexPath = collectionView.indexPath(for: cell) {
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.reconfigureItems([dataSource.itemIdentifier(for: indexPath)!])
|
||||
dataSource.apply(snapshot, animatingDifferences: animated, completion: completion)
|
||||
}
|
||||
}
|
||||
|
||||
func statusCellShowFiltered(_ cell: StatusCollectionViewCell) {
|
||||
// not yet supported
|
||||
extension SearchResultsViewController: StatusTableViewCellDelegate {
|
||||
func statusCellCollapsedStateChanged(_ cell: BaseStatusTableViewCell) {
|
||||
tableView.beginUpdates()
|
||||
tableView.endUpdates()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,30 +86,10 @@ class StatusActionAccountListCollectionViewController: UIViewController, Collect
|
|||
let statusCell = UICollectionView.CellRegistration<TimelineStatusCollectionViewCell, (String, CollapseState)> { [unowned self] cell, indexPath, item in
|
||||
cell.delegate = self
|
||||
cell.updateUI(statusID: item.0, state: item.1, filterResult: .allow, precomputedContent: nil)
|
||||
|
||||
cell.configurationUpdateHandler = { cell, state in
|
||||
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appGroupedCellBackground
|
||||
}
|
||||
cell.backgroundConfiguration = config
|
||||
}
|
||||
}
|
||||
let accountCell = UICollectionView.CellRegistration<AccountCollectionViewCell, String> { [unowned self] cell, indexPath, item in
|
||||
cell.delegate = self
|
||||
cell.updateUI(accountID: item)
|
||||
|
||||
cell.configurationUpdateHandler = { cell, state in
|
||||
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appGroupedCellBackground
|
||||
}
|
||||
cell.backgroundConfiguration = config
|
||||
}
|
||||
}
|
||||
let loadingCell = UICollectionView.CellRegistration<LoadingCollectionViewCell, Void> { cell, indexPath, item in
|
||||
cell.indicator.startAnimating()
|
||||
|
|
|
@ -88,7 +88,7 @@ class StatusActionAccountListViewController: UIViewController {
|
|||
title = NSLocalizedString("Reblogged By", comment: "status reblogged by accounts list title")
|
||||
}
|
||||
|
||||
view.backgroundColor = .appBackground
|
||||
view.backgroundColor = .systemBackground
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ protocol InstanceTimelineViewControllerDelegate: AnyObject {
|
|||
|
||||
class InstanceTimelineViewController: TimelineViewController {
|
||||
|
||||
weak var instanceTimelineDelegate: InstanceTimelineViewControllerDelegate?
|
||||
weak var delegate: InstanceTimelineViewControllerDelegate?
|
||||
|
||||
weak var parentMastodonController: MastodonController?
|
||||
|
||||
|
@ -102,7 +102,7 @@ class InstanceTimelineViewController: TimelineViewController {
|
|||
}
|
||||
|
||||
collectionView.isHidden = true
|
||||
view.backgroundColor = .appBackground
|
||||
view.backgroundColor = .systemBackground
|
||||
|
||||
let image = UIImageView(image: UIImage(systemName: "lock.fill"))
|
||||
image.tintColor = .secondaryLabel
|
||||
|
@ -145,10 +145,10 @@ class InstanceTimelineViewController: TimelineViewController {
|
|||
let existing = try? context.fetch(req).first
|
||||
if let existing = existing {
|
||||
context.delete(existing)
|
||||
instanceTimelineDelegate?.didUnsaveInstance(url: instanceURL)
|
||||
delegate?.didUnsaveInstance(url: instanceURL)
|
||||
} else {
|
||||
_ = SavedInstance(url: instanceURL, account: parentMastodonController!.accountInfo!, context: context)
|
||||
instanceTimelineDelegate?.didSaveInstance(url: instanceURL)
|
||||
delegate?.didSaveInstance(url: instanceURL)
|
||||
}
|
||||
mastodonController.persistentContainer.save(context: context)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class TimelineGapCollectionViewCell: UICollectionViewCell {
|
|||
|
||||
override var isHighlighted: Bool {
|
||||
didSet {
|
||||
backgroundColor = isHighlighted ? .appFill : .appGroupedBackground
|
||||
backgroundColor = isHighlighted ? .systemFill : .systemGroupedBackground
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ class TimelineGapCollectionViewCell: UICollectionViewCell {
|
|||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
backgroundColor = .appGroupedBackground
|
||||
backgroundColor = .systemGroupedBackground
|
||||
|
||||
indicator.isHidden = true
|
||||
indicator.color = .tintColor
|
||||
|
|
|
@ -1,175 +0,0 @@
|
|||
//
|
||||
// TimelineJumpButton.swift
|
||||
// Tusker
|
||||
//
|
||||
// Created by Shadowfacts on 2/6/23.
|
||||
// Copyright © 2023 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class TimelineJumpButton: UIView {
|
||||
|
||||
var action: ((Mode) async -> Void)?
|
||||
|
||||
override var intrinsicContentSize: CGSize {
|
||||
CGSize(width: UIView.noIntrinsicMetric, height: 44)
|
||||
}
|
||||
|
||||
private let button: UIButton = {
|
||||
var config = UIButton.Configuration.plain()
|
||||
config.image = UIImage(systemName: "arrow.up")
|
||||
config.contentInsets = .zero
|
||||
return UIButton(configuration: config)
|
||||
}()
|
||||
|
||||
private(set) var mode = Mode.jump
|
||||
var offscreen = false {
|
||||
didSet {
|
||||
updateOffscreenTransform()
|
||||
}
|
||||
}
|
||||
private(set) var isSyncing = false
|
||||
|
||||
init() {
|
||||
super.init(frame: .zero)
|
||||
|
||||
layer.masksToBounds = true
|
||||
|
||||
button.addAction(UIAction(handler: { [unowned self] _ in
|
||||
Task {
|
||||
switch self.mode {
|
||||
case .jump:
|
||||
await self.jumpAction()
|
||||
case .sync:
|
||||
await self.syncAction()
|
||||
}
|
||||
}
|
||||
}), for: .touchUpInside)
|
||||
|
||||
button.translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(button)
|
||||
NSLayoutConstraint.activate([
|
||||
button.leadingAnchor.constraint(equalTo: leadingAnchor),
|
||||
button.trailingAnchor.constraint(equalTo: trailingAnchor),
|
||||
button.topAnchor.constraint(equalTo: topAnchor),
|
||||
button.bottomAnchor.constraint(equalTo: bottomAnchor),
|
||||
])
|
||||
|
||||
let jumpToPresentAction = UIAction(title: "Jump to Present", image: UIImage(systemName: "arrow.up")) { [unowned self] _ in
|
||||
Task {
|
||||
self.setMode(.jump, animated: false)
|
||||
await self.jumpAction()
|
||||
}
|
||||
}
|
||||
jumpToPresentAction.accessibilityAttributedLabel = TimelinesPageViewController.jumpToPresentTitle
|
||||
|
||||
button.menu = UIMenu(children: [
|
||||
jumpToPresentAction,
|
||||
UIAction(title: "Sync Position", image: UIImage(systemName: "arrow.triangle.2.circlepath"), handler: { [unowned self] _ in
|
||||
Task {
|
||||
self.setMode(.sync, animated: false)
|
||||
await self.syncAction()
|
||||
}
|
||||
})
|
||||
])
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
updateOffscreenTransform()
|
||||
}
|
||||
|
||||
private func updateOffscreenTransform() {
|
||||
if offscreen {
|
||||
button.transform = CGAffineTransform(translationX: 0, y: button.bounds.height)
|
||||
} else {
|
||||
button.transform = .identity
|
||||
}
|
||||
}
|
||||
|
||||
func setMode(_ mode: Mode, animated: Bool) {
|
||||
guard self.mode != mode else {
|
||||
return
|
||||
}
|
||||
self.mode = mode
|
||||
|
||||
var config = UIButton.Configuration.plain()
|
||||
config.contentInsets = .zero
|
||||
switch mode {
|
||||
case .jump:
|
||||
config.image = UIImage(systemName: "arrow.up")
|
||||
case .sync:
|
||||
config.image = UIImage(systemName: "arrow.triangle.2.circlepath")
|
||||
}
|
||||
|
||||
if animated,
|
||||
let snapshot = button.snapshotView(afterScreenUpdates: false) {
|
||||
snapshot.translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(snapshot)
|
||||
NSLayoutConstraint.activate([
|
||||
snapshot.centerXAnchor.constraint(equalTo: centerXAnchor),
|
||||
snapshot.centerYAnchor.constraint(equalTo: centerYAnchor),
|
||||
])
|
||||
button.configuration = config
|
||||
button.layer.opacity = 0
|
||||
UIView.animate(withDuration: 0.5, delay: 0) {
|
||||
self.button.layer.opacity = 1
|
||||
snapshot.layer.opacity = 0
|
||||
} completion: { _ in
|
||||
snapshot.removeFromSuperview()
|
||||
}
|
||||
} else {
|
||||
button.configuration = config
|
||||
}
|
||||
}
|
||||
|
||||
private func jumpAction() async {
|
||||
button.isUserInteractionEnabled = false
|
||||
var config = button.configuration!
|
||||
config.showsActivityIndicator = true
|
||||
button.configuration = config
|
||||
|
||||
await action?(.jump)
|
||||
|
||||
config.showsActivityIndicator = false
|
||||
button.configuration = config
|
||||
button.isUserInteractionEnabled = true
|
||||
}
|
||||
|
||||
private func syncAction() async {
|
||||
isSyncing = true
|
||||
button.isUserInteractionEnabled = false
|
||||
UIView.animateKeyframes(withDuration: 1, delay: 0, options: .repeat) {
|
||||
UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.5) {
|
||||
self.button.imageView!.transform = CGAffineTransform(rotationAngle: 0.5 * .pi)
|
||||
}
|
||||
UIView.addKeyframe(withRelativeStartTime: 0.5, relativeDuration: 0.5) {
|
||||
// the translation is because the symbol isn't perfectly centered
|
||||
self.button.imageView!.transform = CGAffineTransform(translationX: -0.5, y: 0).rotated(by: .pi)
|
||||
}
|
||||
} completion: { _ in
|
||||
}
|
||||
|
||||
await action?(.sync)
|
||||
|
||||
button.imageView!.layer.removeAllAnimations()
|
||||
button.imageView!.transform = .identity
|
||||
button.isUserInteractionEnabled = true
|
||||
isSyncing = false
|
||||
setMode(.jump, animated: true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension TimelineJumpButton {
|
||||
enum Mode {
|
||||
case jump
|
||||
case sync
|
||||
}
|
||||
}
|
|
@ -11,23 +11,7 @@ import Pachyderm
|
|||
import Combine
|
||||
import Sentry
|
||||
|
||||
protocol TimelineViewControllerDelegate: AnyObject {
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willShowJumpToPresentToastWith animator: UIViewPropertyAnimator?)
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willDismissJumpToPresentToastWith animator: UIViewPropertyAnimator?)
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willShowSyncToastWith animator: UIViewPropertyAnimator?)
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willDismissSyncToastWith animator: UIViewPropertyAnimator?)
|
||||
}
|
||||
|
||||
extension TimelineViewControllerDelegate {
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willShowJumpToPresentToastWith animator: UIViewPropertyAnimator?) {}
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willDismissJumpToPresentToastWith animator: UIViewPropertyAnimator?) {}
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willShowSyncToastWith animator: UIViewPropertyAnimator?) {}
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willDismissSyncToastWith animator: UIViewPropertyAnimator?) {}
|
||||
}
|
||||
|
||||
class TimelineViewController: UIViewController, TimelineLikeCollectionViewController, CollectionViewController, RefreshableViewController {
|
||||
weak var delegate: TimelineViewControllerDelegate?
|
||||
|
||||
let timeline: Timeline
|
||||
weak var mastodonController: MastodonController!
|
||||
let filterer: Filterer
|
||||
|
@ -79,7 +63,6 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
super.viewDidLoad()
|
||||
|
||||
var config = UICollectionLayoutListConfiguration(appearance: .plain)
|
||||
config.backgroundColor = .appBackground
|
||||
config.leadingSwipeActionsConfigurationProvider = { [unowned self] in
|
||||
(collectionView.cellForItem(at: $0) as? TimelineStatusCollectionViewCell)?.leadingSwipeActions()
|
||||
}
|
||||
|
@ -116,7 +99,6 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
collectionView.delegate = self
|
||||
collectionView.dragDelegate = self
|
||||
collectionView.allowsFocus = true
|
||||
collectionView.backgroundColor = .appBackground
|
||||
collectionView.translatesAutoresizingMaskIntoConstraints = false
|
||||
view.addSubview(collectionView)
|
||||
NSLayoutConstraint.activate([
|
||||
|
@ -161,9 +143,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
}
|
||||
.debounce(for: .milliseconds(500), scheduler: DispatchQueue.main)
|
||||
.sink { [unowned self] _ in
|
||||
Task {
|
||||
_ = await syncPositionIfNecessary(alwaysPrompt: true)
|
||||
}
|
||||
_ = syncPositionIfNecessary(alwaysPrompt: true)
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleStatusDeleted), name: .statusDeleted, object: nil)
|
||||
|
@ -245,7 +225,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
if case .notLoadedInitial = controller.state {
|
||||
Task {
|
||||
if await restoreState() {
|
||||
await checkPresent(jumpImmediately: false, animateImmediateJump: false)
|
||||
await checkPresent(jumpImmediately: false)
|
||||
} else {
|
||||
await controller.loadInitial()
|
||||
}
|
||||
|
@ -377,12 +357,28 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
|
||||
@MainActor
|
||||
private func loadStatusesToRestore(position: TimelinePosition) async -> Bool {
|
||||
{
|
||||
let crumb = Breadcrumb(level: .info, category: "TimelineViewController")
|
||||
crumb.message = "Original statusIDs before filtering"
|
||||
crumb.data = [
|
||||
"statusIDs": position.statusIDs,
|
||||
]
|
||||
SentrySDK.addBreadcrumb(crumb)
|
||||
}()
|
||||
let originalPositionStatusIDs = position.statusIDs
|
||||
|
||||
let unloaded = position.statusIDs.filter({ mastodonController.persistentContainer.status(for: $0) == nil })
|
||||
guard !unloaded.isEmpty else {
|
||||
return true
|
||||
}
|
||||
{
|
||||
let crumb = Breadcrumb(level: .info, category: "TimelineViewController")
|
||||
crumb.message = "Unloaded ids"
|
||||
crumb.data = [
|
||||
"unloaded": unloaded
|
||||
]
|
||||
SentrySDK.addBreadcrumb(crumb)
|
||||
}()
|
||||
let results = await withTaskGroup(of: (String, Result<Status, Swift.Error>).self) { group -> [(String, Result<Status, Swift.Error>)] in
|
||||
for id in unloaded {
|
||||
group.addTask {
|
||||
|
@ -403,6 +399,9 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
switch result {
|
||||
case .success(let status):
|
||||
statuses.append(status)
|
||||
let crumb = Breadcrumb(level: .info, category: "TimelineViewController")
|
||||
crumb.message = "Loaded status \(id)"
|
||||
SentrySDK.addBreadcrumb(crumb)
|
||||
case .failure(let error):
|
||||
let crumb = Breadcrumb(level: .error, category: "TimelineViewController")
|
||||
crumb.message = "Error loading status"
|
||||
|
@ -415,6 +414,15 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
}
|
||||
await mastodonController.persistentContainer.addAll(statuses: statuses, in: mastodonController.persistentContainer.viewContext)
|
||||
|
||||
_ = {
|
||||
let crumb = Breadcrumb(level: .info, category: "TimelineViewController")
|
||||
crumb.message = "Position statusIDs before filtering"
|
||||
crumb.data = [
|
||||
"statusIDs": position.statusIDs,
|
||||
]
|
||||
SentrySDK.addBreadcrumb(crumb)
|
||||
}()
|
||||
|
||||
// if an icloud sync completed in between starting to load the statuses and finishing, try to load again
|
||||
if position.statusIDs != originalPositionStatusIDs {
|
||||
let crumb = Breadcrumb(level: .info, category: "TimelineViewController")
|
||||
|
@ -436,6 +444,15 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
!unloaded.contains(id) || statuses.contains(where: { $0.id == id })
|
||||
}
|
||||
|
||||
{
|
||||
let crumb = Breadcrumb(level: .info, category: "TimelineViewController")
|
||||
crumb.message = "Filtered position statusIDs"
|
||||
crumb.data = [
|
||||
"statusIDs": position.statusIDs,
|
||||
]
|
||||
SentrySDK.addBreadcrumb(crumb)
|
||||
}()
|
||||
|
||||
return !position.statusIDs.isEmpty
|
||||
}
|
||||
|
||||
|
@ -546,7 +563,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
saveState()
|
||||
}
|
||||
|
||||
func syncPositionIfNecessary(alwaysPrompt: Bool) async -> Bool {
|
||||
private func syncPositionIfNecessary(alwaysPrompt: Bool) -> Bool {
|
||||
guard persistsState,
|
||||
let timelinePosition = mastodonController.persistentContainer.getTimelinePosition(timeline: timeline) else {
|
||||
return false
|
||||
|
@ -574,7 +591,9 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
}
|
||||
stateRestorationLogger.info("Potential restore with centerStatusID: \(timelinePosition.centerStatusID ?? "<none>")")
|
||||
if !alwaysPrompt {
|
||||
_ = await restoreState()
|
||||
Task {
|
||||
_ = await restoreState()
|
||||
}
|
||||
} else {
|
||||
var config = ToastConfiguration(title: "Sync Position")
|
||||
config.edge = .top
|
||||
|
@ -596,12 +615,6 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
toast.dismissToast(animated: true)
|
||||
}
|
||||
}
|
||||
config.onAppear = { [unowned self] animator in
|
||||
self.delegate?.timelineViewController(self, willShowSyncToastWith: animator)
|
||||
}
|
||||
config.onDismiss = { [unowned self] animator in
|
||||
self.delegate?.timelineViewController(self, willDismissSyncToastWith: animator)
|
||||
}
|
||||
showToast(configuration: config, animated: true)
|
||||
UIAccessibility.post(notification: .announcement, argument: "Synced Position Updated")
|
||||
}
|
||||
|
@ -639,31 +652,30 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
return
|
||||
}
|
||||
self.disappearedAt = nil
|
||||
Task {
|
||||
if await syncPositionIfNecessary(alwaysPrompt: false) {
|
||||
// no-op
|
||||
} else {
|
||||
await checkPresent(jumpImmediately: false, animateImmediateJump: false)
|
||||
if syncPositionIfNecessary(alwaysPrompt: false) {
|
||||
// no-op
|
||||
} else {
|
||||
Task {
|
||||
await checkPresent(jumpImmediately: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func checkPresent(jumpImmediately: Bool, animateImmediateJump: Bool) async {
|
||||
guard case .idle = controller.state,
|
||||
let presentItems = try? await loadInitial(),
|
||||
!presentItems.isEmpty else {
|
||||
return
|
||||
}
|
||||
if jumpImmediately {
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.statuses])
|
||||
snapshot.appendItems(presentItems.map { .status(id: $0, collapseState: .unknown, filterState: .unknown) }, toSection: .statuses)
|
||||
dataSource.apply(snapshot, animatingDifferences: animateImmediateJump) {
|
||||
self.collectionView.scrollToItem(at: IndexPath(row: 0, section: 0), at: .top, animated: animateImmediateJump)
|
||||
UIAccessibility.post(notification: .screenChanged, argument: self.collectionView.cellForItem(at: IndexPath(row: 0, section: 0)))
|
||||
func checkPresent(jumpImmediately: Bool) async {
|
||||
if case .idle = controller.state,
|
||||
let presentItems = try? await loadInitial(),
|
||||
!presentItems.isEmpty {
|
||||
if jumpImmediately {
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.statuses])
|
||||
snapshot.appendItems(presentItems.map { .status(id: $0, collapseState: .unknown, filterState: .unknown) }, toSection: .statuses)
|
||||
dataSource.apply(snapshot, animatingDifferences: false) {
|
||||
self.collectionView.scrollToItem(at: IndexPath(row: 0, section: 0), at: .top, animated: false)
|
||||
UIAccessibility.post(notification: .screenChanged, argument: self.collectionView.cellForItem(at: IndexPath(row: 0, section: 0)))
|
||||
}
|
||||
} else {
|
||||
insertPresentItemsAndShowJumpToast(presentItems)
|
||||
}
|
||||
} else {
|
||||
insertPresentItemsAndShowJumpToast(presentItems)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -766,12 +778,6 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
self.showToast(configuration: config, animated: true)
|
||||
}
|
||||
}
|
||||
config.onAppear = { [unowned self] animator in
|
||||
self.delegate?.timelineViewController(self, willShowJumpToPresentToastWith: animator)
|
||||
}
|
||||
config.onDismiss = { [unowned self] animator in
|
||||
self.delegate?.timelineViewController(self, willDismissJumpToPresentToastWith: animator)
|
||||
}
|
||||
self.showToast(configuration: config, animated: true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,22 +13,12 @@ import Combine
|
|||
|
||||
class TimelinesPageViewController: SegmentedPageViewController<TimelinesPageViewController.Page> {
|
||||
|
||||
static let jumpToPresentTitle: NSAttributedString = {
|
||||
let s = NSMutableAttributedString("Jump to Present")
|
||||
// otherwise it pronounces it as 'pɹizˈənt'
|
||||
// its IPA is also bad, this should be an alveolar approximant not a trill
|
||||
s.addAttribute(.accessibilitySpeechIPANotation, value: "ˈprɛ.zənt", range: NSRange(location: "Jump to ".count, length: "Present".count))
|
||||
return s
|
||||
}()
|
||||
|
||||
private let homeTitle = NSLocalizedString("Home", comment: "home timeline tab title")
|
||||
private let federatedTitle = NSLocalizedString("Federated", comment: "federated timeline tab title")
|
||||
private let localTitle = NSLocalizedString("Local", comment: "local timeline tab title")
|
||||
|
||||
weak var mastodonController: MastodonController!
|
||||
|
||||
private let jumpButton = TimelineJumpButton()
|
||||
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
init(mastodonController: MastodonController) {
|
||||
|
@ -56,17 +46,30 @@ class TimelinesPageViewController: SegmentedPageViewController<TimelinesPageView
|
|||
customizeItem.accessibilityLabel = "Customize Timelines"
|
||||
navigationItem.rightBarButtonItem = customizeItem
|
||||
|
||||
jumpButton.action = { [unowned self] mode in
|
||||
switch mode {
|
||||
case .jump:
|
||||
await (self.currentViewController as! TimelineViewController).checkPresent(jumpImmediately: true, animateImmediateJump: true)
|
||||
case .sync:
|
||||
_ = await (self.currentViewController as! TimelineViewController).syncPositionIfNecessary(alwaysPrompt: false)
|
||||
}
|
||||
}
|
||||
let jumpItem = UIBarButtonItem(customView: jumpButton)
|
||||
jumpItem.accessibilityAttributedLabel = Self.jumpToPresentTitle
|
||||
navigationItem.leftBarButtonItem = jumpItem
|
||||
let jumpToPresentName = NSMutableAttributedString("Jump to Present")
|
||||
// otherwise it pronounces it as 'pɹizˈənt'
|
||||
// its IPA is also bad, this should be an alveolar approximant not a trill
|
||||
jumpToPresentName.addAttribute(.accessibilitySpeechIPANotation, value: "ˈprɛ.zənt", range: NSRange(location: "Jump to ".count, length: "Present".count))
|
||||
segmentedControl.accessibilityCustomActions = [
|
||||
UIAccessibilityCustomAction(attributedName: jumpToPresentName, actionHandler: { [unowned self] _ in
|
||||
guard let vc = currentViewController as? TimelineViewController else {
|
||||
return false
|
||||
}
|
||||
Task {
|
||||
await vc.checkPresent(jumpImmediately: true)
|
||||
}
|
||||
return true
|
||||
}),
|
||||
UIAccessibilityCustomAction(name: "Jump to Sync Position", actionHandler: { [unowned self] _ in
|
||||
guard let vc = currentViewController as? TimelineViewController else {
|
||||
return false
|
||||
}
|
||||
Task {
|
||||
_ = await vc.restoreState()
|
||||
}
|
||||
return true
|
||||
}),
|
||||
]
|
||||
|
||||
mastodonController.accountPreferences.publisher(for: \.pinnedTimelinesData)
|
||||
.map { _ in () }
|
||||
|
@ -84,23 +87,6 @@ class TimelinesPageViewController: SegmentedPageViewController<TimelinesPageView
|
|||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func configureViewController(_ viewController: UIViewController) {
|
||||
let vc = viewController as! TimelineViewController
|
||||
vc.delegate = self
|
||||
}
|
||||
|
||||
override func selectPage(_ page: Page, animated: Bool) {
|
||||
super.selectPage(page, animated: animated)
|
||||
if jumpButton.offscreen {
|
||||
jumpButton.setMode(.jump, animated: false)
|
||||
UIView.animate(withDuration: 0.2, delay: 0) {
|
||||
self.jumpButton.offscreen = false
|
||||
}
|
||||
} else {
|
||||
jumpButton.setMode(.jump, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
func selectTimeline(_ timeline: PinnedTimeline, animated: Bool) {
|
||||
self.selectPage(Page(mastodonController: mastodonController, timeline: timeline), animated: animated)
|
||||
}
|
||||
|
@ -150,75 +136,3 @@ extension TimelinesPageViewController {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension TimelinesPageViewController: TimelineViewControllerDelegate {
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willShowJumpToPresentToastWith animator: UIViewPropertyAnimator?) {
|
||||
guard timelineViewController === currentViewController else {
|
||||
return
|
||||
}
|
||||
if let animator {
|
||||
animator.addAnimations {
|
||||
self.jumpButton.offscreen = true
|
||||
}
|
||||
} else {
|
||||
self.jumpButton.offscreen = true
|
||||
}
|
||||
}
|
||||
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willDismissJumpToPresentToastWith animator: UIViewPropertyAnimator?) {
|
||||
guard timelineViewController === currentViewController else {
|
||||
return
|
||||
}
|
||||
jumpButton.setMode(.jump, animated: false)
|
||||
if let animator {
|
||||
animator.addAnimations {
|
||||
self.jumpButton.offscreen = false
|
||||
}
|
||||
} else {
|
||||
self.jumpButton.offscreen = false
|
||||
}
|
||||
}
|
||||
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willShowSyncToastWith animator: UIViewPropertyAnimator?) {
|
||||
guard timelineViewController === currentViewController else {
|
||||
return
|
||||
}
|
||||
if let animator {
|
||||
animator.addAnimations {
|
||||
self.jumpButton.offscreen = true
|
||||
}
|
||||
} else {
|
||||
self.jumpButton.offscreen = true
|
||||
}
|
||||
}
|
||||
|
||||
func timelineViewController(_ timelineViewController: TimelineViewController, willDismissSyncToastWith animator: UIViewPropertyAnimator?) {
|
||||
guard timelineViewController === currentViewController else {
|
||||
return
|
||||
}
|
||||
|
||||
jumpButton.setMode(.sync, animated: false)
|
||||
func resetJumpButtonMode() {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(5)) { [weak self] in
|
||||
guard let self,
|
||||
timelineViewController === self.currentViewController,
|
||||
!self.jumpButton.isSyncing else { return }
|
||||
self.jumpButton.setMode(.jump, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
if let animator {
|
||||
animator.addAnimations {
|
||||
self.jumpButton.offscreen = false
|
||||
}
|
||||
animator.addCompletion { position in
|
||||
if position == .end {
|
||||
resetJumpButtonMode()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.jumpButton.offscreen = false
|
||||
resetJumpButtonMode()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class CustomAlertController: UIViewController {
|
|||
|
||||
blurView = UIVisualEffectView(effect: UIBlurEffect(style: .systemChromeMaterial))
|
||||
|
||||
blurView.backgroundColor = .appBackground
|
||||
blurView.backgroundColor = .systemBackground
|
||||
blurView.layer.cornerRadius = 15
|
||||
blurView.layer.cornerCurve = .continuous
|
||||
blurView.layer.masksToBounds = true
|
||||
|
|
|
@ -346,16 +346,12 @@ extension MenuActionProvider {
|
|||
}
|
||||
}
|
||||
|
||||
func actionsForTrendingLink(card: Card, source: PopoverSource) -> [UIMenuElement] {
|
||||
func actionsForTrendingLink(card: Card) -> [UIMenuElement] {
|
||||
guard let url = URL(card.url) else {
|
||||
return []
|
||||
}
|
||||
return [
|
||||
openInSafariAction(url: url),
|
||||
createAction(identifier: "share", title: "Share", systemImageName: "square.and.arrow.up", handler: { [weak self] (_) in
|
||||
guard let self else { return }
|
||||
self.navigationDelegate?.showMoreOptions(forURL: url, source: source)
|
||||
}),
|
||||
createAction(identifier: "postlink", title: "Post this Link", systemImageName: "square.and.pencil", handler: { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
let draft = self.mastodonController!.createDraft()
|
||||
|
|
|
@ -79,7 +79,7 @@ class SegmentedPageViewController<Page: SegmentedPageViewControllerPage>: UIView
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
view.backgroundColor = .appBackground
|
||||
view.backgroundColor = .systemBackground
|
||||
|
||||
selectPage(initialPage, animated: false)
|
||||
|
||||
|
@ -94,9 +94,6 @@ class SegmentedPageViewController<Page: SegmentedPageViewControllerPage>: UIView
|
|||
}
|
||||
}
|
||||
|
||||
func configureViewController(_ viewController: UIViewController) {
|
||||
}
|
||||
|
||||
func selectPage(_ page: Page, animated: Bool) {
|
||||
guard pages.contains(page) else {
|
||||
fatalError("invalid page \(page) that is not in SegmentedPageViewController.pages")
|
||||
|
@ -119,7 +116,6 @@ class SegmentedPageViewController<Page: SegmentedPageViewControllerPage>: UIView
|
|||
newController = existing
|
||||
} else {
|
||||
newController = pageProvider(page)
|
||||
configureViewController(newController)
|
||||
pageControllers[page] = newController
|
||||
}
|
||||
|
||||
|
@ -134,16 +130,7 @@ class SegmentedPageViewController<Page: SegmentedPageViewControllerPage>: UIView
|
|||
animated != .none else {
|
||||
currentViewController?.removeViewAndController()
|
||||
newViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
// don't use embedChild here because it triggers an appearance transition, even though this vc hasn't appeared yet
|
||||
addChild(newViewController)
|
||||
view.addSubview(newViewController.view)
|
||||
NSLayoutConstraint.activate([
|
||||
newViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||
newViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||
newViewController.view.topAnchor.constraint(equalTo: view.topAnchor),
|
||||
newViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
|
||||
])
|
||||
newViewController.didMove(toParent: self)
|
||||
embedChild(newViewController)
|
||||
self.currentViewController = newViewController
|
||||
return
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import Pachyderm
|
|||
|
||||
protocol TuskerNavigationDelegate: UIViewController, ToastableViewController {
|
||||
var apiController: MastodonController! { get }
|
||||
|
||||
func conversation(mainStatusID: String, state: CollapseState) -> ConversationViewController
|
||||
}
|
||||
|
||||
extension TuskerNavigationDelegate {
|
||||
|
@ -80,12 +82,16 @@ extension TuskerNavigationDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
func conversation(mainStatusID: String, state: CollapseState) -> ConversationViewController {
|
||||
return ConversationViewController(for: mainStatusID, state: state, mastodonController: apiController)
|
||||
}
|
||||
|
||||
func selected(status statusID: String) {
|
||||
self.selected(status: statusID, state: .unknown)
|
||||
}
|
||||
|
||||
func selected(status statusID: String, state: CollapseState) {
|
||||
show(ConversationViewController(for: statusID, state: state, mastodonController: apiController), sender: self)
|
||||
show(conversation(mainStatusID: statusID, state: state), sender: self)
|
||||
}
|
||||
|
||||
func compose(editing draft: Draft, animated: Bool = true) {
|
||||
|
@ -113,11 +119,15 @@ extension TuskerNavigationDelegate {
|
|||
compose(editing: draft, animated: animated)
|
||||
}
|
||||
|
||||
func showLoadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) {
|
||||
func loadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) -> LoadingLargeImageViewController {
|
||||
let vc = LoadingLargeImageViewController(url: url, cache: cache, imageDescription: description)
|
||||
vc.animationSourceView = sourceView
|
||||
vc.transitioningDelegate = self
|
||||
present(vc, animated: true)
|
||||
return vc
|
||||
}
|
||||
|
||||
func showLoadingLargeImage(url: URL, cache: ImageCache, description: String?, animatingFrom sourceView: UIImageView) {
|
||||
present(loadingLargeImage(url: url, cache: cache, description: description, animatingFrom: sourceView), animated: true)
|
||||
}
|
||||
|
||||
func gallery(attachments: [Attachment], sourceViews: [UIImageView?], startIndex: Int) -> GalleryViewController {
|
||||
|
@ -173,6 +183,16 @@ extension TuskerNavigationDelegate {
|
|||
present(vc, animated: true)
|
||||
}
|
||||
|
||||
func showFollowedByList(accountIDs: [String]) {
|
||||
let vc = AccountListViewController(accountIDs: accountIDs, mastodonController: apiController)
|
||||
vc.title = NSLocalizedString("Followed By", comment: "followed by accounts list title")
|
||||
show(vc, sender: self)
|
||||
}
|
||||
|
||||
func statusActionAccountList(action: StatusActionAccountListViewController.ActionType, statusID: String, statusState state: CollapseState, accountIDs: [String]?) -> StatusActionAccountListViewController {
|
||||
return StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: state, accountIDs: accountIDs, mastodonController: apiController)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum PopoverSource {
|
||||
|
|
|
@ -21,16 +21,6 @@ class AlbumTableViewCell: UITableViewCell {
|
|||
thumbnailImageView.layer.cornerRadius = 0.05 * thumbnailImageView.bounds.width
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
func updateUI(album: PHAssetCollection) {
|
||||
albumTitleLabel.text = album.localizedTitle
|
||||
|
||||
|
|
|
@ -33,15 +33,5 @@ class AllPhotosTableViewCell: UITableViewCell {
|
|||
thumbnailImageView.image = nil
|
||||
}
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class ConfirmLoadMoreCollectionViewCell: UICollectionViewCell {
|
|||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
backgroundColor = .appGroupedBackground
|
||||
backgroundColor = .systemGroupedBackground
|
||||
|
||||
let label = UILabel()
|
||||
label.text = "Infinite scrolling is off. Do you want to keep going?"
|
||||
|
|
|
@ -324,7 +324,7 @@ extension ContentTextView: UIContextMenuInteractionDelegate {
|
|||
// Create a dummy containerview for the snapshot view, since using a view with a CALayer mask and UIPreviewParameters(textLineRects:)
|
||||
// causes the mask to be ignored. See FB7832297
|
||||
let snapshotContainer = UIView(frame: snapshot.bounds)
|
||||
snapshotContainer.backgroundColor = .appBackground
|
||||
snapshotContainer.backgroundColor = .systemBackground
|
||||
snapshotContainer.addSubview(snapshot)
|
||||
|
||||
let preview = UITargetedPreview(view: snapshotContainer, parameters: parameters, target: target)
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// HashtagTableViewCell.swift
|
||||
// Tusker
|
||||
//
|
||||
// Created by Shadowfacts on 9/14/19.
|
||||
// Copyright © 2019 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Pachyderm
|
||||
|
||||
class HashtagTableViewCell: UITableViewCell {
|
||||
|
||||
weak var delegate: TuskerNavigationDelegate?
|
||||
|
||||
@IBOutlet weak var hashtagLabel: UILabel!
|
||||
|
||||
var hashtag: Hashtag!
|
||||
|
||||
func updateUI(hashtag: Hashtag) {
|
||||
self.hashtag = hashtag
|
||||
|
||||
hashtagLabel.text = "#\(hashtag.name)"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension HashtagTableViewCell: SelectableTableViewCell {
|
||||
func didSelectCell() {
|
||||
delegate?.selected(tag: hashtag)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="HashtagTableViewCell" customModule="Tusker" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="#hashtag" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vVg-1C-zJr">
|
||||
<rect key="frame" x="16" y="11" width="71.5" height="22"/>
|
||||
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
|
||||
<nil key="textColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="vVg-1C-zJr" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" id="Mnk-L3-dz9"/>
|
||||
<constraint firstAttribute="bottomMargin" secondItem="vVg-1C-zJr" secondAttribute="bottom" id="qgx-dQ-SGs"/>
|
||||
<constraint firstItem="vVg-1C-zJr" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leadingMargin" id="ulh-dS-m0f"/>
|
||||
</constraints>
|
||||
</tableViewCellContentView>
|
||||
<viewLayoutGuide key="safeArea" id="njF-e1-oar"/>
|
||||
<connections>
|
||||
<outlet property="hashtagLabel" destination="vVg-1C-zJr" id="zJM-sN-cvL"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="132" y="154"/>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
|
@ -18,6 +18,8 @@ class TrendingHashtagCollectionViewCell: UICollectionViewCell {
|
|||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
backgroundColor = .systemBackground
|
||||
|
||||
hashtagLabel.font = .preferredFont(forTextStyle: .title2)
|
||||
hashtagLabel.adjustsFontForContentSizeCategory = true
|
||||
peopleTodayLabel.font = .preferredFont(forTextStyle: .caption1)
|
||||
|
@ -58,16 +60,6 @@ class TrendingHashtagCollectionViewCell: UICollectionViewCell {
|
|||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appGroupedCellBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
func updateUI(hashtag: Hashtag) {
|
||||
hashtagLabel.text = "#\(hashtag.name)"
|
||||
historyView.setHistory(hashtag.history)
|
||||
|
|
|
@ -39,16 +39,6 @@ class InstanceTableViewCell: UITableViewCell {
|
|||
descriptionTextView.adjustsFontForContentSizeCategory = true
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listGroupedCell()
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appGroupedCellBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
func updateUI(instance: InstanceSelector.Instance) {
|
||||
self.selectorInstance = instance
|
||||
self.instance = nil
|
||||
|
|
|
@ -14,8 +14,6 @@ class LoadingTableViewCell: UITableViewCell {
|
|||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
||||
super.init(style: style, reuseIdentifier: reuseIdentifier)
|
||||
|
||||
backgroundColor = .appBackground
|
||||
|
||||
indicator.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(indicator)
|
||||
NSLayoutConstraint.activate([
|
||||
|
|
|
@ -47,16 +47,6 @@ class ActionNotificationGroupTableViewCell: UITableViewCell {
|
|||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(updateUIForPreferences), name: .preferencesChanged, object: nil)
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
@objc func updateUIForPreferences() {
|
||||
for case let imageView as UIImageView in actionAvatarStackView.arrangedSubviews {
|
||||
|
@ -273,7 +263,7 @@ extension ActionNotificationGroupTableViewCell: SelectableTableViewCell {
|
|||
default:
|
||||
fatalError()
|
||||
}
|
||||
let vc = StatusActionAccountListViewController(actionType: action, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: mastodonController)
|
||||
let vc = delegate.statusActionAccountList(action: action, statusID: statusID, statusState: .unknown, accountIDs: accountIDs)
|
||||
vc.showInacurateCountWarning = false
|
||||
delegate.show(vc)
|
||||
}
|
||||
|
@ -282,6 +272,9 @@ extension ActionNotificationGroupTableViewCell: SelectableTableViewCell {
|
|||
extension ActionNotificationGroupTableViewCell: MenuPreviewProvider {
|
||||
func getPreviewProviders(for location: CGPoint, sourceViewController: UIViewController) -> PreviewProviders? {
|
||||
return (content: {
|
||||
guard let delegate = self.delegate else {
|
||||
return nil
|
||||
}
|
||||
let notifications = self.group.notifications
|
||||
let accountIDs = notifications.map { $0.account.id }
|
||||
let action: StatusActionAccountListViewController.ActionType
|
||||
|
@ -293,7 +286,7 @@ extension ActionNotificationGroupTableViewCell: MenuPreviewProvider {
|
|||
default:
|
||||
fatalError()
|
||||
}
|
||||
let vc = StatusActionAccountListViewController(actionType: action, statusID: self.statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: self.mastodonController)
|
||||
let vc = delegate.statusActionAccountList(action: action, statusID: self.statusID, statusState: .unknown, accountIDs: accountIDs)
|
||||
vc.showInacurateCountWarning = false
|
||||
return vc
|
||||
}, actions: {
|
||||
|
|
|
@ -43,16 +43,6 @@ class FollowNotificationGroupTableViewCell: UITableViewCell {
|
|||
NotificationCenter.default.addObserver(self, selector: #selector(updateUIForPreferences), name: .preferencesChanged, object: nil)
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
@objc func updateUIForPreferences() {
|
||||
for case let imageView as UIImageView in avatarStackView.arrangedSubviews {
|
||||
imageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: imageView)
|
||||
|
@ -223,9 +213,7 @@ extension FollowNotificationGroupTableViewCell: SelectableTableViewCell {
|
|||
case 1:
|
||||
delegate?.selected(account: accountIDs.first!)
|
||||
default:
|
||||
let vc = AccountListViewController(accountIDs: accountIDs, mastodonController: mastodonController)
|
||||
vc.title = NSLocalizedString("Followed By", comment: "followed by accounts list title")
|
||||
delegate?.show(vc)
|
||||
delegate?.showFollowedByList(accountIDs: accountIDs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,16 +49,6 @@ class FollowRequestNotificationTableViewCell: UITableViewCell {
|
|||
updateUIForPreferences()
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
@objc func updateUIForPreferences() {
|
||||
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadiusFraction * 30
|
||||
|
||||
|
|
|
@ -37,16 +37,6 @@ class PollFinishedTableViewCell: UITableViewCell {
|
|||
displayNameLabel.font = .preferredFont(forTextStyle: .body).withTraits(.traitBold)!
|
||||
displayNameLabel.adjustsFontForContentSizeCategory = true
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
func updateUI(notification: Pachyderm.Notification) {
|
||||
guard let statusID = notification.status?.id,
|
||||
|
@ -130,7 +120,8 @@ extension PollFinishedTableViewCell: SelectableTableViewCell {
|
|||
let status = notification?.status else {
|
||||
return
|
||||
}
|
||||
delegate.selected(status: status.id)
|
||||
let vc = delegate.conversation(mainStatusID: status.id, state: .unknown)
|
||||
delegate.show(vc)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,7 +133,7 @@ extension PollFinishedTableViewCell: MenuPreviewProvider {
|
|||
return nil
|
||||
}
|
||||
return (content: {
|
||||
ConversationViewController(for: statusID, state: .unknown, mastodonController: delegate.apiController)
|
||||
delegate.conversation(mainStatusID: statusID, state: .unknown)
|
||||
}, actions: {
|
||||
delegate.actionsForStatus(status, source: .view(self))
|
||||
})
|
||||
|
|
|
@ -35,16 +35,6 @@ class StatusUpdatedNotificationTableViewCell: UITableViewCell {
|
|||
displayNameLabel.adjustsFontForContentSizeCategory = true
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
func updateUI(notification: Pachyderm.Notification) {
|
||||
guard notification.kind == .update,
|
||||
let status = notification.status else {
|
||||
|
@ -119,7 +109,8 @@ extension StatusUpdatedNotificationTableViewCell: SelectableTableViewCell {
|
|||
let status = notification?.status else {
|
||||
return
|
||||
}
|
||||
delegate.selected(status: status.id)
|
||||
let vc = delegate.conversation(mainStatusID: status.id, state: .unknown)
|
||||
delegate.show(vc)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,7 +122,7 @@ extension StatusUpdatedNotificationTableViewCell: MenuPreviewProvider {
|
|||
return nil
|
||||
}
|
||||
return (content: {
|
||||
ConversationViewController(for: statusID, state: .unknown, mastodonController: delegate.apiController)
|
||||
delegate.conversation(mainStatusID: statusID, state: .unknown)
|
||||
}, actions: {
|
||||
delegate.actionsForStatus(status, source: .view(self))
|
||||
})
|
||||
|
|
|
@ -14,8 +14,6 @@ class ProfileFieldsView: UIView {
|
|||
|
||||
weak var delegate: ProfileHeaderViewDelegate?
|
||||
|
||||
private var fields = [Account.Field]()
|
||||
|
||||
private let stack = UIStackView()
|
||||
private var fieldViews: [(EmojiLabel, ProfileFieldValueView)] = []
|
||||
private var fieldConstraints: [NSLayoutConstraint] = []
|
||||
|
@ -64,11 +62,9 @@ class ProfileFieldsView: UIView {
|
|||
|
||||
func updateUI(account: AccountMO) {
|
||||
isHidden = account.fields.isEmpty
|
||||
guard !account.fields.isEmpty,
|
||||
fields != account.fields else {
|
||||
guard !account.fields.isEmpty else {
|
||||
return
|
||||
}
|
||||
fields = account.fields
|
||||
|
||||
for (name, value) in fieldViews {
|
||||
name.removeFromSuperview()
|
||||
|
@ -187,7 +183,6 @@ private class ProfileFieldValueView: UIView {
|
|||
super.init(frame: .zero)
|
||||
|
||||
textView.isSelectable = false
|
||||
textView.backgroundColor = .clear
|
||||
textView.defaultFont = .preferredFont(forTextStyle: .body)
|
||||
textView.monospaceFont = UIFontMetrics.default.scaledFont(for: .monospacedSystemFont(ofSize: 17, weight: .regular))
|
||||
textView.adjustsFontForContentSizeCategory = true
|
||||
|
@ -226,6 +221,7 @@ private class ProfileFieldValueView: UIView {
|
|||
textView.topAnchor.constraint(equalTo: topAnchor),
|
||||
textView.bottomAnchor.constraint(equalTo: bottomAnchor),
|
||||
])
|
||||
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
|
|
@ -61,9 +61,6 @@ class ProfileHeaderView: UIView {
|
|||
override func awakeFromNib() {
|
||||
super.awakeFromNib()
|
||||
|
||||
backgroundColor = .appBackground
|
||||
|
||||
avatarContainerView.backgroundColor = .appBackground
|
||||
avatarContainerView.layer.masksToBounds = true
|
||||
avatarImageView.layer.masksToBounds = true
|
||||
avatarImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(avatarPressed)))
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
</textView>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vKC-m1-Sbs" customClass="ProfileFieldsView" customModule="Tusker" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="263.5" width="398" height="128"/>
|
||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="128" placeholder="YES" id="xbR-M6-H0I"/>
|
||||
</constraints>
|
||||
|
|
|
@ -317,12 +317,6 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
|
|||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state)
|
||||
config.backgroundColor = .appBackground
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
// MARK: Configure UI
|
||||
|
||||
func updateUI(statusID: String, state: CollapseState) {
|
||||
|
@ -416,7 +410,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
|
|||
guard let delegate else {
|
||||
return
|
||||
}
|
||||
let vc = StatusActionAccountListViewController(actionType: .favorite, statusID: statusID, statusState: statusState.copy(), accountIDs: nil, mastodonController: mastodonController)
|
||||
let vc = delegate.statusActionAccountList(action: .favorite, statusID: statusID, statusState: statusState.copy(), accountIDs: nil)
|
||||
// TODO: only show warning if the instance isn't the logged in one
|
||||
vc.showInacurateCountWarning = true
|
||||
delegate.show(vc)
|
||||
|
@ -426,7 +420,7 @@ class ConversationMainStatusCollectionViewCell: UICollectionViewListCell, Status
|
|||
guard let delegate else {
|
||||
return
|
||||
}
|
||||
let vc = StatusActionAccountListViewController(actionType: .favorite, statusID: statusID, statusState: statusState.copy(), accountIDs: nil, mastodonController: mastodonController)
|
||||
let vc = delegate.statusActionAccountList(action: .reblog, statusID: statusID, statusState: statusState.copy(), accountIDs: nil)
|
||||
vc.showInacurateCountWarning = true
|
||||
delegate.show(vc)
|
||||
}
|
||||
|
|
|
@ -351,16 +351,6 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti
|
|||
}
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
// MARK: Accessibility
|
||||
|
||||
override var isAccessibilityElement: Bool {
|
||||
|
|
|
@ -93,16 +93,6 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
|
|||
updateActionsVisibility()
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listPlainCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
|
||||
override func createObserversIfNecessary() {
|
||||
super.createObserversIfNecessary()
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
//
|
||||
// TrendingStatusCollectionViewCell.swift
|
||||
// Tusker
|
||||
//
|
||||
// Created by Shadowfacts on 2/2/23.
|
||||
// Copyright © 2023 Shadowfacts. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class TrendingStatusCollectionViewCell: TimelineStatusCollectionViewCell {
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
var config = UIBackgroundConfiguration.listGroupedCell().updated(for: state)
|
||||
if state.isHighlighted || state.isSelected {
|
||||
config.backgroundColor = .appSelectedCellBackground
|
||||
} else {
|
||||
config.backgroundColor = .appGroupedCellBackground
|
||||
}
|
||||
backgroundConfiguration = config
|
||||
}
|
||||
}
|
|
@ -22,8 +22,6 @@ struct ToastConfiguration {
|
|||
var edge: Edge = .automatic
|
||||
var dismissOnScroll = true
|
||||
var dismissAutomaticallyAfter: TimeInterval? = nil
|
||||
var onAppear: ((UIViewPropertyAnimator?) -> Void)?
|
||||
var onDismiss: ((UIViewPropertyAnimator?) -> Void)?
|
||||
|
||||
init(title: String) {
|
||||
self.title = title
|
||||
|
|
|
@ -127,30 +127,22 @@ class ToastView: UIView {
|
|||
func dismissToast(animated: Bool) {
|
||||
guard animated else {
|
||||
removeFromSuperview()
|
||||
configuration.onDismiss?(nil)
|
||||
return
|
||||
}
|
||||
let animator = UIViewPropertyAnimator(duration: 0.25, curve: .easeInOut)
|
||||
animator.addAnimations {
|
||||
UIView.animate(withDuration: 0.25, delay: 0, options: .curveEaseInOut) {
|
||||
self.transform = CGAffineTransform(translationX: 0, y: self.offscreenTranslation)
|
||||
}
|
||||
animator.addCompletion { _ in
|
||||
} completion: { (_) in
|
||||
self.removeFromSuperview()
|
||||
}
|
||||
configuration.onDismiss?(animator)
|
||||
animator.startAnimation()
|
||||
}
|
||||
|
||||
func animateAppearance() {
|
||||
self.transform = CGAffineTransform(translationX: 0, y: offscreenTranslation)
|
||||
let duration = 0.5
|
||||
let velocity = CGVector(dx: 0, dy: 0.5)
|
||||
let animator = UIViewPropertyAnimator(duration: duration, timingParameters: UISpringTimingParameters(dampingRatio: 0.65, initialVelocity: velocity))
|
||||
animator.addAnimations {
|
||||
let velocity = 0.5
|
||||
UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 0.65, initialSpringVelocity: velocity, options: []) {
|
||||
self.transform = .identity
|
||||
}
|
||||
configuration.onAppear?(animator)
|
||||
animator.startAnimation()
|
||||
}
|
||||
|
||||
func setupDismissOnScroll(connectedTo scrollView: UIScrollView) {
|
||||
|
@ -192,14 +184,11 @@ class ToastView: UIView {
|
|||
shrinkAnimator = nil
|
||||
}
|
||||
|
||||
private var panGestureDismissAnimator: UIViewPropertyAnimator?
|
||||
|
||||
@objc private func panRecognized(_ recognizer: UIPanGestureRecognizer) {
|
||||
let translation = recognizer.translation(in: self).y
|
||||
|
||||
let isDraggingAwayFromDismissalEdge = (configuration.edge == .top && translation > 0) || (configuration.edge == .bottom && translation < 0)
|
||||
|
||||
|
||||
switch recognizer.state {
|
||||
case .began:
|
||||
recognizedGesture = true
|
||||
|
@ -207,25 +196,19 @@ class ToastView: UIView {
|
|||
UIView.animate(withDuration: 0.1, delay: 0, options: [.curveEaseInOut, .allowUserInteraction]) {
|
||||
self.transform = .identity
|
||||
}
|
||||
panGestureDismissAnimator = UIViewPropertyAnimator(duration: 0.2, curve: .easeInOut)
|
||||
configuration.onDismiss?(panGestureDismissAnimator!)
|
||||
break
|
||||
|
||||
case .changed:
|
||||
var distance: CGFloat
|
||||
var alongsideAnimationProgress: CGFloat
|
||||
if isDraggingAwayFromDismissalEdge {
|
||||
distance = sqrt(abs(translation))
|
||||
if configuration.edge == .bottom {
|
||||
distance *= -1
|
||||
}
|
||||
alongsideAnimationProgress = 0
|
||||
} else {
|
||||
distance = translation
|
||||
alongsideAnimationProgress = abs(translation) / (configuration.edgeSpacing + bounds.height)
|
||||
}
|
||||
|
||||
transform = CGAffineTransform(translationX: 0, y: distance)
|
||||
panGestureDismissAnimator!.fractionComplete = alongsideAnimationProgress
|
||||
|
||||
case .ended, .cancelled:
|
||||
let velocity = recognizer.velocity(in: self).y
|
||||
|
@ -236,31 +219,27 @@ class ToastView: UIView {
|
|||
|
||||
let minDismissalVelocity: CGFloat = 250
|
||||
let dismissDueToVelocity = configuration.edge == .bottom ? velocity > minDismissalDistance : velocity < -minDismissalVelocity
|
||||
|
||||
if dismissDueToDistance || dismissDueToVelocity {
|
||||
|
||||
if abs(translation) < abs(offscreenTranslation) {
|
||||
panGestureDismissAnimator!.addAnimations {
|
||||
let distanceLeft = offscreenTranslation - translation
|
||||
let duration = 1 / TimeInterval(max(velocity, minDismissalVelocity) / distanceLeft)
|
||||
|
||||
UIView.animate(withDuration: duration, delay: 0, options: .allowUserInteraction) {
|
||||
self.transform = CGAffineTransform(translationX: 0, y: self.offscreenTranslation)
|
||||
}
|
||||
panGestureDismissAnimator!.addCompletion { _ in
|
||||
} completion: { (_) in
|
||||
self.removeFromSuperview()
|
||||
}
|
||||
} else {
|
||||
self.removeFromSuperview()
|
||||
}
|
||||
|
||||
panGestureDismissAnimator!.startAnimation()
|
||||
|
||||
} else {
|
||||
let duration = 0.5
|
||||
let velocity = distance * duration
|
||||
UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 0.65, initialSpringVelocity: velocity, options: .allowUserInteraction) {
|
||||
self.transform = .identity
|
||||
}
|
||||
|
||||
panGestureDismissAnimator!.isReversed = true
|
||||
panGestureDismissAnimator!.startAnimation()
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
|
@ -77,8 +77,6 @@ extension ToastableViewController {
|
|||
|
||||
if animated {
|
||||
toast.animateAppearance()
|
||||
} else {
|
||||
config.onAppear?(nil)
|
||||
}
|
||||
|
||||
if config.dismissOnScroll,
|
||||
|
|
|
@ -16,7 +16,7 @@ class TrendHistoryView: UIView {
|
|||
private let curveRadius: CGFloat = 10
|
||||
|
||||
/// The base background color used for the graph fill.
|
||||
var effectiveBackgroundColor = UIColor.appBackground
|
||||
var effectiveBackgroundColor = UIColor.systemBackground
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
|
Loading…
Reference in New Issue