This commit is contained in:
DDIsFriend
2023-08-18 17:28:57 +08:00
commit f0e8a1709d
4282 changed files with 192396 additions and 0 deletions

View File

@@ -0,0 +1,460 @@
//
// ZLPhotoUIConfiguration.swift
// ZLPhotoBrowser
//
// Created by long on 2022/4/18.
//
// Copyright (c) 2020 Long Zhang <495181165@qq.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import UIKit
/// Custom UI configuration (include colors, images, text, font)
@objcMembers
public class ZLPhotoUIConfiguration: NSObject {
@objc public enum CancelButtonStyle: Int {
case text
case image
}
private static var single = ZLPhotoUIConfiguration()
public class func `default`() -> ZLPhotoUIConfiguration {
return ZLPhotoUIConfiguration.single
}
public class func resetConfiguration() {
ZLPhotoUIConfiguration.single = ZLPhotoUIConfiguration()
}
// MARK: Framework style.
public var style: ZLPhotoBrowserStyle = .embedAlbumList
public var statusBarStyle: UIStatusBarStyle = .lightContent
/// text: Cancel. image: 'x'. Defaults to image.
public var navCancelButtonStyle: ZLPhotoUIConfiguration.CancelButtonStyle = .image
/// Whether to show the status bar when previewing photos. Defaults to false.
public var showStatusBarInPreviewInterface = false
/// HUD style. Defaults to dark.
public var hudStyle: ZLProgressHUD.HUDStyle = .dark
/// Adjust Slider Type
public var adjustSliderType: ZLAdjustSliderType = .vertical
public var cellCornerRadio: CGFloat = 0
/// Custom alert class. Defaults to nil.
public var customAlertClass: ZLCustomAlertProtocol.Type?
private var pri_columnCount = 4
/// The column count when iPhone is in portait mode. Minimum is 2, maximum is 6. Defaults to 4.
/// ```
/// iPhone landscape mode: columnCount += 2.
/// iPad portait mode: columnCount += 2.
/// iPad landscape mode: columnCount += 4.
/// ```
///
/// - Note: This property is ignored when using columnCountBlock.
public var columnCount: Int {
get {
pri_columnCount
}
set {
pri_columnCount = min(6, max(newValue, 2))
}
}
/// Use this property to customize the column count for `ZLThumbnailViewController`.
/// This property is recommended.
public var columnCountBlock: ((_ collectionViewWidth: CGFloat) -> Int)?
/// The minimum spacing to use between items in the same row for `ZLThumbnailViewController`.
public var minimumInteritemSpacing: CGFloat = 2
/// The minimum spacing to use between lines of items in the grid for `ZLThumbnailViewController`.
public var minimumLineSpacing: CGFloat = 2
// MARK: Navigation and bottom tool bar
/// The blur effect of the navigation bar in the album list
public var navViewBlurEffectOfAlbumList: UIBlurEffect? = UIBlurEffect(style: .dark)
/// The blur effect of the navigation bar in the preview interface
public var navViewBlurEffectOfPreview: UIBlurEffect? = UIBlurEffect(style: .dark)
/// The blur effect of the bottom tool bar in the album list
public var bottomViewBlurEffectOfAlbumList: UIBlurEffect? = UIBlurEffect(style: .dark)
/// The blur effect of the bottom tool bar in the preview interface
public var bottomViewBlurEffectOfPreview: UIBlurEffect? = UIBlurEffect(style: .dark)
// MARK: Image properties
/// Developers can customize images, but the name of the custom image resource must be consistent with the image name in the replaced bundle.
/// - example: Developers need to replace the selected and unselected image resources, and the array that needs to be passed in is
/// ["zl_btn_selected", "zl_btn_unselected"].
public var customImageNames: [String] = [] {
didSet {
ZLCustomImageDeploy.imageNames = customImageNames
}
}
/// Developers can customize images, but the name of the custom image resource must be consistent with the image name in the replaced bundle.
/// - example: Developers need to replace the selected and unselected image resources, and the array that needs to be passed in is
/// ["zl_btn_selected": selectedImage, "zl_btn_unselected": unselectedImage].
public var customImageForKey: [String: UIImage?] = [:] {
didSet {
customImageForKey.forEach { ZLCustomImageDeploy.imageForKey[$0.key] = $0.value }
}
}
/// Developers can customize images, but the name of the custom image resource must be consistent with the image name in the replaced bundle.
/// - example: Developers need to replace the selected and unselected image resources, and the array that needs to be passed in is
/// ["zl_btn_selected": selectedImage, "zl_btn_unselected": unselectedImage].
public var customImageForKey_objc: [String: UIImage] = [:] {
didSet {
ZLCustomImageDeploy.imageForKey = customImageForKey_objc
}
}
// MARK: Language properties
/// Language for framework.
public var languageType: ZLLanguageType = .system {
didSet {
ZLCustomLanguageDeploy.language = languageType
Bundle.resetLanguage()
}
}
/// Developers can customize languages.
/// - example: If you needs to replace
/// key: .hudLoading, value: "loading, waiting please" language,
/// The dictionary that needs to be passed in is [.hudLoading: "text to be replaced"].
/// - warning: Please pay attention to the placeholders contained in languages when changing, such as %ld, %@.
public var customLanguageKeyValue: [ZLLocalLanguageKey: String] = [:] {
didSet {
ZLCustomLanguageDeploy.deploy = customLanguageKeyValue
}
}
/// Developers can customize languages (This property is only for objc).
/// - example: If you needs to replace
/// key: @"loading", value: @"loading, waiting please" language,
/// The dictionary that needs to be passed in is @[@"hudLoading": @"text to be replaced"].
/// - warning: Please pay attention to the placeholders contained in languages when changing, such as %ld, %@.
public var customLanguageKeyValue_objc: [String: String] = [:] {
didSet {
var swiftParams: [ZLLocalLanguageKey: String] = [:]
customLanguageKeyValue_objc.forEach { key, value in
swiftParams[ZLLocalLanguageKey(rawValue: key)] = value
}
customLanguageKeyValue = swiftParams
}
}
// MARK: Font
/// Font name.
public var themeFontName: String? {
didSet {
ZLCustomFontDeploy.fontName = themeFontName
}
}
// MARK: Color properties
/// The theme color of framework.
///
public var themeColor: UIColor = .zl.rgba(7, 213, 101)
/// Preview selection mode, translucent background color above.
///
public var sheetTranslucentColor: UIColor = .black.withAlphaComponent(0.1)
/// Preview selection mode, a background color for `Camera`, `Album`, `Cancel` buttons.
///
public var sheetBtnBgColor: UIColor = .white
/// Preview selection mode, a text color for `Camera`, `Album`, `Cancel` buttons.
///
public var sheetBtnTitleColor: UIColor = .black
private var pri_sheetBtnTitleTintColor: UIColor?
/// Preview selection mode, cancel button title color when the selection amount is superior than 0.
///
public var sheetBtnTitleTintColor: UIColor {
get {
pri_sheetBtnTitleTintColor ?? themeColor
}
set {
pri_sheetBtnTitleTintColor = newValue
}
}
/// A color for navigation bar.
///
public var navBarColor: UIColor = .zl.rgba(160, 160, 160, 0.65)
/// A color for navigation bar in preview interface.
///
public var navBarColorOfPreviewVC: UIColor = .zl.rgba(160, 160, 160, 0.65)
/// A color for Navigation bar text.
///
public var navTitleColor: UIColor = .white
/// A color for Navigation bar text of preview vc.
///
public var navTitleColorOfPreviewVC: UIColor = .white
/// The background color of the title view when the frame style is embedAlbumList.
///
public var navEmbedTitleViewBgColor: UIColor = .zl.rgba(80, 80, 80)
/// A color for background in album list.
///
public var albumListBgColor: UIColor = .zl.rgba(45, 45, 45)
/// A color of the translucent area below the embed album list.
///
public var embedAlbumListTranslucentColor: UIColor = .black.withAlphaComponent(0.8)
/// A color for album list title label.
///
public var albumListTitleColor: UIColor = .white
/// A color for album list count label.
/// label
public var albumListCountColor: UIColor = .zl.rgba(180, 180, 180)
/// A color for album list separator.
/// 线
public var separatorColor: UIColor = .zl.rgba(60, 60, 60)
/// A color for background in thumbnail interface.
///
public var thumbnailBgColor: UIColor = .zl.rgba(50, 50, 50)
/// A color for background in preview interface..
///
public var previewVCBgColor: UIColor = .black
/// A color for background in bottom tool view.
///
public var bottomToolViewBgColor: UIColor = .zl.rgba(35, 35, 35, 0.3)
/// A color for background in bottom tool view in preview interface.
///
public var bottomToolViewBgColorOfPreviewVC: UIColor = .zl.rgba(35, 35, 35, 0.3)
/// The normal state title color of bottom tool view buttons. Without done button.
/// ``
public var bottomToolViewBtnNormalTitleColor: UIColor = .white
/// The normal state title color of bottom tool view done button.
/// ``
public var bottomToolViewDoneBtnNormalTitleColor: UIColor = .white
/// The normal state title color of bottom tool view buttons in preview interface. Without done button.
/// ``
public var bottomToolViewBtnNormalTitleColorOfPreviewVC: UIColor = .white
/// The normal state title color of bottom tool view done button.
/// ``
public var bottomToolViewDoneBtnNormalTitleColorOfPreviewVC: UIColor = .white
/// The disable state title color of bottom tool view buttons. Without done button.
/// ``
public var bottomToolViewBtnDisableTitleColor: UIColor = .zl.rgba(168, 168, 168)
/// The disable state title color of bottom tool view done button.
/// ``
public var bottomToolViewDoneBtnDisableTitleColor: UIColor = .zl.rgba(168, 168, 168)
/// The disable state title color of bottom tool view buttons in preview interface. Without done button.
/// ``
public var bottomToolViewBtnDisableTitleColorOfPreviewVC: UIColor = .zl.rgba(168, 168, 168)
/// The disable state title color of bottom tool view done button in preview interface.
/// ``
public var bottomToolViewDoneBtnDisableTitleColorOfPreviewVC: UIColor = .zl.rgba(168, 168, 168)
private var pri_bottomToolViewBtnNormalBgColor: UIColor?
/// The normal state background color of bottom tool view buttons.
///
public var bottomToolViewBtnNormalBgColor: UIColor {
get {
pri_bottomToolViewBtnNormalBgColor ?? themeColor
}
set {
pri_bottomToolViewBtnNormalBgColor = newValue
}
}
private var pri_bottomToolViewBtnNormalBgColorOfPreviewVC: UIColor?
/// The normal state background color of bottom tool view buttons in preview interface.
///
public var bottomToolViewBtnNormalBgColorOfPreviewVC: UIColor {
get {
pri_bottomToolViewBtnNormalBgColorOfPreviewVC ?? themeColor
}
set {
pri_bottomToolViewBtnNormalBgColorOfPreviewVC = newValue
}
}
/// The disable state background color of bottom tool view buttons.
///
public var bottomToolViewBtnDisableBgColor: UIColor = .zl.rgba(50, 50, 50)
/// The disable state background color of bottom tool view buttons in preview interface.
///
public var bottomToolViewBtnDisableBgColorOfPreviewVC: UIColor = .zl.rgba(50, 50, 50)
/// With iOS14 limited authority, a color for select more photos at the bottom of the thumbnail interface.
/// iOS14 limited
public var limitedAuthorityTipsColor: UIColor = .white
private var pri_cameraRecodeProgressColor: UIColor?
/// The record progress color of custom camera.
///
public var cameraRecodeProgressColor: UIColor {
get {
pri_cameraRecodeProgressColor ?? themeColor
}
set {
pri_cameraRecodeProgressColor = newValue
}
}
/// Mask layer color of selected cell.
///
public var selectedMaskColor: UIColor = .black.withAlphaComponent(0.2)
private var pri_selectedBorderColor: UIColor?
/// Border color of selected cell.
/// border
public var selectedBorderColor: UIColor {
get {
pri_selectedBorderColor ?? themeColor
}
set {
pri_selectedBorderColor = newValue
}
}
/// Mask layer color of the cell that cannot be selected.
///
public var invalidMaskColor: UIColor = .white.withAlphaComponent(0.5)
/// The text color of selected cell index label.
/// label
public var indexLabelTextColor: UIColor = .white
private var pri_indexLabelBgColor: UIColor?
/// The background color of selected cell index label.
/// label
public var indexLabelBgColor: UIColor {
get {
pri_indexLabelBgColor ?? themeColor
}
set {
pri_indexLabelBgColor = newValue
}
}
/// The background color of camera cell inside album.
///
public var cameraCellBgColor: UIColor = .zl.rgba(76, 76, 76)
/// The normal color of adjust slider.
/// slider
public var adjustSliderNormalColor: UIColor = .white
private var pri_adjustSliderTintColor: UIColor?
/// The tint color of adjust slider.
/// slider
public var adjustSliderTintColor: UIColor {
get {
pri_adjustSliderTintColor ?? themeColor
}
set {
pri_adjustSliderTintColor = newValue
}
}
/// The normal color of the title below the various tools in the image editor.
///
public var imageEditorToolTitleNormalColor: UIColor = .zl.rgba(160, 160, 160)
/// The tint color of the title below the various tools in the image editor.
///
public var imageEditorToolTitleTintColor: UIColor = .white
/// The tint color of the image editor tool icons.
///
public var imageEditorToolIconTintColor: UIColor?
/// Background color of trash can in image editor.
///
public var trashCanBackgroundNormalColor: UIColor = .zl.rgba(40, 40, 40, 0.8)
/// Background tint color of trash can in image editor.
///
public var trashCanBackgroundTintColor: UIColor = .zl.rgba(241, 79, 79, 0.98)
}
/// Font deploy
enum ZLCustomFontDeploy {
static var fontName: String?
}
/// Image source deploy
enum ZLCustomImageDeploy {
static var imageNames: [String] = []
static var imageForKey: [String: UIImage] = [:]
}
@objc public enum ZLPhotoBrowserStyle: Int {
/// The album list is embedded in the navigation of the thumbnail interface, click the drop-down display.
case embedAlbumList
/// The display relationship between the album list and the thumbnail interface is push.
case externalAlbumList
}
/// Language deploy
enum ZLCustomLanguageDeploy {
static var language: ZLLanguageType = .system
static var deploy: [ZLLocalLanguageKey: String] = [:]
}
/// Adjust slider type
@objc public enum ZLAdjustSliderType: Int {
case vertical
case horizontal
}