import { WidgetModel , PropertyModel } from '../models/models' ; import { WrapperPropertyHandler } from "./wrapper-property" ; import { PropertyResolver } from '../resolvers/property-resolver' ; export class WrapperConsumerPropertyHandler extends WrapperPropertyHandler { valueSnippet = '${0:DataType} ${1:instanceName}' ; constructor ( propertyResolver ) { super ( propertyResolver , [ { handler : ':consumer' , targetProperty : 'consumer' } ] , 'Consumer' , undefined , 10000 ) ; } protected createWrapperWidget ( widget , targetProperty , value , onWrapped ) { const parts = value . split ( ' ' ) ; const providerTypeName = parts [ 0 ] ; const providerInstanceName = parts [ 1 ] ; const wrapperWidget = { controllers : [ ] , vars : [ ] , formControls : [ ] , properties : [ { dataType : 'function' , name : 'builder' , value : '' , extraData : { parameters : [ { name : 'context' , type : 'BuildContext' } , { name : providerInstanceName , type : providerTypeName } , { name : 'child' , type : 'Widget' } ] , addReturn : true } } ] , type : `${ this . targetWidgetType }<${ providerTypeName }>` , wrappedWidgets : [ widget ] , onResolved : [ ] } ; return { wrapperWidget , propertyToUpdateAfterBinding : null } ; } }