Skip to content

Commit

Permalink
Remove most imports of UIKit
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin committed Dec 8, 2023
1 parent 77b9cd0 commit 5e22ba5
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 19 deletions.
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 {
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
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))")
}
})
}
}
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

0 comments on commit 5e22ba5

Please sign in to comment.