-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit_hash:ad75916b6896503f436dce62fde8a9c4f3e6f689
- Loading branch information
robot-divkit
committed
Sep 30, 2024
1 parent
6b2fa27
commit 379508e
Showing
30 changed files
with
630 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Foundation | ||
import LayoutKit | ||
import VGSL | ||
|
||
final class TimerActionHandler { | ||
private let performer: DivActionURLHandler.PerformTimerAction | ||
|
||
init (performer: @escaping DivActionURLHandler.PerformTimerAction) { | ||
self.performer = performer | ||
} | ||
|
||
func handle( | ||
_ action: DivActionTimer, | ||
context: DivActionHandlingContext | ||
) { | ||
let expressionResolver = context.expressionResolver | ||
|
||
guard let id = action.resolveId(expressionResolver), | ||
let command = action.resolveAction(expressionResolver) else { | ||
return | ||
} | ||
|
||
performer(context.path.cardId, id, command.toDivTimerAction()) | ||
} | ||
} | ||
|
||
extension DivActionTimer.Action { | ||
func toDivTimerAction() -> DivTimerAction { | ||
switch self { | ||
case .start: | ||
return .start | ||
case .stop: | ||
return .stop | ||
case .pause: | ||
return .pause | ||
case .resume: | ||
return .resume | ||
case .cancel: | ||
return .cancel | ||
case .reset: | ||
return .reset | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Foundation | ||
import LayoutKit | ||
import VGSL | ||
|
||
final class VideoActionHandler { | ||
func handle( | ||
_ action: DivActionVideo, | ||
context: DivActionHandlingContext | ||
) { | ||
let expressionResolver = context.expressionResolver | ||
|
||
guard let id = action.resolveId(expressionResolver), | ||
let command = action.resolveAction(expressionResolver) else { | ||
return | ||
} | ||
|
||
let cardId = context.path.cardId | ||
|
||
context.blockStateStorage.setState( | ||
id: id, | ||
cardId: cardId, | ||
state: VideoBlockViewState(state: command == .start ? .playing : .paused) | ||
) | ||
|
||
context.updateCard(.state(cardId)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.