mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
Add no_animation type of animation
6384ef1c06d9997f4dfa35297044d7ea821700ab
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
## 0.2.0-pre
|
||||
|
||||
* Correct interpretation of dict in variables context
|
||||
* Add support no_animation type of animation
|
||||
* Add support of longtap actions
|
||||
* Remove dispose from public div-context
|
||||
* Provide DivContext in custom elements: you can use variables, actions, timers and states in
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:divkit/src/core/widgets/base/div_base_model.dart';
|
||||
import 'package:divkit/src/core/widgets/div_tap_action_emitter.dart';
|
||||
import 'package:divkit/src/generated_sources/div_action.dart';
|
||||
import 'package:divkit/src/generated_sources/div_animation.dart';
|
||||
import 'package:divkit/src/generated_sources/div_base.dart';
|
||||
import 'package:divkit/src/utils/div_focus_node.dart';
|
||||
import 'package:divkit/src/utils/size_converters.dart';
|
||||
@@ -11,11 +12,13 @@ class DivBaseWidget extends StatefulWidget {
|
||||
|
||||
final List<DivAction> actions;
|
||||
final List<DivAction> longtapActions;
|
||||
final DivAnimation? actionAnimation;
|
||||
|
||||
final Widget child;
|
||||
|
||||
DivBaseWidget({
|
||||
required this.data,
|
||||
this.actionAnimation,
|
||||
super.key,
|
||||
DivAction? action,
|
||||
List<DivAction>? actions,
|
||||
@@ -73,6 +76,7 @@ class _DivBaseWidgetState extends State<DivBaseWidget> {
|
||||
opacity: model.opacity,
|
||||
child: DivTapActionEmitter(
|
||||
actions: widget.actions,
|
||||
actionAnimation: widget.actionAnimation,
|
||||
longtapActions: widget.longtapActions,
|
||||
child: focusNode != null
|
||||
? AnimatedBuilder(
|
||||
|
||||
@@ -44,6 +44,7 @@ class _DivContainerWidgetState extends State<DivContainerWidget> {
|
||||
action: widget.data.action,
|
||||
actions: widget.data.actions,
|
||||
longtapActions: widget.data.longtapActions,
|
||||
actionAnimation: widget.data.actionAnimation,
|
||||
child: StreamBuilder<DivContainerModel>(
|
||||
stream: stream,
|
||||
builder: (context, snapshot) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:divkit/src/core/action/action.dart';
|
||||
import 'package:divkit/src/core/action/action_converter.dart';
|
||||
import 'package:divkit/src/core/protocol/div_context.dart';
|
||||
import 'package:divkit/src/generated_sources/div_animation.dart';
|
||||
import 'package:divkit/src/generated_sources/generated_sources.dart' as dto;
|
||||
import 'package:divkit/src/utils/provider.dart';
|
||||
import 'package:divkit/src/utils/tap_builder.dart';
|
||||
@@ -11,17 +12,20 @@ class DivTapActionModel with EquatableMixin {
|
||||
final List<DivAction> actions;
|
||||
final List<DivAction> longtapActions;
|
||||
final bool enabled;
|
||||
final bool enabledAnimation;
|
||||
|
||||
const DivTapActionModel({
|
||||
required this.actions,
|
||||
required this.longtapActions,
|
||||
required this.enabled,
|
||||
required this.enabledAnimation,
|
||||
});
|
||||
|
||||
static Stream<DivTapActionModel> from(
|
||||
BuildContext context,
|
||||
List<dto.DivAction> actions,
|
||||
List<dto.DivAction> longtapActions,
|
||||
dto.DivAnimation? divAnimation,
|
||||
) {
|
||||
final variables =
|
||||
DivKitProvider.watch<DivContext>(context)!.variableManager;
|
||||
@@ -47,10 +51,14 @@ class DivTapActionModel with EquatableMixin {
|
||||
}
|
||||
}
|
||||
|
||||
final animationName =
|
||||
await divAnimation?.name.resolveValue(context: context);
|
||||
|
||||
return DivTapActionModel(
|
||||
actions: a,
|
||||
longtapActions: la,
|
||||
enabled: a.isNotEmpty || la.isNotEmpty,
|
||||
enabledAnimation: !(animationName == DivAnimationName.noAnimation),
|
||||
);
|
||||
}).distinct();
|
||||
}
|
||||
@@ -58,6 +66,8 @@ class DivTapActionModel with EquatableMixin {
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
actions,
|
||||
longtapActions,
|
||||
enabledAnimation,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -65,6 +75,7 @@ class DivTapActionModel with EquatableMixin {
|
||||
class DivTapActionEmitter extends StatefulWidget {
|
||||
final List<dto.DivAction> actions;
|
||||
final List<dto.DivAction> longtapActions;
|
||||
final DivAnimation? actionAnimation;
|
||||
|
||||
final Widget child;
|
||||
|
||||
@@ -73,6 +84,7 @@ class DivTapActionEmitter extends StatefulWidget {
|
||||
required this.actions,
|
||||
required this.longtapActions,
|
||||
required this.child,
|
||||
required this.actionAnimation,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -92,6 +104,7 @@ class _DivTapActionEmitterState extends State<DivTapActionEmitter> {
|
||||
context,
|
||||
widget.actions,
|
||||
widget.longtapActions,
|
||||
widget.actionAnimation,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -104,6 +117,7 @@ class _DivTapActionEmitterState extends State<DivTapActionEmitter> {
|
||||
context,
|
||||
widget.actions,
|
||||
widget.longtapActions,
|
||||
widget.actionAnimation,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -130,6 +144,9 @@ class _DivTapActionEmitterState extends State<DivTapActionEmitter> {
|
||||
}
|
||||
},
|
||||
builder: (context, pressed, hovered, child) {
|
||||
if (!model.enabledAnimation) {
|
||||
return child;
|
||||
}
|
||||
double opacity = 1.0;
|
||||
if (pressed) {
|
||||
opacity = 0.6;
|
||||
|
||||
@@ -50,6 +50,7 @@ class _DivImageWidgetState extends State<DivImageWidget> {
|
||||
action: widget.data.action,
|
||||
actions: widget.data.actions,
|
||||
longtapActions: widget.data.longtapActions,
|
||||
actionAnimation: widget.data.actionAnimation,
|
||||
child: StreamBuilder<DivImageModel>(
|
||||
stream: stream,
|
||||
builder: (context, snapshot) {
|
||||
|
||||
@@ -42,6 +42,7 @@ class _DivTextWidgetState extends State<DivTextWidget> {
|
||||
action: widget.data.action,
|
||||
actions: widget.data.actions,
|
||||
longtapActions: widget.data.longtapActions,
|
||||
actionAnimation: widget.data.actionAnimation,
|
||||
child: StreamBuilder<DivTextModel>(
|
||||
stream: stream,
|
||||
builder: (context, snapshot) {
|
||||
|
||||
Reference in New Issue
Block a user