From 08f10550bf8707f3c62fbc0828a534336743b5ec Mon Sep 17 00:00:00 2001 From: Mustafa Merza <mustafa.merza95@gmail.com> Date: Sun, 21 Jul 2024 12:53:35 +0300 Subject: [PATCH] - Moved used ui images to image's extension. --- MiniScanner/Common/AppTabBarController.swift | 3 +-- MiniScanner/Extensions/UIImage+Images.swift | 11 +++++++++++ .../CustomTabBarView/CustomTabBarView.swift | 4 ++-- .../ShareSheet/ShareSheetViewController.swift | 2 +- .../Documents/DocumentsTableViewController.swift | 2 +- .../Supporting Files/FontChooserContainerView.swift | 2 +- .../Frameworks/FSPager/FSPagerViewCell.swift | 4 ++-- .../Supporting Files/ImageStickerContainerView.swift | 2 +- 8 files changed, 20 insertions(+), 10 deletions(-) diff --git a/MiniScanner/Common/AppTabBarController.swift b/MiniScanner/Common/AppTabBarController.swift index 192e8ba..ae7a3e4 100644 --- a/MiniScanner/Common/AppTabBarController.swift +++ b/MiniScanner/Common/AppTabBarController.swift @@ -122,8 +122,7 @@ class AppTabBar: UITabBar { } @objc private func setupMiddleButton() { - let image = UIImage(named: "add_doc_icon") - middleButton.setImage(image, for: UIControl.State.normal) + middleButton.setImage(.addDocIcon, for: UIControl.State.normal) middleButton.contentVerticalAlignment = .fill middleButton.contentHorizontalAlignment = .fill middleButton.imageEdgeInsets = .zero diff --git a/MiniScanner/Extensions/UIImage+Images.swift b/MiniScanner/Extensions/UIImage+Images.swift index 255f457..4bae801 100644 --- a/MiniScanner/Extensions/UIImage+Images.swift +++ b/MiniScanner/Extensions/UIImage+Images.swift @@ -11,6 +11,17 @@ import UIKit // MARK: - App images and icons extension UIImage { + static let addDocIcon = UIImage(named: "add_doc_icon") + static let preview = UIImage(named: "preview") + + static let tabbarIPad = UIImage(named: "tabbarIpad") + static let tabBar = UIImage(named: "tabBar") + + static let settings = UIImage(named: "settings") + + static let resize = UIImage(named: "resize") + + static let close = UIImage(named: "close") } // MARK: - Common system images and icons diff --git a/MiniScanner/Modules/Documents/Customs/CustomViews/CustomTabBarView/CustomTabBarView.swift b/MiniScanner/Modules/Documents/Customs/CustomViews/CustomTabBarView/CustomTabBarView.swift index df78b9d..d07f1a7 100644 --- a/MiniScanner/Modules/Documents/Customs/CustomViews/CustomTabBarView/CustomTabBarView.swift +++ b/MiniScanner/Modules/Documents/Customs/CustomViews/CustomTabBarView/CustomTabBarView.swift @@ -60,14 +60,14 @@ class CustomTabBarView: UIView { } private func setupUI() { - editImageIcon.image = UIImage(named: "preview") + editImageIcon.image = .preview editImageLabel.set(text: .preview.localized, color: .white, font: .medium(18)) editImageView.layer.cornerRadius = 10 editImageView.backgroundColor = .buttonsBlue badgeView.layer.cornerRadius = 10 badgeView.backgroundColor = .red - tabbarImage.image = UIDevice.current.userInterfaceIdiom == .pad ? UIImage(named: "tabbarIpad") : UIImage(named: "tabBar") + tabbarImage.image = UIDevice.current.userInterfaceIdiom == .pad ? .tabbarIPad : .tabBar tabbarImage.isHidden = isAddedToPDF fileManagerButton.isHidden = isAddedToPDF galleryButton.isHidden = isAddedToPDF diff --git a/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift b/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift index 6c3827d..1f9b3c1 100644 --- a/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift +++ b/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift @@ -67,7 +67,7 @@ class ShareSheetViewController: UIViewController { pdfImage.layer.cornerRadius = 10 pdfImage.clipsToBounds = true pdfImage.contentMode = .scaleAspectFill - previewButton.setImage(UIImage(named: "preview")?.tint(with: .mainText), for: .normal) + previewButton.setImage(.preview?.tint(with: .mainText), for: .normal) shareStackView.isHidden = !isShareShown shareStack_height.constant = isShareShown ? 96 : 0 } diff --git a/MiniScanner/Modules/Documents/DocumentsTableViewController.swift b/MiniScanner/Modules/Documents/DocumentsTableViewController.swift index bf853e9..100a5a0 100644 --- a/MiniScanner/Modules/Documents/DocumentsTableViewController.swift +++ b/MiniScanner/Modules/Documents/DocumentsTableViewController.swift @@ -64,7 +64,7 @@ final class DocumentsTableViewController: UIViewController, UITableViewDelegate, scanSession = MultiPageScanSession() options = ImageScannerOptions() navigationItem.title = .fileManager.localized - let settingsButton = UIBarButtonItem(image: UIImage(named: "settings"), style: .done, target: self, action: #selector(openSettings)) + let settingsButton = UIBarButtonItem(image: .settings, style: .done, target: self, action: #selector(openSettings)) navigationItem.rightBarButtonItem = settingsButton tableView.register(UINib(nibName: "DocumentsTableViewCell", bundle: nil), forCellReuseIdentifier: "DocumentsTableViewCell") diff --git a/MiniScanner/Supporting Files/FontChooserContainerView.swift b/MiniScanner/Supporting Files/FontChooserContainerView.swift index 9dafde4..78fb763 100644 --- a/MiniScanner/Supporting Files/FontChooserContainerView.swift +++ b/MiniScanner/Supporting Files/FontChooserContainerView.swift @@ -118,7 +118,7 @@ class FontChooserContainerView: UIView, ZLTextFontChooserDelegate { } let hideBtn = UIButton(type: .custom) - hideBtn.setImage(UIImage(named: "close"), for: .normal) + hideBtn.setImage(.close, for: .normal) hideBtn.backgroundColor = .clear hideBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14) hideBtn.addTarget(self, action: #selector(hideBtnClick), for: .touchUpInside) diff --git a/MiniScanner/Supporting Files/Frameworks/FSPager/FSPagerViewCell.swift b/MiniScanner/Supporting Files/Frameworks/FSPager/FSPagerViewCell.swift index 27a03d1..b2b792c 100644 --- a/MiniScanner/Supporting Files/Frameworks/FSPager/FSPagerViewCell.swift +++ b/MiniScanner/Supporting Files/Frameworks/FSPager/FSPagerViewCell.swift @@ -263,8 +263,8 @@ open class FSPagerViewCell: UICollectionViewCell { print("position: \(position)") stickerView.center = position stickerView.delegate = self - if let exitIcon = UIImage(named: "close"), - let rotateIcon = UIImage(named: "resize") { + if let exitIcon = UIImage.close, + let rotateIcon = UIImage.resize { stickerView.setImage(exitIcon, forHandler: StickerViewHandler.close) stickerView.setImage(rotateIcon, forHandler: StickerViewHandler.rotate) } diff --git a/MiniScanner/Supporting Files/ImageStickerContainerView.swift b/MiniScanner/Supporting Files/ImageStickerContainerView.swift index 8df375b..c9a96ba 100644 --- a/MiniScanner/Supporting Files/ImageStickerContainerView.swift +++ b/MiniScanner/Supporting Files/ImageStickerContainerView.swift @@ -69,7 +69,7 @@ class ImageStickerContainerView: UIView, ZLImageStickerContainerDelegate { } let hideBtn = UIButton(type: .custom) - hideBtn.setImage(UIImage(named: "close"), for: .normal) + hideBtn.setImage(.close, for: .normal) hideBtn.backgroundColor = .clear hideBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14) hideBtn.addTarget(self, action: #selector(hideBtnClick), for: .touchUpInside) -- GitLab