From 2afbf04456a8bdf7a934ea5cb0e66a6d47e267be Mon Sep 17 00:00:00 2001 From: Mustafa Merza <mustafa.merza95@gmail.com> Date: Wed, 14 Aug 2024 17:21:53 +0300 Subject: [PATCH] - Fixed used fonts values in UIKit views and view controllers. --- .../DocumentPreviewViewController.swift | 22 +++++++++----- .../ScanSessionPreviewViewController.swift | 30 ++++++++++++------- .../DocumentsCollectionViewCell.swift | 13 ++++++-- .../DocumentsTableViewCell.swift | 11 +++++-- .../AllFolderTableViewCell.swift | 11 ++++++- .../FolderCollectionViewCell.swift | 2 +- .../CustomTabBarView/CustomTabBarView.swift | 18 +++++++---- .../KNAlert/KNAlertViewController.swift | 22 ++++++++++---- .../SearchFilesView/SearchFilesView.swift | 10 ++++++- .../ShareSheet/ShareSheetViewController.swift | 30 +++++++++++++------ .../DocumentsTableViewController.swift | 9 ++++-- .../FolderSelectCollectionViewCell.swift | 7 ++++- .../FoldersViewController.swift | 6 ++++ .../EditViewController.swift | 19 +++++++++--- .../OCRViewController/OCRViewController.swift | 8 +++++ 15 files changed, 165 insertions(+), 53 deletions(-) diff --git a/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift b/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift index 842d135..1394d8d 100644 --- a/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift +++ b/MiniScanner/Modules/DocumentPreview/DocumentPreviewViewController.swift @@ -105,7 +105,7 @@ final class DocumentPreviewViewController: UIViewController, ScanSessionSharable setupColors() - titleLabel.set(font: .regular(15)) + setupFonts() titleLabel.text = session.name @@ -116,20 +116,13 @@ final class DocumentPreviewViewController: UIViewController, ScanSessionSharable activityIndicator.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true activityIndicator.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true - currentPageLabel.set(font: .regular(15)) - currentPageLabel.layer.cornerRadius = 5 - selectedPagesLabel.set(font: .regular(15)) - clearSelectionButton.setTitle(.clear.localized, for: .normal) - clearSelectionButton.titleLabel?.set(font: .regular(12)) extraButton.showsMenuAsPrimaryAction = true extraButton.transform = extraButton.transform.rotated(by: .pi/2) - shareTypeLabel.set(font: .regular(15)) - updateSelectedImagesLabel() updateCurrentPageLabel() @@ -169,6 +162,19 @@ final class DocumentPreviewViewController: UIViewController, ScanSessionSharable layoutButton.customTint(.gray600) } + private func setupFonts() { + + titleLabel.set(font: .bold(22)) + + clearSelectionButton.titleLabel?.set(font: .medium(16)) + + selectedPagesLabel.set(font: .medium(16)) + + currentPageLabel.set(font: .medium(15)) + + shareTypeLabel.set(font: .semibold(16)) + } + private func setupPagerView() { pagerView.register(ScannedItemPagerViewCell.self, forCellWithReuseIdentifier: Constants.cellIdentifier) diff --git a/MiniScanner/Modules/DocumentPreview/ScanSessionPreview/ScanSessionPreviewViewController.swift b/MiniScanner/Modules/DocumentPreview/ScanSessionPreview/ScanSessionPreviewViewController.swift index 7a9257a..6661f77 100644 --- a/MiniScanner/Modules/DocumentPreview/ScanSessionPreview/ScanSessionPreviewViewController.swift +++ b/MiniScanner/Modules/DocumentPreview/ScanSessionPreview/ScanSessionPreviewViewController.swift @@ -59,23 +59,35 @@ extension ScanSessionPreviewViewController { private func setupUI() { - view.customBackground(.base) + setupColors() - closeButton.customTint(.gray600) + setupFonts() - nextPageButton.customTint(.gray600) - previousPageButton.customTint(.gray600) + currentPageLabel.layer.cornerRadius = 5 + + updateCurrentPageLabel() + + setupPagerView() + } + + private func setupColors() { - currentPageLabel.set(font: .regular(15)) currentPageLabel.set(color: .gray600) currentPageLabel.customLayerBackground(.gray100) - currentPageLabel.layer.cornerRadius = 5 + view.customBackground(.base) - updateCurrentPageLabel() + closeButton.customTint(.gray600) - setupPagerView() + nextPageButton.customTint(.gray600) + previousPageButton.customTint(.gray600) + + pagerView.customBackground(.clear) + } + + private func setupFonts() { + currentPageLabel.set(font: .medium(16)) } private func updateCurrentPageIndex(index: Int) { @@ -107,8 +119,6 @@ extension ScanSessionPreviewViewController { pagerView.dataSource = self pagerView.delegate = self - - pagerView.customBackground(.clear) } } diff --git a/MiniScanner/Modules/Documents/Customs/CustomCells/DocumentsCollectionViewCell/DocumentsCollectionViewCell.swift b/MiniScanner/Modules/Documents/Customs/CustomCells/DocumentsCollectionViewCell/DocumentsCollectionViewCell.swift index 28a1032..40a1a13 100644 --- a/MiniScanner/Modules/Documents/Customs/CustomCells/DocumentsCollectionViewCell/DocumentsCollectionViewCell.swift +++ b/MiniScanner/Modules/Documents/Customs/CustomCells/DocumentsCollectionViewCell/DocumentsCollectionViewCell.swift @@ -40,9 +40,7 @@ class DocumentsCollectionViewCell: UICollectionViewCell { private func setupUI() { setupColors() - - nameLabel.set(font: .medium(16)) - detailsLabel.set(font: .regular(10)) + setupFonts() contentView.cornerRadiuss = 20 contentView.borderWidth = 2 @@ -62,6 +60,15 @@ class DocumentsCollectionViewCell: UICollectionViewCell { nameLabel.set(color: .gray600) detailsLabel.set(color: .gray600) + dateLabel.set(color: .gray600) + } + + private func setupFonts() { + + nameLabel.set(font: .semibold(16)) + + detailsLabel.set(font: .regular(10)) + dateLabel.set(font: .regular(10)) } private func setupMenu(indexPath: IndexPath) { diff --git a/MiniScanner/Modules/Documents/Customs/CustomCells/DocumentsTableViewCell/DocumentsTableViewCell.swift b/MiniScanner/Modules/Documents/Customs/CustomCells/DocumentsTableViewCell/DocumentsTableViewCell.swift index 4b4bd52..d16d151 100644 --- a/MiniScanner/Modules/Documents/Customs/CustomCells/DocumentsTableViewCell/DocumentsTableViewCell.swift +++ b/MiniScanner/Modules/Documents/Customs/CustomCells/DocumentsTableViewCell/DocumentsTableViewCell.swift @@ -42,6 +42,8 @@ final class DocumentsTableViewCell: UITableViewCell { setupColors() + setupFonts() + selectionStyle = .none innerView.cornerRadiuss = 20 @@ -50,9 +52,6 @@ final class DocumentsTableViewCell: UITableViewCell { extraButton.transform = extraButton.transform.rotated(by: .pi/2) thumbnailImageView.image = .file - - dateLabel.set(font: .regular(16)) - nameLabel.set(font: .medium(16)) } private func setupColors() { @@ -66,6 +65,12 @@ final class DocumentsTableViewCell: UITableViewCell { extraButton.customTint(.gray600) } + private func setupFonts() { + + nameLabel.set(font: .semibold(16)) + dateLabel.set(font: .regular(12)) + } + private func setupMenu(indexPath: IndexPath) { let move = UIAction(title: .move.localized) { _ in diff --git a/MiniScanner/Modules/Documents/Customs/CustomViews/AllFolderTableView/AllFolderTableViewCell.swift b/MiniScanner/Modules/Documents/Customs/CustomViews/AllFolderTableView/AllFolderTableViewCell.swift index 1878779..3177a4d 100644 --- a/MiniScanner/Modules/Documents/Customs/CustomViews/AllFolderTableView/AllFolderTableViewCell.swift +++ b/MiniScanner/Modules/Documents/Customs/CustomViews/AllFolderTableView/AllFolderTableViewCell.swift @@ -40,8 +40,13 @@ final class AllFolderTableViewCell: UIView { } private func setupUI() { + setupColors() + setupFonts() + + setupCollectionView() + addFolderButton.set(localized: .add) foldersLabel.set(localized: .folders) } @@ -58,7 +63,6 @@ final class AllFolderTableViewCell: UIView { view.autoresizingMask = [.flexibleHeight, .flexibleWidth] addSubview(view) - setupCollectionView() } private func setupColors() { @@ -71,6 +75,11 @@ final class AllFolderTableViewCell: UIView { addFolderButton.set(color: .primary) } + private func setupFonts() { + + foldersLabel.set(font: .bold(20)) + } + @IBAction func addFolderButtonTapped(_ sender: UIButton) { delegate?.addFolderTapped() } diff --git a/MiniScanner/Modules/Documents/Customs/CustomViews/AllFolderTableView/CustomCells/FolderCollectionViewCell.swift b/MiniScanner/Modules/Documents/Customs/CustomViews/AllFolderTableView/CustomCells/FolderCollectionViewCell.swift index 5384d0d..c080bd4 100644 --- a/MiniScanner/Modules/Documents/Customs/CustomViews/AllFolderTableView/CustomCells/FolderCollectionViewCell.swift +++ b/MiniScanner/Modules/Documents/Customs/CustomViews/AllFolderTableView/CustomCells/FolderCollectionViewCell.swift @@ -44,7 +44,7 @@ class FolderCollectionViewCell: UICollectionViewCell { boxView.customBackground(isFolderSelected ? .primary : .gray100) - titleLabel.set(font: isFolderSelected ? .bold(18) : .medium(18)) + titleLabel.set(font: isFolderSelected ? .bold(16) : .medium(16)) titleLabel.set(color: isFolderSelected ? .gray0 : .gray600) } diff --git a/MiniScanner/Modules/Documents/Customs/CustomViews/CustomTabBarView/CustomTabBarView.swift b/MiniScanner/Modules/Documents/Customs/CustomViews/CustomTabBarView/CustomTabBarView.swift index 458c3fd..3c76ba2 100644 --- a/MiniScanner/Modules/Documents/Customs/CustomViews/CustomTabBarView/CustomTabBarView.swift +++ b/MiniScanner/Modules/Documents/Customs/CustomViews/CustomTabBarView/CustomTabBarView.swift @@ -71,10 +71,11 @@ class CustomTabBarView: UIView { setupColors() + setupFonts() + editImageIcon.image = .preview editImageLabel.set(text: .preview.localized) - editImageLabel.set(font: .medium(18)) editImageView.layer.cornerRadius = 10 @@ -89,12 +90,8 @@ class CustomTabBarView: UIView { galleryButton.setImage(.gallery, for: .normal) fileManagerLabel.set(localized: .fileManager) - fileManagerLabel.set(font: .medium(16)) galleryLabel.set(localized: .gallery) - galleryLabel.set(font: .medium(16)) - - badgeLabel.set(font: .medium(14)) } private func setupColors() { @@ -108,6 +105,17 @@ class CustomTabBarView: UIView { galleryLabel.set(color: .gray600) } + private func setupFonts() { + + fileManagerLabel.set(font: .medium(16)) + + galleryLabel.set(font: .medium(16)) + + editImageLabel.set(font: .medium(18)) + + badgeLabel.set(font: .regular(14)) + } + func updateScannedView(session: ScanSession) { if !session.scannedItems.isEmpty { diff --git a/MiniScanner/Modules/Documents/Customs/CustomViews/KNAlert/KNAlertViewController.swift b/MiniScanner/Modules/Documents/Customs/CustomViews/KNAlert/KNAlertViewController.swift index 7479dbf..b8cc94f 100644 --- a/MiniScanner/Modules/Documents/Customs/CustomViews/KNAlert/KNAlertViewController.swift +++ b/MiniScanner/Modules/Documents/Customs/CustomViews/KNAlert/KNAlertViewController.swift @@ -138,17 +138,16 @@ extension KNAlertViewController { setupColors() + setupFonts() + // alert alertView.layer.cornerRadius = 16 - titleLabel.set(color: .gray600) - titleLabel.font = .bold(20) titleLabel.textAlignment = .center // text messageTextView.textAlignment = .center messageTextView.textColor = ColorStyle.gray600.uiColor - messageTextView.font = .medium(16) messageTextView.text = "" messageTextView.isEditable = false messageTextView.isSelectable = false @@ -160,13 +159,11 @@ extension KNAlertViewController { // buttons - confirmationButton.set(font: .bold(17)) confirmationButton.set(localized: confirmButtonTitle) confirmationButton.layer.cornerRadius = 20 confirmationButton.addTarget(self, action: #selector(confirmationButtonTapped), for: .touchUpInside) - destructiveButton.set(font: .bold(17)) destructiveButton.set(localized: destructiveButtonTitle) destructiveButton.layer.cornerRadius = 20 @@ -194,6 +191,8 @@ extension KNAlertViewController { alertView.customBackground(.base) + titleLabel.set(color: .gray600) + buttonStackView.customBackground(.clear) destructiveButton.customBackground(.gray100) @@ -203,6 +202,19 @@ extension KNAlertViewController { confirmationButton.customBackground(.gray600) } + private func setupFonts() { + + folderName.font = .regular(14) + + titleLabel.set(font: .bold(20)) + + messageTextView.font = .regular(18) + + confirmationButton.set(font: .bold(20)) + + destructiveButton.set(font: .regular(20)) + } + @objc func textChanged() { folderNameText = folderName.text ?? "" confirmationButton.isEnabled = folderName.text != "" ? true : false diff --git a/MiniScanner/Modules/Documents/Customs/CustomViews/SearchFilesView/SearchFilesView.swift b/MiniScanner/Modules/Documents/Customs/CustomViews/SearchFilesView/SearchFilesView.swift index 94cf922..fc2b0b4 100644 --- a/MiniScanner/Modules/Documents/Customs/CustomViews/SearchFilesView/SearchFilesView.swift +++ b/MiniScanner/Modules/Documents/Customs/CustomViews/SearchFilesView/SearchFilesView.swift @@ -84,8 +84,9 @@ final class SearchFilesView: UIView { setupColors() + setupFonts() + titleLabel.set(text: .folderFiles.localized) - titleLabel.set(font: .bold(20)) searchTextField.isHidden = true searchTextField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged) @@ -107,6 +108,13 @@ final class SearchFilesView: UIView { titleLabel.set(color: .gray600) } + private func setupFonts() { + + searchTextField.font = .regular(14) + + titleLabel.set(font: .semibold(18)) + } + func reloadLocalization() { titleLabel.set(text: .folderFiles.localized) } diff --git a/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift b/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift index 0575b50..0d17861 100644 --- a/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift +++ b/MiniScanner/Modules/Documents/Customs/CustomViews/ShareSheet/ShareSheetViewController.swift @@ -79,31 +79,25 @@ class ShareSheetViewController: UIViewController { setupColors() + setupFonts() + pagesCountLabel.set(text: "") - pagesCountLabel.set(font: .regular(16)) saveLabel.set(localized: .save) - saveLabel.set(font: .regular(12)) - shareTypeLabel.set(localized: shareType.displayName, color: .gray600, font: .regular(12)) + shareTypeLabel.set(localized: shareType.displayName) whatsappLabel.set(localized: .whatsapp) - whatsappLabel.set(font: .regular(12)) telegramLabel.set(localized: .telegram) - telegramLabel.set(font: .regular(12)) gmailLabel.set(localized: .gmail) - gmailLabel.set(font: .regular(12)) airdropLabel.set(localized: .airdrop) - airdropLabel.set(font: .regular(12)) printLabel.set(localized: .print) - printLabel.set(font: .regular(12)) moreLabel.set(localized: .more) - moreLabel.set(font: .regular(12)) whatsappLabel.textAlignment = .center telegramLabel.textAlignment = .center @@ -156,6 +150,24 @@ class ShareSheetViewController: UIViewController { backgroundView.customBackground(.base) } + private func setupFonts() { + + fileNameTextField.font = .semibold(24) + + pagesCountLabel.set(font: .regular(14)) + + shareTypeLabel.set(font: .semibold(16)) + + saveLabel.set(font: .semibold(16)) + + whatsappLabel.set(font: .regular(16)) + telegramLabel.set(font: .regular(16)) + gmailLabel.set(font: .regular(16)) + airdropLabel.set(font: .regular(16)) + printLabel.set(font: .regular(16)) + moreLabel.set(font: .regular(16)) + } + private func setup() { thumbnailImage.image = session.scannedItems[0].newRenderedImage?.retrieveImage() diff --git a/MiniScanner/Modules/Documents/DocumentsTableViewController.swift b/MiniScanner/Modules/Documents/DocumentsTableViewController.swift index f445066..7a55cb5 100644 --- a/MiniScanner/Modules/Documents/DocumentsTableViewController.swift +++ b/MiniScanner/Modules/Documents/DocumentsTableViewController.swift @@ -132,8 +132,6 @@ extension DocumentsTableViewController { noFilesLabel.set(text: .noFilesToShow.localized) - noFilesLabel.set(font: .medium(22)) - if userSettings.defaultScreen == .camera { openCamera() } @@ -149,6 +147,11 @@ extension DocumentsTableViewController { collectionView.customBackground(.clear) } + private func setupFonts() { + + noFilesLabel.set(font: .medium(22)) + } + private func setupToolbar() { let settingsButton = UIBarButtonItem(image: .settings, style: .done, target: self, action: #selector(settingsTapped)) @@ -217,6 +220,8 @@ extension DocumentsTableViewController { noFilesLabel.set(text: .noFilesToShow.localized) + setupFonts() + allFoldersView.reloadLocalization() searchForFilesView.reloadLocalization() } diff --git a/MiniScanner/Modules/Documents/FoldersViewController/CustomCells/FolderSelectCollectionViewCell.swift b/MiniScanner/Modules/Documents/FoldersViewController/CustomCells/FolderSelectCollectionViewCell.swift index 102084f..7daf03b 100644 --- a/MiniScanner/Modules/Documents/FoldersViewController/CustomCells/FolderSelectCollectionViewCell.swift +++ b/MiniScanner/Modules/Documents/FoldersViewController/CustomCells/FolderSelectCollectionViewCell.swift @@ -21,13 +21,18 @@ class FolderSelectCollectionViewCell: UICollectionViewCell { private func setupUI() { setupColors() - folderTitle.set(font: .bold(15)) + + setupFonts() } private func setupColors() { folderTitle.set(color: .gray600) } + private func setupFonts() { + folderTitle.set(font: .medium(15)) + } + func set(title: String) { self.folderTitle.set(text: title) } diff --git a/MiniScanner/Modules/Documents/FoldersViewController/FoldersViewController.swift b/MiniScanner/Modules/Documents/FoldersViewController/FoldersViewController.swift index 1d643f3..7aaac93 100644 --- a/MiniScanner/Modules/Documents/FoldersViewController/FoldersViewController.swift +++ b/MiniScanner/Modules/Documents/FoldersViewController/FoldersViewController.swift @@ -58,6 +58,8 @@ class FoldersViewController: UIViewController { setupColors() + setupFonts() + searchBar.delegate = self titleLabel.text = .selectFolder.localized @@ -83,6 +85,10 @@ class FoldersViewController: UIViewController { titleLabel.set(color: .gray600) } + + private func setupFonts() { + titleLabel.set(font: .semibold(18)) + } } // MARK: - UICollectionViewDelegate diff --git a/MiniScanner/Modules/EditViewController/EditViewController.swift b/MiniScanner/Modules/EditViewController/EditViewController.swift index 3305515..c6f0ac8 100644 --- a/MiniScanner/Modules/EditViewController/EditViewController.swift +++ b/MiniScanner/Modules/EditViewController/EditViewController.swift @@ -147,6 +147,8 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess setupColors() + setupFonts() + banner.set(session: scanSession) banner.delegate = self @@ -169,8 +171,6 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess directShareLabel.set(localized: .directShare) - shareTypeLabel.set(font: .regular(15)) - shareType = userSettings.defaultFileType.shareType setupMenu() @@ -189,8 +189,6 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess pageIndex.layer.cornerRadius = 5 - pageIndex.set(font: .regular(15)) - hideCropButtons() } @@ -223,6 +221,19 @@ public class EditViewController: UIViewController, ScanSessionSharable, ScanSess saveCropButton.customTitleColor(.gray0) } + private func setupFonts() { + + pageIndex.set(font: .medium(16)) + directShareLabel.set(font: .medium(16)) + + shareTypeLabel.set(font: .semibold(16)) + + signatureLabel.set(font: .medium(14)) + exportTextLabel.set(font: .medium(14)) + editLabel.set(font: .medium(14)) + cropLabel.set(font: .medium(14)) + } + // MARK: - Methods @objc func backTapped() { if navigationItem.rightBarButtonItem == nil { diff --git a/MiniScanner/Modules/OCRViewController/OCRViewController.swift b/MiniScanner/Modules/OCRViewController/OCRViewController.swift index 7459b8b..81844d0 100644 --- a/MiniScanner/Modules/OCRViewController/OCRViewController.swift +++ b/MiniScanner/Modules/OCRViewController/OCRViewController.swift @@ -78,6 +78,10 @@ class OCRViewController: UIViewController { private func setupUI() { + setupColors() + + setupFonts() + view.addSubview(activityIndicator) activityIndicator.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true @@ -97,6 +101,10 @@ class OCRViewController: UIViewController { ocrTextView.customBorderColor(.gray450) } + + private func setupFonts() { + ocrTextView.font = .regular(16) + } } extension OCRViewController { -- GitLab