forked from divkit/divkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppComponents.swift
58 lines (54 loc) · 1.87 KB
/
AppComponents.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import Foundation
import CommonCorePublic
import DivKit
import DivKitExtensions
import LayoutKit
import NetworkingPublic
enum AppComponents {
static let fontProvider = YSFontProvider()
static func makeDivKitComponents(
layoutDirection: UserInterfaceLayoutDirection = .system,
reporter: DivReporter? = nil,
urlHandler: DivUrlHandler = DivUrlHandlerDelegate { _, _ in },
variableStorage: DivVariableStorage? = nil
) -> DivKitComponents {
let performer = URLRequestPerformer(urlTransform: nil)
let requester = NetworkURLResourceRequester(performer: performer)
let lottieExtensionHanlder = LottieExtensionHandler(
factory: LottieAnimationFactory(),
requester: requester
)
let variablesStorage = DivVariablesStorage(outerStorage: variableStorage)
let sizeProviderExtensionHandler = SizeProviderExtensionHandler(
variablesStorage: variablesStorage
)
return DivKitComponents(
divCustomBlockFactory: PlaygroundDivCustomBlockFactory(requester: requester),
extensionHandlers: [
lottieExtensionHanlder,
sizeProviderExtensionHandler,
ShimmerImagePreviewExtension(),
VideoDurationExtensionHandler(),
],
flagsInfo: DivFlagsInfo(imageLoadingOptimizationEnabled: true),
fontProvider: fontProvider,
layoutDirection: layoutDirection,
patchProvider: PlaygroundPatchProvider(),
reporter: reporter,
trackVisibility: { logId, cardId in
AppLogger.info("Visibility: cardId = \(cardId), logId = \(logId)")
},
trackDisappear: { logId, cardId in
AppLogger.info("Disappear: cardId = \(cardId), logId = \(logId)")
},
playerFactory: DefaultPlayerFactory(),
urlHandler: urlHandler,
variablesStorage: variablesStorage
)
}
static var debugParams: DebugParams {
DebugParams(
isDebugInfoEnabled: true
)
}
}