Browse Source

IMP: FLViewStateManager.configure method now support user-defined checker block.

XCBOSA - ITX 3 years ago
parent
commit
95bac5d570
1 changed files with 3 additions and 3 deletions
  1. 3 3
      Sources/FastLayout/FLViewState.swift

+ 3 - 3
Sources/FastLayout/FLViewState.swift

@@ -71,15 +71,15 @@ extension FLViewStateManager {
     
     
     public typealias ConstraintLoader = () -> Void
     public typealias ConstraintLoader = () -> Void
     
     
-    public func configure(withHorizontal horizontal: ConstraintLoader, portrait: ConstraintLoader) {
+    public func configure(withHorizontal horizontal: ConstraintLoader, portrait: ConstraintLoader, horizontalBlock: FLViewStateCheckerBlock? = nil, portraitBlock: FLViewStateCheckerBlock? = nil) {
         if self.viewStates.count > 0 {
         if self.viewStates.count > 0 {
             fatalError("FLViewStateManager.configureWith(horizontal: portrait:) can't called after register(viewState:) called.")
             fatalError("FLViewStateManager.configureWith(horizontal: portrait:) can't called after register(viewState:) called.")
         }
         }
-        let horizontalState = FLViewState(configureWithRecorder: .standard, checkerBlock: FLViewStateCheckerBlockHorizontal)
+        let horizontalState = FLViewState(configureWithRecorder: .standard, checkerBlock: horizontalBlock ?? FLViewStateCheckerBlockHorizontal)
         horizontalState.isExtensionCreated = true
         horizontalState.isExtensionCreated = true
         horizontal()
         horizontal()
         horizontalState.finishRecorder()
         horizontalState.finishRecorder()
-        let portraitState = FLViewState(configureWithRecorder: .standard, checkerBlock: FLViewStateCheckerBlockPortrait)
+        let portraitState = FLViewState(configureWithRecorder: .standard, checkerBlock: portraitBlock ?? FLViewStateCheckerBlockPortrait)
         portraitState.isExtensionCreated = true
         portraitState.isExtensionCreated = true
         portrait()
         portrait()
         portraitState.finishRecorder()
         portraitState.finishRecorder()