diff --git a/TIUIElements/Sources/Views/Placeholder/Localization/DefaultPlaceholderLocalizationProvider.swift b/TIUIElements/Sources/Views/Placeholder/Localization/DefaultPlaceholderLocalizationProvider.swift index 4a76d5c6..4a554825 100644 --- a/TIUIElements/Sources/Views/Placeholder/Localization/DefaultPlaceholderLocalizationProvider.swift +++ b/TIUIElements/Sources/Views/Placeholder/Localization/DefaultPlaceholderLocalizationProvider.swift @@ -22,50 +22,51 @@ import Foundation -/// Provides default localization for alerts' buttons open class DefaultPlaceholderLocalizationProvider: PlaceholderLocalizationProvider { public enum Defaults { public static var errorKey: String { - "placeholder_error_message" + "common_placeholder_title_error" } public static var loadingDataErrorKey: String { - "placeholder_loading_data_error_message" + "common_placeholder_title_loading_data" } public static var emptyStateKey: String { - "placeholder_empty_state_message" + "common_placeholder_title_empty_state" } public static var repeateKey: String { - "common_repeate" + "common_global_repeate" } } public var bundle: Bundle + public var tableName: String? // MARK: - PlaceholderLocalizationProvider open var errorTitle: String { - bundle.localizedString(forKey: Defaults.errorKey, value: "An error has occured.", table: nil) + bundle.localizedString(forKey: Defaults.errorKey, value: "An error has occured.", table: tableName) } open var loadingDataErrorTitle: String { - bundle.localizedString(forKey: Defaults.loadingDataErrorKey, value: "Failed to load data.", table: nil) + bundle.localizedString(forKey: Defaults.loadingDataErrorKey, value: "Failed to load data.", table: tableName) } open var emptyStateTitle: String { - bundle.localizedString(forKey: Defaults.emptyStateKey, value: "The list is empty.", table: nil) + bundle.localizedString(forKey: Defaults.emptyStateKey, value: "The list is empty.", table: tableName) } open var repeateButtonTitle: String { - bundle.localizedString(forKey: Defaults.repeateKey, value: "Repeate", table: nil) + bundle.localizedString(forKey: Defaults.repeateKey, value: "Repeate", table: tableName) } // MARK: - Init - public init(bundle: Bundle = .main) { + public init(bundle: Bundle = .main, tableName: String? = nil) { self.bundle = bundle + self.tableName = tableName } } diff --git a/TIUIElements/Sources/Views/Placeholder/PlaceholderFactory.swift b/TIUIElements/Sources/Views/Placeholder/PlaceholderFactory.swift index 0482057a..ac390b5e 100644 --- a/TIUIElements/Sources/Views/Placeholder/PlaceholderFactory.swift +++ b/TIUIElements/Sources/Views/Placeholder/PlaceholderFactory.swift @@ -26,15 +26,15 @@ import UIKit open class PlaceholderFactory { public enum Defaults { public static var errorStyleImageName: String { - "ti_default_error_state_image" + "placeholder_error_icon" } public static var loadingDataErrorImageName: String { - "ti_loading_data_error_image" + "placeholder_loading_data_icon" } public static var emptyStateImageName: String { - "ti_empty_state_image" + "placeholder_empty_state_icon" } } @@ -130,8 +130,8 @@ open class PlaceholderFactory { // MARK: - Private configurations -extension PlaceholderFactory { - private static var defaultButtonAppearance: UIButton.DefaultAppearance { +private extension PlaceholderFactory { + static var defaultButtonAppearance: UIButton.DefaultAppearance { .make { $0.border.cornerRadius = 25 $0.border.roundedCorners = .allCorners @@ -143,7 +143,7 @@ extension PlaceholderFactory { } } - private static var defaultTitlesAppearance: DefaultTitleSubtitleView.Appearance { + static var defaultTitlesAppearance: DefaultTitleSubtitleView.Appearance { .make { titleSubtitle in titleSubtitle.titleAppearance { title in title.textAttributes = Self.defaultTextAttributes @@ -155,7 +155,7 @@ extension PlaceholderFactory { } } - private static var defaultTextAttributes: BaseTextAttributes { + static var defaultTextAttributes: BaseTextAttributes { .init(font: .systemFont(ofSize: 20, weight: .light), color: .black, alignment: .center, diff --git a/TIUIElements/TIUIElements.app/Contents/MacOS/TIUIElements.playground/Pages/Placeholder.xcplaygroundpage/Contents.swift b/TIUIElements/TIUIElements.app/Contents/MacOS/TIUIElements.playground/Pages/Placeholder.xcplaygroundpage/Contents.swift index 861a4942..dbc6cfe0 100644 --- a/TIUIElements/TIUIElements.app/Contents/MacOS/TIUIElements.playground/Pages/Placeholder.xcplaygroundpage/Contents.swift +++ b/TIUIElements/TIUIElements.app/Contents/MacOS/TIUIElements.playground/Pages/Placeholder.xcplaygroundpage/Contents.swift @@ -158,7 +158,7 @@ let emptyStateStylePlaceholder = factory.createEmptyStatePlaceholder() /*: ### Кастомизация стандартных стилей - Стили `errorStyle`, `loadingDataErrorStyle`, `emptyStateStyle` могут показывать, лежащие в **Assets**. Для этого необходимо только называть картинки: _ti_default_error_state_image_, _ti_loading_data_error_image_, _ti_empty_state_image_ соответственно. Если нужной картинки не будет, то она просто не отобразится в плейсхолдере. При таком изменении никаких дополнительных настроек делать не нужно. + Стили `errorStyle`, `loadingDataErrorStyle`, `emptyStateStyle` могут показывать, лежащие в **Assets**. Для этого необходимо только называть картинки: _placeholder_error_icon_, _placeholder_loading_data_icon_, _placeholder_empty_state_icon_ соответственно. Если нужной картинки не будет, то она просто не отобразится в плейсхолдере. При таком изменении никаких дополнительных настроек делать не нужно. Также при создании фабрики, можно передать в нее объект соответствующий протоколу `PlaceholderLocalizationProvider` для добавления необходимого текста. @@ -170,7 +170,7 @@ let emptyStateStylePlaceholder = factory.createEmptyStatePlaceholder() */ class CustomViewController: BaseInitializableViewController { private var currentPlaceholder: UIView? - + private var customErrorStyle: DefaultPlaceholderStyle { factoryWithCustomErrorStyle.errorStyle() .update { style in diff --git a/docs/tiuielements/placeholder.md b/docs/tiuielements/placeholder.md index 3ccdd799..4e327017 100644 --- a/docs/tiuielements/placeholder.md +++ b/docs/tiuielements/placeholder.md @@ -172,7 +172,7 @@ let emptyStateStylePlaceholder = factory.createEmptyStatePlaceholder() ### Кастомизация стандартных стилей - Стили `errorStyle`, `loadingDataErrorStyle`, `emptyStateStyle` могут показывать, лежащие в **Assets**. Для этого необходимо только называть картинки: _ti_default_error_state_image_, _ti_loading_data_error_image_, _ti_empty_state_image_ соответственно. Если нужной картинки не будет, то она просто не отобразится в плейсхолдере. При таком изменении никаких дополнительных настроек делать не нужно. + Стили `errorStyle`, `loadingDataErrorStyle`, `emptyStateStyle` могут показывать, лежащие в **Assets**. Для этого необходимо только называть картинки: _placeholder_error_icon_, _placeholder_loading_data_icon_, _placeholder_empty_state_icon_ соответственно. Если нужной картинки не будет, то она просто не отобразится в плейсхолдере. При таком изменении никаких дополнительных настроек делать не нужно. Также при создании фабрики, можно передать в нее объект соответствующий протоколу `PlaceholderLocalizationProvider` для добавления необходимого текста. @@ -185,7 +185,7 @@ let emptyStateStylePlaceholder = factory.createEmptyStatePlaceholder() ```swift class CustomViewController: BaseInitializableViewController { private var currentPlaceholder: UIView? - + private var customErrorStyle: DefaultPlaceholderStyle { factoryWithCustomErrorStyle.errorStyle() .update { style in