Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove most imports of UIKit #801

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Mlem/App Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

import Foundation
import KeychainAccess
import UIKit

struct AppConstants {
enum AppConstants {
twizmwazin marked this conversation as resolved.
Show resolved Hide resolved
static let cacheSize = 500_000_000 // 500MB in bytes
static let urlCache: URLCache = .init(memoryCapacity: cacheSize, diskCapacity: cacheSize)
static let imageSizeCache: NSCache<NSString, ImageSize> = .init()
Expand Down
1 change: 0 additions & 1 deletion Mlem/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import Foundation
import SwiftUI
import UIKit

// TODO: we need to do a bit of work to ensure we also switch tab when responding to these
// as currently it launches you into the app, but if the app was already running you're left
Expand Down
2 changes: 0 additions & 2 deletions Mlem/Extensions/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
// Created by David Bureš on 26.03.2022.
//

import Foundation
import SwiftUI
import UIKit

extension Color {
// This is here to give me dynamic light/dark system colors for view backgrounds
Expand Down
1 change: 0 additions & 1 deletion Mlem/MlemApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Dependencies
import Nuke
import SwiftUI
import UIKit
import XCTestDynamicOverlay

@main
Expand Down
3 changes: 1 addition & 2 deletions Mlem/Notifications/NotificationDisplayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
//

import SwiftUI
import UIKit

/// A class responsible for displaying important notifications to the user
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this an enum, this makes it a value type instead of a reference type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class NotificationDisplayer {
enum NotificationDisplayer {
// MARK: - Public methods

/// A method that displays a `Notifiable` object to the user
Expand Down
19 changes: 11 additions & 8 deletions Mlem/Temp Image Viewer/ImageSaver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
//

import Foundation
import UIKit
import Photos

class ImageSaver: NSObject {
func writeToPhotoAlbum(imageData: Data) {
if let image = UIImage(data: imageData) {
UIImageWriteToSavedPhotosAlbum(image, self, #selector(saveCompleted), nil)
}
}

@objc func saveCompleted(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
print("Save finished!")
PHPhotoLibrary.shared().performChanges({
let creationRequest = PHAssetCreationRequest.forAsset()
creationRequest.addResource(with: .photo, data: imageData, options: nil)
}, completionHandler: { success, error in
if success {
print("Save finished!")
} else {
print("Error saving photo: \(String(describing: error?.localizedDescription))")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably good to call out we should maybe handle this better in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, OOS here but I've opened an issue: #802

}
})
}
}
1 change: 0 additions & 1 deletion Mlem/Temp Image Viewer/ZoomableContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import SwiftUI
import UIKit

// ref: https://stackoverflow.com/questions/74238414/is-there-an-easy-way-to-pinch-to-zoom-and-drag-any-view-in-swiftui

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import QuickLook
import UIKit

/// QuickLookPreviewController allows us to use UIKit's Quick Look view inside SwiftUI with interactive dismiss gesture, and a transparent background.
final class QuickLookPreviewController: UIViewController, QLPreviewControllerDataSource, QLPreviewControllerDelegate {
Expand Down
1 change: 0 additions & 1 deletion Mlem/Views/Tabs/Search/SearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Combine
import Dependencies
import Foundation
import SwiftUI
import UIKit

private struct ViewOffsetKey: PreferenceKey {
typealias Value = CGFloat
Expand Down