docs: skeletons playground page
This commit is contained in:
parent
6e30957fe5
commit
e199cd4220
|
|
@ -26,7 +26,7 @@ This repository contains the following frameworks:
|
|||
|
||||
```sh
|
||||
cd TIModuleName
|
||||
nef plaground --name TIModuleName --cocoapods --custom-podfile PlaygroundPodfile
|
||||
nef playground --name TIModuleName --cocoapods --custom-podfile PlaygroundPodfile
|
||||
```
|
||||
See example of `PlaygroundPodfile` in `TIFoundationUtils`
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ ${SRCROOT}/TIModuleName/TIModuleName.app"
|
|||
|
||||
```ruby
|
||||
sources = 'your_sources_expression'
|
||||
if File.basename(Dir.getwd) == s.name # installing using :path =>
|
||||
if ENV["DEVELOPMENT_INSTALL"] # installing using :path =>
|
||||
s.source_files = sources
|
||||
s.exclude_files = s.name + '.app'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
ENV["DEVELOPMENT_INSTALL"] = "true"
|
||||
|
||||
target 'TIUIElements' do
|
||||
platform :ios, 11.0
|
||||
use_frameworks!
|
||||
|
||||
pod 'TIUIElements', :path => '../../../../TIUIElements/TIUIElements.podspec'
|
||||
pod 'TIUIKitCore', :path => '../../../../TIUIKitCore/TIUIKitCore.podspec'
|
||||
pod 'TISwiftUtils', :path => '../../../../TISwiftUtils/TISwiftUtils.podspec'
|
||||
end
|
||||
|
|
@ -25,7 +25,7 @@ import UIKit
|
|||
extension UIView {
|
||||
public var skeletonableViews: [UIView] {
|
||||
if let skeletonableView = self as? Skeletonable {
|
||||
return skeletonableView.viewsToSkeletone
|
||||
return skeletonableView.viewsToSkeletone
|
||||
}
|
||||
|
||||
return subviews
|
||||
|
|
|
|||
|
|
@ -217,7 +217,6 @@ open class StatefulButton: UIButton {
|
|||
} else {
|
||||
updateAppearance(to: .disabled)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private func updateAppearance(to state: State) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>launcher</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>AppIcon</string>
|
||||
<key>CFBundleIconName</key>
|
||||
<string>AppIcon</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.fortysevendeg.nef</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.developer-tools</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.14</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2019 The nef Authors. All rights reserved.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
## gitignore nef files
|
||||
**/build/
|
||||
**/nef/
|
||||
LICENSE
|
||||
|
||||
## User data
|
||||
**/xcuserdata/
|
||||
podfile.lock
|
||||
**.DS_Store
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
## CocoaPods
|
||||
**Pods**
|
||||
|
||||
## Carthage
|
||||
**Carthage**
|
||||
|
||||
## SPM
|
||||
.build
|
||||
.swiftpm
|
||||
swiftpm
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
ENV["DEVELOPMENT_INSTALL"] = "true"
|
||||
|
||||
target 'TIUIElements' do
|
||||
platform :ios, 11.0
|
||||
use_frameworks!
|
||||
|
||||
pod 'TIUIElements', :path => '../../../../TIUIElements/TIUIElements.podspec'
|
||||
pod 'TISwiftUtils', :path => '../../../../TISwiftUtils/TISwiftUtils.podspec'
|
||||
pod 'TIUIKitCore', :path => '../../../../TIUIKitCore/TIUIKitCore.podspec'
|
||||
end
|
||||
|
|
@ -1,2 +1,172 @@
|
|||
import Foundation
|
||||
/*:
|
||||
# Skeletons API
|
||||
|
||||
При импорте _TIUIElements_ вы можете использовать API для показа скелетонов.
|
||||
|
||||
## Базовая настройка
|
||||
|
||||
Чтобы `UIViewController` или `UIView` мог показать скелетоны необходимо, чтобы он соответствовал протоколу `SkeletonsPresenter`.
|
||||
*/
|
||||
import TIUIElements
|
||||
import UIKit
|
||||
|
||||
class DummyVC: UIViewController, SkeletonsPresenter {
|
||||
}
|
||||
|
||||
//: Чтобы показать или скрыть скелетоны необходимо использовать методы `showSkeletons()` и `hideSkeletons()`
|
||||
class CanShowAndHideSkeletons: UIViewController, SkeletonsPresenter {
|
||||
lazy var button: UIButton = {
|
||||
let button = UIButton(frame: CGRect(x: .zero, y: .zero,
|
||||
width: view.frame.width, height: view.frame.height))
|
||||
|
||||
button.setTitle("Hello from SkeletonableViewController", for: .normal)
|
||||
button.setTitleColor(.black, for: .normal)
|
||||
button.titleLabel?.font = .systemFont(ofSize: 30)
|
||||
button.addTarget(self, action: #selector(toggleSkeletons), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
view.backgroundColor = .red
|
||||
view.frame = CGRect(x: 0, y: 0, width: 250, height: 250)
|
||||
view.addSubview(button)
|
||||
}
|
||||
|
||||
@objc func toggleSkeletons() {
|
||||
showSkeletons()
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) { [weak self] in
|
||||
self?.hideSkeletons()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//: Можно так же указать, какие вью будут конвертироваться в скелетоны
|
||||
class CustomSkeletonableTableView: UITableView, SkeletonsPresenter {
|
||||
var viewsToSkeletone: [UIView] {
|
||||
visibleCells
|
||||
}
|
||||
}
|
||||
/*:
|
||||
## Конфигурация внешнего вида
|
||||
|
||||
Для конфигурации скелетонов существует клас `SkeletonsConfiguration` который определяется внутри объекта реализующего протокол `SkeletonsPresenter`.
|
||||
*/
|
||||
class CustomConfigurableSkeletonableView: UIView, SkeletonsPresenter {
|
||||
var skeletonsConfiguration: SkeletonsConfiguration {
|
||||
.init(skeletonsBackgroundColor: .blue)
|
||||
}
|
||||
}
|
||||
|
||||
/*:
|
||||
Возможные опции для настройки:
|
||||
|
||||
- анимация
|
||||
- цвет
|
||||
- форма
|
||||
- отступы
|
||||
|
||||
### Анимация
|
||||
|
||||
`SkeletonsConfiguration` для настройки анимации принимает тип `(SkeletonsLayer) -> CAAnimationGroup`. Это означает, что при необходимости вы можете создать любую необходимую анимацию. Анимация будет применена к каждому скелетону.
|
||||
|
||||
Однако для удобства существует уже определенный класс `SkeletonsAnimationBuilder` со статическим методом `createDirectionalGradientAnimation(_:)` для создания анимаций в одну из сторон:
|
||||
|
||||
```swift
|
||||
public enum SkeletonsAnimationDirection {
|
||||
case leftToRight
|
||||
case rightToLeft
|
||||
case topToBottom
|
||||
case bottomToTop
|
||||
case topLeftToBottomRight
|
||||
case topRightToBottomLeft
|
||||
case bottomLeftToTopRight
|
||||
case bottomRightToTopLeft
|
||||
}
|
||||
```
|
||||
*/
|
||||
let confWithLeftToRightAnim = SkeletonsConfiguration(animation: { _ in
|
||||
let animConfig = DirectionalSkeletonsAnimationConfiguration(direction: .leftToRight, duration: 1.5)
|
||||
return SkeletonsAnimationBuilder.createDirectionalGradientAnimation(animConfig)
|
||||
})
|
||||
|
||||
let confWithTopToBottomAnim = SkeletonsConfiguration(animation: { _ in
|
||||
let animConfig = DirectionalSkeletonsAnimationConfiguration(direction: .topToBottom, duration: 1.5)
|
||||
return SkeletonsAnimationBuilder.createDirectionalGradientAnimation(animConfig)
|
||||
})
|
||||
|
||||
/*:
|
||||
### Цвет
|
||||
|
||||
За настройку цвета отвечает параметр `skeletonsBackgroundColor`: основной цвет скелетонов, им будт заливаться фон и выделяться _border_
|
||||
*/
|
||||
let confWithRedBackgroundColor = SkeletonsConfiguration(skeletonsBackgroundColor: .red)
|
||||
|
||||
/*:
|
||||
### Форма
|
||||
|
||||
Форму можно настраивать отдельно для `UILabel`, `UITextView`, `UIImageView` и остальных вью. Например, картинки можно сделать круглыми, а лейблы прямоугольные с закругленными краями:
|
||||
*/
|
||||
var confWithShape: SkeletonsConfiguration {
|
||||
let labelConf = TextSkeletonsConfiguration(shape: .rectangle(cornerRadius: 10))
|
||||
let imageConf = BaseViewSkeletonsConfiguration(shape: .circle)
|
||||
|
||||
return .init(labelConfiguration: labelConf,
|
||||
imageViewConfiguration: imageConf)
|
||||
}
|
||||
|
||||
/*:
|
||||
Для `UILabel` и `UITextView` есть возможность настроить высоту каждой строчки, расстояние между ними и их количество.
|
||||
*/
|
||||
|
||||
var confWithLabelSettings: SkeletonsConfiguration {
|
||||
let labelConf = TextSkeletonsConfiguration(numberOfLines: 3,
|
||||
lineHeight: { font in
|
||||
if let font = font {
|
||||
return font.pointSize
|
||||
}
|
||||
return 10
|
||||
|
||||
}, lineSpacing: { font in
|
||||
if let font = font {
|
||||
return font.xHeight
|
||||
}
|
||||
return 5
|
||||
})
|
||||
return .init(labelConfiguration: labelConf)
|
||||
}
|
||||
|
||||
/*:
|
||||
### Отступы
|
||||
|
||||
Отступы можно настроить отдельно для `UILabel`, `UITextView`, `UIImageView` и остальных вью. Например, для предыдущего примера можно добавить горизонтальный _padding_ для лейбла:
|
||||
*/
|
||||
var confWithPadding: SkeletonsConfiguration {
|
||||
let labelConf = TextSkeletonsConfiguration(padding: .horizontal(left: 15), shape: .rectangle(cornerRadius: 10))
|
||||
let imageConf = BaseViewSkeletonsConfiguration(shape: .circle)
|
||||
|
||||
return .init(labelConfiguration: labelConf,
|
||||
imageViewConfiguration: imageConf)
|
||||
}
|
||||
|
||||
/*:
|
||||
## Что если нужно больше?
|
||||
|
||||
Если стандартной настройки не хватает, то в конфигуратор можно передать объект, соответствующий протоколу `SkeletonsConfigurationDelegate` через который можно настроить слой скелетона для каждой вью отдельно
|
||||
|
||||
```swift
|
||||
public protocol SkeletonsConfigurationDelegate: AnyObject {
|
||||
func layerDidConfigured(forViewType type: SkeletonLayer.ViewType, layer: SkeletonLayer)
|
||||
}
|
||||
```
|
||||
*/
|
||||
class SkeletonsConfDelegate: SkeletonsConfigurationDelegate {
|
||||
func layerDidConfigured(forViewType type: SkeletonLayer.ViewType, layer: SkeletonLayer) {
|
||||
// Do something...
|
||||
}
|
||||
}
|
||||
|
||||
let delegate = SkeletonsConfDelegate()
|
||||
let confWithDelegate = SkeletonsConfiguration(configurationDelegate: delegate)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='6.0' target-platform='ios' display-mode='raw' buildActiveScheme='true'/>
|
||||
|
|
@ -0,0 +1,395 @@
|
|||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 50;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
B295B0E33533FFC3D833A6CB /* Pods_TIUIElements.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E0E28C6F64363C77CAE4662 /* Pods_TIUIElements.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
2E10916FC4CAF67D840FC3D2 /* Pods-TIUIElements.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Target Support Files/Pods-TIUIElements/Pods-TIUIElements.release.xcconfig"; sourceTree = "<group>"; };
|
||||
8BACBE8322576CAD00266845 /* TIUIElements.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TIUIElements.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8BACBE8622576CAD00266845 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
8E0E28C6F64363C77CAE4662 /* Pods_TIUIElements.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TIUIElements.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CB08C5B0C7051DCB015D3D9F /* Pods-TIUIElements.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TIUIElements.debug.xcconfig"; path = "Target Support Files/Pods-TIUIElements/Pods-TIUIElements.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
8BACBE8022576CAD00266845 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B295B0E33533FFC3D833A6CB /* Pods_TIUIElements.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
6FA8D567F06C39C360B32325 /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2E10916FC4CAF67D840FC3D2 /* Pods-TIUIElements.release.xcconfig */,
|
||||
CB08C5B0C7051DCB015D3D9F /* Pods-TIUIElements.debug.xcconfig */,
|
||||
);
|
||||
path = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7672C2F734E0BBEC76B58962 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8E0E28C6F64363C77CAE4662 /* Pods_TIUIElements.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8B39A26221D40F8700DE2643 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8BACBE8422576CAD00266845 /* TIUIElements */,
|
||||
8B39A26C21D40F8700DE2643 /* Products */,
|
||||
6FA8D567F06C39C360B32325 /* Pods */,
|
||||
7672C2F734E0BBEC76B58962 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8B39A26C21D40F8700DE2643 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8BACBE8322576CAD00266845 /* TIUIElements.framework */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
8BACBE8422576CAD00266845 /* TIUIElements */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8BACBE8622576CAD00266845 /* Info.plist */,
|
||||
);
|
||||
path = TIUIElements;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
8BACBE7E22576CAD00266845 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
8BACBE8222576CAD00266845 /* TIUIElements */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 8BACBE8A22576CAD00266845 /* Build configuration list for PBXNativeTarget "TIUIElements" */;
|
||||
buildPhases = (
|
||||
9D2C80D787CBCD9B1EA728B0 /* [CP] Check Pods Manifest.lock */,
|
||||
8BACBE7E22576CAD00266845 /* Headers */,
|
||||
8BACBE7F22576CAD00266845 /* Sources */,
|
||||
8BACBE8022576CAD00266845 /* Frameworks */,
|
||||
8BACBE8122576CAD00266845 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = TIUIElements;
|
||||
productName = TIUIElements2;
|
||||
productReference = 8BACBE8322576CAD00266845 /* TIUIElements.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
8B39A26321D40F8700DE2643 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 1010;
|
||||
LastUpgradeCheck = 1200;
|
||||
ORGANIZATIONNAME = "47 Degrees";
|
||||
TargetAttributes = {
|
||||
8BACBE8222576CAD00266845 = {
|
||||
CreatedOnToolsVersion = 10.1;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 8B39A26621D40F8700DE2643 /* Build configuration list for PBXProject "TIUIElements" */;
|
||||
compatibilityVersion = "Xcode 9.3";
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 8B39A26221D40F8700DE2643;
|
||||
productRefGroup = 8B39A26C21D40F8700DE2643 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
8BACBE8222576CAD00266845 /* TIUIElements */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
8BACBE8122576CAD00266845 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
9D2C80D787CBCD9B1EA728B0 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
|
||||
"${PODS_ROOT}/Manifest.lock",
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
"$(DERIVED_FILE_DIR)/Pods-TIUIElements-checkManifestLockResult.txt",
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
8BACBE7F22576CAD00266845 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
8B39A27721D40F8800DE2643 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
ENABLE_TESTING_SEARCH_PATHS = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
8B39A27821D40F8800DE2643 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_COMMA = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTING_SEARCH_PATHS = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
8BACBE8822576CAD00266845 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = CB08C5B0C7051DCB015D3D9F /* Pods-TIUIElements.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_TIUIElements_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = "$(SRCROOT)/TIUIElements/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.47deg.ios.TIUIElements;
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 5;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
8BACBE8922576CAD00266845 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 2E10916FC4CAF67D840FC3D2 /* Pods-TIUIElements.release.xcconfig */;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
CODE_SIGN_STYLE = Manual;
|
||||
CURRENT_TIUIElements_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
INFOPLIST_FILE = "$(SRCROOT)/TIUIElements/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 12.1;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@loader_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.47deg.ios.TIUIElements;
|
||||
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_VERSION = 5;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
8B39A26621D40F8700DE2643 /* Build configuration list for PBXProject "TIUIElements" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
8B39A27721D40F8800DE2643 /* Debug */,
|
||||
8B39A27821D40F8800DE2643 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
8BACBE8A22576CAD00266845 /* Build configuration list for PBXNativeTarget "TIUIElements" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
8BACBE8822576CAD00266845 /* Debug */,
|
||||
8BACBE8922576CAD00266845 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 8B39A26321D40F8700DE2643 /* Project object */;
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:TIUIElements.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1200"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BACBE8222576CAD00266845"
|
||||
BuildableName = "TIUIElements.framework"
|
||||
BlueprintName = "TIUIElements"
|
||||
ReferencedContainer = "container:TIUIElements.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BACBE8222576CAD00266845"
|
||||
BuildableName = "TIUIElements.framework"
|
||||
BlueprintName = "TIUIElements"
|
||||
ReferencedContainer = "container:TIUIElements.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "8BACBE8222576CAD00266845"
|
||||
BuildableName = "TIUIElements.framework"
|
||||
BlueprintName = "TIUIElements"
|
||||
ReferencedContainer = "container:TIUIElements.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
11
TIUIElements/TIUIElements.app/Contents/MacOS/TIUIElements.xcworkspace/contents.xcworkspacedata
generated
Normal file
11
TIUIElements/TIUIElements.app/Contents/MacOS/TIUIElements.xcworkspace/contents.xcworkspacedata
generated
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef location = "group:TIUIElements.playground"></FileRef>
|
||||
<FileRef
|
||||
location = "group:TIUIElements.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Pods/Pods.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2019. The nef authors.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
workspace="TIUIElements.xcworkspace"
|
||||
workspacePath=$(echo "$0" | rev | cut -f2- -d '/' | rev)
|
||||
|
||||
open "`pwd`/$workspacePath/$workspace"
|
||||
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
/var/folders/l0/vmsk54092zb07vg6t9h5j5bc0000gn/T/main.swift:2:8: error: no such module 'TIUIElements'
|
||||
import TIUIElements
|
||||
^
|
||||
|
|
@ -0,0 +1 @@
|
|||
TIUIElements.app/Contents/MacOS/TIUIElements.playground
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
|
||||
# Skeletons API
|
||||
|
||||
При импорте _TIUIElements_ вы можете использовать API для показа скелетонов.
|
||||
|
||||
## Базовая настройка
|
||||
|
||||
Чтобы `UIViewController` или `UIView` мог показать скелетоны необходимо, чтобы он соответствовал протоколу `SkeletonsPresenter`.
|
||||
|
||||
```swift
|
||||
import TIUIElements
|
||||
import UIKit
|
||||
|
||||
class DummyVC: UIViewController, SkeletonsPresenter {
|
||||
}
|
||||
```
|
||||
|
||||
Чтобы показать или скрыть скелетоны необходимо использовать методы `showSkeletons()` и `hideSkeletons()`
|
||||
|
||||
```swift
|
||||
class CanShowAndHideSkeletons: UIViewController, SkeletonsPresenter {
|
||||
lazy var button: UIButton = {
|
||||
let button = UIButton(frame: CGRect(x: .zero, y: .zero,
|
||||
width: view.frame.width, height: view.frame.height))
|
||||
|
||||
button.setTitle("Hello from SkeletonableViewController", for: .normal)
|
||||
button.setTitleColor(.black, for: .normal)
|
||||
button.titleLabel?.font = .systemFont(ofSize: 30)
|
||||
button.addTarget(self, action: #selector(toggleSkeletons), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
view.backgroundColor = .red
|
||||
view.frame = CGRect(x: 0, y: 0, width: 250, height: 250)
|
||||
view.addSubview(button)
|
||||
}
|
||||
|
||||
@objc func toggleSkeletons() {
|
||||
showSkeletons()
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3)) { [weak self] in
|
||||
self?.hideSkeletons()
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Можно так же указать, какие вью будут конвертироваться в скелетоны
|
||||
|
||||
```swift
|
||||
class CustomSkeletonableTableView: UITableView, SkeletonsPresenter {
|
||||
var viewsToSkeletone: [UIView] {
|
||||
visibleCells
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Конфигурация внешнего вида
|
||||
|
||||
Для конфигурации скелетонов существует клас `SkeletonsConfiguration` который определяется внутри объекта реализующего протокол `SkeletonsPresenter`.
|
||||
|
||||
```swift
|
||||
class CustomConfigurableSkeletonableView: UIView, SkeletonsPresenter {
|
||||
var skeletonsConfiguration: SkeletonsConfiguration {
|
||||
.init(skeletonsBackgroundColor: .blue)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Возможные опции для настройки:
|
||||
|
||||
- анимация
|
||||
- цвет
|
||||
- форма
|
||||
- отступы
|
||||
|
||||
### Анимация
|
||||
|
||||
`SkeletonsConfiguration` для настройки анимации принимает тип `(SkeletonsLayer) -> CAAnimationGroup`. Это означает, что при необходимости вы можете создать любую необходимую анимацию. Анимация будет применена к каждому скелетону.
|
||||
|
||||
Однако для удобства существует уже определенный класс `SkeletonsAnimationBuilder` со статическим методом `createDirectionalGradientAnimation(_:)` для создания анимаций в одну из сторон:
|
||||
|
||||
```swift
|
||||
public enum SkeletonsAnimationDirection {
|
||||
case leftToRight
|
||||
case rightToLeft
|
||||
case topToBottom
|
||||
case bottomToTop
|
||||
case topLeftToBottomRight
|
||||
case topRightToBottomLeft
|
||||
case bottomLeftToTopRight
|
||||
case bottomRightToTopLeft
|
||||
}
|
||||
```
|
||||
|
||||
```swift
|
||||
let confWithLeftToRightAnim = SkeletonsConfiguration(animation: { _ in
|
||||
let animConfig = DirectionalSkeletonsAnimationConfiguration(direction: .leftToRight, duration: 1.5)
|
||||
return SkeletonsAnimationBuilder.createDirectionalGradientAnimation(animConfig)
|
||||
})
|
||||
|
||||
let confWithTopToBottomAnim = SkeletonsConfiguration(animation: { _ in
|
||||
let animConfig = DirectionalSkeletonsAnimationConfiguration(direction: .topToBottom, duration: 1.5)
|
||||
return SkeletonsAnimationBuilder.createDirectionalGradientAnimation(animConfig)
|
||||
})
|
||||
```
|
||||
|
||||
### Цвет
|
||||
|
||||
За настройку цвета отвечает параметр `skeletonsBackgroundColor`: основной цвет скелетонов, им будт заливаться фон и выделяться _border_
|
||||
|
||||
```swift
|
||||
let confWithRedBackgroundColor = SkeletonsConfiguration(skeletonsBackgroundColor: .red)
|
||||
```
|
||||
|
||||
### Форма
|
||||
|
||||
Форму можно настраивать отдельно для `UILabel`, `UITextView`, `UIImageView` и остальных вью. Например, картинки можно сделать круглыми, а лейблы прямоугольные с закругленными краями:
|
||||
|
||||
```swift
|
||||
var confWithShape: SkeletonsConfiguration {
|
||||
let labelConf = TextSkeletonsConfiguration(shape: .rectangle(cornerRadius: 10))
|
||||
let imageConf = BaseViewSkeletonsConfiguration(shape: .circle)
|
||||
|
||||
return .init(labelConfiguration: labelConf,
|
||||
imageViewConfiguration: imageConf)
|
||||
}
|
||||
```
|
||||
|
||||
Для `UILabel` и `UITextView` есть возможность настроить высоту каждой строчки, расстояние между ними и их количество.
|
||||
|
||||
```swift
|
||||
var confWithLabelSettings: SkeletonsConfiguration {
|
||||
let labelConf = TextSkeletonsConfiguration(numberOfLines: 3,
|
||||
lineHeight: { font in
|
||||
if let font = font {
|
||||
return font.pointSize
|
||||
}
|
||||
return 10
|
||||
|
||||
}, lineSpacing: { font in
|
||||
if let font = font {
|
||||
return font.xHeight
|
||||
}
|
||||
return 5
|
||||
})
|
||||
return .init(labelConfiguration: labelConf)
|
||||
}
|
||||
```
|
||||
|
||||
### Отступы
|
||||
|
||||
Отступы можно настроить отдельно для `UILabel`, `UITextView`, `UIImageView` и остальных вью. Например, для предыдущего примера можно добавить горизонтальный _padding_ для лейбла:
|
||||
|
||||
```swift
|
||||
var confWithPadding: SkeletonsConfiguration {
|
||||
let labelConf = TextSkeletonsConfiguration(padding: .horizontal(left: 15), shape: .rectangle(cornerRadius: 10))
|
||||
let imageConf = BaseViewSkeletonsConfiguration(shape: .circle)
|
||||
|
||||
return .init(labelConfiguration: labelConf,
|
||||
imageViewConfiguration: imageConf)
|
||||
}
|
||||
```
|
||||
|
||||
## Что если нужно больше?
|
||||
|
||||
Если стандартной настройки не хватает, то в конфигуратор можно передать объект, соответствующий протоколу `SkeletonsConfigurationDelegate` через который можно настроить слой скелетона для каждой вью отдельно
|
||||
|
||||
```swift
|
||||
public protocol SkeletonsConfigurationDelegate: AnyObject {
|
||||
func layerDidConfigured(forViewType type: SkeletonLayer.ViewType, layer: SkeletonLayer)
|
||||
}
|
||||
```
|
||||
|
||||
```swift
|
||||
class SkeletonsConfDelegate: SkeletonsConfigurationDelegate {
|
||||
func layerDidConfigured(forViewType type: SkeletonLayer.ViewType, layer: SkeletonLayer) {
|
||||
// Do something...
|
||||
}
|
||||
}
|
||||
|
||||
let delegate = SkeletonsConfDelegate()
|
||||
let confWithDelegate = SkeletonsConfiguration(configurationDelegate: delegate)
|
||||
```
|
||||
|
|
@ -7,9 +7,10 @@
|
|||
# SRCROOT - path to project folder.
|
||||
#
|
||||
|
||||
PLAYGROUNDS="${SRCROOT}/TIFoundationUtils/TIFoundationUtils.app"
|
||||
PLAYGROUNDS="${SRCROOT}/TIFoundationUtils/TIFoundationUtils.app
|
||||
${SRCROOT}/TIUIElements/TIUIElements.app"
|
||||
|
||||
for playground_path in ${PLAYGROUNDS}; do
|
||||
nef compile --project ${playground_path}
|
||||
# nef compile --project ${playground_path}
|
||||
nef markdown --project ${playground_path} --output ../docs
|
||||
done
|
||||
done
|
||||
|
|
|
|||
Loading…
Reference in New Issue