DivKit 28.7.0 release

DivKit 28.7.0 release

DivKit

Hi everyone! 

Here's what's new in the recent DivKit 28.7.0 release

Web Client

Release 28.7 brings the long-awaited support for the custom component to the web version of DivKit! You can find an example of using the component and documentation on our GitHub.

iOS

  • Support for the scale parameter for DivVideo is now available, which works similarly to scale for images, except no support for the no_scale option due to platform limitations.


    fill - fills all available space, anything that doesn't fit is cropped;

    fit - fits within the boundaries, the remaining space will be empty;

    no_scale is not supported for video element.


  • Added the ability to create nested DivVariableStorage.

DivVariableStorage allows you to have variable stores with different scope and lifetime. For example, there are application level variables and screen level variables. Nesting DivVariableStorage makes it possible to create several storages and nest them into each other.

let appVariables = DivVaraibleStorage()
appVariables.add("theme", .string("light"))

let screenVariables = DivVariableStorage(appVariables)
screenVariables.add("screen_width", .number(640))
screenVariables.add("screen_height", .number(480))

let cardVariables = DivVariableStorage(screenVariables)
cardVariables.add(divData.variables) // adding variables from DivData

// The consumer doesn't need to think about which scope the variable is in.
// Everything is available through the top-level storage.
let theme = cardVariables.getValue("theme")

let subscription = cardVariables.addObserver {
 // Also receive all notifications of changes to nested repositories.
}

class DivVaraibleStorage {
  let innerStorage: DivVariableStorage?
  
  // Adds variable(s).
  funс add(_ variable: DivVaraible)
  funс add(_ variables: [DivVaraible])
  funс add(name: DivVariableName, value: DivVariableValue)
  
  // Changes the value of the variable.
  // Если перменой с таким именем нет, вызывает innerStorage.update.
  funс update(name: DivVariableName, value: DivVariableValue)
  
  // Gets the value of the variable.
  // Если перменой с таким именем нет, вызывает innerStorage.getValue.
  funс getValue(name: DivVariableName) -> DivVariableValue?
  
  // Change subscription. Notifies about changes also in nested storages.
  funс addObserver(_ observer: (ChangeEvent) -> Void) -> Disposable
}


Report Page