mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 02:01:02 +00:00
Swiftformat
This commit is contained in:
parent
94d50fafc4
commit
b259b6739e
31 changed files with 164 additions and 165 deletions
|
@ -3,12 +3,12 @@ import AppAccount
|
||||||
import Conversations
|
import Conversations
|
||||||
import DesignSystem
|
import DesignSystem
|
||||||
import Env
|
import Env
|
||||||
|
import LinkPresentation
|
||||||
import Lists
|
import Lists
|
||||||
|
import Models
|
||||||
import Status
|
import Status
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Timeline
|
import Timeline
|
||||||
import LinkPresentation
|
|
||||||
import Models
|
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
extension View {
|
extension View {
|
||||||
|
@ -124,7 +124,7 @@ struct ActivityView: UIViewControllerRepresentable {
|
||||||
self.status = status
|
self.status = status
|
||||||
}
|
}
|
||||||
|
|
||||||
func activityViewControllerLinkMetadata(_ activityViewController: UIActivityViewController) -> LPLinkMetadata? {
|
func activityViewControllerLinkMetadata(_: UIActivityViewController) -> LPLinkMetadata? {
|
||||||
let imageProvider = NSItemProvider(object: image)
|
let imageProvider = NSItemProvider(object: image)
|
||||||
let metadata = LPLinkMetadata()
|
let metadata = LPLinkMetadata()
|
||||||
metadata.imageProvider = imageProvider
|
metadata.imageProvider = imageProvider
|
||||||
|
@ -132,20 +132,21 @@ struct ActivityView: UIViewControllerRepresentable {
|
||||||
return metadata
|
return metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any {
|
func activityViewControllerPlaceholderItem(_: UIActivityViewController) -> Any {
|
||||||
image
|
image
|
||||||
}
|
}
|
||||||
|
|
||||||
func activityViewController(_ activityViewController: UIActivityViewController,
|
func activityViewController(_: UIActivityViewController,
|
||||||
itemForActivityType activityType: UIActivity.ActivityType?) -> Any? {
|
itemForActivityType _: UIActivity.ActivityType?) -> Any?
|
||||||
|
{
|
||||||
nil
|
nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeUIViewController(context: UIViewControllerRepresentableContext<ActivityView>) -> UIActivityViewController {
|
func makeUIViewController(context _: UIViewControllerRepresentableContext<ActivityView>) -> UIActivityViewController {
|
||||||
return UIActivityViewController(activityItems: [image, LinkDelegate(image: image, status: status)],
|
return UIActivityViewController(activityItems: [image, LinkDelegate(image: image, status: status)],
|
||||||
applicationActivities: nil)
|
applicationActivities: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUIViewController(_ uiViewController: UIActivityViewController, context: UIViewControllerRepresentableContext<ActivityView>) {}
|
func updateUIViewController(_: UIActivityViewController, context _: UIViewControllerRepresentableContext<ActivityView>) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,8 @@ struct IceCubesApp: App {
|
||||||
|
|
||||||
private func badgeFor(tab: Tab) -> Int {
|
private func badgeFor(tab: Tab) -> Int {
|
||||||
if tab == .notifications && selectedTab != tab,
|
if tab == .notifications && selectedTab != tab,
|
||||||
let token = appAccountsManager.currentAccount.oauthToken {
|
let token = appAccountsManager.currentAccount.oauthToken
|
||||||
|
{
|
||||||
return watcher.unreadNotificationsCount + userPreferences.getNotificationsCount(for: token)
|
return watcher.unreadNotificationsCount + userPreferences.getNotificationsCount(for: token)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
|
@ -169,7 +170,8 @@ struct IceCubesApp: App {
|
||||||
}
|
}
|
||||||
selectedTab = newTab
|
selectedTab = newTab
|
||||||
if selectedTab == .notifications,
|
if selectedTab == .notifications,
|
||||||
let token = appAccountsManager.currentAccount.oauthToken {
|
let token = appAccountsManager.currentAccount.oauthToken
|
||||||
|
{
|
||||||
userPreferences.setNotification(count: 0, token: token)
|
userPreferences.setNotification(count: 0, token: token)
|
||||||
watcher.unreadNotificationsCount = 0
|
watcher.unreadNotificationsCount = 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,14 +58,14 @@ private struct SafariRouter: ViewModifier {
|
||||||
|
|
||||||
private class InAppSafariManager: NSObject, ObservableObject, SFSafariViewControllerDelegate {
|
private class InAppSafariManager: NSObject, ObservableObject, SFSafariViewControllerDelegate {
|
||||||
var windowScene: UIWindowScene?
|
var windowScene: UIWindowScene?
|
||||||
let viewController: UIViewController = UIViewController()
|
let viewController: UIViewController = .init()
|
||||||
var window: UIWindow?
|
var window: UIWindow?
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
func open(_ url: URL) -> OpenURLAction.Result {
|
func open(_ url: URL) -> OpenURLAction.Result {
|
||||||
guard let windowScene = windowScene else { return .systemAction }
|
guard let windowScene = windowScene else { return .systemAction }
|
||||||
|
|
||||||
self.window = setupWindow(windowScene: windowScene)
|
window = setupWindow(windowScene: windowScene)
|
||||||
|
|
||||||
let configuration = SFSafariViewController.Configuration()
|
let configuration = SFSafariViewController.Configuration()
|
||||||
configuration.entersReaderIfAvailable = UserPreferences.shared.inAppBrowserReaderView
|
configuration.entersReaderIfAvailable = UserPreferences.shared.inAppBrowserReaderView
|
||||||
|
@ -99,7 +99,7 @@ private class InAppSafariManager: NSObject, ObservableObject, SFSafariViewContro
|
||||||
return window
|
return window
|
||||||
}
|
}
|
||||||
|
|
||||||
func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
|
func safariViewControllerDidFinish(_: SFSafariViewController) {
|
||||||
window?.resignKey()
|
window?.resignKey()
|
||||||
window?.isHidden = false
|
window?.isHidden = false
|
||||||
window = nil
|
window = nil
|
||||||
|
@ -109,12 +109,11 @@ private class InAppSafariManager: NSObject, ObservableObject, SFSafariViewContro
|
||||||
private struct WindowReader: UIViewRepresentable {
|
private struct WindowReader: UIViewRepresentable {
|
||||||
var onUpdate: (UIWindow) -> Void
|
var onUpdate: (UIWindow) -> Void
|
||||||
|
|
||||||
func makeUIView(context: Context) -> InjectView {
|
func makeUIView(context _: Context) -> InjectView {
|
||||||
InjectView(onUpdate: onUpdate)
|
InjectView(onUpdate: onUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUIView(_ uiView: InjectView, context: Context) {
|
func updateUIView(_: InjectView, context _: Context) {}
|
||||||
}
|
|
||||||
|
|
||||||
class InjectView: UIView {
|
class InjectView: UIView {
|
||||||
var onUpdate: (UIWindow) -> Void
|
var onUpdate: (UIWindow) -> Void
|
||||||
|
@ -127,7 +126,7 @@ private struct WindowReader: UIViewRepresentable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(*, unavailable)
|
@available(*, unavailable)
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder _: NSCoder) {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,8 @@ struct SideBarView<Content: View>: View {
|
||||||
|
|
||||||
private func badgeFor(tab: Tab) -> Int {
|
private func badgeFor(tab: Tab) -> Int {
|
||||||
if tab == .notifications && selectedTab != tab,
|
if tab == .notifications && selectedTab != tab,
|
||||||
let token = appAccounts.currentAccount.oauthToken {
|
let token = appAccounts.currentAccount.oauthToken
|
||||||
|
{
|
||||||
return watcher.unreadNotificationsCount + userPreferences.getNotificationsCount(for: token)
|
return watcher.unreadNotificationsCount + userPreferences.getNotificationsCount(for: token)
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
|
@ -79,7 +80,8 @@ struct SideBarView<Content: View>: View {
|
||||||
AppAccountView(viewModel: .init(appAccount: account, isCompact: true))
|
AppAccountView(viewModel: .init(appAccount: account, isCompact: true))
|
||||||
if showBadge,
|
if showBadge,
|
||||||
let token = account.oauthToken,
|
let token = account.oauthToken,
|
||||||
userPreferences.getNotificationsCount(for: token) > 0 {
|
userPreferences.getNotificationsCount(for: token) > 0
|
||||||
|
{
|
||||||
makeBadgeView(count: userPreferences.getNotificationsCount(for: token))
|
makeBadgeView(count: userPreferences.getNotificationsCount(for: token))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,8 @@ struct AccountDetailHeaderView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let note = viewModel.relationship?.note, !note.isEmpty,
|
if let note = viewModel.relationship?.note, !note.isEmpty,
|
||||||
!viewModel.isCurrentUser {
|
!viewModel.isCurrentUser
|
||||||
|
{
|
||||||
makeNoteView(note)
|
makeNoteView(note)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -485,8 +485,7 @@ public struct AccountDetailView: View {
|
||||||
|
|
||||||
private extension View {
|
private extension View {
|
||||||
func applyAccountDetailsRowStyle(theme: Theme) -> some View {
|
func applyAccountDetailsRowStyle(theme: Theme) -> some View {
|
||||||
self
|
listRowInsets(.init())
|
||||||
.listRowInsets(.init())
|
|
||||||
.listRowSeparator(.hidden)
|
.listRowSeparator(.hidden)
|
||||||
.listRowBackground(theme.primaryBackgroundColor)
|
.listRowBackground(theme.primaryBackgroundColor)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@ class EditRelationshipNoteViewModel: ObservableObject {
|
||||||
|
|
||||||
func save() async {
|
func save() async {
|
||||||
if relatedAccountId != nil,
|
if relatedAccountId != nil,
|
||||||
client != nil {
|
client != nil
|
||||||
|
{
|
||||||
isSaving = true
|
isSaving = true
|
||||||
do {
|
do {
|
||||||
let _ = try await client!.post(endpoint: Accounts.relationshipNote(id: relatedAccountId!, json: RelationshipNoteData(note: note)))
|
let _ = try await client!.post(endpoint: Accounts.relationshipNote(id: relatedAccountId!, json: RelationshipNoteData(note: note)))
|
||||||
|
|
|
@ -92,7 +92,8 @@ public struct AppAccountsSelectorView: View {
|
||||||
Image(uiImage: image)
|
Image(uiImage: image)
|
||||||
}
|
}
|
||||||
if let token = viewModel.appAccount.oauthToken,
|
if let token = viewModel.appAccount.oauthToken,
|
||||||
preferences.getNotificationsCount(for: token) > 0 {
|
preferences.getNotificationsCount(for: token) > 0
|
||||||
|
{
|
||||||
Text("\(viewModel.account?.displayName ?? "") (\(preferences.getNotificationsCount(for: token)))")
|
Text("\(viewModel.account?.displayName ?? "") (\(preferences.getNotificationsCount(for: token)))")
|
||||||
} else {
|
} else {
|
||||||
Text("\(viewModel.account?.displayName ?? "")")
|
Text("\(viewModel.account?.displayName ?? "")")
|
||||||
|
|
|
@ -15,12 +15,10 @@ public extension Font {
|
||||||
private static let onMac = ProcessInfo.processInfo.isiOSAppOnMac
|
private static let onMac = ProcessInfo.processInfo.isiOSAppOnMac
|
||||||
|
|
||||||
private static func customFont(size: CGFloat, relativeTo textStyle: TextStyle) -> Font {
|
private static func customFont(size: CGFloat, relativeTo textStyle: TextStyle) -> Font {
|
||||||
|
|
||||||
if let chosenFont = Theme.shared.chosenFont {
|
if let chosenFont = Theme.shared.chosenFont {
|
||||||
if chosenFont.fontName == ".AppleSystemUIFontRounded-Regular" {
|
if chosenFont.fontName == ".AppleSystemUIFontRounded-Regular" {
|
||||||
return .system(size: size, design: .rounded)
|
return .system(size: size, design: .rounded)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return .custom(chosenFont.fontName, size: size, relativeTo: textStyle)
|
return .custom(chosenFont.fontName, size: size, relativeTo: textStyle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,10 +70,8 @@ public extension Font {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public extension UIFont {
|
||||||
|
func rounded() -> UIFont {
|
||||||
extension UIFont {
|
|
||||||
public func rounded() -> UIFont {
|
|
||||||
guard let descriptor = fontDescriptor.withDesign(.rounded) else {
|
guard let descriptor = fontDescriptor.withDesign(.rounded) else {
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import NukeUI
|
|
||||||
import Nuke
|
import Nuke
|
||||||
|
import NukeUI
|
||||||
import Shimmer
|
import Shimmer
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class UserPreferences: ObservableObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public func getNotificationsTotalCount(for tokens: [OauthToken]) -> Int {
|
public func getNotificationsTotalCount(for tokens: [OauthToken]) -> Int {
|
||||||
var count: Int = 0
|
var count = 0
|
||||||
for token in tokens {
|
for token in tokens {
|
||||||
count += getNotificationsCount(for: token)
|
count += getNotificationsCount(for: token)
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,3 @@ public class UserPreferences: ObservableObject {
|
||||||
recentlyUsedLanguages = Array(copy.prefix(3))
|
recentlyUsedLanguages = Array(copy.prefix(3))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,9 @@ public struct Poll: Codable, Equatable, Hashable {
|
||||||
// the votersCount can be null according to the docs when multiple is false.
|
// the votersCount can be null according to the docs when multiple is false.
|
||||||
// Didn't find that to be true, but we make sure
|
// Didn't find that to be true, but we make sure
|
||||||
public var safeVotersCount: Int {
|
public var safeVotersCount: Int {
|
||||||
get {
|
|
||||||
return votersCount ?? votesCount
|
return votersCount ?? votesCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public struct NullableString: Codable, Equatable, Hashable {
|
public struct NullableString: Codable, Equatable, Hashable {
|
||||||
public let value: ServerDate?
|
public let value: ServerDate?
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct StatusRowActionsView: View {
|
||||||
@ObservedObject var viewModel: StatusRowViewModel
|
@ObservedObject var viewModel: StatusRowViewModel
|
||||||
|
|
||||||
func privateBoost() -> Bool {
|
func privateBoost() -> Bool {
|
||||||
return self.viewModel.status.visibility == .priv && self.viewModel.status.account.id == self.currentAccount.account?.id
|
return viewModel.status.visibility == .priv && viewModel.status.account.id == currentAccount.account?.id
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
|
@ -22,7 +22,7 @@ struct StatusRowActionsView: View {
|
||||||
case .respond:
|
case .respond:
|
||||||
return "arrowshape.turn.up.left"
|
return "arrowshape.turn.up.left"
|
||||||
case .boost:
|
case .boost:
|
||||||
if (privateBoost) {
|
if privateBoost {
|
||||||
return viewModel.isReblogged ? "arrow.left.arrow.right.circle.fill" : "lock.rotation"
|
return viewModel.isReblogged ? "arrow.left.arrow.right.circle.fill" : "lock.rotation"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
import DesignSystem
|
||||||
import Env
|
import Env
|
||||||
import Foundation
|
import Foundation
|
||||||
import SwiftUI
|
|
||||||
import DesignSystem
|
|
||||||
import Network
|
import Network
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
struct StatusRowContextMenu: View {
|
struct StatusRowContextMenu: View {
|
||||||
@Environment(\.displayScale) var displayScale
|
@Environment(\.displayScale) var displayScale
|
||||||
|
@ -201,9 +201,9 @@ struct StatusRowContextMenu: View {
|
||||||
struct ActivityView: UIViewControllerRepresentable {
|
struct ActivityView: UIViewControllerRepresentable {
|
||||||
let image: Image
|
let image: Image
|
||||||
|
|
||||||
func makeUIViewController(context: UIViewControllerRepresentableContext<ActivityView>) -> UIActivityViewController {
|
func makeUIViewController(context _: UIViewControllerRepresentableContext<ActivityView>) -> UIActivityViewController {
|
||||||
return UIActivityViewController(activityItems: [image], applicationActivities: nil)
|
return UIActivityViewController(activityItems: [image], applicationActivities: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUIViewController(_ uiViewController: UIActivityViewController, context: UIViewControllerRepresentableContext<ActivityView>) {}
|
func updateUIViewController(_: UIActivityViewController, context _: UIViewControllerRepresentableContext<ActivityView>) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import DesignSystem
|
import DesignSystem
|
||||||
|
import Env
|
||||||
import Models
|
import Models
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Env
|
|
||||||
|
|
||||||
struct StatusRowHeaderView: View {
|
struct StatusRowHeaderView: View {
|
||||||
@Environment(\.isInCaptureMode) private var isInCaptureMode: Bool
|
@Environment(\.isInCaptureMode) private var isInCaptureMode: Bool
|
||||||
|
|
|
@ -156,7 +156,8 @@ public struct StatusRowMediaPreviewView: View {
|
||||||
case .image:
|
case .image:
|
||||||
if isInCaptureMode,
|
if isInCaptureMode,
|
||||||
let image = Nuke.ImagePipeline.shared.cache.cachedImage(for: .init(url: attachment.url,
|
let image = Nuke.ImagePipeline.shared.cache.cachedImage(for: .init(url: attachment.url,
|
||||||
processors: processors))?.image {
|
processors: processors))?.image
|
||||||
|
{
|
||||||
Image(uiImage: image)
|
Image(uiImage: image)
|
||||||
.resizable()
|
.resizable()
|
||||||
.aspectRatio(contentMode: .fill)
|
.aspectRatio(contentMode: .fill)
|
||||||
|
@ -246,7 +247,8 @@ public struct StatusRowMediaPreviewView: View {
|
||||||
let alt = attachment.description,
|
let alt = attachment.description,
|
||||||
!alt.isEmpty,
|
!alt.isEmpty,
|
||||||
!isNotifications,
|
!isNotifications,
|
||||||
preferences.showAltTextForMedia {
|
preferences.showAltTextForMedia
|
||||||
|
{
|
||||||
Button {
|
Button {
|
||||||
altTextDisplayed = alt
|
altTextDisplayed = alt
|
||||||
isAltAlertDisplayed = true
|
isAltAlertDisplayed = true
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
import SwiftUI
|
|
||||||
import UIKit
|
|
||||||
import Models
|
import Models
|
||||||
import Nuke
|
import Nuke
|
||||||
|
import SwiftUI
|
||||||
|
import UIKit
|
||||||
|
|
||||||
final class TimelinePrefetcher: NSObject, ObservableObject, UICollectionViewDataSourcePrefetching {
|
final class TimelinePrefetcher: NSObject, ObservableObject, UICollectionViewDataSourcePrefetching {
|
||||||
private let prefetcher = ImagePrefetcher()
|
private let prefetcher = ImagePrefetcher()
|
||||||
|
|
||||||
weak var viewModel: TimelineViewModel?
|
weak var viewModel: TimelineViewModel?
|
||||||
|
|
||||||
func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) {
|
func collectionView(_: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) {
|
||||||
let imageURLs = getImageURLs(for: indexPaths)
|
let imageURLs = getImageURLs(for: indexPaths)
|
||||||
prefetcher.startPrefetching(with: imageURLs)
|
prefetcher.startPrefetching(with: imageURLs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func collectionView(_ collectionView: UICollectionView, cancelPrefetchingForItemsAt indexPaths: [IndexPath]) {
|
func collectionView(_: UICollectionView, cancelPrefetchingForItemsAt indexPaths: [IndexPath]) {
|
||||||
let imageURLs = getImageURLs(for: indexPaths)
|
let imageURLs = getImageURLs(for: indexPaths)
|
||||||
prefetcher.stopPrefetching(with: imageURLs)
|
prefetcher.stopPrefetching(with: imageURLs)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getImageURLs(for indexPaths: [IndexPath]) -> [URL] {
|
private func getImageURLs(for indexPaths: [IndexPath]) -> [URL] {
|
||||||
guard let viewModel, case .display(let statuses, _) = viewModel.statusesState else {
|
guard let viewModel, case let .display(statuses, _) = viewModel.statusesState else {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return indexPaths.compactMap {
|
return indexPaths.compactMap {
|
||||||
|
|
Loading…
Reference in a new issue