fix: code review notes

This commit is contained in:
Nikita Semenov 2023-03-18 12:51:58 +03:00
parent 026700b4c7
commit cde2420f7d
3 changed files with 6 additions and 46 deletions

View File

@ -24,24 +24,20 @@ import TIUIKitCore
import UIKit
open class BasePlaceholderImageView<Placeholder: UIView>: UIImageView,
InitializableViewProtocol,
AppearanceUpdatable {
InitializableViewProtocol {
public let placeholderView = Placeholder()
public var placeholderConstraints: SubviewConstraints?
public var cachedAppearance: UIView.DefaultWrappedAppearance?
open override var image: UIImage? {
get {
super.image
}
set {
placeholderView.isHidden = newValue == nil ? false : true
placeholderView.isHidden = newValue != nil
super.image = newValue
updateAppearance()
}
}
@ -104,18 +100,11 @@ open class BasePlaceholderImageView<Placeholder: UIView>: UIImageView,
// MARK: - Open methods
open func configureAppearance(appearance: BaseWrappedViewHolderAppearance<UIView.DefaultWrappedAppearance, some WrappedViewLayout>) {
cachedAppearance = appearance.subviewAppearance
open func configureBasePlaceholder(appearance: BaseWrappedViewHolderAppearance<UIView.DefaultWrappedAppearance, some WrappedViewLayout>) {
configureUIView(appearance: appearance)
updateAppearance()
}
open func updateAppearance() {
if let cachedAppearance = cachedAppearance {
placeholderView.configureUIView(appearance: cachedAppearance)
configurePlaceholderLayout(layout: cachedAppearance.layout)
}
placeholderView.configureUIView(appearance: appearance.subviewAppearance)
configurePlaceholderLayout(layout: appearance.subviewAppearance.layout)
}
// MARK: - Private methods

View File

@ -71,6 +71,6 @@ final public class DefaultPlaceholderImageView: BasePlaceholderImageView<UIImage
// MARK: - AppearanceConfigurable
public func configure(appearance: Appearance) {
configureAppearance(appearance: appearance)
configureBasePlaceholder(appearance: appearance)
}
}

View File

@ -1,29 +0,0 @@
//
// Copyright (c) 2023 Touch Instinct
//
// 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.
//
public protocol AppearanceUpdatable {
associatedtype Appearance: ViewAppearance
var cachedAppearance: Appearance? { get set }
func updateAppearance()
}