From dc353fa267c7a1106640da996b7b620505dd2520 Mon Sep 17 00:00:00 2001 From: Impresyjna Date: Thu, 6 Sep 2018 21:58:55 +0200 Subject: [PATCH 1/3] Setting done button title from Config, changing everything to make it work for swift 4.2 --- Sources/Camera/CameraView.swift | 8 +- Sources/Camera/TripleButton.swift | 4 +- Sources/Images/ImagesController.swift | 4 +- Sources/Utils/Config.swift | 205 +++++++++--------- Sources/Utils/Constraints.swift | 4 +- .../Utils/Dropdown/DropdownController.swift | 2 +- .../UIViewController+Extensions.swift | 8 +- Sources/Utils/Pages/PageIndicator.swift | 4 +- Sources/Utils/Pages/PagesController.swift | 4 +- .../Permission/PermissionController.swift | 2 +- Sources/Utils/Permission/PermissionView.swift | 6 +- .../VideoEditor/AdvancedVideoEditor.swift | 2 +- Sources/Utils/VideoEditor/EditInfo.swift | 4 +- Sources/Utils/VideoEditor/VideoEditor.swift | 2 +- Sources/Utils/View/AlbumCell.swift | 2 +- Sources/Utils/View/GridView.swift | 8 +- 16 files changed, 136 insertions(+), 133 deletions(-) diff --git a/Sources/Camera/CameraView.swift b/Sources/Camera/CameraView.swift index 2b223c63..9caa6b00 100644 --- a/Sources/Camera/CameraView.swift +++ b/Sources/Camera/CameraView.swift @@ -167,7 +167,7 @@ class CameraView: UIView, UIGestureRecognizerDelegate { func makeCloseButton() -> UIButton { let button = UIButton(type: .custom) - button.setImage(GalleryBundle.image("gallery_close"), for: UIControl.State()) + button.setImage(GalleryBundle.image("gallery_close"), for: UIControlState()) return button } @@ -186,7 +186,7 @@ class CameraView: UIView, UIGestureRecognizerDelegate { func makeRotateButton() -> UIButton { let button = UIButton(type: .custom) - button.setImage(GalleryBundle.image("gallery_camera_rotate"), for: UIControl.State()) + button.setImage(GalleryBundle.image("gallery_camera_rotate"), for: UIControlState()) return button } @@ -220,10 +220,10 @@ class CameraView: UIView, UIGestureRecognizerDelegate { func makeDoneButton() -> UIButton { let button = UIButton(type: .system) - button.setTitleColor(UIColor.white, for: UIControl.State()) + button.setTitleColor(UIColor.white, for: UIControlState()) button.setTitleColor(UIColor.lightGray, for: .disabled) button.titleLabel?.font = Config.Font.Text.regular.withSize(16) - button.setTitle("Gallery.Done".g_localize(fallback: "Done"), for: UIControl.State()) + button.setTitle("Gallery.Done".g_localize(fallback: Config.DoneButton.title), for: UIControlState()) return button } diff --git a/Sources/Camera/TripleButton.swift b/Sources/Camera/TripleButton.swift index 81ba1631..721fd389 100644 --- a/Sources/Camera/TripleButton.swift +++ b/Sources/Camera/TripleButton.swift @@ -46,7 +46,7 @@ class TripleButton: UIButton { let state = states[index] - setTitle(state.title, for: UIControl.State()) - setImage(state.image, for: UIControl.State()) + setTitle(state.title, for: UIControlState()) + setImage(state.image, for: UIControlState()) } } diff --git a/Sources/Images/ImagesController.swift b/Sources/Images/ImagesController.swift index c70a3160..5e8f014a 100644 --- a/Sources/Images/ImagesController.swift +++ b/Sources/Images/ImagesController.swift @@ -40,9 +40,9 @@ class ImagesController: UIViewController { view.addSubview(gridView) - addChild(dropdownController) + addChildViewController(dropdownController) gridView.insertSubview(dropdownController.view, belowSubview: gridView.topView) - dropdownController.didMove(toParent: self) + dropdownController.didMove(toParentViewController: self) gridView.bottomView.addSubview(stackView) diff --git a/Sources/Utils/Config.swift b/Sources/Utils/Config.swift index 07dbc955..67d74bf3 100644 --- a/Sources/Utils/Config.swift +++ b/Sources/Utils/Config.swift @@ -2,117 +2,120 @@ import UIKit import AVFoundation public struct Config { - - @available(*, deprecated, message: "Use tabsToShow instead.") - public static var showsVideoTab: Bool { - // Maintains backwards-compatibility. - get { - return tabsToShow.index(of: .videoTab) != nil - } - set(newValue) { - if !newValue { - tabsToShow = tabsToShow.filter({$0 != .videoTab}) - } else { - if tabsToShow.index(of: .videoTab) == nil { - tabsToShow.append(.videoTab) + + @available(*, deprecated, message: "Use tabsToShow instead.") + public static var showsVideoTab: Bool { + // Maintains backwards-compatibility. + get { + return tabsToShow.index(of: .videoTab) != nil + } + set(newValue) { + if !newValue { + tabsToShow = tabsToShow.filter({$0 != .videoTab}) + } else { + if tabsToShow.index(of: .videoTab) == nil { + tabsToShow.append(.videoTab) + } + } } - } - } - } - public static var tabsToShow: [GalleryTab] = [.imageTab, .cameraTab, .videoTab] - // Defaults to cameraTab if present, or whatever tab is first if cameraTab isn't present. - public static var initialTab: GalleryTab? - - public enum GalleryTab { - case imageTab - case cameraTab - case videoTab - } - - public struct PageIndicator { - public static var backgroundColor: UIColor = UIColor(red: 0, green: 3/255, blue: 10/255, alpha: 1) - public static var textColor: UIColor = UIColor.white - } - - public struct Camera { - - public static var recordLocation: Bool = false - - public struct ShutterButton { - public static var numberColor: UIColor = UIColor(red: 54/255, green: 56/255, blue: 62/255, alpha: 1) - } - - public struct BottomContainer { - public static var backgroundColor: UIColor = UIColor(red: 23/255, green: 25/255, blue: 28/255, alpha: 0.8) } - - public struct StackView { - public static let imageCount: Int = 4 + public static var tabsToShow: [GalleryTab] = [.imageTab, .cameraTab, .videoTab] + // Defaults to cameraTab if present, or whatever tab is first if cameraTab isn't present. + public static var initialTab: GalleryTab? + + public enum GalleryTab { + case imageTab + case cameraTab + case videoTab } - public static var imageLimit: Int = 0 + public struct PageIndicator { + public static var backgroundColor: UIColor = UIColor(red: 0, green: 3/255, blue: 10/255, alpha: 1) + public static var textColor: UIColor = UIColor.white + } - } - - public struct Grid { - - public struct CloseButton { - public static var tintColor: UIColor = UIColor(red: 109/255, green: 107/255, blue: 132/255, alpha: 1) + public struct Camera { + + public static var recordLocation: Bool = false + + public struct ShutterButton { + public static var numberColor: UIColor = UIColor(red: 54/255, green: 56/255, blue: 62/255, alpha: 1) + } + + public struct BottomContainer { + public static var backgroundColor: UIColor = UIColor(red: 23/255, green: 25/255, blue: 28/255, alpha: 0.8) + } + + public struct StackView { + public static let imageCount: Int = 4 + } + + public static var imageLimit: Int = 0 } - - public struct ArrowButton { - public static var tintColor: UIColor = UIColor(red: 110/255, green: 117/255, blue: 131/255, alpha: 1) + + public struct Grid { + + public struct CloseButton { + public static var tintColor: UIColor = UIColor(red: 109/255, green: 107/255, blue: 132/255, alpha: 1) + } + + public struct ArrowButton { + public static var tintColor: UIColor = UIColor(red: 110/255, green: 117/255, blue: 131/255, alpha: 1) + } + + public struct FrameView { + public static var fillColor: UIColor = UIColor(red: 50/255, green: 51/255, blue: 59/255, alpha: 1) + public static var borderColor: UIColor = UIColor(red: 0, green: 239/255, blue: 155/255, alpha: 1) + } + + struct Dimension { + static let columnCount: CGFloat = 4 + static let cellSpacing: CGFloat = 2 + } } - - public struct FrameView { - public static var fillColor: UIColor = UIColor(red: 50/255, green: 51/255, blue: 59/255, alpha: 1) - public static var borderColor: UIColor = UIColor(red: 0, green: 239/255, blue: 155/255, alpha: 1) + + public struct EmptyView { + public static var image: UIImage? = GalleryBundle.image("gallery_empty_view_image") + public static var textColor: UIColor = UIColor(red: 102/255, green: 118/255, blue: 138/255, alpha: 1) } - - struct Dimension { - static let columnCount: CGFloat = 4 - static let cellSpacing: CGFloat = 2 + + public struct Permission { + public static var image: UIImage? = GalleryBundle.image("gallery_permission_view_camera") + public static var textColor: UIColor = UIColor(red: 102/255, green: 118/255, blue: 138/255, alpha: 1) + + public struct Button { + public static var textColor: UIColor = UIColor.white + public static var highlightedTextColor: UIColor = UIColor.lightGray + public static var backgroundColor = UIColor(red: 40/255, green: 170/255, blue: 236/255, alpha: 1) + } } - } - - public struct EmptyView { - public static var image: UIImage? = GalleryBundle.image("gallery_empty_view_image") - public static var textColor: UIColor = UIColor(red: 102/255, green: 118/255, blue: 138/255, alpha: 1) - } - - public struct Permission { - public static var image: UIImage? = GalleryBundle.image("gallery_permission_view_camera") - public static var textColor: UIColor = UIColor(red: 102/255, green: 118/255, blue: 138/255, alpha: 1) - - public struct Button { - public static var textColor: UIColor = UIColor.white - public static var highlightedTextColor: UIColor = UIColor.lightGray - public static var backgroundColor = UIColor(red: 40/255, green: 170/255, blue: 236/255, alpha: 1) + + public struct Font { + + public struct Main { + public static var light: UIFont = UIFont.systemFont(ofSize: 1) + public static var regular: UIFont = UIFont.systemFont(ofSize: 1) + public static var bold: UIFont = UIFont.boldSystemFont(ofSize: 1) + public static var medium: UIFont = UIFont.boldSystemFont(ofSize: 1) + } + + public struct Text { + public static var regular: UIFont = UIFont.systemFont(ofSize: 1) + public static var bold: UIFont = UIFont.boldSystemFont(ofSize: 1) + public static var semibold: UIFont = UIFont.boldSystemFont(ofSize: 1) + } } - } - - public struct Font { - - public struct Main { - public static var light: UIFont = UIFont.systemFont(ofSize: 1) - public static var regular: UIFont = UIFont.systemFont(ofSize: 1) - public static var bold: UIFont = UIFont.boldSystemFont(ofSize: 1) - public static var medium: UIFont = UIFont.boldSystemFont(ofSize: 1) + + public struct VideoEditor { + + public static var quality: String = AVAssetExportPresetHighestQuality + public static var savesEditedVideoToLibrary: Bool = false + public static var maximumDuration: TimeInterval = 15 + public static var portraitSize: CGSize = CGSize(width: 360, height: 640) + public static var landscapeSize: CGSize = CGSize(width: 640, height: 360) } - - public struct Text { - public static var regular: UIFont = UIFont.systemFont(ofSize: 1) - public static var bold: UIFont = UIFont.boldSystemFont(ofSize: 1) - public static var semibold: UIFont = UIFont.boldSystemFont(ofSize: 1) + + public struct DoneButton { + public static var title: String = "Done" } - } - - public struct VideoEditor { - - public static var quality: String = AVAssetExportPresetHighestQuality - public static var savesEditedVideoToLibrary: Bool = false - public static var maximumDuration: TimeInterval = 15 - public static var portraitSize: CGSize = CGSize(width: 360, height: 640) - public static var landscapeSize: CGSize = CGSize(width: 640, height: 360) - } } diff --git a/Sources/Utils/Constraints.swift b/Sources/Utils/Constraints.swift index 4d676b52..2d971e61 100644 --- a/Sources/Utils/Constraints.swift +++ b/Sources/Utils/Constraints.swift @@ -2,8 +2,8 @@ import UIKit extension UIView { - @discardableResult func g_pin(on type1: NSLayoutConstraint.Attribute, - view: UIView? = nil, on type2: NSLayoutConstraint.Attribute? = nil, + @discardableResult func g_pin(on type1: NSLayoutAttribute, + view: UIView? = nil, on type2: NSLayoutAttribute? = nil, constant: CGFloat = 0, priority: Float? = nil) -> NSLayoutConstraint? { guard let view = view ?? superview else { diff --git a/Sources/Utils/Dropdown/DropdownController.swift b/Sources/Utils/Dropdown/DropdownController.swift index 55ae0602..a9ebfb5f 100644 --- a/Sources/Utils/Dropdown/DropdownController.swift +++ b/Sources/Utils/Dropdown/DropdownController.swift @@ -64,7 +64,7 @@ class DropdownController: UIViewController { collapsedTopConstraint?.isActive = true } - UIView.animate(withDuration: 0.25, delay: 0, options: UIView.AnimationOptions(), animations: { + UIView.animate(withDuration: 0.25, delay: 0, options: UIViewAnimationOptions(), animations: { self.view.superview?.layoutIfNeeded() }, completion: { finished in self.animating = false diff --git a/Sources/Utils/Extensions/UIViewController+Extensions.swift b/Sources/Utils/Extensions/UIViewController+Extensions.swift index e5314575..50e24c04 100644 --- a/Sources/Utils/Extensions/UIViewController+Extensions.swift +++ b/Sources/Utils/Extensions/UIViewController+Extensions.swift @@ -3,16 +3,16 @@ import UIKit extension UIViewController { func g_addChildController(_ controller: UIViewController) { - addChild(controller) + addChildViewController(controller) view.addSubview(controller.view) - controller.didMove(toParent: self) + controller.didMove(toParentViewController: self) controller.view.g_pinEdges() } func g_removeFromParentController() { - willMove(toParent: nil) + willMove(toParentViewController: nil) view.removeFromSuperview() - removeFromParent() + removeFromParentViewController() } } diff --git a/Sources/Utils/Pages/PageIndicator.swift b/Sources/Utils/Pages/PageIndicator.swift index 1f6835e8..70dd166c 100644 --- a/Sources/Utils/Pages/PageIndicator.swift +++ b/Sources/Utils/Pages/PageIndicator.swift @@ -69,8 +69,8 @@ class PageIndicator: UIView { func makeButton(_ title: String) -> UIButton { let button = UIButton(type: .custom) - button.setTitle(title, for: UIControl.State()) - button.setTitleColor(Config.PageIndicator.textColor, for: UIControl.State()) + button.setTitle(title, for: UIControlState()) + button.setTitleColor(Config.PageIndicator.textColor, for: UIControlState()) button.setTitleColor(UIColor.gray, for: .highlighted) button.backgroundColor = Config.PageIndicator.backgroundColor button.addTarget(self, action: #selector(buttonTouched(_:)), for: .touchUpInside) diff --git a/Sources/Utils/Pages/PagesController.swift b/Sources/Utils/Pages/PagesController.swift index 777887d9..0a24eb3d 100644 --- a/Sources/Utils/Pages/PagesController.swift +++ b/Sources/Utils/Pages/PagesController.swift @@ -119,9 +119,9 @@ class PagesController: UIViewController { scrollViewContentView.g_pinEdges() for (i, controller) in controllers.enumerated() { - addChild(controller) + addChildViewController(controller) scrollViewContentView.addSubview(controller.view) - controller.didMove(toParent: self) + controller.didMove(toParentViewController: self) controller.view.g_pin(on: .top) controller.view.g_pin(on: .bottom) diff --git a/Sources/Utils/Permission/PermissionController.swift b/Sources/Utils/Permission/PermissionController.swift index 2e60b6ad..15ecb6c3 100644 --- a/Sources/Utils/Permission/PermissionController.swift +++ b/Sources/Utils/Permission/PermissionController.swift @@ -67,7 +67,7 @@ class PermissionController: UIViewController { @objc func settingButtonTouched(_ button: UIButton) { DispatchQueue.main.async { - if let settingsURL = URL(string: UIApplication.openSettingsURLString) { + if let settingsURL = URL(string: UIApplicationOpenSettingsURLString) { UIApplication.shared.openURL(settingsURL) } } diff --git a/Sources/Utils/Permission/PermissionView.swift b/Sources/Utils/Permission/PermissionView.swift index 1a9598c4..c4ea4629 100644 --- a/Sources/Utils/Permission/PermissionView.swift +++ b/Sources/Utils/Permission/PermissionView.swift @@ -63,10 +63,10 @@ class PermissionView: UIView { func makeSettingButton() -> UIButton { let button = UIButton(type: .custom) button.setTitle("Gallery.Permission.Button".g_localize(fallback: "Go to Settings").uppercased(), - for: UIControl.State()) + for: UIControlState()) button.backgroundColor = Config.Permission.Button.backgroundColor button.titleLabel?.font = Config.Font.Main.medium.withSize(16) - button.setTitleColor(Config.Permission.Button.textColor, for: UIControl.State()) + button.setTitleColor(Config.Permission.Button.textColor, for: UIControlState()) button.setTitleColor(Config.Permission.Button.highlightedTextColor, for: .highlighted) button.layer.cornerRadius = 22 button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15) @@ -76,7 +76,7 @@ class PermissionView: UIView { func makeCloseButton() -> UIButton { let button = UIButton(type: .custom) - button.setImage(GalleryBundle.image("gallery_close")?.withRenderingMode(.alwaysTemplate), for: UIControl.State()) + button.setImage(GalleryBundle.image("gallery_close")?.withRenderingMode(.alwaysTemplate), for: UIControlState()) button.tintColor = Config.Grid.CloseButton.tintColor return button diff --git a/Sources/Utils/VideoEditor/AdvancedVideoEditor.swift b/Sources/Utils/VideoEditor/AdvancedVideoEditor.swift index c6347aff..2ec7f00d 100644 --- a/Sources/Utils/VideoEditor/AdvancedVideoEditor.swift +++ b/Sources/Utils/VideoEditor/AdvancedVideoEditor.swift @@ -53,7 +53,7 @@ public class AdvancedVideoEditor: VideoEditing { // Start writer.startWriting() reader.startReading() - writer.startSession(atSourceTime: CMTime.zero) + writer.startSession(atSourceTime: kCMTimeInvalid) // Video if let videoOutput = videoOutput, let videoInput = videoInput { diff --git a/Sources/Utils/VideoEditor/EditInfo.swift b/Sources/Utils/VideoEditor/EditInfo.swift index 2b691172..b981c3e9 100644 --- a/Sources/Utils/VideoEditor/EditInfo.swift +++ b/Sources/Utils/VideoEditor/EditInfo.swift @@ -11,7 +11,7 @@ struct EditInfo { let cropInfo = EditInfo.cropInfo(avAsset) let layer = AVMutableVideoCompositionLayerInstruction(assetTrack: track) - layer.setTransform(EditInfo.transform(avAsset, scale: cropInfo.scale), at: CMTime.zero) + layer.setTransform(EditInfo.transform(avAsset, scale: cropInfo.scale), at: kCMTimeZero) let instruction = AVMutableVideoCompositionInstruction() instruction.layerInstructions = [layer] @@ -81,7 +81,7 @@ struct EditInfo { end = CMTime(seconds: Config.VideoEditor.maximumDuration, preferredTimescale: 1000) } - return CMTimeRange(start: CMTime.zero, duration: end) + return CMTimeRange(start: kCMTimeZero, duration: end) } static var file: (type: AVFileType, pathExtension: String) { diff --git a/Sources/Utils/VideoEditor/VideoEditor.swift b/Sources/Utils/VideoEditor/VideoEditor.swift index 6238b5b1..ba87fddf 100644 --- a/Sources/Utils/VideoEditor/VideoEditor.swift +++ b/Sources/Utils/VideoEditor/VideoEditor.swift @@ -30,7 +30,7 @@ public class VideoEditor: VideoEditing { export?.shouldOptimizeForNetworkUse = true export?.exportAsynchronously { - if export?.status == AVAssetExportSession.Status.completed { + if export?.status == AVAssetExportSessionStatus.completed { completion(outputURL) } else { completion(nil) diff --git a/Sources/Utils/View/AlbumCell.swift b/Sources/Utils/View/AlbumCell.swift index dfca31dc..ff367a45 100644 --- a/Sources/Utils/View/AlbumCell.swift +++ b/Sources/Utils/View/AlbumCell.swift @@ -8,7 +8,7 @@ class AlbumCell: UITableViewCell { // MARK: - Initialization - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) setup() diff --git a/Sources/Utils/View/GridView.swift b/Sources/Utils/View/GridView.swift index d9bc11a9..4b76b69d 100644 --- a/Sources/Utils/View/GridView.swift +++ b/Sources/Utils/View/GridView.swift @@ -119,7 +119,7 @@ class GridView: UIView { private func makeCloseButton() -> UIButton { let button = UIButton(type: .custom) - button.setImage(GalleryBundle.image("gallery_close")?.withRenderingMode(.alwaysTemplate), for: UIControl.State()) + button.setImage(GalleryBundle.image("gallery_close")?.withRenderingMode(.alwaysTemplate), for: UIControlState()) button.tintColor = Config.Grid.CloseButton.tintColor return button @@ -127,10 +127,10 @@ class GridView: UIView { private func makeDoneButton() -> UIButton { let button = UIButton(type: .system) - button.setTitleColor(UIColor.white, for: UIControl.State()) + button.setTitleColor(UIColor.white, for: UIControlState()) button.setTitleColor(UIColor.lightGray, for: .disabled) button.titleLabel?.font = Config.Font.Text.regular.withSize(16) - button.setTitle("Gallery.Done".g_localize(fallback: "Done"), for: UIControl.State()) + button.setTitle("Gallery.Done".g_localize(fallback: Config.DoneButton.title), for: UIControlState()) return button } @@ -154,7 +154,7 @@ class GridView: UIView { } private func makeLoadingIndicator() -> UIActivityIndicatorView { - let view = UIActivityIndicatorView(style: .whiteLarge) + let view = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge) view.color = .gray view.hidesWhenStopped = true From 156ae0340a18b09635cd20595cdb2128d60766ac Mon Sep 17 00:00:00 2001 From: Impresyjna Date: Sun, 14 Oct 2018 22:33:11 +0200 Subject: [PATCH 2/3] Revert "Setting done button title from Config, changing everything to make it work for swift 4.2" This reverts commit dc353fa267c7a1106640da996b7b620505dd2520. --- Sources/Camera/CameraView.swift | 8 +- Sources/Camera/TripleButton.swift | 4 +- Sources/Images/ImagesController.swift | 4 +- Sources/Utils/Config.swift | 205 +++++++++--------- Sources/Utils/Constraints.swift | 4 +- .../Utils/Dropdown/DropdownController.swift | 2 +- .../UIViewController+Extensions.swift | 8 +- Sources/Utils/Pages/PageIndicator.swift | 4 +- Sources/Utils/Pages/PagesController.swift | 4 +- .../Permission/PermissionController.swift | 2 +- Sources/Utils/Permission/PermissionView.swift | 6 +- .../VideoEditor/AdvancedVideoEditor.swift | 2 +- Sources/Utils/VideoEditor/EditInfo.swift | 4 +- Sources/Utils/VideoEditor/VideoEditor.swift | 2 +- Sources/Utils/View/AlbumCell.swift | 2 +- Sources/Utils/View/GridView.swift | 8 +- 16 files changed, 133 insertions(+), 136 deletions(-) diff --git a/Sources/Camera/CameraView.swift b/Sources/Camera/CameraView.swift index 9caa6b00..2b223c63 100644 --- a/Sources/Camera/CameraView.swift +++ b/Sources/Camera/CameraView.swift @@ -167,7 +167,7 @@ class CameraView: UIView, UIGestureRecognizerDelegate { func makeCloseButton() -> UIButton { let button = UIButton(type: .custom) - button.setImage(GalleryBundle.image("gallery_close"), for: UIControlState()) + button.setImage(GalleryBundle.image("gallery_close"), for: UIControl.State()) return button } @@ -186,7 +186,7 @@ class CameraView: UIView, UIGestureRecognizerDelegate { func makeRotateButton() -> UIButton { let button = UIButton(type: .custom) - button.setImage(GalleryBundle.image("gallery_camera_rotate"), for: UIControlState()) + button.setImage(GalleryBundle.image("gallery_camera_rotate"), for: UIControl.State()) return button } @@ -220,10 +220,10 @@ class CameraView: UIView, UIGestureRecognizerDelegate { func makeDoneButton() -> UIButton { let button = UIButton(type: .system) - button.setTitleColor(UIColor.white, for: UIControlState()) + button.setTitleColor(UIColor.white, for: UIControl.State()) button.setTitleColor(UIColor.lightGray, for: .disabled) button.titleLabel?.font = Config.Font.Text.regular.withSize(16) - button.setTitle("Gallery.Done".g_localize(fallback: Config.DoneButton.title), for: UIControlState()) + button.setTitle("Gallery.Done".g_localize(fallback: "Done"), for: UIControl.State()) return button } diff --git a/Sources/Camera/TripleButton.swift b/Sources/Camera/TripleButton.swift index 721fd389..81ba1631 100644 --- a/Sources/Camera/TripleButton.swift +++ b/Sources/Camera/TripleButton.swift @@ -46,7 +46,7 @@ class TripleButton: UIButton { let state = states[index] - setTitle(state.title, for: UIControlState()) - setImage(state.image, for: UIControlState()) + setTitle(state.title, for: UIControl.State()) + setImage(state.image, for: UIControl.State()) } } diff --git a/Sources/Images/ImagesController.swift b/Sources/Images/ImagesController.swift index 5e8f014a..c70a3160 100644 --- a/Sources/Images/ImagesController.swift +++ b/Sources/Images/ImagesController.swift @@ -40,9 +40,9 @@ class ImagesController: UIViewController { view.addSubview(gridView) - addChildViewController(dropdownController) + addChild(dropdownController) gridView.insertSubview(dropdownController.view, belowSubview: gridView.topView) - dropdownController.didMove(toParentViewController: self) + dropdownController.didMove(toParent: self) gridView.bottomView.addSubview(stackView) diff --git a/Sources/Utils/Config.swift b/Sources/Utils/Config.swift index 67d74bf3..07dbc955 100644 --- a/Sources/Utils/Config.swift +++ b/Sources/Utils/Config.swift @@ -2,120 +2,117 @@ import UIKit import AVFoundation public struct Config { - - @available(*, deprecated, message: "Use tabsToShow instead.") - public static var showsVideoTab: Bool { - // Maintains backwards-compatibility. - get { - return tabsToShow.index(of: .videoTab) != nil - } - set(newValue) { - if !newValue { - tabsToShow = tabsToShow.filter({$0 != .videoTab}) - } else { - if tabsToShow.index(of: .videoTab) == nil { - tabsToShow.append(.videoTab) - } - } + + @available(*, deprecated, message: "Use tabsToShow instead.") + public static var showsVideoTab: Bool { + // Maintains backwards-compatibility. + get { + return tabsToShow.index(of: .videoTab) != nil + } + set(newValue) { + if !newValue { + tabsToShow = tabsToShow.filter({$0 != .videoTab}) + } else { + if tabsToShow.index(of: .videoTab) == nil { + tabsToShow.append(.videoTab) } + } } - public static var tabsToShow: [GalleryTab] = [.imageTab, .cameraTab, .videoTab] - // Defaults to cameraTab if present, or whatever tab is first if cameraTab isn't present. - public static var initialTab: GalleryTab? - - public enum GalleryTab { - case imageTab - case cameraTab - case videoTab + } + public static var tabsToShow: [GalleryTab] = [.imageTab, .cameraTab, .videoTab] + // Defaults to cameraTab if present, or whatever tab is first if cameraTab isn't present. + public static var initialTab: GalleryTab? + + public enum GalleryTab { + case imageTab + case cameraTab + case videoTab + } + + public struct PageIndicator { + public static var backgroundColor: UIColor = UIColor(red: 0, green: 3/255, blue: 10/255, alpha: 1) + public static var textColor: UIColor = UIColor.white + } + + public struct Camera { + + public static var recordLocation: Bool = false + + public struct ShutterButton { + public static var numberColor: UIColor = UIColor(red: 54/255, green: 56/255, blue: 62/255, alpha: 1) } - - public struct PageIndicator { - public static var backgroundColor: UIColor = UIColor(red: 0, green: 3/255, blue: 10/255, alpha: 1) - public static var textColor: UIColor = UIColor.white + + public struct BottomContainer { + public static var backgroundColor: UIColor = UIColor(red: 23/255, green: 25/255, blue: 28/255, alpha: 0.8) } - - public struct Camera { - - public static var recordLocation: Bool = false - - public struct ShutterButton { - public static var numberColor: UIColor = UIColor(red: 54/255, green: 56/255, blue: 62/255, alpha: 1) - } - - public struct BottomContainer { - public static var backgroundColor: UIColor = UIColor(red: 23/255, green: 25/255, blue: 28/255, alpha: 0.8) - } - - public struct StackView { - public static let imageCount: Int = 4 - } - - public static var imageLimit: Int = 0 + + public struct StackView { + public static let imageCount: Int = 4 } - public struct Grid { - - public struct CloseButton { - public static var tintColor: UIColor = UIColor(red: 109/255, green: 107/255, blue: 132/255, alpha: 1) - } - - public struct ArrowButton { - public static var tintColor: UIColor = UIColor(red: 110/255, green: 117/255, blue: 131/255, alpha: 1) - } - - public struct FrameView { - public static var fillColor: UIColor = UIColor(red: 50/255, green: 51/255, blue: 59/255, alpha: 1) - public static var borderColor: UIColor = UIColor(red: 0, green: 239/255, blue: 155/255, alpha: 1) - } - - struct Dimension { - static let columnCount: CGFloat = 4 - static let cellSpacing: CGFloat = 2 - } - } + public static var imageLimit: Int = 0 - public struct EmptyView { - public static var image: UIImage? = GalleryBundle.image("gallery_empty_view_image") - public static var textColor: UIColor = UIColor(red: 102/255, green: 118/255, blue: 138/255, alpha: 1) + } + + public struct Grid { + + public struct CloseButton { + public static var tintColor: UIColor = UIColor(red: 109/255, green: 107/255, blue: 132/255, alpha: 1) } - - public struct Permission { - public static var image: UIImage? = GalleryBundle.image("gallery_permission_view_camera") - public static var textColor: UIColor = UIColor(red: 102/255, green: 118/255, blue: 138/255, alpha: 1) - - public struct Button { - public static var textColor: UIColor = UIColor.white - public static var highlightedTextColor: UIColor = UIColor.lightGray - public static var backgroundColor = UIColor(red: 40/255, green: 170/255, blue: 236/255, alpha: 1) - } + + public struct ArrowButton { + public static var tintColor: UIColor = UIColor(red: 110/255, green: 117/255, blue: 131/255, alpha: 1) } - - public struct Font { - - public struct Main { - public static var light: UIFont = UIFont.systemFont(ofSize: 1) - public static var regular: UIFont = UIFont.systemFont(ofSize: 1) - public static var bold: UIFont = UIFont.boldSystemFont(ofSize: 1) - public static var medium: UIFont = UIFont.boldSystemFont(ofSize: 1) - } - - public struct Text { - public static var regular: UIFont = UIFont.systemFont(ofSize: 1) - public static var bold: UIFont = UIFont.boldSystemFont(ofSize: 1) - public static var semibold: UIFont = UIFont.boldSystemFont(ofSize: 1) - } + + public struct FrameView { + public static var fillColor: UIColor = UIColor(red: 50/255, green: 51/255, blue: 59/255, alpha: 1) + public static var borderColor: UIColor = UIColor(red: 0, green: 239/255, blue: 155/255, alpha: 1) } - - public struct VideoEditor { - - public static var quality: String = AVAssetExportPresetHighestQuality - public static var savesEditedVideoToLibrary: Bool = false - public static var maximumDuration: TimeInterval = 15 - public static var portraitSize: CGSize = CGSize(width: 360, height: 640) - public static var landscapeSize: CGSize = CGSize(width: 640, height: 360) + + struct Dimension { + static let columnCount: CGFloat = 4 + static let cellSpacing: CGFloat = 2 } - - public struct DoneButton { - public static var title: String = "Done" + } + + public struct EmptyView { + public static var image: UIImage? = GalleryBundle.image("gallery_empty_view_image") + public static var textColor: UIColor = UIColor(red: 102/255, green: 118/255, blue: 138/255, alpha: 1) + } + + public struct Permission { + public static var image: UIImage? = GalleryBundle.image("gallery_permission_view_camera") + public static var textColor: UIColor = UIColor(red: 102/255, green: 118/255, blue: 138/255, alpha: 1) + + public struct Button { + public static var textColor: UIColor = UIColor.white + public static var highlightedTextColor: UIColor = UIColor.lightGray + public static var backgroundColor = UIColor(red: 40/255, green: 170/255, blue: 236/255, alpha: 1) + } + } + + public struct Font { + + public struct Main { + public static var light: UIFont = UIFont.systemFont(ofSize: 1) + public static var regular: UIFont = UIFont.systemFont(ofSize: 1) + public static var bold: UIFont = UIFont.boldSystemFont(ofSize: 1) + public static var medium: UIFont = UIFont.boldSystemFont(ofSize: 1) + } + + public struct Text { + public static var regular: UIFont = UIFont.systemFont(ofSize: 1) + public static var bold: UIFont = UIFont.boldSystemFont(ofSize: 1) + public static var semibold: UIFont = UIFont.boldSystemFont(ofSize: 1) } + } + + public struct VideoEditor { + + public static var quality: String = AVAssetExportPresetHighestQuality + public static var savesEditedVideoToLibrary: Bool = false + public static var maximumDuration: TimeInterval = 15 + public static var portraitSize: CGSize = CGSize(width: 360, height: 640) + public static var landscapeSize: CGSize = CGSize(width: 640, height: 360) + } } diff --git a/Sources/Utils/Constraints.swift b/Sources/Utils/Constraints.swift index 2d971e61..4d676b52 100644 --- a/Sources/Utils/Constraints.swift +++ b/Sources/Utils/Constraints.swift @@ -2,8 +2,8 @@ import UIKit extension UIView { - @discardableResult func g_pin(on type1: NSLayoutAttribute, - view: UIView? = nil, on type2: NSLayoutAttribute? = nil, + @discardableResult func g_pin(on type1: NSLayoutConstraint.Attribute, + view: UIView? = nil, on type2: NSLayoutConstraint.Attribute? = nil, constant: CGFloat = 0, priority: Float? = nil) -> NSLayoutConstraint? { guard let view = view ?? superview else { diff --git a/Sources/Utils/Dropdown/DropdownController.swift b/Sources/Utils/Dropdown/DropdownController.swift index a9ebfb5f..55ae0602 100644 --- a/Sources/Utils/Dropdown/DropdownController.swift +++ b/Sources/Utils/Dropdown/DropdownController.swift @@ -64,7 +64,7 @@ class DropdownController: UIViewController { collapsedTopConstraint?.isActive = true } - UIView.animate(withDuration: 0.25, delay: 0, options: UIViewAnimationOptions(), animations: { + UIView.animate(withDuration: 0.25, delay: 0, options: UIView.AnimationOptions(), animations: { self.view.superview?.layoutIfNeeded() }, completion: { finished in self.animating = false diff --git a/Sources/Utils/Extensions/UIViewController+Extensions.swift b/Sources/Utils/Extensions/UIViewController+Extensions.swift index 50e24c04..e5314575 100644 --- a/Sources/Utils/Extensions/UIViewController+Extensions.swift +++ b/Sources/Utils/Extensions/UIViewController+Extensions.swift @@ -3,16 +3,16 @@ import UIKit extension UIViewController { func g_addChildController(_ controller: UIViewController) { - addChildViewController(controller) + addChild(controller) view.addSubview(controller.view) - controller.didMove(toParentViewController: self) + controller.didMove(toParent: self) controller.view.g_pinEdges() } func g_removeFromParentController() { - willMove(toParentViewController: nil) + willMove(toParent: nil) view.removeFromSuperview() - removeFromParentViewController() + removeFromParent() } } diff --git a/Sources/Utils/Pages/PageIndicator.swift b/Sources/Utils/Pages/PageIndicator.swift index 70dd166c..1f6835e8 100644 --- a/Sources/Utils/Pages/PageIndicator.swift +++ b/Sources/Utils/Pages/PageIndicator.swift @@ -69,8 +69,8 @@ class PageIndicator: UIView { func makeButton(_ title: String) -> UIButton { let button = UIButton(type: .custom) - button.setTitle(title, for: UIControlState()) - button.setTitleColor(Config.PageIndicator.textColor, for: UIControlState()) + button.setTitle(title, for: UIControl.State()) + button.setTitleColor(Config.PageIndicator.textColor, for: UIControl.State()) button.setTitleColor(UIColor.gray, for: .highlighted) button.backgroundColor = Config.PageIndicator.backgroundColor button.addTarget(self, action: #selector(buttonTouched(_:)), for: .touchUpInside) diff --git a/Sources/Utils/Pages/PagesController.swift b/Sources/Utils/Pages/PagesController.swift index 0a24eb3d..777887d9 100644 --- a/Sources/Utils/Pages/PagesController.swift +++ b/Sources/Utils/Pages/PagesController.swift @@ -119,9 +119,9 @@ class PagesController: UIViewController { scrollViewContentView.g_pinEdges() for (i, controller) in controllers.enumerated() { - addChildViewController(controller) + addChild(controller) scrollViewContentView.addSubview(controller.view) - controller.didMove(toParentViewController: self) + controller.didMove(toParent: self) controller.view.g_pin(on: .top) controller.view.g_pin(on: .bottom) diff --git a/Sources/Utils/Permission/PermissionController.swift b/Sources/Utils/Permission/PermissionController.swift index 15ecb6c3..2e60b6ad 100644 --- a/Sources/Utils/Permission/PermissionController.swift +++ b/Sources/Utils/Permission/PermissionController.swift @@ -67,7 +67,7 @@ class PermissionController: UIViewController { @objc func settingButtonTouched(_ button: UIButton) { DispatchQueue.main.async { - if let settingsURL = URL(string: UIApplicationOpenSettingsURLString) { + if let settingsURL = URL(string: UIApplication.openSettingsURLString) { UIApplication.shared.openURL(settingsURL) } } diff --git a/Sources/Utils/Permission/PermissionView.swift b/Sources/Utils/Permission/PermissionView.swift index c4ea4629..1a9598c4 100644 --- a/Sources/Utils/Permission/PermissionView.swift +++ b/Sources/Utils/Permission/PermissionView.swift @@ -63,10 +63,10 @@ class PermissionView: UIView { func makeSettingButton() -> UIButton { let button = UIButton(type: .custom) button.setTitle("Gallery.Permission.Button".g_localize(fallback: "Go to Settings").uppercased(), - for: UIControlState()) + for: UIControl.State()) button.backgroundColor = Config.Permission.Button.backgroundColor button.titleLabel?.font = Config.Font.Main.medium.withSize(16) - button.setTitleColor(Config.Permission.Button.textColor, for: UIControlState()) + button.setTitleColor(Config.Permission.Button.textColor, for: UIControl.State()) button.setTitleColor(Config.Permission.Button.highlightedTextColor, for: .highlighted) button.layer.cornerRadius = 22 button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15) @@ -76,7 +76,7 @@ class PermissionView: UIView { func makeCloseButton() -> UIButton { let button = UIButton(type: .custom) - button.setImage(GalleryBundle.image("gallery_close")?.withRenderingMode(.alwaysTemplate), for: UIControlState()) + button.setImage(GalleryBundle.image("gallery_close")?.withRenderingMode(.alwaysTemplate), for: UIControl.State()) button.tintColor = Config.Grid.CloseButton.tintColor return button diff --git a/Sources/Utils/VideoEditor/AdvancedVideoEditor.swift b/Sources/Utils/VideoEditor/AdvancedVideoEditor.swift index 2ec7f00d..c6347aff 100644 --- a/Sources/Utils/VideoEditor/AdvancedVideoEditor.swift +++ b/Sources/Utils/VideoEditor/AdvancedVideoEditor.swift @@ -53,7 +53,7 @@ public class AdvancedVideoEditor: VideoEditing { // Start writer.startWriting() reader.startReading() - writer.startSession(atSourceTime: kCMTimeInvalid) + writer.startSession(atSourceTime: CMTime.zero) // Video if let videoOutput = videoOutput, let videoInput = videoInput { diff --git a/Sources/Utils/VideoEditor/EditInfo.swift b/Sources/Utils/VideoEditor/EditInfo.swift index b981c3e9..2b691172 100644 --- a/Sources/Utils/VideoEditor/EditInfo.swift +++ b/Sources/Utils/VideoEditor/EditInfo.swift @@ -11,7 +11,7 @@ struct EditInfo { let cropInfo = EditInfo.cropInfo(avAsset) let layer = AVMutableVideoCompositionLayerInstruction(assetTrack: track) - layer.setTransform(EditInfo.transform(avAsset, scale: cropInfo.scale), at: kCMTimeZero) + layer.setTransform(EditInfo.transform(avAsset, scale: cropInfo.scale), at: CMTime.zero) let instruction = AVMutableVideoCompositionInstruction() instruction.layerInstructions = [layer] @@ -81,7 +81,7 @@ struct EditInfo { end = CMTime(seconds: Config.VideoEditor.maximumDuration, preferredTimescale: 1000) } - return CMTimeRange(start: kCMTimeZero, duration: end) + return CMTimeRange(start: CMTime.zero, duration: end) } static var file: (type: AVFileType, pathExtension: String) { diff --git a/Sources/Utils/VideoEditor/VideoEditor.swift b/Sources/Utils/VideoEditor/VideoEditor.swift index ba87fddf..6238b5b1 100644 --- a/Sources/Utils/VideoEditor/VideoEditor.swift +++ b/Sources/Utils/VideoEditor/VideoEditor.swift @@ -30,7 +30,7 @@ public class VideoEditor: VideoEditing { export?.shouldOptimizeForNetworkUse = true export?.exportAsynchronously { - if export?.status == AVAssetExportSessionStatus.completed { + if export?.status == AVAssetExportSession.Status.completed { completion(outputURL) } else { completion(nil) diff --git a/Sources/Utils/View/AlbumCell.swift b/Sources/Utils/View/AlbumCell.swift index ff367a45..dfca31dc 100644 --- a/Sources/Utils/View/AlbumCell.swift +++ b/Sources/Utils/View/AlbumCell.swift @@ -8,7 +8,7 @@ class AlbumCell: UITableViewCell { // MARK: - Initialization - override init(style: UITableViewCellStyle, reuseIdentifier: String?) { + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) setup() diff --git a/Sources/Utils/View/GridView.swift b/Sources/Utils/View/GridView.swift index 4b76b69d..d9bc11a9 100644 --- a/Sources/Utils/View/GridView.swift +++ b/Sources/Utils/View/GridView.swift @@ -119,7 +119,7 @@ class GridView: UIView { private func makeCloseButton() -> UIButton { let button = UIButton(type: .custom) - button.setImage(GalleryBundle.image("gallery_close")?.withRenderingMode(.alwaysTemplate), for: UIControlState()) + button.setImage(GalleryBundle.image("gallery_close")?.withRenderingMode(.alwaysTemplate), for: UIControl.State()) button.tintColor = Config.Grid.CloseButton.tintColor return button @@ -127,10 +127,10 @@ class GridView: UIView { private func makeDoneButton() -> UIButton { let button = UIButton(type: .system) - button.setTitleColor(UIColor.white, for: UIControlState()) + button.setTitleColor(UIColor.white, for: UIControl.State()) button.setTitleColor(UIColor.lightGray, for: .disabled) button.titleLabel?.font = Config.Font.Text.regular.withSize(16) - button.setTitle("Gallery.Done".g_localize(fallback: Config.DoneButton.title), for: UIControlState()) + button.setTitle("Gallery.Done".g_localize(fallback: "Done"), for: UIControl.State()) return button } @@ -154,7 +154,7 @@ class GridView: UIView { } private func makeLoadingIndicator() -> UIActivityIndicatorView { - let view = UIActivityIndicatorView(activityIndicatorStyle: .whiteLarge) + let view = UIActivityIndicatorView(style: .whiteLarge) view.color = .gray view.hidesWhenStopped = true From 473bb07dce812f4fd9860dc77f1d301abbe591d6 Mon Sep 17 00:00:00 2001 From: Impresyjna Date: Sun, 14 Oct 2018 22:47:49 +0200 Subject: [PATCH 3/3] Better way to config texts in Gallery framework - config per view, not per app --- Sources/Camera/CameraView.swift | 8 ++++---- Sources/Gallery/GalleryController.swift | 6 +++--- Sources/Utils/Config.swift | 15 +++++++++++++++ Sources/Utils/Permission/PermissionView.swift | 6 +++--- Sources/Utils/View/EmptyView.swift | 2 +- Sources/Utils/View/GridView.swift | 2 +- Sources/Videos/VideosController.swift | 2 +- 7 files changed, 28 insertions(+), 13 deletions(-) diff --git a/Sources/Camera/CameraView.swift b/Sources/Camera/CameraView.swift index 2b223c63..08376675 100644 --- a/Sources/Camera/CameraView.swift +++ b/Sources/Camera/CameraView.swift @@ -174,9 +174,9 @@ class CameraView: UIView, UIGestureRecognizerDelegate { func makeFlashButton() -> TripleButton { let states: [TripleButton.ButtonState] = [ - TripleButton.ButtonState(title: "Gallery.Camera.Flash.Off".g_localize(fallback: "OFF"), image: GalleryBundle.image("gallery_camera_flash_off")!), - TripleButton.ButtonState(title: "Gallery.Camera.Flash.On".g_localize(fallback: "ON"), image: GalleryBundle.image("gallery_camera_flash_on")!), - TripleButton.ButtonState(title: "Gallery.Camera.Flash.Auto".g_localize(fallback: "AUTO"), image: GalleryBundle.image("gallery_camera_flash_auto")!) + TripleButton.ButtonState(title: Config.TextsConfig.cameraFlashOff, image: GalleryBundle.image("gallery_camera_flash_off")!), + TripleButton.ButtonState(title: Config.TextsConfig.cameraFlashOn, image: GalleryBundle.image("gallery_camera_flash_on")!), + TripleButton.ButtonState(title: Config.TextsConfig.cameraFlashAuto, image: GalleryBundle.image("gallery_camera_flash_auto")!) ] let button = TripleButton(states: states) @@ -223,7 +223,7 @@ class CameraView: UIView, UIGestureRecognizerDelegate { button.setTitleColor(UIColor.white, for: UIControl.State()) button.setTitleColor(UIColor.lightGray, for: .disabled) button.titleLabel?.font = Config.Font.Text.regular.withSize(16) - button.setTitle("Gallery.Done".g_localize(fallback: "Done"), for: UIControl.State()) + button.setTitle(Config.TextsConfig.doneButton, for: UIControl.State()) return button } diff --git a/Sources/Gallery/GalleryController.swift b/Sources/Gallery/GalleryController.swift index f442b066..02637ef7 100644 --- a/Sources/Gallery/GalleryController.swift +++ b/Sources/Gallery/GalleryController.swift @@ -48,21 +48,21 @@ public class GalleryController: UIViewController, PermissionControllerDelegate { func makeImagesController() -> ImagesController { let controller = ImagesController(cart: cart) - controller.title = "Gallery.Images.Title".g_localize(fallback: "PHOTOS") + controller.title = Config.TextsConfig.imagesTitle return controller } func makeCameraController() -> CameraController { let controller = CameraController(cart: cart) - controller.title = "Gallery.Camera.Title".g_localize(fallback: "CAMERA") + controller.title = Config.TextsConfig.cameraTitle return controller } func makeVideosController() -> VideosController { let controller = VideosController(cart: cart) - controller.title = "Gallery.Videos.Title".g_localize(fallback: "VIDEOS") + controller.title = Config.TextsConfig.videoTitle return controller } diff --git a/Sources/Utils/Config.swift b/Sources/Utils/Config.swift index 07dbc955..97ab99a3 100644 --- a/Sources/Utils/Config.swift +++ b/Sources/Utils/Config.swift @@ -115,4 +115,19 @@ public struct Config { public static var portraitSize: CGSize = CGSize(width: 360, height: 640) public static var landscapeSize: CGSize = CGSize(width: 640, height: 360) } + + public struct TextsConfig { + public static var cameraFlashOff = "Gallery.Camera.Flash.Off".g_localize(fallback: "OFF") + public static var cameraFlashOn = "Gallery.Camera.Flash.On".g_localize(fallback: "ON") + public static var cameraFlashAuto = "Gallery.Camera.Flash.Auto".g_localize(fallback: "AUTO") + public static var doneButton = "Gallery.Done".g_localize(fallback: "Done") + public static var imagesTitle = "Gallery.Images.Title".g_localize(fallback: "PHOTOS") + public static var cameraTitle = "Gallery.Camera.Title".g_localize(fallback: "CAMERA") + public static var videoTitle = "Gallery.Videos.Title".g_localize(fallback: "VIDEOS") + public static var cameraAndGalleryPermission = "GalleryAndCamera.Permission.Info".g_localize(fallback: "Please grant access to photos and the camera.") + public static var galleryPermission = "Gallery.Permission.Info".g_localize(fallback: "Please grant access to photos.") + public static var permisionButton = "Gallery.Permission.Button".g_localize(fallback: "Go to Settings") + public static var emptyView = "Gallery.EmptyView.Text".g_localize(fallback: "Nothing to show") + public static var allVideos = "Gallery.AllVideos".g_localize(fallback: "ALL VIDEOS") + } } diff --git a/Sources/Utils/Permission/PermissionView.swift b/Sources/Utils/Permission/PermissionView.swift index 1a9598c4..b56872e9 100644 --- a/Sources/Utils/Permission/PermissionView.swift +++ b/Sources/Utils/Permission/PermissionView.swift @@ -49,9 +49,9 @@ class PermissionView: UIView { label.textColor = Config.Permission.textColor label.font = Config.Font.Text.regular.withSize(14) if Permission.Camera.needsPermission { - label.text = "GalleryAndCamera.Permission.Info".g_localize(fallback: "Please grant access to photos and the camera.") + label.text = Config.TextsConfig.cameraAndGalleryPermission } else { - label.text = "Gallery.Permission.Info".g_localize(fallback: "Please grant access to photos.") + label.text = Config.TextsConfig.galleryPermission } label.textAlignment = .center label.numberOfLines = 0 @@ -62,7 +62,7 @@ class PermissionView: UIView { func makeSettingButton() -> UIButton { let button = UIButton(type: .custom) - button.setTitle("Gallery.Permission.Button".g_localize(fallback: "Go to Settings").uppercased(), + button.setTitle(Config.TextsConfig.permisionButton.uppercased(), for: UIControl.State()) button.backgroundColor = Config.Permission.Button.backgroundColor button.titleLabel?.font = Config.Font.Main.medium.withSize(16) diff --git a/Sources/Utils/View/EmptyView.swift b/Sources/Utils/View/EmptyView.swift index 9b6bb6eb..474abdd7 100644 --- a/Sources/Utils/View/EmptyView.swift +++ b/Sources/Utils/View/EmptyView.swift @@ -35,7 +35,7 @@ class EmptyView: UIView { let label = UILabel() label.textColor = Config.EmptyView.textColor label.font = Config.Font.Text.regular.withSize(14) - label.text = "Gallery.EmptyView.Text".g_localize(fallback: "Nothing to show") + label.text = Config.TextsConfig.emptyView return label } diff --git a/Sources/Utils/View/GridView.swift b/Sources/Utils/View/GridView.swift index d9bc11a9..f2c096d8 100644 --- a/Sources/Utils/View/GridView.swift +++ b/Sources/Utils/View/GridView.swift @@ -130,7 +130,7 @@ class GridView: UIView { button.setTitleColor(UIColor.white, for: UIControl.State()) button.setTitleColor(UIColor.lightGray, for: .disabled) button.titleLabel?.font = Config.Font.Text.regular.withSize(16) - button.setTitle("Gallery.Done".g_localize(fallback: "Done"), for: UIControl.State()) + button.setTitle(Config.TextsConfig.doneButton, for: UIControl.State()) return button } diff --git a/Sources/Videos/VideosController.swift b/Sources/Videos/VideosController.swift index f056f41d..cc467f9b 100644 --- a/Sources/Videos/VideosController.swift +++ b/Sources/Videos/VideosController.swift @@ -60,7 +60,7 @@ class VideosController: UIViewController { gridView.collectionView.delegate = self gridView.collectionView.register(VideoCell.self, forCellWithReuseIdentifier: String(describing: VideoCell.self)) - gridView.arrowButton.updateText("Gallery.AllVideos".g_localize(fallback: "ALL VIDEOS")) + gridView.arrowButton.updateText(Config.TextsConfig.allVideos) gridView.arrowButton.arrow.isHidden = true }