Line data Source code
1 :
2 : import 'package:flutter/material.dart';
3 : import 'package:flutter/services.dart';
4 : import 'package:pal/src/ui/client/helpers/simple_helper/simple_helper.dart';
5 :
6 : class SimpleHelperLayout extends StatefulWidget {
7 : final SimpleHelperPage toaster;
8 : final DismissDirectionCallback onDismissed;
9 :
10 1 : SimpleHelperLayout({this.toaster, this.onDismissed, Key key})
11 1 : : super(key: key);
12 :
13 1 : @override
14 1 : SimpleHelperLayoutState createState() => SimpleHelperLayoutState();
15 : }
16 :
17 : class SimpleHelperLayoutState extends State<SimpleHelperLayout>
18 : with SingleTickerProviderStateMixin {
19 : // Offset firstEventPosition;
20 : // Tween<double> _blurTween = Tween(begin: 0.0, end: 4.0);
21 : // Tween<double> _opacityTween = Tween(begin: 0.0, end: 1.0);
22 : // Animation<double> _blurAnimation;
23 : // Animation<double> _opacityAnimation;
24 : // AnimationController _controller;
25 : // bool _isDismissibleVisible = true;
26 :
27 : final double padding = 32;
28 :
29 1 : @override
30 : void initState() {
31 1 : super.initState();
32 : // _controller = AnimationController(
33 : // vsync: this,
34 : // duration: Duration(milliseconds: 1300),
35 : // );
36 :
37 : // _blurAnimation = _blurTween.animate(_controller)
38 : // ..addListener(
39 : // () {
40 : // setState(() {});
41 : // },
42 : // );
43 : // _opacityAnimation = _opacityTween.animate(_controller)
44 : // ..addListener(
45 : // () {
46 : // setState(() {});
47 : // },
48 : // );
49 :
50 : // _controller.forward();
51 : }
52 :
53 0 : reverseAnimations() async {
54 : // Remove dismissible from tree before calling setState
55 : // _isDismissibleVisible = false;
56 : // _controller.reverse();
57 : // await Future.delayed(Duration(milliseconds: 2300));
58 : }
59 :
60 1 : @override
61 : Widget build(BuildContext context) {
62 1 : return Container(
63 : // backgroundColor: Colors.transparent,
64 1 : child: Stack(
65 1 : children: <Widget>[
66 : // BackdropFilter(
67 : // filter: ImageFilter.blur(
68 : // sigmaX: _blurAnimation.value,
69 : // sigmaY: _blurAnimation.value,
70 : // ),
71 : // child: Opacity(
72 : // opacity: _opacityAnimation.value,
73 : // child: Container(
74 : // color: Colors.black26,
75 : // ),
76 : // ),
77 : // ),
78 : // if (_isDismissibleVisible)
79 1 : Positioned(
80 1 : bottom: padding,
81 1 : left: padding,
82 1 : right: padding,
83 1 : child: _buildToaster(),
84 : ),
85 : // Positioned.fill(
86 : // child: Center(
87 : // child: _buildOnDismissFeedback(),
88 : // ))
89 : ],
90 : ),
91 : );
92 : }
93 :
94 : // AnimatedBuilder _buildOnDismissFeedback() {
95 : // return AnimatedBuilder(
96 : // animation: _opacityIconAnimation,
97 : // builder: (context, child) {
98 : // return Transform.scale(
99 : // scale: sin(_opacityIconAnimation.value * pi),
100 : // child: Opacity(
101 : // opacity: sin(_opacityIconAnimation.value * pi),
102 : // child: child,
103 : // ),
104 : // );
105 : // },
106 : // child: Icon(Icons.thumb_up, size: 200),
107 : // );
108 : // }
109 :
110 1 : Widget _buildToaster() {
111 1 : return Material(
112 : type: MaterialType.canvas,
113 : elevation: 0,
114 : color: Colors.transparent,
115 : shadowColor: Colors.transparent,
116 1 : child: Dismissible(
117 1 : key: ValueKey("toaster"),
118 2 : child: widget.toaster,
119 0 : onDismissed: (DismissDirection direction) {
120 0 : if (widget.onDismissed != null) {
121 : switch (direction) {
122 0 : case DismissDirection.startToEnd:
123 0 : HapticFeedback.heavyImpact();
124 : break;
125 0 : case DismissDirection.endToStart:
126 0 : HapticFeedback.heavyImpact();
127 : break;
128 : default:
129 : }
130 :
131 0 : widget.onDismissed(direction);
132 : }
133 : },
134 : ),
135 : );
136 : }
137 : }
|