mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
Clean parsing
commit_hash:f52c9ec07cfd92428951188f6e859d00a4eac429
This commit is contained in:
+3
-1
@@ -10957,6 +10957,7 @@
|
||||
"client/flutter/divkit/lib/src/core/divkit.dart":"divkit/public/client/flutter/divkit/lib/src/core/divkit.dart",
|
||||
"client/flutter/divkit/lib/src/core/expression/analyzer.dart":"divkit/public/client/flutter/divkit/lib/src/core/expression/analyzer.dart",
|
||||
"client/flutter/divkit/lib/src/core/expression/expression.dart":"divkit/public/client/flutter/divkit/lib/src/core/expression/expression.dart",
|
||||
"client/flutter/divkit/lib/src/core/expression/parse.dart":"divkit/public/client/flutter/divkit/lib/src/core/expression/parse.dart",
|
||||
"client/flutter/divkit/lib/src/core/expression/resolver.dart":"divkit/public/client/flutter/divkit/lib/src/core/expression/resolver.dart",
|
||||
"client/flutter/divkit/lib/src/core/patch/patch.dart":"divkit/public/client/flutter/divkit/lib/src/core/patch/patch.dart",
|
||||
"client/flutter/divkit/lib/src/core/patch/patch_converter.dart":"divkit/public/client/flutter/divkit/lib/src/core/patch/patch_converter.dart",
|
||||
@@ -11156,6 +11157,7 @@
|
||||
"client/flutter/divkit/lib/src/schema/div_neighbour_page_size.dart":"divkit/public/client/flutter/divkit/lib/src/schema/div_neighbour_page_size.dart",
|
||||
"client/flutter/divkit/lib/src/schema/div_nine_patch_background.dart":"divkit/public/client/flutter/divkit/lib/src/schema/div_nine_patch_background.dart",
|
||||
"client/flutter/divkit/lib/src/schema/div_number_animator.dart":"divkit/public/client/flutter/divkit/lib/src/schema/div_number_animator.dart",
|
||||
"client/flutter/divkit/lib/src/schema/div_page_content_size.dart":"divkit/public/client/flutter/divkit/lib/src/schema/div_page_content_size.dart",
|
||||
"client/flutter/divkit/lib/src/schema/div_page_size.dart":"divkit/public/client/flutter/divkit/lib/src/schema/div_page_size.dart",
|
||||
"client/flutter/divkit/lib/src/schema/div_page_transformation.dart":"divkit/public/client/flutter/divkit/lib/src/schema/div_page_transformation.dart",
|
||||
"client/flutter/divkit/lib/src/schema/div_page_transformation_overlap.dart":"divkit/public/client/flutter/divkit/lib/src/schema/div_page_transformation_overlap.dart",
|
||||
@@ -11231,7 +11233,7 @@
|
||||
"client/flutter/divkit/lib/src/utils/div_focus_node.dart":"divkit/public/client/flutter/divkit/lib/src/utils/div_focus_node.dart",
|
||||
"client/flutter/divkit/lib/src/utils/duration_helper.dart":"divkit/public/client/flutter/divkit/lib/src/utils/duration_helper.dart",
|
||||
"client/flutter/divkit/lib/src/utils/mapping_widget.dart":"divkit/public/client/flutter/divkit/lib/src/utils/mapping_widget.dart",
|
||||
"client/flutter/divkit/lib/src/utils/parsing_utils.dart":"divkit/public/client/flutter/divkit/lib/src/utils/parsing_utils.dart",
|
||||
"client/flutter/divkit/lib/src/utils/parsing.dart":"divkit/public/client/flutter/divkit/lib/src/utils/parsing.dart",
|
||||
"client/flutter/divkit/lib/src/utils/provider.dart":"divkit/public/client/flutter/divkit/lib/src/utils/provider.dart",
|
||||
"client/flutter/divkit/lib/src/utils/tap_builder.dart":"divkit/public/client/flutter/divkit/lib/src/utils/tap_builder.dart",
|
||||
"client/flutter/divkit/lib/src/utils/trace.dart":"divkit/public/client/flutter/divkit/lib/src/utils/trace.dart",
|
||||
|
||||
@@ -180,66 +180,76 @@ class DartProperty(Property):
|
||||
raise ValueError(type_val)
|
||||
return utils.capitalize_camel_case(enum_case[0])
|
||||
|
||||
# ToDo(man-y): Transfer the parsing strategy to the subtypes themselves.
|
||||
def get_parse_strategy(self, is_future=False) -> str:
|
||||
def get_decode_strategy(self) -> str:
|
||||
var = 'V' if self.supports_expressions else ''
|
||||
required = not self.optional or self.has_default
|
||||
decode = self._decode_property()
|
||||
|
||||
if required:
|
||||
prop_name = f"'{self.name}'"
|
||||
prop_type_declaration = cast(DartPropertyType, self.property_type).declaration()
|
||||
return f"req{var}Prop<{prop_type_declaration}>({decode}, name: {prop_name},)"
|
||||
return decode
|
||||
|
||||
def _decode_property(self) -> str:
|
||||
prop_type = cast(DartPropertyType, self.property_type)
|
||||
prop_type_decl = prop_type.declaration()
|
||||
required = '' if self.optional and not self.has_default else '!'
|
||||
prop_type_declaration = prop_type.declaration()
|
||||
fallback = f' fallback: {self.fallback_declaration},' if self.has_default else ''
|
||||
expr = 'Expr' if self.supports_expressions else ''
|
||||
_async = 'Async' if is_future else ''
|
||||
_await = 'await ' if is_future else ''
|
||||
br0 = '(' if is_future and (not self.optional or self.has_default) else ''
|
||||
br1 = ')' if is_future and (not self.optional or self.has_default) else ''
|
||||
src = f"json['{self.name}']"
|
||||
|
||||
if isinstance(prop_type, Int):
|
||||
return f"{br0}{_await}safeParseInt{expr}{_async}(json['{self.name}'],{fallback}){br1}{required}"
|
||||
return f"safeParseInt{expr}({src},{fallback})"
|
||||
elif isinstance(prop_type, Color):
|
||||
return f"{br0}{_await}safeParseColor{expr}{_async}(json['{self.name}'],{fallback}){br1}{required}"
|
||||
return f"safeParseColor{expr}({src},{fallback})"
|
||||
elif isinstance(prop_type, Double):
|
||||
return f"{br0}{_await}safeParseDouble{expr}{_async}(json['{self.name}'],{fallback}){br1}{required}"
|
||||
return f"safeParseDouble{expr}({src},{fallback})"
|
||||
elif isinstance(prop_type, (Bool, BoolInt)):
|
||||
return f"{br0}{_await}safeParseBool{expr}{_async}(json['{self.name}'],{fallback}){br1}{required}"
|
||||
return f"safeParseBool{expr}({src},{fallback})"
|
||||
elif isinstance(prop_type, (String, StaticString)):
|
||||
return f"{br0}{_await}safeParseStr{expr}{_async}(json['{self.name}']?.toString(),{fallback}){br1}{required}"
|
||||
return f"safeParseStr{expr}({src},{fallback})"
|
||||
elif isinstance(prop_type, Dictionary):
|
||||
return f"{br0}{_await}safeParseMap{expr}{_async}(json['{self.name}'],{fallback}){br1}{required}"
|
||||
return f"safeParseMap{expr}({src},{fallback})"
|
||||
elif isinstance(prop_type, RawArray):
|
||||
return f"{br0}{_await}safeParseList{expr}{_async}(json['{self.name}'],{fallback}){br1}{required}"
|
||||
return f"safeParseList{expr}({src},{fallback})"
|
||||
elif isinstance(prop_type, Url):
|
||||
return f"{br0}{_await}safeParseUri{expr}{_async}(json['{self.name}']){br1}{required}"
|
||||
return f"safeParseUri{expr}({src},{fallback})"
|
||||
elif prop_type.is_string_enumeration():
|
||||
return f"{br0}{_await}safeParseStrEnum{expr}{_async}(json['{self.name}'], parse: {prop_type_decl}.fromJson,{fallback}){br1}{required}"
|
||||
return f"safeParseStrEnum{expr}({src}, " \
|
||||
f"parse: {prop_type_declaration}.fromJson,{fallback})"
|
||||
elif prop_type.is_class():
|
||||
return f"{br0}{_await}safeParseObj{expr}{_async}({prop_type_decl}.fromJson(json['{self.name}']),{fallback}){br1}{required}"
|
||||
return f"safeParseObject{expr}({src}, " \
|
||||
f"parse: {prop_type_declaration}.fromJson,{fallback})"
|
||||
elif prop_type.is_list():
|
||||
list_item_type = prop_type.get_list_inner_class()
|
||||
list_item_decl = list_item_type.declaration()
|
||||
list_item_declaration = list_item_type.declaration()
|
||||
if isinstance(list_item_type, Int):
|
||||
strategy = "safeParseInt(v,)!"
|
||||
strategy = "reqProp<int>(safeParseInt(v),)"
|
||||
elif isinstance(list_item_type, Color):
|
||||
strategy = "safeParseColor(v,)!"
|
||||
strategy = "reqProp<Color>(safeParseColor(v),)"
|
||||
elif isinstance(list_item_type, Double):
|
||||
strategy = "safeParseDouble(v,)!"
|
||||
strategy = "reqProp<double>(safeParseDouble(v)',)"
|
||||
elif isinstance(list_item_type, (Bool, BoolInt)):
|
||||
strategy = "safeParseBool(v,)!"
|
||||
strategy = "reqProp<bool>(safeParseBool(v),)"
|
||||
elif isinstance(list_item_type, (String, StaticString)):
|
||||
strategy = "safeParseStr(v?.toString(),)!"
|
||||
strategy = "reqProp<String>(safeParseStr(v),)"
|
||||
elif isinstance(list_item_type, Dictionary):
|
||||
strategy = "safeParseMap(json,)!"
|
||||
strategy = "reqProp<Obj>(safeParseMap(v),)"
|
||||
elif isinstance(list_item_type, RawArray):
|
||||
strategy = "safeParseList(v,)!"
|
||||
strategy = "reqProp<Arr>(safeParseList(v),)"
|
||||
elif isinstance(list_item_type, Url):
|
||||
strategy = "safeParseUri(v)!"
|
||||
strategy = "reqProp<Uri>(safeParseUri(v),)"
|
||||
elif list_item_type.is_string_enumeration():
|
||||
strategy = f"safeParseStrEnum(v, parse: {list_item_decl}.fromJson,)!"
|
||||
strategy = f"reqProp<{list_item_declaration}>(safeParseStrEnum(v, " \
|
||||
f"parse: {list_item_declaration}.fromJson,),)"
|
||||
elif list_item_type.is_class():
|
||||
strategy = f"safeParseObj({list_item_decl}.fromJson(v),)!"
|
||||
strategy = f"reqProp<{list_item_declaration}>(safeParseObject(v, " \
|
||||
f"parse: {list_item_declaration}.fromJson,),)"
|
||||
else:
|
||||
strategy = ""
|
||||
|
||||
return f"{br0}{_await}safeParseObj{expr}{_async}({_await}safeListMap{_async}(json['{self.name}'], (v) => {strategy},)," \
|
||||
f"{fallback}){br1}{required}"
|
||||
return f"safeParseObjects{expr}(json['{self.name}']," \
|
||||
f"(v) => {strategy}, {fallback})"
|
||||
|
||||
def get_resolve_strategy(self) -> Optional[str]:
|
||||
prop_type = cast(DartPropertyType, self.property_type)
|
||||
@@ -254,7 +264,7 @@ class DartProperty(Property):
|
||||
if prop_type.is_class():
|
||||
return f'{name}{option}.resolve(context);'
|
||||
elif prop_type.is_list():
|
||||
return f'safeListResolve({name}, (v) => v.resolve(context));'
|
||||
return f'tryResolveList({name}, (v) => v.resolve(context));'
|
||||
|
||||
@property
|
||||
def fallback_declaration(self) -> str:
|
||||
@@ -339,15 +349,15 @@ class DartPropertyType(PropertyType):
|
||||
elif isinstance(self, Color):
|
||||
return 'Color'
|
||||
elif isinstance(self, Dictionary):
|
||||
return 'Map<String, dynamic>'
|
||||
return 'Obj'
|
||||
elif isinstance(self, RawArray):
|
||||
return 'List<dynamic>'
|
||||
return 'Arr'
|
||||
elif isinstance(self, Url):
|
||||
return 'Uri'
|
||||
elif isinstance(self, Array):
|
||||
item_type = cast(DartPropertyType, self.property_type)
|
||||
item_decl = item_type.declaration()
|
||||
return f'List<{item_decl}>'
|
||||
return f'Arr<{item_decl}>'
|
||||
elif isinstance(self, Object):
|
||||
if self.name.startswith('$predefined_'):
|
||||
return self.name.replace('$predefined_', '')
|
||||
|
||||
@@ -56,7 +56,7 @@ class DartGenerator(Generator):
|
||||
filter(None, [d.get_default_import for d in entity.instance_properties])]
|
||||
|
||||
# Parsing utils import
|
||||
parsing_ext_import = ["import 'package:divkit/src/utils/parsing_utils.dart';"]
|
||||
parsing_ext_import = ["import 'package:divkit/src/utils/parsing.dart';"]
|
||||
|
||||
# Imports section declaration
|
||||
if entity.is_main_declaration:
|
||||
@@ -153,10 +153,11 @@ class DartGenerator(Generator):
|
||||
result += ' try {'
|
||||
result += f' return {full_name}('
|
||||
for prop in entity.instance_properties:
|
||||
decode_strategy = prop.get_parse_strategy()
|
||||
decode_strategy = prop.get_decode_strategy()
|
||||
result += f" {utils.lower_camel_case(prop.name)}: {decode_strategy},"
|
||||
result += ' );'
|
||||
result += ' } catch (e, st) {'
|
||||
result += ' logger.warning("Parsing error", error: e, stackTrace: st);'
|
||||
result += ' return null;'
|
||||
result += ' }'
|
||||
result += ' }'
|
||||
@@ -198,7 +199,7 @@ class DartGenerator(Generator):
|
||||
# Equatable util import
|
||||
result += "import 'package:equatable/equatable.dart';\n"
|
||||
# Parsing utils import
|
||||
result += "import 'package:divkit/src/utils/parsing_utils.dart';"
|
||||
result += "import 'package:divkit/src/utils/parsing.dart';"
|
||||
result += EMPTY
|
||||
|
||||
full_name = get_full_name(entity_enumeration)
|
||||
@@ -281,9 +282,9 @@ class DartGenerator(Generator):
|
||||
for (i, n) in enumerate(sorted(entity_enumeration.entity_names)):
|
||||
result += f' case {utils.capitalize_camel_case(n)}.type :\n' \
|
||||
f' return {full_name}.{utils.lower_camel_case(n)}({utils.capitalize_camel_case(n)}.fromJson(json)!,);'
|
||||
result += ' }'
|
||||
result += ' }'
|
||||
result += ' return null;'
|
||||
result += ' } catch (e, st) {'
|
||||
result += ' } catch (_) {'
|
||||
result += ' return null;'
|
||||
result += ' }'
|
||||
result += ' }'
|
||||
@@ -300,7 +301,7 @@ class DartGenerator(Generator):
|
||||
|
||||
if string_enumeration.parent is None:
|
||||
# Parsing utils import
|
||||
result += "import 'package:divkit/src/utils/parsing_utils.dart';"
|
||||
result += "import 'package:divkit/src/utils/parsing.dart';"
|
||||
result += EMPTY
|
||||
|
||||
full_name = get_full_name(string_enumeration)
|
||||
@@ -362,6 +363,7 @@ class DartGenerator(Generator):
|
||||
result += ' }'
|
||||
result += ' return null;'
|
||||
result += ' } catch (e, st) {'
|
||||
result += f' logger.warning("Invalid type of {full_name}: $json", error: e, stackTrace: st,);'
|
||||
result += ' return null;'
|
||||
result += ' }'
|
||||
result += ' }'
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
import 'entity_with_array.dart';
|
||||
import 'entity_with_array_of_enums.dart';
|
||||
@@ -376,9 +376,9 @@ class Entity extends Resolvable with EquatableMixin {
|
||||
return Entity.entityWithStringEnumPropertyWithDefaultValue(EntityWithStringEnumPropertyWithDefaultValue.fromJson(json)!,);
|
||||
case EntityWithoutProperties.type :
|
||||
return Entity.entityWithoutProperties(EntityWithoutProperties.fromJson(json)!,);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (e, st) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'entity.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithArray extends Resolvable with EquatableMixin {
|
||||
@@ -13,7 +13,7 @@ class EntityWithArray extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "entity_with_array";
|
||||
// at least 1 elements
|
||||
final List<Entity> array;
|
||||
final Arr<Entity> array;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -21,7 +21,7 @@ class EntityWithArray extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
EntityWithArray copyWith({
|
||||
List<Entity>? array,
|
||||
Arr<Entity>? array,
|
||||
}) => EntityWithArray(
|
||||
array: array ?? this.array,
|
||||
);
|
||||
@@ -32,15 +32,16 @@ class EntityWithArray extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithArray(
|
||||
array: safeParseObj(safeListMap(json['array'], (v) => safeParseObj(Entity.fromJson(v),)!,),)!,
|
||||
array: reqProp<Arr<Entity>>(safeParseObjects(json['array'],(v) => reqProp<Entity>(safeParseObject(v, parse: Entity.fromJson,),), ), name: 'array',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
EntityWithArray resolve(DivVariableContext context) {
|
||||
safeListResolve(array, (v) => v.resolve(context));
|
||||
tryResolveList(array, (v) => v.resolve(context));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithArrayOfEnums extends Resolvable with EquatableMixin {
|
||||
@@ -12,7 +12,7 @@ class EntityWithArrayOfEnums extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "entity_with_array_of_enums";
|
||||
// at least 1 elements
|
||||
final List<EntityWithArrayOfEnumsItem> items;
|
||||
final Arr<EntityWithArrayOfEnumsItem> items;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -20,7 +20,7 @@ class EntityWithArrayOfEnums extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
EntityWithArrayOfEnums copyWith({
|
||||
List<EntityWithArrayOfEnumsItem>? items,
|
||||
Arr<EntityWithArrayOfEnumsItem>? items,
|
||||
}) => EntityWithArrayOfEnums(
|
||||
items: items ?? this.items,
|
||||
);
|
||||
@@ -31,9 +31,10 @@ class EntityWithArrayOfEnums extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithArrayOfEnums(
|
||||
items: safeParseObj(safeListMap(json['items'], (v) => safeParseStrEnum(v, parse: EntityWithArrayOfEnumsItem.fromJson,)!,),)!,
|
||||
items: reqProp<Arr<EntityWithArrayOfEnumsItem>>(safeParseObjects(json['items'],(v) => reqProp<EntityWithArrayOfEnumsItem>(safeParseStrEnum(v, parse: EntityWithArrayOfEnumsItem.fromJson,),), ), name: 'items',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -94,6 +95,7 @@ enum EntityWithArrayOfEnumsItem implements Resolvable {
|
||||
}
|
||||
return null;
|
||||
} catch (e, st) {
|
||||
logger.warning("Invalid type of EntityWithArrayOfEnumsItem: $json", error: e, stackTrace: st,);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithArrayOfExpressions extends Resolvable with EquatableMixin {
|
||||
@@ -12,7 +12,7 @@ class EntityWithArrayOfExpressions extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "entity_with_array_of_expressions";
|
||||
// at least 1 elements
|
||||
final Expression<List<String>> items;
|
||||
final Expression<Arr<String>> items;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -20,7 +20,7 @@ class EntityWithArrayOfExpressions extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
EntityWithArrayOfExpressions copyWith({
|
||||
Expression<List<String>>? items,
|
||||
Expression<Arr<String>>? items,
|
||||
}) => EntityWithArrayOfExpressions(
|
||||
items: items ?? this.items,
|
||||
);
|
||||
@@ -31,9 +31,10 @@ class EntityWithArrayOfExpressions extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithArrayOfExpressions(
|
||||
items: safeParseObjExpr(safeListMap(json['items'], (v) => safeParseStr(v?.toString(),)!,),)!,
|
||||
items: reqVProp<Arr<String>>(safeParseObjectsExpr(json['items'],(v) => reqProp<String>(safeParseStr(v),), ), name: 'items',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'entity.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithArrayOfNestedItems extends Resolvable with EquatableMixin {
|
||||
@@ -13,7 +13,7 @@ class EntityWithArrayOfNestedItems extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "entity_with_array_of_nested_items";
|
||||
// at least 1 elements
|
||||
final List<EntityWithArrayOfNestedItemsItem> items;
|
||||
final Arr<EntityWithArrayOfNestedItemsItem> items;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -21,7 +21,7 @@ class EntityWithArrayOfNestedItems extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
EntityWithArrayOfNestedItems copyWith({
|
||||
List<EntityWithArrayOfNestedItemsItem>? items,
|
||||
Arr<EntityWithArrayOfNestedItemsItem>? items,
|
||||
}) => EntityWithArrayOfNestedItems(
|
||||
items: items ?? this.items,
|
||||
);
|
||||
@@ -32,9 +32,10 @@ class EntityWithArrayOfNestedItems extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithArrayOfNestedItems(
|
||||
items: safeParseObj(safeListMap(json['items'], (v) => safeParseObj(EntityWithArrayOfNestedItemsItem.fromJson(v),)!,),)!,
|
||||
items: reqProp<Arr<EntityWithArrayOfNestedItemsItem>>(safeParseObjects(json['items'],(v) => reqProp<EntityWithArrayOfNestedItemsItem>(safeParseObject(v, parse: EntityWithArrayOfNestedItemsItem.fromJson,),), ), name: 'items',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -74,10 +75,11 @@ class EntityWithArrayOfNestedItemsItem extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithArrayOfNestedItemsItem(
|
||||
entity: safeParseObj(Entity.fromJson(json['entity']),)!,
|
||||
property: safeParseStrExpr(json['property']?.toString(),)!,
|
||||
entity: reqProp<Entity>(safeParseObject(json['entity'], parse: Entity.fromJson,), name: 'entity',),
|
||||
property: reqVProp<String>(safeParseStrExpr(json['property'],), name: 'property',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithArrayWithTransform extends Resolvable with EquatableMixin {
|
||||
@@ -12,7 +12,7 @@ class EntityWithArrayWithTransform extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "entity_with_array_with_transform";
|
||||
// at least 1 elements
|
||||
final Expression<List<Color>> array;
|
||||
final Expression<Arr<Color>> array;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -20,7 +20,7 @@ class EntityWithArrayWithTransform extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
EntityWithArrayWithTransform copyWith({
|
||||
Expression<List<Color>>? array,
|
||||
Expression<Arr<Color>>? array,
|
||||
}) => EntityWithArrayWithTransform(
|
||||
array: array ?? this.array,
|
||||
);
|
||||
@@ -31,9 +31,10 @@ class EntityWithArrayWithTransform extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithArrayWithTransform(
|
||||
array: safeParseObjExpr(safeListMap(json['array'], (v) => safeParseColor(v,)!,),)!,
|
||||
array: reqVProp<Arr<Color>>(safeParseObjectsExpr(json['array'],(v) => reqProp<Color>(safeParseColor(v),), ), name: 'array',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithComplexProperty extends Resolvable with EquatableMixin {
|
||||
@@ -30,9 +30,10 @@ class EntityWithComplexProperty extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithComplexProperty(
|
||||
property: safeParseObj(EntityWithComplexPropertyProperty.fromJson(json['property']),)!,
|
||||
property: reqProp<EntityWithComplexPropertyProperty>(safeParseObject(json['property'], parse: EntityWithComplexPropertyProperty.fromJson,), name: 'property',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -68,9 +69,10 @@ class EntityWithComplexPropertyProperty extends Resolvable with EquatableMixin
|
||||
}
|
||||
try {
|
||||
return EntityWithComplexPropertyProperty(
|
||||
value: safeParseUriExpr(json['value'])!,
|
||||
value: reqVProp<Uri>(safeParseUriExpr(json['value'],), name: 'value',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithComplexPropertyWithDefaultValue extends Resolvable with EquatableMixin {
|
||||
@@ -31,9 +31,10 @@ class EntityWithComplexPropertyWithDefaultValue extends Resolvable with Equatabl
|
||||
}
|
||||
try {
|
||||
return EntityWithComplexPropertyWithDefaultValue(
|
||||
property: safeParseObj(EntityWithComplexPropertyWithDefaultValueProperty.fromJson(json['property']), fallback: const EntityWithComplexPropertyWithDefaultValueProperty(value: ValueExpression("Default text",),),)!,
|
||||
property: reqProp<EntityWithComplexPropertyWithDefaultValueProperty>(safeParseObject(json['property'], parse: EntityWithComplexPropertyWithDefaultValueProperty.fromJson, fallback: const EntityWithComplexPropertyWithDefaultValueProperty(value: ValueExpression("Default text",),),), name: 'property',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -69,9 +70,10 @@ class EntityWithComplexPropertyWithDefaultValueProperty extends Resolvable with
|
||||
}
|
||||
try {
|
||||
return EntityWithComplexPropertyWithDefaultValueProperty(
|
||||
value: safeParseStrExpr(json['value']?.toString(),)!,
|
||||
value: reqVProp<String>(safeParseStrExpr(json['value'],), name: 'value',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'entity.dart';
|
||||
import 'entity_with_string_enum_property.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithEntityProperty extends Resolvable with EquatableMixin {
|
||||
@@ -33,9 +33,10 @@ class EntityWithEntityProperty extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithEntityProperty(
|
||||
entity: safeParseObj(Entity.fromJson(json['entity']), fallback: const Entity.entityWithStringEnumProperty(const EntityWithStringEnumProperty(property: ValueExpression(EntityWithStringEnumPropertyProperty.second,),),),)!,
|
||||
entity: reqProp<Entity>(safeParseObject(json['entity'], parse: Entity.fromJson, fallback: const Entity.entityWithStringEnumProperty(const EntityWithStringEnumProperty(property: ValueExpression(EntityWithStringEnumPropertyProperty.second,),),),), name: 'entity',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithJsonProperty extends Resolvable with EquatableMixin {
|
||||
@@ -12,7 +12,7 @@ class EntityWithJsonProperty extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "entity_with_json_property";
|
||||
// default value: None
|
||||
final Map<String, dynamic> jsonProperty;
|
||||
final Obj jsonProperty;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -20,7 +20,7 @@ class EntityWithJsonProperty extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
EntityWithJsonProperty copyWith({
|
||||
Map<String, dynamic>? jsonProperty,
|
||||
Obj? jsonProperty,
|
||||
}) => EntityWithJsonProperty(
|
||||
jsonProperty: jsonProperty ?? this.jsonProperty,
|
||||
);
|
||||
@@ -31,9 +31,10 @@ class EntityWithJsonProperty extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithJsonProperty(
|
||||
jsonProperty: safeParseMap(json['json_property'], fallback: None,)!,
|
||||
jsonProperty: reqProp<Obj>(safeParseMap(json['json_property'], fallback: None,), name: 'json_property',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithOptionalComplexProperty extends Resolvable with EquatableMixin {
|
||||
@@ -30,9 +30,10 @@ class EntityWithOptionalComplexProperty extends Resolvable with EquatableMixin
|
||||
}
|
||||
try {
|
||||
return EntityWithOptionalComplexProperty(
|
||||
property: safeParseObj(EntityWithOptionalComplexPropertyProperty.fromJson(json['property']),),
|
||||
property: safeParseObject(json['property'], parse: EntityWithOptionalComplexPropertyProperty.fromJson,),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -68,9 +69,10 @@ class EntityWithOptionalComplexPropertyProperty extends Resolvable with Equatabl
|
||||
}
|
||||
try {
|
||||
return EntityWithOptionalComplexPropertyProperty(
|
||||
value: safeParseUriExpr(json['value'])!,
|
||||
value: reqVProp<Uri>(safeParseUriExpr(json['value'],), name: 'value',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithOptionalProperty extends Resolvable with EquatableMixin {
|
||||
@@ -30,9 +30,10 @@ class EntityWithOptionalProperty extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithOptionalProperty(
|
||||
property: safeParseStrExpr(json['property']?.toString(),),
|
||||
property: safeParseStrExpr(json['property'],),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithOptionalStringEnumProperty extends Resolvable with EquatableMixin {
|
||||
@@ -33,6 +33,7 @@ class EntityWithOptionalStringEnumProperty extends Resolvable with EquatableMixi
|
||||
property: safeParseStrEnumExpr(json['property'], parse: EntityWithOptionalStringEnumPropertyProperty.fromJson,),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -94,6 +95,7 @@ enum EntityWithOptionalStringEnumPropertyProperty implements Resolvable {
|
||||
}
|
||||
return null;
|
||||
} catch (e, st) {
|
||||
logger.warning("Invalid type of EntityWithOptionalStringEnumPropertyProperty: $json", error: e, stackTrace: st,);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithPropertyWithDefaultValue extends Resolvable with EquatableMixin {
|
||||
@@ -43,11 +43,12 @@ class EntityWithPropertyWithDefaultValue extends Resolvable with EquatableMixin
|
||||
}
|
||||
try {
|
||||
return EntityWithPropertyWithDefaultValue(
|
||||
iNum: safeParseIntExpr(json['iNum'], fallback: 0,)!,
|
||||
nested: safeParseObj(EntityWithPropertyWithDefaultValueNested.fromJson(json['nested']),),
|
||||
url: safeParseUriExpr(json['url'])!,
|
||||
iNum: reqVProp<int>(safeParseIntExpr(json['iNum'], fallback: 0,), name: 'iNum',),
|
||||
nested: safeParseObject(json['nested'], parse: EntityWithPropertyWithDefaultValueNested.fromJson,),
|
||||
url: reqVProp<Uri>(safeParseUriExpr(json['url'], fallback: const Uri.parse("https://yandex.ru"),), name: 'url',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -97,11 +98,12 @@ class EntityWithPropertyWithDefaultValueNested extends Resolvable with Equatable
|
||||
}
|
||||
try {
|
||||
return EntityWithPropertyWithDefaultValueNested(
|
||||
iNum: safeParseIntExpr(json['iNum'], fallback: 0,)!,
|
||||
nonOptional: safeParseStrExpr(json['non_optional']?.toString(),)!,
|
||||
url: safeParseUriExpr(json['url'])!,
|
||||
iNum: reqVProp<int>(safeParseIntExpr(json['iNum'], fallback: 0,), name: 'iNum',),
|
||||
nonOptional: reqVProp<String>(safeParseStrExpr(json['non_optional'],), name: 'non_optional',),
|
||||
url: reqVProp<Uri>(safeParseUriExpr(json['url'], fallback: const Uri.parse("https://yandex.ru"),), name: 'url',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithRawArray extends Resolvable with EquatableMixin {
|
||||
@@ -11,7 +11,7 @@ class EntityWithRawArray extends Resolvable with EquatableMixin {
|
||||
});
|
||||
|
||||
static const type = "entity_with_raw_array";
|
||||
final Expression<List<dynamic>> array;
|
||||
final Expression<Arr> array;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -19,7 +19,7 @@ class EntityWithRawArray extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
EntityWithRawArray copyWith({
|
||||
Expression<List<dynamic>>? array,
|
||||
Expression<Arr>? array,
|
||||
}) => EntityWithRawArray(
|
||||
array: array ?? this.array,
|
||||
);
|
||||
@@ -30,9 +30,10 @@ class EntityWithRawArray extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithRawArray(
|
||||
array: safeParseListExpr(json['array'],)!,
|
||||
array: reqVProp<Arr>(safeParseListExpr(json['array'],), name: 'array',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithRequiredProperty extends Resolvable with EquatableMixin {
|
||||
@@ -31,9 +31,10 @@ class EntityWithRequiredProperty extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithRequiredProperty(
|
||||
property: safeParseStrExpr(json['property']?.toString(),)!,
|
||||
property: reqVProp<String>(safeParseStrExpr(json['property'],), name: 'property',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
/// Entity with simple properties.
|
||||
class EntityWithSimpleProperties extends Resolvable with EquatableMixin {
|
||||
@@ -85,13 +85,14 @@ class EntityWithSimpleProperties extends Resolvable with EquatableMixin {
|
||||
booleanInt: safeParseBoolExpr(json['boolean_int'],),
|
||||
color: safeParseColorExpr(json['color'],),
|
||||
dNum: safeParseDoubleExpr(json['dNum'],),
|
||||
id: safeParseInt(json['id'], fallback: 0,)!,
|
||||
integer: safeParseIntExpr(json['integer'], fallback: 0,)!,
|
||||
id: reqProp<int>(safeParseInt(json['id'], fallback: 0,), name: 'id',),
|
||||
integer: reqVProp<int>(safeParseIntExpr(json['integer'], fallback: 0,), name: 'integer',),
|
||||
positiveInteger: safeParseIntExpr(json['positive_integer'],),
|
||||
string: safeParseStrExpr(json['string']?.toString(),),
|
||||
url: safeParseUriExpr(json['url']),
|
||||
string: safeParseStrExpr(json['string'],),
|
||||
url: safeParseUriExpr(json['url'],),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithStringArrayProperty extends Resolvable with EquatableMixin {
|
||||
@@ -12,7 +12,7 @@ class EntityWithStringArrayProperty extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "entity_with_string_array_property";
|
||||
// at least 1 elements
|
||||
final Expression<List<String>> array;
|
||||
final Expression<Arr<String>> array;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -20,7 +20,7 @@ class EntityWithStringArrayProperty extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
EntityWithStringArrayProperty copyWith({
|
||||
Expression<List<String>>? array,
|
||||
Expression<Arr<String>>? array,
|
||||
}) => EntityWithStringArrayProperty(
|
||||
array: array ?? this.array,
|
||||
);
|
||||
@@ -31,9 +31,10 @@ class EntityWithStringArrayProperty extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithStringArrayProperty(
|
||||
array: safeParseObjExpr(safeListMap(json['array'], (v) => safeParseStr(v?.toString(),)!,),)!,
|
||||
array: reqVProp<Arr<String>>(safeParseObjectsExpr(json['array'],(v) => reqProp<String>(safeParseStr(v),), ), name: 'array',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithStringEnumProperty extends Resolvable with EquatableMixin {
|
||||
@@ -30,9 +30,10 @@ class EntityWithStringEnumProperty extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return EntityWithStringEnumProperty(
|
||||
property: safeParseStrEnumExpr(json['property'], parse: EntityWithStringEnumPropertyProperty.fromJson,)!,
|
||||
property: reqVProp<EntityWithStringEnumPropertyProperty>(safeParseStrEnumExpr(json['property'], parse: EntityWithStringEnumPropertyProperty.fromJson,), name: 'property',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -94,6 +95,7 @@ enum EntityWithStringEnumPropertyProperty implements Resolvable {
|
||||
}
|
||||
return null;
|
||||
} catch (e, st) {
|
||||
logger.warning("Invalid type of EntityWithStringEnumPropertyProperty: $json", error: e, stackTrace: st,);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithStringEnumPropertyWithDefaultValue extends Resolvable with EquatableMixin {
|
||||
@@ -31,9 +31,10 @@ class EntityWithStringEnumPropertyWithDefaultValue extends Resolvable with Equat
|
||||
}
|
||||
try {
|
||||
return EntityWithStringEnumPropertyWithDefaultValue(
|
||||
value: safeParseStrEnumExpr(json['value'], parse: EntityWithStringEnumPropertyWithDefaultValueValue.fromJson, fallback: EntityWithStringEnumPropertyWithDefaultValueValue.second,)!,
|
||||
value: reqVProp<EntityWithStringEnumPropertyWithDefaultValueValue>(safeParseStrEnumExpr(json['value'], parse: EntityWithStringEnumPropertyWithDefaultValueValue.fromJson, fallback: EntityWithStringEnumPropertyWithDefaultValueValue.second,), name: 'value',),
|
||||
);
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -106,6 +107,7 @@ enum EntityWithStringEnumPropertyWithDefaultValueValue implements Resolvable {
|
||||
}
|
||||
return null;
|
||||
} catch (e, st) {
|
||||
logger.warning("Invalid type of EntityWithStringEnumPropertyWithDefaultValueValue: $json", error: e, stackTrace: st,);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class EntityWithoutProperties extends Resolvable with EquatableMixin {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
import 'with_default.dart';
|
||||
import 'without_default.dart';
|
||||
@@ -70,9 +70,9 @@ class EnumWithDefaultType extends Resolvable with EquatableMixin {
|
||||
return EnumWithDefaultType.withDefault(WithDefault.fromJson(json)!,);
|
||||
case WithoutDefault.type :
|
||||
return EnumWithDefaultType.withoutDefault(WithoutDefault.fromJson(json)!,);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (e, st) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class WithDefault extends Resolvable with EquatableMixin {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
|
||||
class WithoutDefault extends Resolvable with EquatableMixin {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
## 0.6.0-rc.2
|
||||
## 0.6.0-rc.3
|
||||
|
||||
* Update generated schema
|
||||
* Support nullable end in div-ranges and cloud background fallback
|
||||
@@ -8,15 +8,20 @@
|
||||
* Rewrite context initialization mechanism to synchronous
|
||||
* Rewrite conversion mechanism, simplify and standardize
|
||||
* Rewrite expression analyzer to synchronous
|
||||
* Rewrite parsing to improve error handling
|
||||
* Fix the missing valid state error
|
||||
* Fix unsafe map of backgrounds
|
||||
|
||||
|
||||
## Migration 0.5.0 → 0.6.0
|
||||
* Remove DivData `preload` and `parse` methods for simplification
|
||||
* Remove DivKitView property `cacheManager` as unsupported to the proper extent
|
||||
* Remove DivKitView property `loadingBuilder` as unused
|
||||
* Replace DivKitView props `viewScale` and `textScale` to `scale`
|
||||
* Remove DivData `preload` and `parse` methods for simplification
|
||||
* Change `safeParseObj` to `safeParseObject`
|
||||
* Change `safeListMap` to `safeParseObjects`
|
||||
* Change `prop.resolve(context: context)` to `prop.resolve(context)`
|
||||
* DTO models use the generated resolve instead of extension
|
||||
* Change prop.resolve(context: context) to prop.resolve(context)
|
||||
* Now are required to perform the conversion DTO to DivModel
|
||||
* Due to architecture changes and conversion mechanism changes, you need to migrate your codebase
|
||||
|
||||
|
||||
@@ -46,18 +46,16 @@ flutter:
|
||||
- assets/regression/accessibility/
|
||||
- assets/regression/accessibility/mode/
|
||||
- assets/regression/action_animation/
|
||||
- assets/regression/actions/
|
||||
- assets/regression/animations/
|
||||
- assets/regression/animations/animators/
|
||||
- assets/regression/animations/lottie/
|
||||
- assets/regression/animations/transition/
|
||||
- assets/regression/animations/rive/
|
||||
- assets/regression/animations/transition/
|
||||
- assets/regression/container/
|
||||
- assets/regression/gallery/
|
||||
- assets/regression/indicator/
|
||||
- assets/regression/pager/
|
||||
- assets/regression/variables/
|
||||
- assets/regression/video/
|
||||
- assets/regression/actions/
|
||||
- assets/regression/container/
|
||||
- assets/regression/patch/
|
||||
- assets/regression/rebind/
|
||||
- assets/regression/rebind/container/
|
||||
@@ -68,6 +66,9 @@ flutter:
|
||||
- assets/regression/rebind/tabs/
|
||||
- assets/regression/state/
|
||||
- assets/regression/timers/
|
||||
- assets/regression/tooltips/
|
||||
- assets/regression/variables/
|
||||
- assets/regression/video/
|
||||
- assets/regression/visibility_actions/
|
||||
- assets/perf/
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ export 'src/core/action/handler/action_handler.dart';
|
||||
export 'src/core/data/data.dart';
|
||||
export 'src/core/divkit.dart';
|
||||
export 'src/core/expression/expression.dart';
|
||||
export 'src/core/expression/parse.dart';
|
||||
export 'src/core/expression/resolver.dart';
|
||||
export 'src/core/patch/patch.dart';
|
||||
export 'src/core/protocol/protocol.dart';
|
||||
@@ -14,9 +15,9 @@ export 'src/core/state/state.dart';
|
||||
export 'src/core/template/resolver.dart';
|
||||
export 'src/core/timer/timer.dart';
|
||||
export 'src/core/trigger/trigger.dart';
|
||||
export 'src/core/types.dart';
|
||||
export 'src/core/variable/variable.dart';
|
||||
export 'src/core/variable/variable_storage.dart';
|
||||
export 'src/core/visibility/visibility.dart';
|
||||
export 'src/core/widgets/widgets.dart';
|
||||
export 'src/schema/schema.dart';
|
||||
export 'src/utils/parsing_utils.dart';
|
||||
|
||||
+71
-295
@@ -1,11 +1,8 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:divkit/divkit.dart';
|
||||
|
||||
export 'dart:ui' show Color;
|
||||
|
||||
export 'package:divkit/src/core/expression/expression.dart';
|
||||
export 'package:divkit/src/core/variable/variable_context.dart';
|
||||
import 'package:divkit/src/core/expression/expression.dart';
|
||||
import 'package:divkit/src/core/protocol/div_logger.dart';
|
||||
import 'package:divkit/src/core/types.dart';
|
||||
|
||||
dynamic Function(dynamic source) safeParseNamed(String? name) {
|
||||
switch (name) {
|
||||
@@ -25,10 +22,8 @@ dynamic Function(dynamic source) safeParseNamed(String? name) {
|
||||
return safeParseList;
|
||||
case 'dict':
|
||||
return safeParseMap;
|
||||
case 'error':
|
||||
return safeParseStr;
|
||||
default:
|
||||
return safeParseObj;
|
||||
return safeParseMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,94 +41,56 @@ dynamic safeParseTyped(Type type) {
|
||||
return safeParseColor;
|
||||
case Uri:
|
||||
return safeParseUri;
|
||||
case List:
|
||||
case List<dynamic>:
|
||||
return safeParseList;
|
||||
case Map<String, dynamic>:
|
||||
return safeParseMap;
|
||||
default:
|
||||
return safeParseObj;
|
||||
return safeParseMap;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> safeFuturesWait(
|
||||
dynamic list,
|
||||
Function(dynamic) waiter,
|
||||
) async {
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (list is List<dynamic>) {
|
||||
for (final l in list) {
|
||||
List<T>? safeParseObjects<T>(
|
||||
Object? source,
|
||||
T Function(dynamic) mapper, {
|
||||
List<T>? fallback,
|
||||
}) {
|
||||
if (source is List) {
|
||||
final result = <T>[];
|
||||
for (final l in source) {
|
||||
try {
|
||||
await waiter(l);
|
||||
final res = mapper(l);
|
||||
result.add(res);
|
||||
} catch (e, st) {
|
||||
logger.warning("Not wait on $l", error: e, stackTrace: st);
|
||||
logger.warning("Error: ", error: e, stackTrace: st);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
void safeListResolve(
|
||||
dynamic list,
|
||||
Function(dynamic) resolve,
|
||||
) async {
|
||||
if (list == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (list is List<dynamic>) {
|
||||
for (final l in list) {
|
||||
try {
|
||||
resolve(l);
|
||||
} catch (e, st) {
|
||||
logger.warning("Not resolve $l", error: e, stackTrace: st);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<T>?> safeListMapAsync<T>(
|
||||
dynamic list,
|
||||
T Function(dynamic) mapper,
|
||||
) async =>
|
||||
safeListMap(
|
||||
list,
|
||||
mapper,
|
||||
);
|
||||
|
||||
List<T>? safeListMap<T>(
|
||||
dynamic list,
|
||||
T Function(dynamic) mapper,
|
||||
) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final result = <T>[];
|
||||
if (list is List<dynamic>) {
|
||||
for (final l in list) {
|
||||
try {
|
||||
result.add(mapper(l));
|
||||
} catch (e, st) {
|
||||
logger.warning("Error in ${l['type']}", error: e, stackTrace: st);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<T?> safeParseStrEnumAsync<T>(
|
||||
String? source, {
|
||||
T? Function(String? source)? parse,
|
||||
T? fallback,
|
||||
}) async =>
|
||||
safeParseStrEnum(
|
||||
Expression<List<T>>? safeParseObjectsExpr<T>(
|
||||
Object? source,
|
||||
T Function(dynamic) mapper, {
|
||||
List<T>? fallback,
|
||||
}) {
|
||||
if (source is String && source.contains("@{")) {
|
||||
return ResolvableExpression(
|
||||
source,
|
||||
parse: parse,
|
||||
parse: (obj) => safeParseObjects(obj, mapper),
|
||||
fallback: fallback,
|
||||
);
|
||||
}
|
||||
|
||||
final value = safeParseObjects(source, mapper);
|
||||
if (value != null) {
|
||||
return ValueExpression(value);
|
||||
}
|
||||
|
||||
return fallback != null ? ValueExpression(fallback) : null;
|
||||
}
|
||||
|
||||
T? safeParseStrEnum<T>(
|
||||
String? source, {
|
||||
@@ -142,17 +99,6 @@ T? safeParseStrEnum<T>(
|
||||
}) =>
|
||||
parse?.call(source) ?? fallback;
|
||||
|
||||
Future<Expression<T>?> safeParseStrEnumExprAsync<T>(
|
||||
String? source, {
|
||||
T? Function(String? source)? parse,
|
||||
T? fallback,
|
||||
}) async =>
|
||||
safeParseStrEnumExpr(
|
||||
source,
|
||||
parse: parse,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
Expression<T>? safeParseStrEnumExpr<T>(
|
||||
String? source, {
|
||||
T? Function(String? source)? parse,
|
||||
@@ -161,27 +107,38 @@ Expression<T>? safeParseStrEnumExpr<T>(
|
||||
final value = parse?.call(source);
|
||||
if (value != null) {
|
||||
return ValueExpression(value);
|
||||
}
|
||||
|
||||
if (source?.contains("@{") ?? false) {
|
||||
} else if (source?.contains("@{") ?? false) {
|
||||
return ResolvableExpression(
|
||||
source,
|
||||
parse: (obj) => parse?.call(obj.toString()),
|
||||
fallback: fallback,
|
||||
);
|
||||
}
|
||||
|
||||
return fallback != null ? ValueExpression(fallback) : null;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>?> safeParseMapAsync(
|
||||
Object? source, {
|
||||
Map<String, dynamic>? fallback,
|
||||
}) async =>
|
||||
safeParseMap(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
T? safeParseObject<T>(
|
||||
Obj? source, {
|
||||
T? Function(Obj? source)? parse,
|
||||
T? fallback,
|
||||
}) =>
|
||||
parse?.call(source) ?? fallback;
|
||||
|
||||
Expression<T>? safeParseObjectExpr<T>(
|
||||
Obj? source, {
|
||||
T? Function(Obj? source)? parse,
|
||||
T? fallback,
|
||||
}) {
|
||||
final value = parse?.call(source);
|
||||
if (value != null) {
|
||||
return ValueExpression(value);
|
||||
} else {
|
||||
if (fallback != null) {
|
||||
return ValueExpression(fallback);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String, dynamic>? safeParseMap(
|
||||
Object? source, {
|
||||
@@ -189,24 +146,15 @@ Map<String, dynamic>? safeParseMap(
|
||||
}) {
|
||||
if (source is Map<String, dynamic>) {
|
||||
return source;
|
||||
}
|
||||
|
||||
if (source is String) {
|
||||
} else if (source is String) {
|
||||
final map = jsonDecode(source);
|
||||
if (map is Map<String, dynamic>) {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
Future<Expression<Map<String, dynamic>>?> safeParseMapExprAsync(
|
||||
Object? source, {
|
||||
Object? fallback,
|
||||
}) async =>
|
||||
safeParseMapExpr(source, fallback: fallback);
|
||||
|
||||
Expression<Map<String, dynamic>>? safeParseMapExpr(
|
||||
Object? source, {
|
||||
Object? fallback,
|
||||
@@ -222,46 +170,24 @@ Expression<Map<String, dynamic>>? safeParseMapExpr(
|
||||
return ValueExpression(map);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<List?> safeParseListAsync(
|
||||
Object? source, {
|
||||
List? fallback,
|
||||
}) async =>
|
||||
safeParseList(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
List? safeParseList(
|
||||
Object? source, {
|
||||
List? fallback,
|
||||
}) {
|
||||
if (source is List) {
|
||||
return source;
|
||||
}
|
||||
|
||||
if (source is String) {
|
||||
} else if (source is String) {
|
||||
final list = jsonDecode(source);
|
||||
if (list is List) {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
Future<Expression<List>?> safeParseListExprAsync(
|
||||
Object? source, {
|
||||
Object? fallback,
|
||||
}) async =>
|
||||
safeParseListExpr(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
Expression<List>? safeParseListExpr(
|
||||
Object? source, {
|
||||
Object? fallback,
|
||||
@@ -279,75 +205,17 @@ Expression<List>? safeParseListExpr(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<T?> safeParseObjAsync<T>(
|
||||
T? source, {
|
||||
T? fallback,
|
||||
}) async =>
|
||||
safeParseObj(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
T? safeParseObj<T>(
|
||||
T? source, {
|
||||
T? fallback,
|
||||
}) =>
|
||||
source ?? fallback;
|
||||
|
||||
Future<Expression<T>?> safeParseObjExprAsync<T>(
|
||||
T? source, {
|
||||
T? fallback,
|
||||
}) async =>
|
||||
safeParseObjExpr(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
Expression<T>? safeParseObjExpr<T>(
|
||||
T? source, {
|
||||
T? fallback,
|
||||
}) {
|
||||
if (source != null) {
|
||||
return ValueExpression(source);
|
||||
} else {
|
||||
if (fallback != null) {
|
||||
return ValueExpression(fallback);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<String?> safeParseStrAsync(
|
||||
Object? source, {
|
||||
String? fallback,
|
||||
}) async =>
|
||||
safeParseStr(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
String? safeParseStr(
|
||||
Object? source, {
|
||||
String? fallback,
|
||||
}) =>
|
||||
source?.toString() ?? fallback;
|
||||
|
||||
Future<Expression<String>?> safeParseStrExprAsync(
|
||||
String? source, {
|
||||
String? fallback,
|
||||
}) async =>
|
||||
safeParseStrExpr(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
Expression<String>? safeParseStrExpr(
|
||||
String? source, {
|
||||
Object? source, {
|
||||
String? fallback,
|
||||
}) {
|
||||
if (source is String && source.contains("@{")) {
|
||||
@@ -360,25 +228,16 @@ Expression<String>? safeParseStrExpr(
|
||||
|
||||
final value = source;
|
||||
if (value != null) {
|
||||
return ValueExpression(value);
|
||||
return ValueExpression(value.toString());
|
||||
}
|
||||
|
||||
return fallback != null ? ValueExpression(fallback) : null;
|
||||
}
|
||||
|
||||
Future<Color?> safeParseColorAsync(
|
||||
Object? source,
|
||||
) async =>
|
||||
safeParseColor(
|
||||
source,
|
||||
);
|
||||
|
||||
Color? safeParseColor(Object? source) {
|
||||
if (source is Color) {
|
||||
return source;
|
||||
}
|
||||
|
||||
if (source is String) {
|
||||
} else if (source is String) {
|
||||
final colorValue = source.substring(1).toUpperCase();
|
||||
String? colorArgbHex;
|
||||
if (colorValue.length == 3) {
|
||||
@@ -412,15 +271,6 @@ Color? safeParseColor(Object? source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<Expression<Color>?> safeParseColorExprAsync(
|
||||
Object? source, {
|
||||
Color? fallback,
|
||||
}) async =>
|
||||
safeParseColorExpr(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
Expression<Color>? safeParseColorExpr(
|
||||
Object? source, {
|
||||
Color? fallback,
|
||||
@@ -441,13 +291,6 @@ Expression<Color>? safeParseColorExpr(
|
||||
return fallback != null ? ValueExpression(fallback) : null;
|
||||
}
|
||||
|
||||
Future<int?> safeParseIntAsync(
|
||||
Object? source,
|
||||
) async =>
|
||||
safeParseInt(
|
||||
source,
|
||||
);
|
||||
|
||||
int? safeParseInt(Object? source) {
|
||||
if (source is int) {
|
||||
return source;
|
||||
@@ -459,15 +302,6 @@ int? safeParseInt(Object? source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<Expression<int>?> safeParseIntExprAsync(
|
||||
Object? source, {
|
||||
int? fallback,
|
||||
}) async =>
|
||||
safeParseIntExpr(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
Expression<int>? safeParseIntExpr(
|
||||
Object? source, {
|
||||
int? fallback,
|
||||
@@ -488,35 +322,17 @@ Expression<int>? safeParseIntExpr(
|
||||
return fallback != null ? ValueExpression(fallback) : null;
|
||||
}
|
||||
|
||||
Future<double?> safeParseDoubleAsync(
|
||||
Object? source,
|
||||
) async =>
|
||||
safeParseDouble(
|
||||
source,
|
||||
);
|
||||
|
||||
double? safeParseDouble(Object? source) {
|
||||
if (source is double) {
|
||||
return source;
|
||||
}
|
||||
if (source is int) {
|
||||
} else if (source is int) {
|
||||
return source.toDouble();
|
||||
}
|
||||
if (source is String) {
|
||||
} else if (source is String) {
|
||||
return double.tryParse(source);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<Expression<double>?> safeParseDoubleExprAsync(
|
||||
Object? source, {
|
||||
double? fallback,
|
||||
}) async =>
|
||||
safeParseDoubleExpr(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
Expression<double>? safeParseDoubleExpr(
|
||||
Object? source, {
|
||||
double? fallback,
|
||||
@@ -537,19 +353,10 @@ Expression<double>? safeParseDoubleExpr(
|
||||
return fallback != null ? ValueExpression(fallback) : null;
|
||||
}
|
||||
|
||||
Future<Uri?> safeParseUriAsync(
|
||||
Object? source,
|
||||
) async =>
|
||||
safeParseUri(
|
||||
source,
|
||||
);
|
||||
|
||||
Uri? safeParseUri(Object? source) {
|
||||
if (source is Uri) {
|
||||
return source;
|
||||
}
|
||||
|
||||
if (source is String) {
|
||||
} else if (source is String) {
|
||||
// The implementation of the parser replaces '+' with a ' ',
|
||||
// which is incorrect. Needs to replace the symbol in advance.
|
||||
return Uri.tryParse(source.replaceAll('+', '%2B'));
|
||||
@@ -558,15 +365,6 @@ Uri? safeParseUri(Object? source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<Expression<Uri>?> safeParseUriExprAsync(
|
||||
Object? source, {
|
||||
Uri? fallback,
|
||||
}) async =>
|
||||
safeParseUriExpr(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
Expression<Uri>? safeParseUriExpr(
|
||||
Object? source, {
|
||||
Uri? fallback,
|
||||
@@ -587,36 +385,23 @@ Expression<Uri>? safeParseUriExpr(
|
||||
return fallback != null ? ValueExpression(fallback) : null;
|
||||
}
|
||||
|
||||
Future<bool?> safeParseBoolAsync(
|
||||
Object? source,
|
||||
) async =>
|
||||
safeParseBool(
|
||||
source,
|
||||
);
|
||||
|
||||
bool? safeParseBool(Object? source) {
|
||||
if (source is bool) {
|
||||
return source;
|
||||
}
|
||||
|
||||
if (source is int) {
|
||||
} else if (source is int) {
|
||||
switch (source) {
|
||||
case 1:
|
||||
return true;
|
||||
case 0:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (source is double) {
|
||||
} else if (source is double) {
|
||||
if (source == 1.0) {
|
||||
return true;
|
||||
} else if (source == 0.0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (source is String) {
|
||||
} else if (source is String) {
|
||||
switch (source.toLowerCase()) {
|
||||
case 'true':
|
||||
return true;
|
||||
@@ -638,15 +423,6 @@ bool? safeParseBool(Object? source) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<Expression<bool>?> safeParseBoolExprAsync(
|
||||
Object? source, {
|
||||
bool? fallback,
|
||||
}) async =>
|
||||
safeParseBoolExpr(
|
||||
source,
|
||||
fallback: fallback,
|
||||
);
|
||||
|
||||
Expression<bool>? safeParseBoolExpr(
|
||||
Object? source, {
|
||||
bool? fallback,
|
||||
@@ -3,8 +3,9 @@ import 'dart:ui';
|
||||
|
||||
import 'package:divkit/src/core/runtime/compatible/integer.dart';
|
||||
|
||||
typedef RuntimeFunction = Object Function(List);
|
||||
export 'package:divkit/src/core/types.dart';
|
||||
|
||||
typedef RuntimeFunction = Object Function(List);
|
||||
typedef RuntimeContextFunction = Object Function(List, Map<String, dynamic>);
|
||||
|
||||
bool equals(Object left, Object right) {
|
||||
@@ -252,15 +253,6 @@ T expectResult<T>({
|
||||
throw onThrow;
|
||||
}
|
||||
|
||||
/// Error handling with explicit fallback.
|
||||
T guard<T>(T Function() tst, T alt) {
|
||||
try {
|
||||
return tst();
|
||||
} catch (_) {
|
||||
return alt;
|
||||
}
|
||||
}
|
||||
|
||||
bool toBoolean(Object src) {
|
||||
if (src == 0 || src == 'false') {
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:divkit/src/core/runtime/core.dart';
|
||||
|
||||
const collectionFunctions = <String, RuntimeFunction>{
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:divkit/src/core/runtime/core.dart';
|
||||
|
||||
const colorFunctions = <String, RuntimeFunction>{
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:divkit/src/core/runtime/core.dart';
|
||||
|
||||
const legacyCollectionFunctions = <String, RuntimeFunction>{
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:divkit/src/core/runtime/core.dart';
|
||||
|
||||
const storageFunctions = <String, RuntimeContextFunction>{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
typedef Obj = Map<String, dynamic>;
|
||||
typedef Arr = List<dynamic>;
|
||||
import 'package:divkit/src/core/types.dart';
|
||||
|
||||
class _ReplaceResult {
|
||||
final Obj obj;
|
||||
|
||||
@@ -1,2 +1,13 @@
|
||||
export 'dart:ui' show Color;
|
||||
|
||||
typedef Obj<T> = Map<String, T>;
|
||||
typedef Arr<T> = List<T>;
|
||||
|
||||
/// Error handling with explicit fallback.
|
||||
T guard<T>(T Function() tst, T alt) {
|
||||
try {
|
||||
return tst();
|
||||
} catch (_) {
|
||||
return alt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:divkit/divkit.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class DivRootModel with EquatableMixin {
|
||||
final List<DivDataState> states;
|
||||
final String stateId;
|
||||
final String? stateId;
|
||||
|
||||
const DivRootModel({
|
||||
required this.states,
|
||||
required this.stateId,
|
||||
});
|
||||
|
||||
DivDataState get state => states.firstWhere(
|
||||
DivDataState? get state =>
|
||||
states.firstWhereOrNull(
|
||||
(element) => element.stateId.toString() == stateId,
|
||||
orElse: () => states.first,
|
||||
);
|
||||
) ??
|
||||
(states.isNotEmpty ? states.first : null);
|
||||
|
||||
String get path => stateId;
|
||||
String? get path => stateId;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -25,7 +27,7 @@ class DivRootModel with EquatableMixin {
|
||||
}
|
||||
|
||||
extension DivDataStateBinder on DivData {
|
||||
DivRootModel bind(String stateId) => DivRootModel(
|
||||
DivRootModel bind(String? stateId) => DivRootModel(
|
||||
stateId: stateId,
|
||||
states: states,
|
||||
);
|
||||
|
||||
@@ -59,7 +59,11 @@ class _DivRendererState extends State<DivRenderer> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
final divContext = read<DivContext>(context)!;
|
||||
final initialState = widget.data.states.first.stateId.toString();
|
||||
|
||||
final states = widget.data.states;
|
||||
final initialState =
|
||||
states.isNotEmpty ? states.first.stateId.toString() : null;
|
||||
|
||||
// Register first state
|
||||
divContext.stateManager.registerState('root', initialState);
|
||||
widget.data.resolve(divContext.variables);
|
||||
@@ -73,7 +77,7 @@ class _DivRendererState extends State<DivRenderer> {
|
||||
if (stream == null) {
|
||||
final divContext = watch<DivContext>(context)!;
|
||||
stream = divContext.stateManager.watch((state) {
|
||||
return widget.data.bind(state['root']!);
|
||||
return widget.data.bind(state['root']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -89,7 +93,7 @@ class _DivRendererState extends State<DivRenderer> {
|
||||
divContext.stateManager.updateState('root', initialState);
|
||||
value = widget.data.bind(initialState);
|
||||
stream = divContext.stateManager.watch((state) {
|
||||
return widget.data.bind(state['root']!);
|
||||
return widget.data.bind(state['root']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -100,12 +104,19 @@ class _DivRendererState extends State<DivRenderer> {
|
||||
stream: stream,
|
||||
builder: (context, snapshot) {
|
||||
final model = snapshot.requireData;
|
||||
|
||||
if (model.state?.div == null) {
|
||||
loggerUse(watch<DivContext>(context)?.loggerContext).error(
|
||||
'DivKitView is not drawn! Valid root state is missing',
|
||||
);
|
||||
}
|
||||
|
||||
return provide(
|
||||
DivStateId(model.path),
|
||||
child: DivWidget(
|
||||
// The unique identifier of the state subtree
|
||||
key: ValueKey(model.path),
|
||||
model.state.div,
|
||||
model.state?.div,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
class ArrayValue extends Resolvable with EquatableMixin {
|
||||
const ArrayValue({
|
||||
required this.value,
|
||||
});
|
||||
|
||||
static const type = "array";
|
||||
final Expression<List<dynamic>> value;
|
||||
final Expression<Arr> value;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -17,7 +18,7 @@ class ArrayValue extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
ArrayValue copyWith({
|
||||
Expression<List<dynamic>>? value,
|
||||
Expression<Arr>? value,
|
||||
}) =>
|
||||
ArrayValue(
|
||||
value: value ?? this.value,
|
||||
@@ -31,16 +32,19 @@ class ArrayValue extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return ArrayValue(
|
||||
value: safeParseListExpr(
|
||||
json['value'],
|
||||
)!,
|
||||
value: reqVProp<Arr>(
|
||||
safeParseListExpr(
|
||||
json['value'],
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
ArrayValue resolve(DivVariableContext context) {
|
||||
value.resolve(context);
|
||||
return this;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// An arbitrary array in JSON format.
|
||||
@@ -16,7 +16,7 @@ class ArrayVariable extends Resolvable with EquatableMixin {
|
||||
final String name;
|
||||
|
||||
/// Value.
|
||||
final List<dynamic> value;
|
||||
final Arr value;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -26,7 +26,7 @@ class ArrayVariable extends Resolvable with EquatableMixin {
|
||||
|
||||
ArrayVariable copyWith({
|
||||
String? name,
|
||||
List<dynamic>? value,
|
||||
Arr? value,
|
||||
}) =>
|
||||
ArrayVariable(
|
||||
name: name ?? this.name,
|
||||
@@ -41,14 +41,21 @@ class ArrayVariable extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return ArrayVariable(
|
||||
name: safeParseStr(
|
||||
json['name']?.toString(),
|
||||
)!,
|
||||
value: safeParseList(
|
||||
json['value'],
|
||||
)!,
|
||||
name: reqProp<String>(
|
||||
safeParseStr(
|
||||
json['name'],
|
||||
),
|
||||
name: 'name',
|
||||
),
|
||||
value: reqProp<Arr>(
|
||||
safeParseList(
|
||||
json['value'],
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class BooleanValue extends Resolvable with EquatableMixin {
|
||||
@@ -31,11 +31,15 @@ class BooleanValue extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return BooleanValue(
|
||||
value: safeParseBoolExpr(
|
||||
json['value'],
|
||||
)!,
|
||||
value: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['value'],
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// A Boolean variable in binary format.
|
||||
@@ -41,14 +41,21 @@ class BooleanVariable extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return BooleanVariable(
|
||||
name: safeParseStr(
|
||||
json['name']?.toString(),
|
||||
)!,
|
||||
value: safeParseBool(
|
||||
json['value'],
|
||||
)!,
|
||||
name: reqProp<String>(
|
||||
safeParseStr(
|
||||
json['name'],
|
||||
),
|
||||
name: 'name',
|
||||
),
|
||||
value: reqProp<bool>(
|
||||
safeParseBool(
|
||||
json['value'],
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class ColorValue extends Resolvable with EquatableMixin {
|
||||
@@ -31,11 +31,15 @@ class ColorValue extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return ColorValue(
|
||||
value: safeParseColorExpr(
|
||||
json['value'],
|
||||
)!,
|
||||
value: reqVProp<Color>(
|
||||
safeParseColorExpr(
|
||||
json['value'],
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Variable — HEX color as a string.
|
||||
@@ -41,14 +41,21 @@ class ColorVariable extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return ColorVariable(
|
||||
name: safeParseStr(
|
||||
json['name']?.toString(),
|
||||
)!,
|
||||
value: safeParseColor(
|
||||
json['value'],
|
||||
)!,
|
||||
name: reqProp<String>(
|
||||
safeParseStr(
|
||||
json['name'],
|
||||
),
|
||||
name: 'name',
|
||||
),
|
||||
value: reqProp<Color>(
|
||||
safeParseColor(
|
||||
json['value'],
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class ContentText extends Resolvable with EquatableMixin {
|
||||
@@ -31,11 +31,15 @@ class ContentText extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return ContentText(
|
||||
value: safeParseStrExpr(
|
||||
json['value']?.toString(),
|
||||
)!,
|
||||
value: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['value'],
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class ContentUrl extends Resolvable with EquatableMixin {
|
||||
@@ -31,9 +31,15 @@ class ContentUrl extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return ContentUrl(
|
||||
value: safeParseUriExpr(json['value'])!,
|
||||
value: reqVProp<Uri>(
|
||||
safeParseUriExpr(
|
||||
json['value'],
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class DictValue extends Resolvable with EquatableMixin {
|
||||
@@ -9,7 +9,7 @@ class DictValue extends Resolvable with EquatableMixin {
|
||||
});
|
||||
|
||||
static const type = "dict";
|
||||
final Map<String, dynamic> value;
|
||||
final Obj value;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -17,7 +17,7 @@ class DictValue extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
DictValue copyWith({
|
||||
Map<String, dynamic>? value,
|
||||
Obj? value,
|
||||
}) =>
|
||||
DictValue(
|
||||
value: value ?? this.value,
|
||||
@@ -31,11 +31,15 @@ class DictValue extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DictValue(
|
||||
value: safeParseMap(
|
||||
json['value'],
|
||||
)!,
|
||||
value: reqProp<Obj>(
|
||||
safeParseMap(
|
||||
json['value'],
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// An arbitrary object in JSON format.
|
||||
@@ -16,7 +16,7 @@ class DictVariable extends Resolvable with EquatableMixin {
|
||||
final String name;
|
||||
|
||||
/// Value.
|
||||
final Map<String, dynamic> value;
|
||||
final Obj value;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -26,7 +26,7 @@ class DictVariable extends Resolvable with EquatableMixin {
|
||||
|
||||
DictVariable copyWith({
|
||||
String? name,
|
||||
Map<String, dynamic>? value,
|
||||
Obj? value,
|
||||
}) =>
|
||||
DictVariable(
|
||||
name: name ?? this.name,
|
||||
@@ -41,14 +41,21 @@ class DictVariable extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DictVariable(
|
||||
name: safeParseStr(
|
||||
json['name']?.toString(),
|
||||
)!,
|
||||
value: safeParseMap(
|
||||
json['value'],
|
||||
)!,
|
||||
name: reqProp<String>(
|
||||
safeParseStr(
|
||||
json['name'],
|
||||
),
|
||||
name: 'name',
|
||||
),
|
||||
value: reqProp<Obj>(
|
||||
safeParseMap(
|
||||
json['value'],
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import 'package:divkit/src/schema/div_switch.dart';
|
||||
import 'package:divkit/src/schema/div_tabs.dart';
|
||||
import 'package:divkit/src/schema/div_text.dart';
|
||||
import 'package:divkit/src/schema/div_video.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class Div extends Resolvable with EquatableMixin {
|
||||
@@ -463,7 +463,7 @@ class Div extends Resolvable with EquatableMixin {
|
||||
);
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Sets margins without regard to screen properties.
|
||||
@@ -57,24 +57,37 @@ class DivAbsoluteEdgeInsets extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivAbsoluteEdgeInsets(
|
||||
bottom: safeParseIntExpr(
|
||||
json['bottom'],
|
||||
fallback: 0,
|
||||
)!,
|
||||
left: safeParseIntExpr(
|
||||
json['left'],
|
||||
fallback: 0,
|
||||
)!,
|
||||
right: safeParseIntExpr(
|
||||
json['right'],
|
||||
fallback: 0,
|
||||
)!,
|
||||
top: safeParseIntExpr(
|
||||
json['top'],
|
||||
fallback: 0,
|
||||
)!,
|
||||
bottom: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['bottom'],
|
||||
fallback: 0,
|
||||
),
|
||||
name: 'bottom',
|
||||
),
|
||||
left: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['left'],
|
||||
fallback: 0,
|
||||
),
|
||||
name: 'left',
|
||||
),
|
||||
right: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['right'],
|
||||
fallback: 0,
|
||||
),
|
||||
name: 'right',
|
||||
),
|
||||
top: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['top'],
|
||||
fallback: 0,
|
||||
),
|
||||
name: 'top',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Accessibility settings.
|
||||
@@ -74,30 +74,40 @@ class DivAccessibility extends Resolvable with EquatableMixin {
|
||||
try {
|
||||
return DivAccessibility(
|
||||
description: safeParseStrExpr(
|
||||
json['description']?.toString(),
|
||||
json['description'],
|
||||
),
|
||||
hint: safeParseStrExpr(
|
||||
json['hint']?.toString(),
|
||||
json['hint'],
|
||||
),
|
||||
mode: reqVProp<DivAccessibilityMode>(
|
||||
safeParseStrEnumExpr(
|
||||
json['mode'],
|
||||
parse: DivAccessibilityMode.fromJson,
|
||||
fallback: DivAccessibilityMode.default_,
|
||||
),
|
||||
name: 'mode',
|
||||
),
|
||||
muteAfterAction: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['mute_after_action'],
|
||||
fallback: false,
|
||||
),
|
||||
name: 'mute_after_action',
|
||||
),
|
||||
mode: safeParseStrEnumExpr(
|
||||
json['mode'],
|
||||
parse: DivAccessibilityMode.fromJson,
|
||||
fallback: DivAccessibilityMode.default_,
|
||||
)!,
|
||||
muteAfterAction: safeParseBoolExpr(
|
||||
json['mute_after_action'],
|
||||
fallback: false,
|
||||
)!,
|
||||
stateDescription: safeParseStrExpr(
|
||||
json['state_description']?.toString(),
|
||||
json['state_description'],
|
||||
),
|
||||
type: reqProp<DivAccessibilityType>(
|
||||
safeParseStrEnum(
|
||||
json['type'],
|
||||
parse: DivAccessibilityType.fromJson,
|
||||
fallback: DivAccessibilityType.auto,
|
||||
),
|
||||
name: 'type',
|
||||
),
|
||||
type: safeParseStrEnum(
|
||||
json['type'],
|
||||
parse: DivAccessibilityType.fromJson,
|
||||
fallback: DivAccessibilityType.auto,
|
||||
)!,
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -252,7 +262,12 @@ enum DivAccessibilityType implements Resolvable {
|
||||
return DivAccessibilityType.auto;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivAccessibilityType: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -322,7 +337,12 @@ enum DivAccessibilityMode implements Resolvable {
|
||||
return DivAccessibilityMode.exclude;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivAccessibilityMode: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:divkit/src/schema/div_action_typed.dart';
|
||||
import 'package:divkit/src/schema/div_download_callbacks.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// It defines an action when clicking on an element.
|
||||
@@ -35,10 +35,10 @@ class DivAction extends Resolvable with EquatableMixin {
|
||||
final Expression<Uri>? logUrl;
|
||||
|
||||
/// Context menu.
|
||||
final List<DivActionMenuItem>? menuItems;
|
||||
final Arr<DivActionMenuItem>? menuItems;
|
||||
|
||||
/// Additional parameters, passed to the host application.
|
||||
final Map<String, dynamic>? payload;
|
||||
final Obj? payload;
|
||||
|
||||
/// Referer URL for logging.
|
||||
final Expression<Uri>? referer;
|
||||
@@ -73,8 +73,8 @@ class DivAction extends Resolvable with EquatableMixin {
|
||||
Expression<bool>? isEnabled,
|
||||
Expression<String>? logId,
|
||||
Expression<Uri>? Function()? logUrl,
|
||||
List<DivActionMenuItem>? Function()? menuItems,
|
||||
Map<String, dynamic>? Function()? payload,
|
||||
Arr<DivActionMenuItem>? Function()? menuItems,
|
||||
Obj? Function()? payload,
|
||||
Expression<Uri>? Function()? referer,
|
||||
String? Function()? scopeId,
|
||||
Expression<DivActionTarget>? Function()? target,
|
||||
@@ -105,42 +105,58 @@ class DivAction extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivAction(
|
||||
downloadCallbacks: safeParseObj(
|
||||
DivDownloadCallbacks.fromJson(json['download_callbacks']),
|
||||
downloadCallbacks: safeParseObject(
|
||||
json['download_callbacks'],
|
||||
parse: DivDownloadCallbacks.fromJson,
|
||||
),
|
||||
isEnabled: safeParseBoolExpr(
|
||||
json['is_enabled'],
|
||||
fallback: true,
|
||||
)!,
|
||||
logId: safeParseStrExpr(
|
||||
json['log_id']?.toString(),
|
||||
)!,
|
||||
logUrl: safeParseUriExpr(json['log_url']),
|
||||
menuItems: safeParseObj(
|
||||
safeListMap(
|
||||
json['menu_items'],
|
||||
(v) => safeParseObj(
|
||||
DivActionMenuItem.fromJson(v),
|
||||
)!,
|
||||
isEnabled: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['is_enabled'],
|
||||
fallback: true,
|
||||
),
|
||||
name: 'is_enabled',
|
||||
),
|
||||
logId: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['log_id'],
|
||||
),
|
||||
name: 'log_id',
|
||||
),
|
||||
logUrl: safeParseUriExpr(
|
||||
json['log_url'],
|
||||
),
|
||||
menuItems: safeParseObjects(
|
||||
json['menu_items'],
|
||||
(v) => reqProp<DivActionMenuItem>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivActionMenuItem.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
payload: safeParseMap(
|
||||
json['payload'],
|
||||
),
|
||||
referer: safeParseUriExpr(json['referer']),
|
||||
referer: safeParseUriExpr(
|
||||
json['referer'],
|
||||
),
|
||||
scopeId: safeParseStr(
|
||||
json['scope_id']?.toString(),
|
||||
json['scope_id'],
|
||||
),
|
||||
target: safeParseStrEnumExpr(
|
||||
json['target'],
|
||||
parse: DivActionTarget.fromJson,
|
||||
),
|
||||
typed: safeParseObj(
|
||||
DivActionTyped.fromJson(json['typed']),
|
||||
typed: safeParseObject(
|
||||
json['typed'],
|
||||
parse: DivActionTyped.fromJson,
|
||||
),
|
||||
url: safeParseUriExpr(
|
||||
json['url'],
|
||||
),
|
||||
url: safeParseUriExpr(json['url']),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +167,7 @@ class DivAction extends Resolvable with EquatableMixin {
|
||||
isEnabled.resolve(context);
|
||||
logId.resolve(context);
|
||||
logUrl?.resolve(context);
|
||||
safeListResolve(menuItems, (v) => v.resolve(context));
|
||||
tryResolveList(menuItems, (v) => v.resolve(context));
|
||||
referer?.resolve(context);
|
||||
target?.resolve(context);
|
||||
typed?.resolve(context);
|
||||
@@ -171,7 +187,7 @@ class DivActionMenuItem extends Resolvable with EquatableMixin {
|
||||
final DivAction? action;
|
||||
|
||||
/// Multiple actions when clicking on a menu item.
|
||||
final List<DivAction>? actions;
|
||||
final Arr<DivAction>? actions;
|
||||
|
||||
/// Menu item title.
|
||||
final Expression<String> text;
|
||||
@@ -185,7 +201,7 @@ class DivActionMenuItem extends Resolvable with EquatableMixin {
|
||||
|
||||
DivActionMenuItem copyWith({
|
||||
DivAction? Function()? action,
|
||||
List<DivAction>? Function()? actions,
|
||||
Arr<DivAction>? Function()? actions,
|
||||
Expression<String>? text,
|
||||
}) =>
|
||||
DivActionMenuItem(
|
||||
@@ -202,22 +218,28 @@ class DivActionMenuItem extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionMenuItem(
|
||||
action: safeParseObj(
|
||||
DivAction.fromJson(json['action']),
|
||||
action: safeParseObject(
|
||||
json['action'],
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
actions: safeParseObj(
|
||||
safeListMap(
|
||||
json['actions'],
|
||||
(v) => safeParseObj(
|
||||
DivAction.fromJson(v),
|
||||
)!,
|
||||
actions: safeParseObjects(
|
||||
json['actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
text: safeParseStrExpr(
|
||||
json['text']?.toString(),
|
||||
)!,
|
||||
text: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['text'],
|
||||
),
|
||||
name: 'text',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -225,7 +247,7 @@ class DivActionMenuItem extends Resolvable with EquatableMixin {
|
||||
@override
|
||||
DivActionMenuItem resolve(DivVariableContext context) {
|
||||
action?.resolve(context);
|
||||
safeListResolve(actions, (v) => v.resolve(context));
|
||||
tryResolveList(actions, (v) => v.resolve(context));
|
||||
text.resolve(context);
|
||||
return this;
|
||||
}
|
||||
@@ -281,7 +303,12 @@ enum DivActionTarget implements Resolvable {
|
||||
return DivActionTarget.blank;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivActionTarget: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:divkit/src/schema/div_animation_direction.dart';
|
||||
import 'package:divkit/src/schema/div_animation_interpolator.dart';
|
||||
import 'package:divkit/src/schema/div_count.dart';
|
||||
import 'package:divkit/src/schema/div_typed_value.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Launches the specified animator.
|
||||
@@ -91,9 +91,12 @@ class DivActionAnimatorStart extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionAnimatorStart(
|
||||
animatorId: safeParseStr(
|
||||
json['animator_id']?.toString(),
|
||||
)!,
|
||||
animatorId: reqProp<String>(
|
||||
safeParseStr(
|
||||
json['animator_id'],
|
||||
),
|
||||
name: 'animator_id',
|
||||
),
|
||||
direction: safeParseStrEnumExpr(
|
||||
json['direction'],
|
||||
parse: DivAnimationDirection.fromJson,
|
||||
@@ -101,24 +104,28 @@ class DivActionAnimatorStart extends Resolvable with EquatableMixin {
|
||||
duration: safeParseIntExpr(
|
||||
json['duration'],
|
||||
),
|
||||
endValue: safeParseObj(
|
||||
DivTypedValue.fromJson(json['end_value']),
|
||||
endValue: safeParseObject(
|
||||
json['end_value'],
|
||||
parse: DivTypedValue.fromJson,
|
||||
),
|
||||
interpolator: safeParseStrEnumExpr(
|
||||
json['interpolator'],
|
||||
parse: DivAnimationInterpolator.fromJson,
|
||||
),
|
||||
repeatCount: safeParseObj(
|
||||
DivCount.fromJson(json['repeat_count']),
|
||||
repeatCount: safeParseObject(
|
||||
json['repeat_count'],
|
||||
parse: DivCount.fromJson,
|
||||
),
|
||||
startDelay: safeParseIntExpr(
|
||||
json['start_delay'],
|
||||
),
|
||||
startValue: safeParseObj(
|
||||
DivTypedValue.fromJson(json['start_value']),
|
||||
startValue: safeParseObject(
|
||||
json['start_value'],
|
||||
parse: DivTypedValue.fromJson,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Stops the specified animator.
|
||||
@@ -11,7 +11,7 @@ class DivActionAnimatorStop extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "animator_stop";
|
||||
|
||||
/// The identifier of the animator being stopped.
|
||||
/// ID of the animator to be stopped.
|
||||
final String animatorId;
|
||||
|
||||
@override
|
||||
@@ -34,11 +34,15 @@ class DivActionAnimatorStop extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionAnimatorStop(
|
||||
animatorId: safeParseStr(
|
||||
json['animator_id']?.toString(),
|
||||
)!,
|
||||
animatorId: reqProp<String>(
|
||||
safeParseStr(
|
||||
json['animator_id'],
|
||||
),
|
||||
name: 'animator_id',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_typed_value.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Adds a value to the array
|
||||
@@ -46,14 +46,22 @@ class DivActionArrayInsertValue extends Resolvable with EquatableMixin {
|
||||
index: safeParseIntExpr(
|
||||
json['index'],
|
||||
),
|
||||
value: safeParseObj(
|
||||
DivTypedValue.fromJson(json['value']),
|
||||
)!,
|
||||
variableName: safeParseStrExpr(
|
||||
json['variable_name']?.toString(),
|
||||
)!,
|
||||
value: reqProp<DivTypedValue>(
|
||||
safeParseObject(
|
||||
json['value'],
|
||||
parse: DivTypedValue.fromJson,
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
variableName: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['variable_name'],
|
||||
),
|
||||
name: 'variable_name',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Deletes a value from the array
|
||||
@@ -37,14 +37,21 @@ class DivActionArrayRemoveValue extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionArrayRemoveValue(
|
||||
index: safeParseIntExpr(
|
||||
json['index'],
|
||||
)!,
|
||||
variableName: safeParseStrExpr(
|
||||
json['variable_name']?.toString(),
|
||||
)!,
|
||||
index: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['index'],
|
||||
),
|
||||
name: 'index',
|
||||
),
|
||||
variableName: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['variable_name'],
|
||||
),
|
||||
name: 'variable_name',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_typed_value.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Sets the value in the array by index.
|
||||
@@ -43,17 +43,28 @@ class DivActionArraySetValue extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionArraySetValue(
|
||||
index: safeParseIntExpr(
|
||||
json['index'],
|
||||
)!,
|
||||
value: safeParseObj(
|
||||
DivTypedValue.fromJson(json['value']),
|
||||
)!,
|
||||
variableName: safeParseStrExpr(
|
||||
json['variable_name']?.toString(),
|
||||
)!,
|
||||
index: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['index'],
|
||||
),
|
||||
name: 'index',
|
||||
),
|
||||
value: reqProp<DivTypedValue>(
|
||||
safeParseObject(
|
||||
json['value'],
|
||||
parse: DivTypedValue.fromJson,
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
variableName: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['variable_name'],
|
||||
),
|
||||
name: 'variable_name',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Removes focus from an element.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_action_copy_to_clipboard_content.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Copies data to the clipboard.
|
||||
@@ -33,11 +33,16 @@ class DivActionCopyToClipboard extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionCopyToClipboard(
|
||||
content: safeParseObj(
|
||||
DivActionCopyToClipboardContent.fromJson(json['content']),
|
||||
)!,
|
||||
content: reqProp<DivActionCopyToClipboardContent>(
|
||||
safeParseObject(
|
||||
json['content'],
|
||||
parse: DivActionCopyToClipboardContent.fromJson,
|
||||
),
|
||||
name: 'content',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:divkit/src/schema/content_text.dart';
|
||||
import 'package:divkit/src/schema/content_url.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class DivActionCopyToClipboardContent extends Resolvable with EquatableMixin {
|
||||
@@ -87,7 +87,7 @@ class DivActionCopyToClipboardContent extends Resolvable with EquatableMixin {
|
||||
);
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_typed_value.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Sets the value in the dictionary by the specified key. Deletes the key if the value is not set.
|
||||
@@ -43,17 +43,25 @@ class DivActionDictSetValue extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionDictSetValue(
|
||||
key: safeParseStrExpr(
|
||||
json['key']?.toString(),
|
||||
)!,
|
||||
value: safeParseObj(
|
||||
DivTypedValue.fromJson(json['value']),
|
||||
key: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['key'],
|
||||
),
|
||||
name: 'key',
|
||||
),
|
||||
value: safeParseObject(
|
||||
json['value'],
|
||||
parse: DivTypedValue.fromJson,
|
||||
),
|
||||
variableName: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['variable_name'],
|
||||
),
|
||||
name: 'variable_name',
|
||||
),
|
||||
variableName: safeParseStrExpr(
|
||||
json['variable_name']?.toString(),
|
||||
)!,
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_action.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Loads additional data in `div-patch` format and updates the current element.
|
||||
@@ -15,10 +15,10 @@ class DivActionDownload extends Resolvable with EquatableMixin {
|
||||
static const type = "download";
|
||||
|
||||
/// Actions in case of unsuccessful loading if the host reported it or the waiting time expired.
|
||||
final List<DivAction>? onFailActions;
|
||||
final Arr<DivAction>? onFailActions;
|
||||
|
||||
/// Actions in case of successful loading.
|
||||
final List<DivAction>? onSuccessActions;
|
||||
final Arr<DivAction>? onSuccessActions;
|
||||
|
||||
/// Link for receiving changes.
|
||||
final Expression<String> url;
|
||||
@@ -31,8 +31,8 @@ class DivActionDownload extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
DivActionDownload copyWith({
|
||||
List<DivAction>? Function()? onFailActions,
|
||||
List<DivAction>? Function()? onSuccessActions,
|
||||
Arr<DivAction>? Function()? onFailActions,
|
||||
Arr<DivAction>? Function()? onSuccessActions,
|
||||
Expression<String>? url,
|
||||
}) =>
|
||||
DivActionDownload(
|
||||
@@ -52,35 +52,41 @@ class DivActionDownload extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionDownload(
|
||||
onFailActions: safeParseObj(
|
||||
safeListMap(
|
||||
json['on_fail_actions'],
|
||||
(v) => safeParseObj(
|
||||
DivAction.fromJson(v),
|
||||
)!,
|
||||
onFailActions: safeParseObjects(
|
||||
json['on_fail_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
onSuccessActions: safeParseObj(
|
||||
safeListMap(
|
||||
json['on_success_actions'],
|
||||
(v) => safeParseObj(
|
||||
DivAction.fromJson(v),
|
||||
)!,
|
||||
onSuccessActions: safeParseObjects(
|
||||
json['on_success_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
url: safeParseStrExpr(
|
||||
json['url']?.toString(),
|
||||
)!,
|
||||
url: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['url'],
|
||||
),
|
||||
name: 'url',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
DivActionDownload resolve(DivVariableContext context) {
|
||||
safeListResolve(onFailActions, (v) => v.resolve(context));
|
||||
safeListResolve(onSuccessActions, (v) => v.resolve(context));
|
||||
tryResolveList(onFailActions, (v) => v.resolve(context));
|
||||
tryResolveList(onSuccessActions, (v) => v.resolve(context));
|
||||
url.resolve(context);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Requests focus for an element. May require a user action on the web.
|
||||
@@ -32,11 +32,15 @@ class DivActionFocusElement extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionFocusElement(
|
||||
elementId: safeParseStrExpr(
|
||||
json['element_id']?.toString(),
|
||||
)!,
|
||||
elementId: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['element_id'],
|
||||
),
|
||||
name: 'element_id',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Hides the tooltip.
|
||||
@@ -34,11 +34,15 @@ class DivActionHideTooltip extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionHideTooltip(
|
||||
id: safeParseStrExpr(
|
||||
json['id']?.toString(),
|
||||
)!,
|
||||
id: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['id'],
|
||||
),
|
||||
name: 'id',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Scrolls scrollable container from current position by `item_count` or by `offset`, if both provided scroll action will be combined, negative numbers associated with backward scroll.
|
||||
/// Scrolls the container by `item_count` or `offset` starting from the current position. If both values are specified, the action will be combined. For scrolling back, use negative values.
|
||||
class DivActionScrollBy extends Resolvable with EquatableMixin {
|
||||
const DivActionScrollBy({
|
||||
this.animated = const ValueExpression(true),
|
||||
@@ -15,24 +15,24 @@ class DivActionScrollBy extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "scroll_by";
|
||||
|
||||
/// If `true` (default value) scroll will be animated, else not.
|
||||
/// Enables scrolling animation.
|
||||
// default value: true
|
||||
final Expression<bool> animated;
|
||||
|
||||
/// Identifier of the view that is going to be manipulated.
|
||||
/// ID of the element where the action should be performed.
|
||||
final Expression<String> id;
|
||||
|
||||
/// Count of container items to scroll, negative value is associated with backward scroll.
|
||||
/// Number of container elements to scroll through. For scrolling back, use negative values.
|
||||
// default value: 0
|
||||
final Expression<int> itemCount;
|
||||
|
||||
/// Distance to scroll measured in `dp` from current position, negative value is associated with backward scroll. Applicable only in `gallery`.
|
||||
/// Scrolling distance measured in `dp` from the current position. For scrolling back, use negative values. Only applies in `gallery`.
|
||||
// default value: 0
|
||||
final Expression<int> offset;
|
||||
|
||||
/// Specifies how navigation will occur when the boundary elements are reached:
|
||||
/// • `clamp` — Transition will stop at the boundary element (default value);
|
||||
/// • `ring` — Transition will be to the beginning or the end depending on the current element.
|
||||
/// Defines navigation behavior at boundary elements:
|
||||
/// • `clamp`: Stop navigation at the boundary element (default)
|
||||
/// • `ring`: Navigate to the start or end, depending on the current element.
|
||||
// default value: DivActionScrollByOverflow.clamp
|
||||
final Expression<DivActionScrollByOverflow> overflow;
|
||||
|
||||
@@ -68,28 +68,44 @@ class DivActionScrollBy extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionScrollBy(
|
||||
animated: safeParseBoolExpr(
|
||||
json['animated'],
|
||||
fallback: true,
|
||||
)!,
|
||||
id: safeParseStrExpr(
|
||||
json['id']?.toString(),
|
||||
)!,
|
||||
itemCount: safeParseIntExpr(
|
||||
json['item_count'],
|
||||
fallback: 0,
|
||||
)!,
|
||||
offset: safeParseIntExpr(
|
||||
json['offset'],
|
||||
fallback: 0,
|
||||
)!,
|
||||
overflow: safeParseStrEnumExpr(
|
||||
json['overflow'],
|
||||
parse: DivActionScrollByOverflow.fromJson,
|
||||
fallback: DivActionScrollByOverflow.clamp,
|
||||
)!,
|
||||
animated: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['animated'],
|
||||
fallback: true,
|
||||
),
|
||||
name: 'animated',
|
||||
),
|
||||
id: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['id'],
|
||||
),
|
||||
name: 'id',
|
||||
),
|
||||
itemCount: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['item_count'],
|
||||
fallback: 0,
|
||||
),
|
||||
name: 'item_count',
|
||||
),
|
||||
offset: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['offset'],
|
||||
fallback: 0,
|
||||
),
|
||||
name: 'offset',
|
||||
),
|
||||
overflow: reqVProp<DivActionScrollByOverflow>(
|
||||
safeParseStrEnumExpr(
|
||||
json['overflow'],
|
||||
parse: DivActionScrollByOverflow.fromJson,
|
||||
fallback: DivActionScrollByOverflow.clamp,
|
||||
),
|
||||
name: 'overflow',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -155,7 +171,12 @@ enum DivActionScrollByOverflow implements Resolvable {
|
||||
return DivActionScrollByOverflow.ring;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivActionScrollByOverflow: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:divkit/src/schema/end_destination.dart';
|
||||
import 'package:divkit/src/schema/index_destination.dart';
|
||||
import 'package:divkit/src/schema/offset_destination.dart';
|
||||
import 'package:divkit/src/schema/start_destination.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class DivActionScrollDestination extends Resolvable with EquatableMixin {
|
||||
@@ -137,7 +137,7 @@ class DivActionScrollDestination extends Resolvable with EquatableMixin {
|
||||
);
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_action_scroll_destination.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Scrolls or switches container to given destination provided by `destination`.
|
||||
/// Scrolls to a position or switches to the container element specified by the `destination` parameter.
|
||||
class DivActionScrollTo extends Resolvable with EquatableMixin {
|
||||
const DivActionScrollTo({
|
||||
this.animated = const ValueExpression(true),
|
||||
@@ -14,18 +14,18 @@ class DivActionScrollTo extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "scroll_to";
|
||||
|
||||
/// If `true` (default value) scroll will be animated, else not.
|
||||
/// Enables scrolling animation.
|
||||
// default value: true
|
||||
final Expression<bool> animated;
|
||||
|
||||
/// Specifies destination of scroll:
|
||||
/// • `index` - scroll or switch to item with index provided by `value`;
|
||||
/// • `offset` - scroll to position measured in `dp` from container's start and provided by `value`. Applicable only in `gallery`;
|
||||
/// • `start` - scrolls to start of container;
|
||||
/// • `end` - scrolls to end of container..
|
||||
/// Defines the scrolling end position:
|
||||
/// • `index`: Scroll to the element with the index provided in `value`
|
||||
/// • `offset`: Scroll to the position specified in `value` and measured in `dp` from the start of the container. Applies only in `gallery`;
|
||||
/// • `start`: Scroll to the container start;
|
||||
/// • `end`: Scroll to the container end.
|
||||
final DivActionScrollDestination destination;
|
||||
|
||||
/// Identifier of the view that is going to be manipulated.
|
||||
/// ID of the element where the action should be performed.
|
||||
final Expression<String> id;
|
||||
|
||||
@override
|
||||
@@ -54,18 +54,29 @@ class DivActionScrollTo extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionScrollTo(
|
||||
animated: safeParseBoolExpr(
|
||||
json['animated'],
|
||||
fallback: true,
|
||||
)!,
|
||||
destination: safeParseObj(
|
||||
DivActionScrollDestination.fromJson(json['destination']),
|
||||
)!,
|
||||
id: safeParseStrExpr(
|
||||
json['id']?.toString(),
|
||||
)!,
|
||||
animated: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['animated'],
|
||||
fallback: true,
|
||||
),
|
||||
name: 'animated',
|
||||
),
|
||||
destination: reqProp<DivActionScrollDestination>(
|
||||
safeParseObject(
|
||||
json['destination'],
|
||||
parse: DivActionScrollDestination.fromJson,
|
||||
),
|
||||
name: 'destination',
|
||||
),
|
||||
id: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['id'],
|
||||
),
|
||||
name: 'id',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Applies a new appearance to the content in `div-state'.
|
||||
@@ -47,15 +47,22 @@ class DivActionSetState extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionSetState(
|
||||
stateId: safeParseStrExpr(
|
||||
json['state_id']?.toString(),
|
||||
)!,
|
||||
temporary: safeParseBoolExpr(
|
||||
json['temporary'],
|
||||
fallback: true,
|
||||
)!,
|
||||
stateId: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['state_id'],
|
||||
),
|
||||
name: 'state_id',
|
||||
),
|
||||
temporary: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['temporary'],
|
||||
fallback: true,
|
||||
),
|
||||
name: 'temporary',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_typed_value.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Temporarily saves variable to the persistent storage.
|
||||
/// Temporarily saves the variable in storage.
|
||||
class DivActionSetStoredValue extends Resolvable with EquatableMixin {
|
||||
const DivActionSetStoredValue({
|
||||
required this.lifetime,
|
||||
@@ -14,13 +14,13 @@ class DivActionSetStoredValue extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "set_stored_value";
|
||||
|
||||
/// Storing time in seconds.
|
||||
/// Duration of storage in seconds.
|
||||
final Expression<int> lifetime;
|
||||
|
||||
/// Nave of stored variable.
|
||||
/// Name of the saved variable.
|
||||
final Expression<String> name;
|
||||
|
||||
/// Value to be stored.
|
||||
/// Saved value.
|
||||
final DivTypedValue value;
|
||||
|
||||
@override
|
||||
@@ -49,17 +49,28 @@ class DivActionSetStoredValue extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionSetStoredValue(
|
||||
lifetime: safeParseIntExpr(
|
||||
json['lifetime'],
|
||||
)!,
|
||||
name: safeParseStrExpr(
|
||||
json['name']?.toString(),
|
||||
)!,
|
||||
value: safeParseObj(
|
||||
DivTypedValue.fromJson(json['value']),
|
||||
)!,
|
||||
lifetime: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['lifetime'],
|
||||
),
|
||||
name: 'lifetime',
|
||||
),
|
||||
name: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['name'],
|
||||
),
|
||||
name: 'name',
|
||||
),
|
||||
value: reqProp<DivTypedValue>(
|
||||
safeParseObject(
|
||||
json['value'],
|
||||
parse: DivTypedValue.fromJson,
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_typed_value.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Assigns a value to the variable
|
||||
@@ -38,14 +38,22 @@ class DivActionSetVariable extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionSetVariable(
|
||||
value: safeParseObj(
|
||||
DivTypedValue.fromJson(json['value']),
|
||||
)!,
|
||||
variableName: safeParseStrExpr(
|
||||
json['variable_name']?.toString(),
|
||||
)!,
|
||||
value: reqProp<DivTypedValue>(
|
||||
safeParseObject(
|
||||
json['value'],
|
||||
parse: DivTypedValue.fromJson,
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
variableName: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['variable_name'],
|
||||
),
|
||||
name: 'variable_name',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Shows the tooltip.
|
||||
@@ -41,14 +41,18 @@ class DivActionShowTooltip extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionShowTooltip(
|
||||
id: safeParseStrExpr(
|
||||
json['id']?.toString(),
|
||||
)!,
|
||||
id: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['id'],
|
||||
),
|
||||
name: 'id',
|
||||
),
|
||||
multiple: safeParseBoolExpr(
|
||||
json['multiple'],
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_action.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Sends variables from the container via a url. The data sending configuration can be determined by the host application. By default, variables are passed in body in json format, the request method is POST.
|
||||
/// Sends variables from the container by link. Data sending configuration can be defined by the host app. By default, variables are sent as JSON in the request body using the POST method.
|
||||
class DivActionSubmit extends Resolvable with EquatableMixin {
|
||||
const DivActionSubmit({
|
||||
required this.containerId,
|
||||
@@ -15,16 +15,16 @@ class DivActionSubmit extends Resolvable with EquatableMixin {
|
||||
|
||||
static const type = "submit";
|
||||
|
||||
/// The identifier of the container that contains variables to submit.
|
||||
/// ID of the container with the variables to be sent.
|
||||
final Expression<String> containerId;
|
||||
|
||||
/// Actions in case of unsuccessful submit.
|
||||
final List<DivAction>? onFailActions;
|
||||
/// Actions when sending data is unsuccessful.
|
||||
final Arr<DivAction>? onFailActions;
|
||||
|
||||
/// Actions in case of successful submit.
|
||||
final List<DivAction>? onSuccessActions;
|
||||
/// Actions when sending data is successful.
|
||||
final Arr<DivAction>? onSuccessActions;
|
||||
|
||||
/// The HTTP request parameters that are used to configure how data is sent.
|
||||
/// HTTP request parameters for configuring the sending of data.
|
||||
final DivActionSubmitRequest request;
|
||||
|
||||
@override
|
||||
@@ -37,8 +37,8 @@ class DivActionSubmit extends Resolvable with EquatableMixin {
|
||||
|
||||
DivActionSubmit copyWith({
|
||||
Expression<String>? containerId,
|
||||
List<DivAction>? Function()? onFailActions,
|
||||
List<DivAction>? Function()? onSuccessActions,
|
||||
Arr<DivAction>? Function()? onFailActions,
|
||||
Arr<DivAction>? Function()? onSuccessActions,
|
||||
DivActionSubmitRequest? request,
|
||||
}) =>
|
||||
DivActionSubmit(
|
||||
@@ -59,30 +59,40 @@ class DivActionSubmit extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionSubmit(
|
||||
containerId: safeParseStrExpr(
|
||||
json['container_id']?.toString(),
|
||||
)!,
|
||||
onFailActions: safeParseObj(
|
||||
safeListMap(
|
||||
json['on_fail_actions'],
|
||||
(v) => safeParseObj(
|
||||
DivAction.fromJson(v),
|
||||
)!,
|
||||
containerId: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['container_id'],
|
||||
),
|
||||
name: 'container_id',
|
||||
),
|
||||
onFailActions: safeParseObjects(
|
||||
json['on_fail_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
onSuccessActions: safeParseObj(
|
||||
safeListMap(
|
||||
json['on_success_actions'],
|
||||
(v) => safeParseObj(
|
||||
DivAction.fromJson(v),
|
||||
)!,
|
||||
onSuccessActions: safeParseObjects(
|
||||
json['on_success_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
request: safeParseObj(
|
||||
DivActionSubmitRequest.fromJson(json['request']),
|
||||
)!,
|
||||
request: reqProp<DivActionSubmitRequest>(
|
||||
safeParseObject(
|
||||
json['request'],
|
||||
parse: DivActionSubmitRequest.fromJson,
|
||||
),
|
||||
name: 'request',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -90,14 +100,14 @@ class DivActionSubmit extends Resolvable with EquatableMixin {
|
||||
@override
|
||||
DivActionSubmit resolve(DivVariableContext context) {
|
||||
containerId.resolve(context);
|
||||
safeListResolve(onFailActions, (v) => v.resolve(context));
|
||||
safeListResolve(onSuccessActions, (v) => v.resolve(context));
|
||||
tryResolveList(onFailActions, (v) => v.resolve(context));
|
||||
tryResolveList(onSuccessActions, (v) => v.resolve(context));
|
||||
request.resolve(context);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/// The HTTP request parameters that are used to configure how data is sent.
|
||||
/// HTTP request parameters for configuring the sending of data.
|
||||
class DivActionSubmitRequest extends Resolvable with EquatableMixin {
|
||||
const DivActionSubmitRequest({
|
||||
this.headers,
|
||||
@@ -105,14 +115,14 @@ class DivActionSubmitRequest extends Resolvable with EquatableMixin {
|
||||
required this.url,
|
||||
});
|
||||
|
||||
/// The HTTP request headers.
|
||||
final List<DivActionSubmitRequestHeader>? headers;
|
||||
/// HTTP request headers.
|
||||
final Arr<DivActionSubmitRequestHeader>? headers;
|
||||
|
||||
/// The HTTP request method.
|
||||
/// HTTP request method.
|
||||
// default value: DivActionSubmitRequestMethod.post
|
||||
final Expression<DivActionSubmitRequestMethod> method;
|
||||
|
||||
/// The url to which data from the container is sent.
|
||||
/// Link for sending data from the container.
|
||||
final Expression<Uri> url;
|
||||
|
||||
@override
|
||||
@@ -123,7 +133,7 @@ class DivActionSubmitRequest extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
DivActionSubmitRequest copyWith({
|
||||
List<DivActionSubmitRequestHeader>? Function()? headers,
|
||||
Arr<DivActionSubmitRequestHeader>? Function()? headers,
|
||||
Expression<DivActionSubmitRequestMethod>? method,
|
||||
Expression<Uri>? url,
|
||||
}) =>
|
||||
@@ -141,29 +151,39 @@ class DivActionSubmitRequest extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionSubmitRequest(
|
||||
headers: safeParseObj(
|
||||
safeListMap(
|
||||
json['headers'],
|
||||
(v) => safeParseObj(
|
||||
DivActionSubmitRequestHeader.fromJson(v),
|
||||
)!,
|
||||
headers: safeParseObjects(
|
||||
json['headers'],
|
||||
(v) => reqProp<DivActionSubmitRequestHeader>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivActionSubmitRequestHeader.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
method: safeParseStrEnumExpr(
|
||||
json['method'],
|
||||
parse: DivActionSubmitRequestMethod.fromJson,
|
||||
fallback: DivActionSubmitRequestMethod.post,
|
||||
)!,
|
||||
url: safeParseUriExpr(json['url'])!,
|
||||
method: reqVProp<DivActionSubmitRequestMethod>(
|
||||
safeParseStrEnumExpr(
|
||||
json['method'],
|
||||
parse: DivActionSubmitRequestMethod.fromJson,
|
||||
fallback: DivActionSubmitRequestMethod.post,
|
||||
),
|
||||
name: 'method',
|
||||
),
|
||||
url: reqVProp<Uri>(
|
||||
safeParseUriExpr(
|
||||
json['url'],
|
||||
),
|
||||
name: 'url',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
DivActionSubmitRequest resolve(DivVariableContext context) {
|
||||
safeListResolve(headers, (v) => v.resolve(context));
|
||||
tryResolveList(headers, (v) => v.resolve(context));
|
||||
method.resolve(context);
|
||||
url.resolve(context);
|
||||
return this;
|
||||
@@ -202,14 +222,21 @@ class DivActionSubmitRequestHeader extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionSubmitRequestHeader(
|
||||
name: safeParseStrExpr(
|
||||
json['name']?.toString(),
|
||||
)!,
|
||||
value: safeParseStrExpr(
|
||||
json['value']?.toString(),
|
||||
)!,
|
||||
name: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['name'],
|
||||
),
|
||||
name: 'name',
|
||||
),
|
||||
value: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['value'],
|
||||
),
|
||||
name: 'value',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -327,7 +354,12 @@ enum DivActionSubmitRequestMethod implements Resolvable {
|
||||
return DivActionSubmitRequestMethod.options;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivActionSubmitRequestMethod: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Controls the timer.
|
||||
@@ -47,15 +47,22 @@ class DivActionTimer extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionTimer(
|
||||
action: safeParseStrEnumExpr(
|
||||
json['action'],
|
||||
parse: DivActionTimerAction.fromJson,
|
||||
)!,
|
||||
id: safeParseStrExpr(
|
||||
json['id']?.toString(),
|
||||
)!,
|
||||
action: reqVProp<DivActionTimerAction>(
|
||||
safeParseStrEnumExpr(
|
||||
json['action'],
|
||||
parse: DivActionTimerAction.fromJson,
|
||||
),
|
||||
name: 'action',
|
||||
),
|
||||
id: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['id'],
|
||||
),
|
||||
name: 'id',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -162,7 +169,12 @@ enum DivActionTimerAction implements Resolvable {
|
||||
return DivActionTimerAction.reset;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivActionTimerAction: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import 'package:divkit/src/schema/div_action_show_tooltip.dart';
|
||||
import 'package:divkit/src/schema/div_action_submit.dart';
|
||||
import 'package:divkit/src/schema/div_action_timer.dart';
|
||||
import 'package:divkit/src/schema/div_action_video.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class DivActionTyped extends Resolvable with EquatableMixin {
|
||||
@@ -537,7 +537,7 @@ class DivActionTyped extends Resolvable with EquatableMixin {
|
||||
);
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Manages video playback.
|
||||
@@ -43,15 +43,22 @@ class DivActionVideo extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivActionVideo(
|
||||
action: safeParseStrEnumExpr(
|
||||
json['action'],
|
||||
parse: DivActionVideoAction.fromJson,
|
||||
)!,
|
||||
id: safeParseStrExpr(
|
||||
json['id']?.toString(),
|
||||
)!,
|
||||
action: reqVProp<DivActionVideoAction>(
|
||||
safeParseStrEnumExpr(
|
||||
json['action'],
|
||||
parse: DivActionVideoAction.fromJson,
|
||||
),
|
||||
name: 'action',
|
||||
),
|
||||
id: reqVProp<String>(
|
||||
safeParseStrExpr(
|
||||
json['id'],
|
||||
),
|
||||
name: 'id',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -114,7 +121,12 @@ enum DivActionVideoAction implements Resolvable {
|
||||
return DivActionVideoAction.pause;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivActionVideoAction: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
enum DivAlignmentHorizontal implements Resolvable {
|
||||
left('left'),
|
||||
@@ -85,7 +85,12 @@ enum DivAlignmentHorizontal implements Resolvable {
|
||||
return DivAlignmentHorizontal.end;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivAlignmentHorizontal: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
enum DivAlignmentVertical implements Resolvable {
|
||||
top('top'),
|
||||
@@ -74,7 +74,12 @@ enum DivAlignmentVertical implements Resolvable {
|
||||
return DivAlignmentVertical.baseline;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivAlignmentVertical: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import 'package:divkit/src/schema/div_animation_interpolator.dart';
|
||||
import 'package:divkit/src/schema/div_count.dart';
|
||||
import 'package:divkit/src/schema/div_infinity_count.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Element animation parameters.
|
||||
@@ -38,7 +38,7 @@ class DivAnimation extends Resolvable with EquatableMixin {
|
||||
final Expression<DivAnimationInterpolator> interpolator;
|
||||
|
||||
/// Animation elements.
|
||||
final List<DivAnimation>? items;
|
||||
final Arr<DivAnimation>? items;
|
||||
|
||||
/// Animation type.
|
||||
final Expression<DivAnimationName> name;
|
||||
@@ -70,7 +70,7 @@ class DivAnimation extends Resolvable with EquatableMixin {
|
||||
Expression<int>? duration,
|
||||
Expression<double>? Function()? endValue,
|
||||
Expression<DivAnimationInterpolator>? interpolator,
|
||||
List<DivAnimation>? Function()? items,
|
||||
Arr<DivAnimation>? Function()? items,
|
||||
Expression<DivAnimationName>? name,
|
||||
DivCount? repeat,
|
||||
Expression<int>? startDelay,
|
||||
@@ -95,45 +95,63 @@ class DivAnimation extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivAnimation(
|
||||
duration: safeParseIntExpr(
|
||||
json['duration'],
|
||||
fallback: 300,
|
||||
)!,
|
||||
duration: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['duration'],
|
||||
fallback: 300,
|
||||
),
|
||||
name: 'duration',
|
||||
),
|
||||
endValue: safeParseDoubleExpr(
|
||||
json['end_value'],
|
||||
),
|
||||
interpolator: safeParseStrEnumExpr(
|
||||
json['interpolator'],
|
||||
parse: DivAnimationInterpolator.fromJson,
|
||||
fallback: DivAnimationInterpolator.spring,
|
||||
)!,
|
||||
items: safeParseObj(
|
||||
safeListMap(
|
||||
json['items'],
|
||||
(v) => safeParseObj(
|
||||
DivAnimation.fromJson(v),
|
||||
)!,
|
||||
interpolator: reqVProp<DivAnimationInterpolator>(
|
||||
safeParseStrEnumExpr(
|
||||
json['interpolator'],
|
||||
parse: DivAnimationInterpolator.fromJson,
|
||||
fallback: DivAnimationInterpolator.spring,
|
||||
),
|
||||
name: 'interpolator',
|
||||
),
|
||||
items: safeParseObjects(
|
||||
json['items'],
|
||||
(v) => reqProp<DivAnimation>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAnimation.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
name: safeParseStrEnumExpr(
|
||||
json['name'],
|
||||
parse: DivAnimationName.fromJson,
|
||||
)!,
|
||||
repeat: safeParseObj(
|
||||
DivCount.fromJson(json['repeat']),
|
||||
fallback: const DivCount.divInfinityCount(
|
||||
DivInfinityCount(),
|
||||
name: reqVProp<DivAnimationName>(
|
||||
safeParseStrEnumExpr(
|
||||
json['name'],
|
||||
parse: DivAnimationName.fromJson,
|
||||
),
|
||||
)!,
|
||||
startDelay: safeParseIntExpr(
|
||||
json['start_delay'],
|
||||
fallback: 0,
|
||||
)!,
|
||||
name: 'name',
|
||||
),
|
||||
repeat: reqProp<DivCount>(
|
||||
safeParseObject(
|
||||
json['repeat'],
|
||||
parse: DivCount.fromJson,
|
||||
fallback: const DivCount.divInfinityCount(
|
||||
DivInfinityCount(),
|
||||
),
|
||||
),
|
||||
name: 'repeat',
|
||||
),
|
||||
startDelay: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['start_delay'],
|
||||
fallback: 0,
|
||||
),
|
||||
name: 'start_delay',
|
||||
),
|
||||
startValue: safeParseDoubleExpr(
|
||||
json['start_value'],
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -245,7 +263,12 @@ enum DivAnimationName implements Resolvable {
|
||||
return DivAnimationName.noAnimation;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivAnimationName: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
enum DivAnimationDirection implements Resolvable {
|
||||
normal('normal'),
|
||||
@@ -74,7 +74,12 @@ enum DivAnimationDirection implements Resolvable {
|
||||
return DivAnimationDirection.alternateReverse;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivAnimationDirection: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
enum DivAnimationInterpolator implements Resolvable {
|
||||
linear('linear'),
|
||||
@@ -96,7 +96,12 @@ enum DivAnimationInterpolator implements Resolvable {
|
||||
return DivAnimationInterpolator.spring;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivAnimationInterpolator: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import 'package:divkit/src/schema/div_animator_base.dart';
|
||||
import 'package:divkit/src/schema/div_color_animator.dart';
|
||||
import 'package:divkit/src/schema/div_number_animator.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class DivAnimator extends Resolvable with EquatableMixin {
|
||||
@@ -88,7 +88,7 @@ class DivAnimator extends Resolvable with EquatableMixin {
|
||||
);
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import 'package:divkit/src/schema/div_action.dart';
|
||||
import 'package:divkit/src/schema/div_animation_direction.dart';
|
||||
import 'package:divkit/src/schema/div_animation_interpolator.dart';
|
||||
import 'package:divkit/src/schema/div_count.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
abstract class DivAnimatorBase extends Resolvable {
|
||||
List<DivAction>? get cancelActions;
|
||||
Arr<DivAction>? get cancelActions;
|
||||
|
||||
// default value: DivAnimationDirection.normal
|
||||
Expression<DivAnimationDirection> get direction;
|
||||
@@ -15,7 +15,7 @@ abstract class DivAnimatorBase extends Resolvable {
|
||||
// constraint: number >= 0
|
||||
Expression<int> get duration;
|
||||
|
||||
List<DivAction>? get endActions;
|
||||
Arr<DivAction>? get endActions;
|
||||
|
||||
String get id;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_appearance_transition.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// A set of animations to be applied simultaneously.
|
||||
@@ -14,7 +14,7 @@ class DivAppearanceSetTransition extends Resolvable with EquatableMixin {
|
||||
|
||||
/// An array of animations.
|
||||
// at least 1 elements
|
||||
final List<DivAppearanceTransition> items;
|
||||
final Arr<DivAppearanceTransition> items;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -22,7 +22,7 @@ class DivAppearanceSetTransition extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
DivAppearanceSetTransition copyWith({
|
||||
List<DivAppearanceTransition>? items,
|
||||
Arr<DivAppearanceTransition>? items,
|
||||
}) =>
|
||||
DivAppearanceSetTransition(
|
||||
items: items ?? this.items,
|
||||
@@ -36,16 +36,21 @@ class DivAppearanceSetTransition extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivAppearanceSetTransition(
|
||||
items: safeParseObj(
|
||||
safeListMap(
|
||||
items: reqProp<Arr<DivAppearanceTransition>>(
|
||||
safeParseObjects(
|
||||
json['items'],
|
||||
(v) => safeParseObj(
|
||||
DivAppearanceTransition.fromJson(v),
|
||||
)!,
|
||||
(v) => reqProp<DivAppearanceTransition>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAppearanceTransition.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
)!,
|
||||
name: 'items',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:divkit/src/schema/div_appearance_set_transition.dart';
|
||||
import 'package:divkit/src/schema/div_fade_transition.dart';
|
||||
import 'package:divkit/src/schema/div_scale_transition.dart';
|
||||
import 'package:divkit/src/schema/div_slide_transition.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class DivAppearanceTransition extends Resolvable with EquatableMixin {
|
||||
@@ -137,7 +137,7 @@ class DivAppearanceTransition extends Resolvable with EquatableMixin {
|
||||
);
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Fixed aspect ratio. The element's height is calculated based on the width, ignoring the `height` value.
|
||||
@@ -33,11 +33,15 @@ class DivAspect extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivAspect(
|
||||
ratio: safeParseDoubleExpr(
|
||||
json['ratio'],
|
||||
)!,
|
||||
ratio: reqVProp<double>(
|
||||
safeParseDoubleExpr(
|
||||
json['ratio'],
|
||||
),
|
||||
name: 'ratio',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:divkit/src/schema/div_linear_gradient.dart';
|
||||
import 'package:divkit/src/schema/div_nine_patch_background.dart';
|
||||
import 'package:divkit/src/schema/div_radial_gradient.dart';
|
||||
import 'package:divkit/src/schema/div_solid_background.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class DivBackground extends Resolvable with EquatableMixin {
|
||||
@@ -162,7 +162,7 @@ class DivBackground extends Resolvable with EquatableMixin {
|
||||
);
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import 'package:divkit/src/schema/div_trigger.dart';
|
||||
import 'package:divkit/src/schema/div_variable.dart';
|
||||
import 'package:divkit/src/schema/div_visibility.dart';
|
||||
import 'package:divkit/src/schema/div_visibility_action.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
abstract class DivBase extends Resolvable {
|
||||
DivAccessibility get accessibility;
|
||||
@@ -35,22 +35,22 @@ abstract class DivBase extends Resolvable {
|
||||
// constraint: number >= 0.0 && number <= 1.0; default value: 1.0
|
||||
Expression<double> get alpha;
|
||||
|
||||
List<DivAnimator>? get animators;
|
||||
Arr<DivAnimator>? get animators;
|
||||
|
||||
List<DivBackground>? get background;
|
||||
Arr<DivBackground>? get background;
|
||||
|
||||
DivBorder get border;
|
||||
|
||||
// constraint: number >= 0
|
||||
Expression<int>? get columnSpan;
|
||||
|
||||
List<DivDisappearAction>? get disappearActions;
|
||||
Arr<DivDisappearAction>? get disappearActions;
|
||||
|
||||
List<DivExtension>? get extensions;
|
||||
Arr<DivExtension>? get extensions;
|
||||
|
||||
DivFocus? get focus;
|
||||
|
||||
List<DivFunction>? get functions;
|
||||
Arr<DivFunction>? get functions;
|
||||
|
||||
// default value: const DivSize.divWrapContentSize(DivWrapContentSize(),)
|
||||
DivSize get height;
|
||||
@@ -68,9 +68,9 @@ abstract class DivBase extends Resolvable {
|
||||
// constraint: number >= 0
|
||||
Expression<int>? get rowSpan;
|
||||
|
||||
List<DivAction>? get selectedActions;
|
||||
Arr<DivAction>? get selectedActions;
|
||||
|
||||
List<DivTooltip>? get tooltips;
|
||||
Arr<DivTooltip>? get tooltips;
|
||||
|
||||
DivTransform get transform;
|
||||
|
||||
@@ -81,18 +81,18 @@ abstract class DivBase extends Resolvable {
|
||||
DivAppearanceTransition? get transitionOut;
|
||||
|
||||
// at least 1 elements
|
||||
List<DivTransitionTrigger>? get transitionTriggers;
|
||||
Arr<DivTransitionTrigger>? get transitionTriggers;
|
||||
|
||||
List<DivTrigger>? get variableTriggers;
|
||||
Arr<DivTrigger>? get variableTriggers;
|
||||
|
||||
List<DivVariable>? get variables;
|
||||
Arr<DivVariable>? get variables;
|
||||
|
||||
// default value: DivVisibility.visible
|
||||
Expression<DivVisibility> get visibility;
|
||||
|
||||
DivVisibilityAction? get visibilityAction;
|
||||
|
||||
List<DivVisibilityAction>? get visibilityActions;
|
||||
Arr<DivVisibilityAction>? get visibilityActions;
|
||||
|
||||
// default value: const DivSize.divMatchParentSize(DivMatchParentSize(),)
|
||||
DivSize get width;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
|
||||
enum DivBlendMode implements Resolvable {
|
||||
sourceIn('source_in'),
|
||||
@@ -96,7 +96,12 @@ enum DivBlendMode implements Resolvable {
|
||||
return DivBlendMode.screen;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivBlendMode: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Gaussian image blur.
|
||||
@@ -35,11 +35,15 @@ class DivBlur extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivBlur(
|
||||
radius: safeParseIntExpr(
|
||||
json['radius'],
|
||||
)!,
|
||||
radius: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['radius'],
|
||||
),
|
||||
name: 'radius',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import 'package:divkit/src/schema/div_corners_radius.dart';
|
||||
import 'package:divkit/src/schema/div_shadow.dart';
|
||||
import 'package:divkit/src/schema/div_stroke.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Stroke around the element.
|
||||
@@ -70,21 +70,28 @@ class DivBorder extends Resolvable with EquatableMixin {
|
||||
cornerRadius: safeParseIntExpr(
|
||||
json['corner_radius'],
|
||||
),
|
||||
cornersRadius: safeParseObj(
|
||||
DivCornersRadius.fromJson(json['corners_radius']),
|
||||
cornersRadius: safeParseObject(
|
||||
json['corners_radius'],
|
||||
parse: DivCornersRadius.fromJson,
|
||||
),
|
||||
hasShadow: safeParseBoolExpr(
|
||||
json['has_shadow'],
|
||||
fallback: false,
|
||||
)!,
|
||||
shadow: safeParseObj(
|
||||
DivShadow.fromJson(json['shadow']),
|
||||
hasShadow: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['has_shadow'],
|
||||
fallback: false,
|
||||
),
|
||||
name: 'has_shadow',
|
||||
),
|
||||
stroke: safeParseObj(
|
||||
DivStroke.fromJson(json['stroke']),
|
||||
shadow: safeParseObject(
|
||||
json['shadow'],
|
||||
parse: DivShadow.fromJson,
|
||||
),
|
||||
stroke: safeParseObject(
|
||||
json['stroke'],
|
||||
parse: DivStroke.fromJson,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:divkit/src/schema/div_animation_interpolator.dart';
|
||||
import 'package:divkit/src/schema/div_transition_base.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Element position and size change animation.
|
||||
@@ -59,21 +59,31 @@ class DivChangeBoundsTransition extends Resolvable
|
||||
}
|
||||
try {
|
||||
return DivChangeBoundsTransition(
|
||||
duration: safeParseIntExpr(
|
||||
json['duration'],
|
||||
fallback: 200,
|
||||
)!,
|
||||
interpolator: safeParseStrEnumExpr(
|
||||
json['interpolator'],
|
||||
parse: DivAnimationInterpolator.fromJson,
|
||||
fallback: DivAnimationInterpolator.easeInOut,
|
||||
)!,
|
||||
startDelay: safeParseIntExpr(
|
||||
json['start_delay'],
|
||||
fallback: 0,
|
||||
)!,
|
||||
duration: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['duration'],
|
||||
fallback: 200,
|
||||
),
|
||||
name: 'duration',
|
||||
),
|
||||
interpolator: reqVProp<DivAnimationInterpolator>(
|
||||
safeParseStrEnumExpr(
|
||||
json['interpolator'],
|
||||
parse: DivAnimationInterpolator.fromJson,
|
||||
fallback: DivAnimationInterpolator.easeInOut,
|
||||
),
|
||||
name: 'interpolator',
|
||||
),
|
||||
startDelay: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['start_delay'],
|
||||
fallback: 0,
|
||||
),
|
||||
name: 'start_delay',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_change_transition.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Animations.
|
||||
@@ -14,7 +14,7 @@ class DivChangeSetTransition extends Resolvable with EquatableMixin {
|
||||
|
||||
/// List of animations.
|
||||
// at least 1 elements
|
||||
final List<DivChangeTransition> items;
|
||||
final Arr<DivChangeTransition> items;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -22,7 +22,7 @@ class DivChangeSetTransition extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
DivChangeSetTransition copyWith({
|
||||
List<DivChangeTransition>? items,
|
||||
Arr<DivChangeTransition>? items,
|
||||
}) =>
|
||||
DivChangeSetTransition(
|
||||
items: items ?? this.items,
|
||||
@@ -36,16 +36,21 @@ class DivChangeSetTransition extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivChangeSetTransition(
|
||||
items: safeParseObj(
|
||||
safeListMap(
|
||||
items: reqProp<Arr<DivChangeTransition>>(
|
||||
safeParseObjects(
|
||||
json['items'],
|
||||
(v) => safeParseObj(
|
||||
DivChangeTransition.fromJson(v),
|
||||
)!,
|
||||
(v) => reqProp<DivChangeTransition>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivChangeTransition.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
)!,
|
||||
name: 'items',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:divkit/src/schema/div_change_bounds_transition.dart';
|
||||
import 'package:divkit/src/schema/div_change_set_transition.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class DivChangeTransition extends Resolvable with EquatableMixin {
|
||||
@@ -87,7 +87,7 @@ class DivChangeTransition extends Resolvable with EquatableMixin {
|
||||
);
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import 'package:divkit/src/schema/div_fixed_size.dart';
|
||||
import 'package:divkit/src/schema/div_stroke.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Circle.
|
||||
@@ -60,19 +60,25 @@ class DivCircleShape extends Resolvable with EquatableMixin {
|
||||
backgroundColor: safeParseColorExpr(
|
||||
json['background_color'],
|
||||
),
|
||||
radius: safeParseObj(
|
||||
DivFixedSize.fromJson(json['radius']),
|
||||
fallback: const DivFixedSize(
|
||||
value: ValueExpression(
|
||||
10,
|
||||
radius: reqProp<DivFixedSize>(
|
||||
safeParseObject(
|
||||
json['radius'],
|
||||
parse: DivFixedSize.fromJson,
|
||||
fallback: const DivFixedSize(
|
||||
value: ValueExpression(
|
||||
10,
|
||||
),
|
||||
),
|
||||
),
|
||||
)!,
|
||||
stroke: safeParseObj(
|
||||
DivStroke.fromJson(json['stroke']),
|
||||
name: 'radius',
|
||||
),
|
||||
stroke: safeParseObject(
|
||||
json['stroke'],
|
||||
parse: DivStroke.fromJson,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div_edge_insets.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Cloud text background. Lines draws a rectangular background with the specified color and rounded corners.
|
||||
/// Cloud-style text background. Rows have a rectangular background in the specified color with rounded corners.
|
||||
class DivCloudBackground extends Resolvable with EquatableMixin {
|
||||
const DivCloudBackground({
|
||||
required this.color,
|
||||
@@ -21,7 +21,7 @@ class DivCloudBackground extends Resolvable with EquatableMixin {
|
||||
// constraint: number >= 0
|
||||
final Expression<int> cornerRadius;
|
||||
|
||||
/// Margins between line bounds and background.
|
||||
/// Margins between the row border and background border.
|
||||
final DivEdgeInsets paddings;
|
||||
|
||||
@override
|
||||
@@ -50,18 +50,29 @@ class DivCloudBackground extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivCloudBackground(
|
||||
color: safeParseColorExpr(
|
||||
json['color'],
|
||||
)!,
|
||||
cornerRadius: safeParseIntExpr(
|
||||
json['corner_radius'],
|
||||
)!,
|
||||
paddings: safeParseObj(
|
||||
DivEdgeInsets.fromJson(json['paddings']),
|
||||
fallback: const DivEdgeInsets(),
|
||||
)!,
|
||||
color: reqVProp<Color>(
|
||||
safeParseColorExpr(
|
||||
json['color'],
|
||||
),
|
||||
name: 'color',
|
||||
),
|
||||
cornerRadius: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['corner_radius'],
|
||||
),
|
||||
name: 'corner_radius',
|
||||
),
|
||||
paddings: reqProp<DivEdgeInsets>(
|
||||
safeParseObject(
|
||||
json['paddings'],
|
||||
parse: DivEdgeInsets.fromJson,
|
||||
fallback: const DivEdgeInsets(),
|
||||
),
|
||||
name: 'paddings',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated code. Do not modify.
|
||||
|
||||
import 'package:divkit/src/schema/div.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class DivCollectionItemBuilder extends Resolvable with EquatableMixin {
|
||||
@@ -12,7 +12,7 @@ class DivCollectionItemBuilder extends Resolvable with EquatableMixin {
|
||||
});
|
||||
|
||||
/// Data that will be used to create collection elements.
|
||||
final Expression<List<dynamic>> data;
|
||||
final Expression<Arr> data;
|
||||
|
||||
/// Name for accessing the next `data` element in the prototype. Working with this element is the same as with dictionaries.
|
||||
// default value: "it"
|
||||
@@ -20,7 +20,7 @@ class DivCollectionItemBuilder extends Resolvable with EquatableMixin {
|
||||
|
||||
/// Array of `div` elements from which the collection elements will be created.
|
||||
// at least 1 elements
|
||||
final List<DivCollectionItemBuilderPrototype> prototypes;
|
||||
final Arr<DivCollectionItemBuilderPrototype> prototypes;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -30,9 +30,9 @@ class DivCollectionItemBuilder extends Resolvable with EquatableMixin {
|
||||
];
|
||||
|
||||
DivCollectionItemBuilder copyWith({
|
||||
Expression<List<dynamic>>? data,
|
||||
Expression<Arr>? data,
|
||||
String? dataElementName,
|
||||
List<DivCollectionItemBuilderPrototype>? prototypes,
|
||||
Arr<DivCollectionItemBuilderPrototype>? prototypes,
|
||||
}) =>
|
||||
DivCollectionItemBuilder(
|
||||
data: data ?? this.data,
|
||||
@@ -48,23 +48,34 @@ class DivCollectionItemBuilder extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivCollectionItemBuilder(
|
||||
data: safeParseListExpr(
|
||||
json['data'],
|
||||
)!,
|
||||
dataElementName: safeParseStr(
|
||||
json['data_element_name']?.toString(),
|
||||
fallback: "it",
|
||||
)!,
|
||||
prototypes: safeParseObj(
|
||||
safeListMap(
|
||||
json['prototypes'],
|
||||
(v) => safeParseObj(
|
||||
DivCollectionItemBuilderPrototype.fromJson(v),
|
||||
)!,
|
||||
data: reqVProp<Arr>(
|
||||
safeParseListExpr(
|
||||
json['data'],
|
||||
),
|
||||
)!,
|
||||
name: 'data',
|
||||
),
|
||||
dataElementName: reqProp<String>(
|
||||
safeParseStr(
|
||||
json['data_element_name'],
|
||||
fallback: "it",
|
||||
),
|
||||
name: 'data_element_name',
|
||||
),
|
||||
prototypes: reqProp<Arr<DivCollectionItemBuilderPrototype>>(
|
||||
safeParseObjects(
|
||||
json['prototypes'],
|
||||
(v) => reqProp<DivCollectionItemBuilderPrototype>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivCollectionItemBuilderPrototype.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
name: 'prototypes',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -72,7 +83,7 @@ class DivCollectionItemBuilder extends Resolvable with EquatableMixin {
|
||||
@override
|
||||
DivCollectionItemBuilder resolve(DivVariableContext context) {
|
||||
data.resolve(context);
|
||||
safeListResolve(prototypes, (v) => v.resolve(context));
|
||||
tryResolveList(prototypes, (v) => v.resolve(context));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -120,18 +131,26 @@ class DivCollectionItemBuilderPrototype extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivCollectionItemBuilderPrototype(
|
||||
div: safeParseObj(
|
||||
Div.fromJson(json['div']),
|
||||
)!,
|
||||
id: safeParseStrExpr(
|
||||
json['id']?.toString(),
|
||||
div: reqProp<Div>(
|
||||
safeParseObject(
|
||||
json['div'],
|
||||
parse: Div.fromJson,
|
||||
),
|
||||
name: 'div',
|
||||
),
|
||||
id: safeParseStrExpr(
|
||||
json['id'],
|
||||
),
|
||||
selector: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['selector'],
|
||||
fallback: true,
|
||||
),
|
||||
name: 'selector',
|
||||
),
|
||||
selector: safeParseBoolExpr(
|
||||
json['selector'],
|
||||
fallback: true,
|
||||
)!,
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:divkit/src/schema/div_animation_interpolator.dart';
|
||||
import 'package:divkit/src/schema/div_animator_base.dart';
|
||||
import 'package:divkit/src/schema/div_count.dart';
|
||||
import 'package:divkit/src/schema/div_fixed_count.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Color animator.
|
||||
@@ -35,9 +35,9 @@ class DivColorAnimator extends Resolvable
|
||||
|
||||
static const type = "color_animator";
|
||||
|
||||
/// Actions to be performed if the animator is canceled. For example, when a command with the type `animator_stop` is received.
|
||||
/// Actions performed when the animation is canceled. For example, when a command with the 'animator_stop' type is received.
|
||||
@override
|
||||
final List<DivAction>? cancelActions;
|
||||
final Arr<DivAction>? cancelActions;
|
||||
|
||||
/// Animation direction. Determines whether the animation should be played forward, backward, or alternate between forward and backward.
|
||||
// default value: DivAnimationDirection.normal
|
||||
@@ -49,9 +49,9 @@ class DivColorAnimator extends Resolvable
|
||||
@override
|
||||
final Expression<int> duration;
|
||||
|
||||
/// Actions to be performed after the animator finishes.
|
||||
/// Actions when the animation is completed.
|
||||
@override
|
||||
final List<DivAction>? endActions;
|
||||
final Arr<DivAction>? endActions;
|
||||
|
||||
/// The value the variable will have when the animation ends.
|
||||
final Expression<Color> endValue;
|
||||
@@ -98,10 +98,10 @@ class DivColorAnimator extends Resolvable
|
||||
];
|
||||
|
||||
DivColorAnimator copyWith({
|
||||
List<DivAction>? Function()? cancelActions,
|
||||
Arr<DivAction>? Function()? cancelActions,
|
||||
Expression<DivAnimationDirection>? direction,
|
||||
Expression<int>? duration,
|
||||
List<DivAction>? Function()? endActions,
|
||||
Arr<DivAction>? Function()? endActions,
|
||||
Expression<Color>? endValue,
|
||||
String? id,
|
||||
Expression<DivAnimationInterpolator>? interpolator,
|
||||
@@ -133,73 +133,101 @@ class DivColorAnimator extends Resolvable
|
||||
}
|
||||
try {
|
||||
return DivColorAnimator(
|
||||
cancelActions: safeParseObj(
|
||||
safeListMap(
|
||||
json['cancel_actions'],
|
||||
(v) => safeParseObj(
|
||||
DivAction.fromJson(v),
|
||||
)!,
|
||||
cancelActions: safeParseObjects(
|
||||
json['cancel_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
direction: safeParseStrEnumExpr(
|
||||
json['direction'],
|
||||
parse: DivAnimationDirection.fromJson,
|
||||
fallback: DivAnimationDirection.normal,
|
||||
)!,
|
||||
duration: safeParseIntExpr(
|
||||
json['duration'],
|
||||
)!,
|
||||
endActions: safeParseObj(
|
||||
safeListMap(
|
||||
json['end_actions'],
|
||||
(v) => safeParseObj(
|
||||
DivAction.fromJson(v),
|
||||
)!,
|
||||
direction: reqVProp<DivAnimationDirection>(
|
||||
safeParseStrEnumExpr(
|
||||
json['direction'],
|
||||
parse: DivAnimationDirection.fromJson,
|
||||
fallback: DivAnimationDirection.normal,
|
||||
),
|
||||
name: 'direction',
|
||||
),
|
||||
duration: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['duration'],
|
||||
),
|
||||
name: 'duration',
|
||||
),
|
||||
endActions: safeParseObjects(
|
||||
json['end_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
endValue: safeParseColorExpr(
|
||||
json['end_value'],
|
||||
)!,
|
||||
id: safeParseStr(
|
||||
json['id']?.toString(),
|
||||
)!,
|
||||
interpolator: safeParseStrEnumExpr(
|
||||
json['interpolator'],
|
||||
parse: DivAnimationInterpolator.fromJson,
|
||||
fallback: DivAnimationInterpolator.linear,
|
||||
)!,
|
||||
repeatCount: safeParseObj(
|
||||
DivCount.fromJson(json['repeat_count']),
|
||||
fallback: const DivCount.divFixedCount(
|
||||
DivFixedCount(
|
||||
value: ValueExpression(
|
||||
1,
|
||||
endValue: reqVProp<Color>(
|
||||
safeParseColorExpr(
|
||||
json['end_value'],
|
||||
),
|
||||
name: 'end_value',
|
||||
),
|
||||
id: reqProp<String>(
|
||||
safeParseStr(
|
||||
json['id'],
|
||||
),
|
||||
name: 'id',
|
||||
),
|
||||
interpolator: reqVProp<DivAnimationInterpolator>(
|
||||
safeParseStrEnumExpr(
|
||||
json['interpolator'],
|
||||
parse: DivAnimationInterpolator.fromJson,
|
||||
fallback: DivAnimationInterpolator.linear,
|
||||
),
|
||||
name: 'interpolator',
|
||||
),
|
||||
repeatCount: reqProp<DivCount>(
|
||||
safeParseObject(
|
||||
json['repeat_count'],
|
||||
parse: DivCount.fromJson,
|
||||
fallback: const DivCount.divFixedCount(
|
||||
DivFixedCount(
|
||||
value: ValueExpression(
|
||||
1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)!,
|
||||
startDelay: safeParseIntExpr(
|
||||
json['start_delay'],
|
||||
fallback: 0,
|
||||
)!,
|
||||
name: 'repeat_count',
|
||||
),
|
||||
startDelay: reqVProp<int>(
|
||||
safeParseIntExpr(
|
||||
json['start_delay'],
|
||||
fallback: 0,
|
||||
),
|
||||
name: 'start_delay',
|
||||
),
|
||||
startValue: safeParseColorExpr(
|
||||
json['start_value'],
|
||||
),
|
||||
variableName: safeParseStr(
|
||||
json['variable_name']?.toString(),
|
||||
)!,
|
||||
variableName: reqProp<String>(
|
||||
safeParseStr(
|
||||
json['variable_name'],
|
||||
),
|
||||
name: 'variable_name',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
DivColorAnimator resolve(DivVariableContext context) {
|
||||
safeListResolve(cancelActions, (v) => v.resolve(context));
|
||||
tryResolveList(cancelActions, (v) => v.resolve(context));
|
||||
direction.resolve(context);
|
||||
duration.resolve(context);
|
||||
safeListResolve(endActions, (v) => v.resolve(context));
|
||||
tryResolveList(endActions, (v) => v.resolve(context));
|
||||
endValue.resolve(context);
|
||||
interpolator.resolve(context);
|
||||
repeatCount.resolve(context);
|
||||
|
||||
@@ -33,7 +33,7 @@ import 'package:divkit/src/schema/div_variable.dart';
|
||||
import 'package:divkit/src/schema/div_visibility.dart';
|
||||
import 'package:divkit/src/schema/div_visibility_action.dart';
|
||||
import 'package:divkit/src/schema/div_wrap_content_size.dart';
|
||||
import 'package:divkit/src/utils/parsing_utils.dart';
|
||||
import 'package:divkit/src/utils/parsing.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Container. It contains other elements and is responsible for their location. It is used to arrange elements vertically, horizontally, and with an overlay in a certain order, simulating the third dimension.
|
||||
@@ -77,6 +77,8 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
this.height = const DivSize.divWrapContentSize(
|
||||
DivWrapContentSize(),
|
||||
),
|
||||
this.hoverEndActions,
|
||||
this.hoverStartActions,
|
||||
this.id,
|
||||
this.itemBuilder,
|
||||
this.items,
|
||||
@@ -87,6 +89,8 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
this.margins = const DivEdgeInsets(),
|
||||
this.orientation = const ValueExpression(DivContainerOrientation.vertical),
|
||||
this.paddings = const DivEdgeInsets(),
|
||||
this.pressEndActions,
|
||||
this.pressStartActions,
|
||||
this.reuseId,
|
||||
this.rowSpan,
|
||||
this.selectedActions,
|
||||
@@ -121,7 +125,7 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
final DivAnimation actionAnimation;
|
||||
|
||||
/// Multiple actions when clicking on an element.
|
||||
final List<DivAction>? actions;
|
||||
final Arr<DivAction>? actions;
|
||||
|
||||
/// Horizontal alignment of an element inside the parent element.
|
||||
@override
|
||||
@@ -138,7 +142,7 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
|
||||
/// Declaration of animators that change variable values over time.
|
||||
@override
|
||||
final List<DivAnimator>? animators;
|
||||
final Arr<DivAnimator>? animators;
|
||||
|
||||
/// Fixed aspect ratio of the container. The element's height is calculated based on the width, ignoring the `height` parameter's value.
|
||||
/// On the web, support for the `aspect-ratio` CSS property is required to use this parameter.
|
||||
@@ -146,7 +150,7 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
|
||||
/// Element background. It can contain multiple layers.
|
||||
@override
|
||||
final List<DivBackground>? background;
|
||||
final Arr<DivBackground>? background;
|
||||
|
||||
/// Element stroke.
|
||||
@override
|
||||
@@ -171,14 +175,14 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
|
||||
/// Actions when an element disappears from the screen.
|
||||
@override
|
||||
final List<DivDisappearAction>? disappearActions;
|
||||
final Arr<DivDisappearAction>? disappearActions;
|
||||
|
||||
/// Action when double-clicking on an element.
|
||||
final List<DivAction>? doubletapActions;
|
||||
final Arr<DivAction>? doubletapActions;
|
||||
|
||||
/// Extensions for additional processing of an element. The list of extensions is given in [DivExtension](https://divkit.tech/docs/en/concepts/extensions).
|
||||
@override
|
||||
final List<DivExtension>? extensions;
|
||||
final Arr<DivExtension>? extensions;
|
||||
|
||||
/// Parameters when focusing on an element or losing focus.
|
||||
@override
|
||||
@@ -186,13 +190,19 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
|
||||
/// User functions.
|
||||
@override
|
||||
final List<DivFunction>? functions;
|
||||
final Arr<DivFunction>? functions;
|
||||
|
||||
/// Element height. For Android: if there is text in this or in a child element, specify height in `sp` to scale the element together with the text. To learn more about units of size measurement, see [Layout inside the card](https://divkit.tech/docs/en/concepts/layout).
|
||||
// default value: const DivSize.divWrapContentSize(DivWrapContentSize(),)
|
||||
@override
|
||||
final DivSize height;
|
||||
|
||||
/// Actions performed when hovering over an element ends. Available on platforms with pointing device support (mouse, stylus, etc).
|
||||
final Arr<DivAction>? hoverEndActions;
|
||||
|
||||
/// Actions performed when hovering over an element. Available on platforms with pointing device support (mouse, stylus, etc).
|
||||
final Arr<DivAction>? hoverStartActions;
|
||||
|
||||
/// Element ID. It must be unique within the root element. It is used as `accessibilityIdentifier` on iOS.
|
||||
@override
|
||||
final String? id;
|
||||
@@ -201,7 +211,7 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
final DivCollectionItemBuilder? itemBuilder;
|
||||
|
||||
/// Nested elements.
|
||||
final List<Div>? items;
|
||||
final Arr<Div>? items;
|
||||
|
||||
/// Element placement method. The `wrap` value transfers elements to the next line if they don't fit in the previous one. If the `wrap` value is set:
|
||||
/// • A separate line is allocated for each element along the main axis with the size value set to `match_parent`.
|
||||
@@ -217,7 +227,7 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
final DivContainerSeparator? lineSeparator;
|
||||
|
||||
/// Action when long-clicking an element. Doesn't work on devices that don't support touch gestures.
|
||||
final List<DivAction>? longtapActions;
|
||||
final Arr<DivAction>? longtapActions;
|
||||
|
||||
/// External margins from the element stroke.
|
||||
@override
|
||||
@@ -231,6 +241,12 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
@override
|
||||
final DivEdgeInsets paddings;
|
||||
|
||||
/// Actions performed when an element is released.
|
||||
final Arr<DivAction>? pressEndActions;
|
||||
|
||||
/// Actions performed when an element is pressed.
|
||||
final Arr<DivAction>? pressStartActions;
|
||||
|
||||
/// ID for the div object structure. Used to optimize block reuse. See [block reuse](https://divkit.tech/docs/en/concepts/reuse/reuse.md).
|
||||
@override
|
||||
final Expression<String>? reuseId;
|
||||
@@ -242,14 +258,14 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
|
||||
/// List of [actions](div-action.md) to be executed when selecting an element in [pager](div-pager.md).
|
||||
@override
|
||||
final List<DivAction>? selectedActions;
|
||||
final Arr<DivAction>? selectedActions;
|
||||
|
||||
/// Separator between elements along the main axis. Not used if the `orientation` parameter is set to `overlap`. Only new browsers are supported on the web (the `gap` property must be supported for flex blocks).
|
||||
final DivContainerSeparator? separator;
|
||||
|
||||
/// Tooltips linked to an element. A tooltip can be shown by `div-action://show_tooltip?id=`, hidden by `div-action://hide_tooltip?id=` where `id` — tooltip id.
|
||||
@override
|
||||
final List<DivTooltip>? tooltips;
|
||||
final Arr<DivTooltip>? tooltips;
|
||||
|
||||
/// Applies the passed transformation to the element. Content that doesn't fit into the original view area is cut off.
|
||||
@override
|
||||
@@ -270,15 +286,15 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
/// Animation starting triggers. Default value: `[state_change, visibility_change]`.
|
||||
// at least 1 elements
|
||||
@override
|
||||
final List<DivTransitionTrigger>? transitionTriggers;
|
||||
final Arr<DivTransitionTrigger>? transitionTriggers;
|
||||
|
||||
/// Triggers for changing variables within an element.
|
||||
@override
|
||||
final List<DivTrigger>? variableTriggers;
|
||||
final Arr<DivTrigger>? variableTriggers;
|
||||
|
||||
/// Declaration of variables that can be used within an element. Variables declared in this array can only be used within the element and its child elements.
|
||||
@override
|
||||
final List<DivVariable>? variables;
|
||||
final Arr<DivVariable>? variables;
|
||||
|
||||
/// Element visibility.
|
||||
// default value: DivVisibility.visible
|
||||
@@ -291,7 +307,7 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
|
||||
/// Actions when an element appears on the screen.
|
||||
@override
|
||||
final List<DivVisibilityAction>? visibilityActions;
|
||||
final Arr<DivVisibilityAction>? visibilityActions;
|
||||
|
||||
/// Element width.
|
||||
// default value: const DivSize.divMatchParentSize(DivMatchParentSize(),)
|
||||
@@ -321,6 +337,8 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
focus,
|
||||
functions,
|
||||
height,
|
||||
hoverEndActions,
|
||||
hoverStartActions,
|
||||
id,
|
||||
itemBuilder,
|
||||
items,
|
||||
@@ -331,6 +349,8 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
margins,
|
||||
orientation,
|
||||
paddings,
|
||||
pressEndActions,
|
||||
pressStartActions,
|
||||
reuseId,
|
||||
rowSpan,
|
||||
selectedActions,
|
||||
@@ -353,49 +373,53 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
DivAccessibility? accessibility,
|
||||
DivAction? Function()? action,
|
||||
DivAnimation? actionAnimation,
|
||||
List<DivAction>? Function()? actions,
|
||||
Arr<DivAction>? Function()? actions,
|
||||
Expression<DivAlignmentHorizontal>? Function()? alignmentHorizontal,
|
||||
Expression<DivAlignmentVertical>? Function()? alignmentVertical,
|
||||
Expression<double>? alpha,
|
||||
List<DivAnimator>? Function()? animators,
|
||||
Arr<DivAnimator>? Function()? animators,
|
||||
DivAspect? Function()? aspect,
|
||||
List<DivBackground>? Function()? background,
|
||||
Arr<DivBackground>? Function()? background,
|
||||
DivBorder? border,
|
||||
Expression<bool>? clipToBounds,
|
||||
Expression<int>? Function()? columnSpan,
|
||||
Expression<DivContentAlignmentHorizontal>? contentAlignmentHorizontal,
|
||||
Expression<DivContentAlignmentVertical>? contentAlignmentVertical,
|
||||
List<DivDisappearAction>? Function()? disappearActions,
|
||||
List<DivAction>? Function()? doubletapActions,
|
||||
List<DivExtension>? Function()? extensions,
|
||||
Arr<DivDisappearAction>? Function()? disappearActions,
|
||||
Arr<DivAction>? Function()? doubletapActions,
|
||||
Arr<DivExtension>? Function()? extensions,
|
||||
DivFocus? Function()? focus,
|
||||
List<DivFunction>? Function()? functions,
|
||||
Arr<DivFunction>? Function()? functions,
|
||||
DivSize? height,
|
||||
Arr<DivAction>? Function()? hoverEndActions,
|
||||
Arr<DivAction>? Function()? hoverStartActions,
|
||||
String? Function()? id,
|
||||
DivCollectionItemBuilder? Function()? itemBuilder,
|
||||
List<Div>? Function()? items,
|
||||
Arr<Div>? Function()? items,
|
||||
Expression<DivContainerLayoutMode>? layoutMode,
|
||||
DivLayoutProvider? Function()? layoutProvider,
|
||||
DivContainerSeparator? Function()? lineSeparator,
|
||||
List<DivAction>? Function()? longtapActions,
|
||||
Arr<DivAction>? Function()? longtapActions,
|
||||
DivEdgeInsets? margins,
|
||||
Expression<DivContainerOrientation>? orientation,
|
||||
DivEdgeInsets? paddings,
|
||||
Arr<DivAction>? Function()? pressEndActions,
|
||||
Arr<DivAction>? Function()? pressStartActions,
|
||||
Expression<String>? Function()? reuseId,
|
||||
Expression<int>? Function()? rowSpan,
|
||||
List<DivAction>? Function()? selectedActions,
|
||||
Arr<DivAction>? Function()? selectedActions,
|
||||
DivContainerSeparator? Function()? separator,
|
||||
List<DivTooltip>? Function()? tooltips,
|
||||
Arr<DivTooltip>? Function()? tooltips,
|
||||
DivTransform? transform,
|
||||
DivChangeTransition? Function()? transitionChange,
|
||||
DivAppearanceTransition? Function()? transitionIn,
|
||||
DivAppearanceTransition? Function()? transitionOut,
|
||||
List<DivTransitionTrigger>? Function()? transitionTriggers,
|
||||
List<DivTrigger>? Function()? variableTriggers,
|
||||
List<DivVariable>? Function()? variables,
|
||||
Arr<DivTransitionTrigger>? Function()? transitionTriggers,
|
||||
Arr<DivTrigger>? Function()? variableTriggers,
|
||||
Arr<DivVariable>? Function()? variables,
|
||||
Expression<DivVisibility>? visibility,
|
||||
DivVisibilityAction? Function()? visibilityAction,
|
||||
List<DivVisibilityAction>? Function()? visibilityActions,
|
||||
Arr<DivVisibilityAction>? Function()? visibilityActions,
|
||||
DivSize? width,
|
||||
}) =>
|
||||
DivContainer(
|
||||
@@ -430,6 +454,12 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
focus: focus != null ? focus.call() : this.focus,
|
||||
functions: functions != null ? functions.call() : this.functions,
|
||||
height: height ?? this.height,
|
||||
hoverEndActions: hoverEndActions != null
|
||||
? hoverEndActions.call()
|
||||
: this.hoverEndActions,
|
||||
hoverStartActions: hoverStartActions != null
|
||||
? hoverStartActions.call()
|
||||
: this.hoverStartActions,
|
||||
id: id != null ? id.call() : this.id,
|
||||
itemBuilder:
|
||||
itemBuilder != null ? itemBuilder.call() : this.itemBuilder,
|
||||
@@ -446,6 +476,12 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
margins: margins ?? this.margins,
|
||||
orientation: orientation ?? this.orientation,
|
||||
paddings: paddings ?? this.paddings,
|
||||
pressEndActions: pressEndActions != null
|
||||
? pressEndActions.call()
|
||||
: this.pressEndActions,
|
||||
pressStartActions: pressStartActions != null
|
||||
? pressStartActions.call()
|
||||
: this.pressStartActions,
|
||||
reuseId: reuseId != null ? reuseId.call() : this.reuseId,
|
||||
rowSpan: rowSpan != null ? rowSpan.call() : this.rowSpan,
|
||||
selectedActions: selectedActions != null
|
||||
@@ -486,36 +522,46 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
}
|
||||
try {
|
||||
return DivContainer(
|
||||
accessibility: safeParseObj(
|
||||
DivAccessibility.fromJson(json['accessibility']),
|
||||
fallback: const DivAccessibility(),
|
||||
)!,
|
||||
action: safeParseObj(
|
||||
DivAction.fromJson(json['action']),
|
||||
accessibility: reqProp<DivAccessibility>(
|
||||
safeParseObject(
|
||||
json['accessibility'],
|
||||
parse: DivAccessibility.fromJson,
|
||||
fallback: const DivAccessibility(),
|
||||
),
|
||||
name: 'accessibility',
|
||||
),
|
||||
actionAnimation: safeParseObj(
|
||||
DivAnimation.fromJson(json['action_animation']),
|
||||
fallback: const DivAnimation(
|
||||
duration: ValueExpression(
|
||||
100,
|
||||
),
|
||||
endValue: ValueExpression(
|
||||
0.6,
|
||||
),
|
||||
name: ValueExpression(
|
||||
DivAnimationName.fade,
|
||||
),
|
||||
startValue: ValueExpression(
|
||||
1,
|
||||
action: safeParseObject(
|
||||
json['action'],
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
actionAnimation: reqProp<DivAnimation>(
|
||||
safeParseObject(
|
||||
json['action_animation'],
|
||||
parse: DivAnimation.fromJson,
|
||||
fallback: const DivAnimation(
|
||||
duration: ValueExpression(
|
||||
100,
|
||||
),
|
||||
endValue: ValueExpression(
|
||||
0.6,
|
||||
),
|
||||
name: ValueExpression(
|
||||
DivAnimationName.fade,
|
||||
),
|
||||
startValue: ValueExpression(
|
||||
1,
|
||||
),
|
||||
),
|
||||
),
|
||||
)!,
|
||||
actions: safeParseObj(
|
||||
safeListMap(
|
||||
json['actions'],
|
||||
(v) => safeParseObj(
|
||||
DivAction.fromJson(v),
|
||||
)!,
|
||||
name: 'action_animation',
|
||||
),
|
||||
actions: safeParseObjects(
|
||||
json['actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
alignmentHorizontal: safeParseStrEnumExpr(
|
||||
@@ -526,224 +572,329 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
json['alignment_vertical'],
|
||||
parse: DivAlignmentVertical.fromJson,
|
||||
),
|
||||
alpha: safeParseDoubleExpr(
|
||||
json['alpha'],
|
||||
fallback: 1.0,
|
||||
)!,
|
||||
animators: safeParseObj(
|
||||
safeListMap(
|
||||
json['animators'],
|
||||
(v) => safeParseObj(
|
||||
DivAnimator.fromJson(v),
|
||||
)!,
|
||||
alpha: reqVProp<double>(
|
||||
safeParseDoubleExpr(
|
||||
json['alpha'],
|
||||
fallback: 1.0,
|
||||
),
|
||||
name: 'alpha',
|
||||
),
|
||||
animators: safeParseObjects(
|
||||
json['animators'],
|
||||
(v) => reqProp<DivAnimator>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAnimator.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
aspect: safeParseObj(
|
||||
DivAspect.fromJson(json['aspect']),
|
||||
aspect: safeParseObject(
|
||||
json['aspect'],
|
||||
parse: DivAspect.fromJson,
|
||||
),
|
||||
background: safeParseObj(
|
||||
safeListMap(
|
||||
json['background'],
|
||||
(v) => safeParseObj(
|
||||
DivBackground.fromJson(v),
|
||||
)!,
|
||||
background: safeParseObjects(
|
||||
json['background'],
|
||||
(v) => reqProp<DivBackground>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivBackground.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
border: safeParseObj(
|
||||
DivBorder.fromJson(json['border']),
|
||||
fallback: const DivBorder(),
|
||||
)!,
|
||||
clipToBounds: safeParseBoolExpr(
|
||||
json['clip_to_bounds'],
|
||||
fallback: true,
|
||||
)!,
|
||||
border: reqProp<DivBorder>(
|
||||
safeParseObject(
|
||||
json['border'],
|
||||
parse: DivBorder.fromJson,
|
||||
fallback: const DivBorder(),
|
||||
),
|
||||
name: 'border',
|
||||
),
|
||||
clipToBounds: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['clip_to_bounds'],
|
||||
fallback: true,
|
||||
),
|
||||
name: 'clip_to_bounds',
|
||||
),
|
||||
columnSpan: safeParseIntExpr(
|
||||
json['column_span'],
|
||||
),
|
||||
contentAlignmentHorizontal: safeParseStrEnumExpr(
|
||||
json['content_alignment_horizontal'],
|
||||
parse: DivContentAlignmentHorizontal.fromJson,
|
||||
fallback: DivContentAlignmentHorizontal.start,
|
||||
)!,
|
||||
contentAlignmentVertical: safeParseStrEnumExpr(
|
||||
json['content_alignment_vertical'],
|
||||
parse: DivContentAlignmentVertical.fromJson,
|
||||
fallback: DivContentAlignmentVertical.top,
|
||||
)!,
|
||||
disappearActions: safeParseObj(
|
||||
safeListMap(
|
||||
json['disappear_actions'],
|
||||
(v) => safeParseObj(
|
||||
DivDisappearAction.fromJson(v),
|
||||
)!,
|
||||
contentAlignmentHorizontal: reqVProp<DivContentAlignmentHorizontal>(
|
||||
safeParseStrEnumExpr(
|
||||
json['content_alignment_horizontal'],
|
||||
parse: DivContentAlignmentHorizontal.fromJson,
|
||||
fallback: DivContentAlignmentHorizontal.start,
|
||||
),
|
||||
name: 'content_alignment_horizontal',
|
||||
),
|
||||
contentAlignmentVertical: reqVProp<DivContentAlignmentVertical>(
|
||||
safeParseStrEnumExpr(
|
||||
json['content_alignment_vertical'],
|
||||
parse: DivContentAlignmentVertical.fromJson,
|
||||
fallback: DivContentAlignmentVertical.top,
|
||||
),
|
||||
name: 'content_alignment_vertical',
|
||||
),
|
||||
disappearActions: safeParseObjects(
|
||||
json['disappear_actions'],
|
||||
(v) => reqProp<DivDisappearAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivDisappearAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
doubletapActions: safeParseObj(
|
||||
safeListMap(
|
||||
json['doubletap_actions'],
|
||||
(v) => safeParseObj(
|
||||
DivAction.fromJson(v),
|
||||
)!,
|
||||
doubletapActions: safeParseObjects(
|
||||
json['doubletap_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
extensions: safeParseObj(
|
||||
safeListMap(
|
||||
json['extensions'],
|
||||
(v) => safeParseObj(
|
||||
DivExtension.fromJson(v),
|
||||
)!,
|
||||
extensions: safeParseObjects(
|
||||
json['extensions'],
|
||||
(v) => reqProp<DivExtension>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivExtension.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
focus: safeParseObj(
|
||||
DivFocus.fromJson(json['focus']),
|
||||
focus: safeParseObject(
|
||||
json['focus'],
|
||||
parse: DivFocus.fromJson,
|
||||
),
|
||||
functions: safeParseObj(
|
||||
safeListMap(
|
||||
json['functions'],
|
||||
(v) => safeParseObj(
|
||||
DivFunction.fromJson(v),
|
||||
)!,
|
||||
functions: safeParseObjects(
|
||||
json['functions'],
|
||||
(v) => reqProp<DivFunction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivFunction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
height: safeParseObj(
|
||||
DivSize.fromJson(json['height']),
|
||||
fallback: const DivSize.divWrapContentSize(
|
||||
DivWrapContentSize(),
|
||||
height: reqProp<DivSize>(
|
||||
safeParseObject(
|
||||
json['height'],
|
||||
parse: DivSize.fromJson,
|
||||
fallback: const DivSize.divWrapContentSize(
|
||||
DivWrapContentSize(),
|
||||
),
|
||||
),
|
||||
)!,
|
||||
name: 'height',
|
||||
),
|
||||
hoverEndActions: safeParseObjects(
|
||||
json['hover_end_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
hoverStartActions: safeParseObjects(
|
||||
json['hover_start_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
id: safeParseStr(
|
||||
json['id']?.toString(),
|
||||
json['id'],
|
||||
),
|
||||
itemBuilder: safeParseObj(
|
||||
DivCollectionItemBuilder.fromJson(json['item_builder']),
|
||||
itemBuilder: safeParseObject(
|
||||
json['item_builder'],
|
||||
parse: DivCollectionItemBuilder.fromJson,
|
||||
),
|
||||
items: safeParseObj(
|
||||
safeListMap(
|
||||
json['items'],
|
||||
(v) => safeParseObj(
|
||||
Div.fromJson(v),
|
||||
)!,
|
||||
items: safeParseObjects(
|
||||
json['items'],
|
||||
(v) => reqProp<Div>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: Div.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
layoutMode: safeParseStrEnumExpr(
|
||||
json['layout_mode'],
|
||||
parse: DivContainerLayoutMode.fromJson,
|
||||
fallback: DivContainerLayoutMode.noWrap,
|
||||
)!,
|
||||
layoutProvider: safeParseObj(
|
||||
DivLayoutProvider.fromJson(json['layout_provider']),
|
||||
layoutMode: reqVProp<DivContainerLayoutMode>(
|
||||
safeParseStrEnumExpr(
|
||||
json['layout_mode'],
|
||||
parse: DivContainerLayoutMode.fromJson,
|
||||
fallback: DivContainerLayoutMode.noWrap,
|
||||
),
|
||||
name: 'layout_mode',
|
||||
),
|
||||
lineSeparator: safeParseObj(
|
||||
DivContainerSeparator.fromJson(json['line_separator']),
|
||||
layoutProvider: safeParseObject(
|
||||
json['layout_provider'],
|
||||
parse: DivLayoutProvider.fromJson,
|
||||
),
|
||||
longtapActions: safeParseObj(
|
||||
safeListMap(
|
||||
json['longtap_actions'],
|
||||
(v) => safeParseObj(
|
||||
DivAction.fromJson(v),
|
||||
)!,
|
||||
lineSeparator: safeParseObject(
|
||||
json['line_separator'],
|
||||
parse: DivContainerSeparator.fromJson,
|
||||
),
|
||||
longtapActions: safeParseObjects(
|
||||
json['longtap_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
margins: reqProp<DivEdgeInsets>(
|
||||
safeParseObject(
|
||||
json['margins'],
|
||||
parse: DivEdgeInsets.fromJson,
|
||||
fallback: const DivEdgeInsets(),
|
||||
),
|
||||
name: 'margins',
|
||||
),
|
||||
orientation: reqVProp<DivContainerOrientation>(
|
||||
safeParseStrEnumExpr(
|
||||
json['orientation'],
|
||||
parse: DivContainerOrientation.fromJson,
|
||||
fallback: DivContainerOrientation.vertical,
|
||||
),
|
||||
name: 'orientation',
|
||||
),
|
||||
paddings: reqProp<DivEdgeInsets>(
|
||||
safeParseObject(
|
||||
json['paddings'],
|
||||
parse: DivEdgeInsets.fromJson,
|
||||
fallback: const DivEdgeInsets(),
|
||||
),
|
||||
name: 'paddings',
|
||||
),
|
||||
pressEndActions: safeParseObjects(
|
||||
json['press_end_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
pressStartActions: safeParseObjects(
|
||||
json['press_start_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
margins: safeParseObj(
|
||||
DivEdgeInsets.fromJson(json['margins']),
|
||||
fallback: const DivEdgeInsets(),
|
||||
)!,
|
||||
orientation: safeParseStrEnumExpr(
|
||||
json['orientation'],
|
||||
parse: DivContainerOrientation.fromJson,
|
||||
fallback: DivContainerOrientation.vertical,
|
||||
)!,
|
||||
paddings: safeParseObj(
|
||||
DivEdgeInsets.fromJson(json['paddings']),
|
||||
fallback: const DivEdgeInsets(),
|
||||
)!,
|
||||
reuseId: safeParseStrExpr(
|
||||
json['reuse_id']?.toString(),
|
||||
json['reuse_id'],
|
||||
),
|
||||
rowSpan: safeParseIntExpr(
|
||||
json['row_span'],
|
||||
),
|
||||
selectedActions: safeParseObj(
|
||||
safeListMap(
|
||||
json['selected_actions'],
|
||||
(v) => safeParseObj(
|
||||
DivAction.fromJson(v),
|
||||
)!,
|
||||
selectedActions: safeParseObjects(
|
||||
json['selected_actions'],
|
||||
(v) => reqProp<DivAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
separator: safeParseObj(
|
||||
DivContainerSeparator.fromJson(json['separator']),
|
||||
separator: safeParseObject(
|
||||
json['separator'],
|
||||
parse: DivContainerSeparator.fromJson,
|
||||
),
|
||||
tooltips: safeParseObj(
|
||||
safeListMap(
|
||||
json['tooltips'],
|
||||
(v) => safeParseObj(
|
||||
DivTooltip.fromJson(v),
|
||||
)!,
|
||||
tooltips: safeParseObjects(
|
||||
json['tooltips'],
|
||||
(v) => reqProp<DivTooltip>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivTooltip.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
transform: safeParseObj(
|
||||
DivTransform.fromJson(json['transform']),
|
||||
fallback: const DivTransform(),
|
||||
)!,
|
||||
transitionChange: safeParseObj(
|
||||
DivChangeTransition.fromJson(json['transition_change']),
|
||||
transform: reqProp<DivTransform>(
|
||||
safeParseObject(
|
||||
json['transform'],
|
||||
parse: DivTransform.fromJson,
|
||||
fallback: const DivTransform(),
|
||||
),
|
||||
name: 'transform',
|
||||
),
|
||||
transitionIn: safeParseObj(
|
||||
DivAppearanceTransition.fromJson(json['transition_in']),
|
||||
transitionChange: safeParseObject(
|
||||
json['transition_change'],
|
||||
parse: DivChangeTransition.fromJson,
|
||||
),
|
||||
transitionOut: safeParseObj(
|
||||
DivAppearanceTransition.fromJson(json['transition_out']),
|
||||
transitionIn: safeParseObject(
|
||||
json['transition_in'],
|
||||
parse: DivAppearanceTransition.fromJson,
|
||||
),
|
||||
transitionTriggers: safeParseObj(
|
||||
safeListMap(
|
||||
json['transition_triggers'],
|
||||
(v) => safeParseStrEnum(
|
||||
transitionOut: safeParseObject(
|
||||
json['transition_out'],
|
||||
parse: DivAppearanceTransition.fromJson,
|
||||
),
|
||||
transitionTriggers: safeParseObjects(
|
||||
json['transition_triggers'],
|
||||
(v) => reqProp<DivTransitionTrigger>(
|
||||
safeParseStrEnum(
|
||||
v,
|
||||
parse: DivTransitionTrigger.fromJson,
|
||||
)!,
|
||||
),
|
||||
),
|
||||
),
|
||||
variableTriggers: safeParseObj(
|
||||
safeListMap(
|
||||
json['variable_triggers'],
|
||||
(v) => safeParseObj(
|
||||
DivTrigger.fromJson(v),
|
||||
)!,
|
||||
variableTriggers: safeParseObjects(
|
||||
json['variable_triggers'],
|
||||
(v) => reqProp<DivTrigger>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivTrigger.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
variables: safeParseObj(
|
||||
safeListMap(
|
||||
json['variables'],
|
||||
(v) => safeParseObj(
|
||||
DivVariable.fromJson(v),
|
||||
)!,
|
||||
variables: safeParseObjects(
|
||||
json['variables'],
|
||||
(v) => reqProp<DivVariable>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivVariable.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
visibility: safeParseStrEnumExpr(
|
||||
json['visibility'],
|
||||
parse: DivVisibility.fromJson,
|
||||
fallback: DivVisibility.visible,
|
||||
)!,
|
||||
visibilityAction: safeParseObj(
|
||||
DivVisibilityAction.fromJson(json['visibility_action']),
|
||||
visibility: reqVProp<DivVisibility>(
|
||||
safeParseStrEnumExpr(
|
||||
json['visibility'],
|
||||
parse: DivVisibility.fromJson,
|
||||
fallback: DivVisibility.visible,
|
||||
),
|
||||
name: 'visibility',
|
||||
),
|
||||
visibilityActions: safeParseObj(
|
||||
safeListMap(
|
||||
json['visibility_actions'],
|
||||
(v) => safeParseObj(
|
||||
DivVisibilityAction.fromJson(v),
|
||||
)!,
|
||||
visibilityAction: safeParseObject(
|
||||
json['visibility_action'],
|
||||
parse: DivVisibilityAction.fromJson,
|
||||
),
|
||||
visibilityActions: safeParseObjects(
|
||||
json['visibility_actions'],
|
||||
(v) => reqProp<DivVisibilityAction>(
|
||||
safeParseObject(
|
||||
v,
|
||||
parse: DivVisibilityAction.fromJson,
|
||||
),
|
||||
),
|
||||
),
|
||||
width: safeParseObj(
|
||||
DivSize.fromJson(json['width']),
|
||||
fallback: const DivSize.divMatchParentSize(
|
||||
DivMatchParentSize(),
|
||||
width: reqProp<DivSize>(
|
||||
safeParseObject(
|
||||
json['width'],
|
||||
parse: DivSize.fromJson,
|
||||
fallback: const DivSize.divMatchParentSize(
|
||||
DivMatchParentSize(),
|
||||
),
|
||||
),
|
||||
)!,
|
||||
name: 'width',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -753,47 +904,51 @@ class DivContainer extends Resolvable with EquatableMixin implements DivBase {
|
||||
accessibility.resolve(context);
|
||||
action?.resolve(context);
|
||||
actionAnimation.resolve(context);
|
||||
safeListResolve(actions, (v) => v.resolve(context));
|
||||
tryResolveList(actions, (v) => v.resolve(context));
|
||||
alignmentHorizontal?.resolve(context);
|
||||
alignmentVertical?.resolve(context);
|
||||
alpha.resolve(context);
|
||||
safeListResolve(animators, (v) => v.resolve(context));
|
||||
tryResolveList(animators, (v) => v.resolve(context));
|
||||
aspect?.resolve(context);
|
||||
safeListResolve(background, (v) => v.resolve(context));
|
||||
tryResolveList(background, (v) => v.resolve(context));
|
||||
border.resolve(context);
|
||||
clipToBounds.resolve(context);
|
||||
columnSpan?.resolve(context);
|
||||
contentAlignmentHorizontal.resolve(context);
|
||||
contentAlignmentVertical.resolve(context);
|
||||
safeListResolve(disappearActions, (v) => v.resolve(context));
|
||||
safeListResolve(doubletapActions, (v) => v.resolve(context));
|
||||
safeListResolve(extensions, (v) => v.resolve(context));
|
||||
tryResolveList(disappearActions, (v) => v.resolve(context));
|
||||
tryResolveList(doubletapActions, (v) => v.resolve(context));
|
||||
tryResolveList(extensions, (v) => v.resolve(context));
|
||||
focus?.resolve(context);
|
||||
safeListResolve(functions, (v) => v.resolve(context));
|
||||
tryResolveList(functions, (v) => v.resolve(context));
|
||||
height.resolve(context);
|
||||
tryResolveList(hoverEndActions, (v) => v.resolve(context));
|
||||
tryResolveList(hoverStartActions, (v) => v.resolve(context));
|
||||
itemBuilder?.resolve(context);
|
||||
layoutMode.resolve(context);
|
||||
layoutProvider?.resolve(context);
|
||||
lineSeparator?.resolve(context);
|
||||
safeListResolve(longtapActions, (v) => v.resolve(context));
|
||||
tryResolveList(longtapActions, (v) => v.resolve(context));
|
||||
margins.resolve(context);
|
||||
orientation.resolve(context);
|
||||
paddings.resolve(context);
|
||||
tryResolveList(pressEndActions, (v) => v.resolve(context));
|
||||
tryResolveList(pressStartActions, (v) => v.resolve(context));
|
||||
reuseId?.resolve(context);
|
||||
rowSpan?.resolve(context);
|
||||
safeListResolve(selectedActions, (v) => v.resolve(context));
|
||||
tryResolveList(selectedActions, (v) => v.resolve(context));
|
||||
separator?.resolve(context);
|
||||
safeListResolve(tooltips, (v) => v.resolve(context));
|
||||
tryResolveList(tooltips, (v) => v.resolve(context));
|
||||
transform.resolve(context);
|
||||
transitionChange?.resolve(context);
|
||||
transitionIn?.resolve(context);
|
||||
transitionOut?.resolve(context);
|
||||
safeListResolve(transitionTriggers, (v) => v.resolve(context));
|
||||
safeListResolve(variableTriggers, (v) => v.resolve(context));
|
||||
safeListResolve(variables, (v) => v.resolve(context));
|
||||
tryResolveList(transitionTriggers, (v) => v.resolve(context));
|
||||
tryResolveList(variableTriggers, (v) => v.resolve(context));
|
||||
tryResolveList(variables, (v) => v.resolve(context));
|
||||
visibility.resolve(context);
|
||||
visibilityAction?.resolve(context);
|
||||
safeListResolve(visibilityActions, (v) => v.resolve(context));
|
||||
tryResolveList(visibilityActions, (v) => v.resolve(context));
|
||||
width.resolve(context);
|
||||
return this;
|
||||
}
|
||||
@@ -858,27 +1013,45 @@ class DivContainerSeparator extends Resolvable with EquatableMixin {
|
||||
}
|
||||
try {
|
||||
return DivContainerSeparator(
|
||||
margins: safeParseObj(
|
||||
DivEdgeInsets.fromJson(json['margins']),
|
||||
fallback: const DivEdgeInsets(),
|
||||
)!,
|
||||
showAtEnd: safeParseBoolExpr(
|
||||
json['show_at_end'],
|
||||
fallback: false,
|
||||
)!,
|
||||
showAtStart: safeParseBoolExpr(
|
||||
json['show_at_start'],
|
||||
fallback: false,
|
||||
)!,
|
||||
showBetween: safeParseBoolExpr(
|
||||
json['show_between'],
|
||||
fallback: true,
|
||||
)!,
|
||||
style: safeParseObj(
|
||||
DivDrawable.fromJson(json['style']),
|
||||
)!,
|
||||
margins: reqProp<DivEdgeInsets>(
|
||||
safeParseObject(
|
||||
json['margins'],
|
||||
parse: DivEdgeInsets.fromJson,
|
||||
fallback: const DivEdgeInsets(),
|
||||
),
|
||||
name: 'margins',
|
||||
),
|
||||
showAtEnd: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['show_at_end'],
|
||||
fallback: false,
|
||||
),
|
||||
name: 'show_at_end',
|
||||
),
|
||||
showAtStart: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['show_at_start'],
|
||||
fallback: false,
|
||||
),
|
||||
name: 'show_at_start',
|
||||
),
|
||||
showBetween: reqVProp<bool>(
|
||||
safeParseBoolExpr(
|
||||
json['show_between'],
|
||||
fallback: true,
|
||||
),
|
||||
name: 'show_between',
|
||||
),
|
||||
style: reqProp<DivDrawable>(
|
||||
safeParseObject(
|
||||
json['style'],
|
||||
parse: DivDrawable.fromJson,
|
||||
),
|
||||
name: 'style',
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning("Parsing error", error: e, stackTrace: st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -955,7 +1128,12 @@ enum DivContainerOrientation implements Resolvable {
|
||||
return DivContainerOrientation.overlap;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivContainerOrientation: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1014,7 +1192,12 @@ enum DivContainerLayoutMode implements Resolvable {
|
||||
return DivContainerLayoutMode.wrap;
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
logger.warning(
|
||||
"Invalid type of DivContainerLayoutMode: $json",
|
||||
error: e,
|
||||
stackTrace: st,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user