Commit 4b83683952480c6c204867a269c8fd9a4897a660

Authored by wdn127929
1 parent c4e334ad

按钮动画

@@ -3,6 +3,8 @@ import 'dart:ui'; @@ -3,6 +3,8 @@ import 'dart:ui';
3 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
4 import 'package:flutter_screenutil/flutter_screenutil.dart'; 4 import 'package:flutter_screenutil/flutter_screenutil.dart';
5 import 'package:one_key/models/notebook.dart'; 5 import 'package:one_key/models/notebook.dart';
  6 +import 'package:one_key/pages/notebook/spread_widget.dart';
  7 +import 'package:one_key/provider/user_model.dart';
6 import 'package:one_key/res/colors.dart'; 8 import 'package:one_key/res/colors.dart';
7 import 'package:one_key/route/navigator_util.dart'; 9 import 'package:one_key/route/navigator_util.dart';
8 import 'package:one_key/utils/utils.dart'; 10 import 'package:one_key/utils/utils.dart';
@@ -10,6 +12,7 @@ import 'package:one_key/widgets/MyDivider.dart'; @@ -10,6 +12,7 @@ import 'package:one_key/widgets/MyDivider.dart';
10 import 'package:one_key/widgets/h_empty_view.dart'; 12 import 'package:one_key/widgets/h_empty_view.dart';
11 import 'package:one_key/widgets/round_button.dart'; 13 import 'package:one_key/widgets/round_button.dart';
12 import 'package:one_key/widgets/v_empty_view.dart'; 14 import 'package:one_key/widgets/v_empty_view.dart';
  15 +import 'package:provider/provider.dart';
13 16
14 /** 17 /**
15 * 详细模式 18 * 详细模式
@@ -27,7 +30,9 @@ class NoteBookItemF extends StatefulWidget { @@ -27,7 +30,9 @@ class NoteBookItemF extends StatefulWidget {
27 } 30 }
28 } 31 }
29 32
30 -class NoteBookItemFState extends State<NoteBookItemF> { 33 +class NoteBookItemFState extends State<NoteBookItemF>
  34 + with SingleTickerProviderStateMixin {
  35 + bool _large = false;
31 _onOperateClick() { 36 _onOperateClick() {
32 if (widget.notebook.operationText == "通知客户") { 37 if (widget.notebook.operationText == "通知客户") {
33 // String _nameStr = ''; 38 // String _nameStr = '';
@@ -69,10 +74,27 @@ class NoteBookItemFState extends State<NoteBookItemF> { @@ -69,10 +74,27 @@ class NoteBookItemFState extends State<NoteBookItemF> {
69 } 74 }
70 } 75 }
71 76
  77 + _updateSize(bool cando) {
  78 + if (!cando) {
  79 + return;
  80 + }
  81 + setState(() {
  82 + _large = !_large;
  83 + });
  84 + }
  85 +
72 @override 86 @override
73 Widget build(BuildContext context) { 87 Widget build(BuildContext context) {
74 // TODO: implement build 88 // TODO: implement build
75 Notebook notebook = widget.notebook; 89 Notebook notebook = widget.notebook;
  90 + UserModel userModel = Provider.of<UserModel>(context, listen: false);
  91 + bool canDo = true;
  92 + if (userModel.user.role_name != '管理员' &&
  93 + userModel.user.role_name != '店长' &&
  94 + notebook.uid != "null" &&
  95 + notebook.uid != userModel.user.openid) {
  96 + canDo = false;
  97 + }
76 98
77 Color bgColor = notebook.status == "2" || notebook.status == "1" 99 Color bgColor = notebook.status == "2" || notebook.status == "1"
78 ? MyColours.color_438E93 100 ? MyColours.color_438E93
@@ -297,12 +319,127 @@ class NoteBookItemFState extends State<NoteBookItemF> { @@ -297,12 +319,127 @@ class NoteBookItemFState extends State<NoteBookItemF> {
297 ], 319 ],
298 ), 320 ),
299 ), 321 ),
  322 +
300 Positioned( 323 Positioned(
301 right: ScreenUtil().setWidth(8), 324 right: ScreenUtil().setWidth(8),
302 - child: Image.asset(  
303 - Utils.getImgPath(true ? 'ordered_open' : 'ordered_off'),  
304 - width: ScreenUtil().setWidth(80),  
305 - )) 325 + child: StatefulBuilder(builder: (context, state) {
  326 + // return ScaleAnimatedContent(
  327 + // child: InkWell(
  328 + // onTap: () {
  329 + // state(() {
  330 + // show = !show;
  331 + // });
  332 + // },
  333 + // child: Image.asset(
  334 + // Utils.getImgPath(show ? 'ordered_open' : 'ordered_off'),
  335 + // width: ScreenUtil().setWidth(80),
  336 + // )),
  337 + // show: show,
  338 + // );
  339 + return InkWell(
  340 + onTap: () => _updateSize(canDo),
  341 + child: AnimatedSize(
  342 + curve: Curves.easeIn,
  343 + duration: Duration(microseconds: 30000),
  344 + vsync: this,
  345 + child: _large
  346 + ? Stack(
  347 + children: [
  348 + Container(
  349 + width: ScreenUtil()
  350 + .setWidth(232 * 2 + 8 * 2),
  351 + height: ScreenUtil().setWidth(80),
  352 + decoration: BoxDecoration(
  353 + color:
  354 + Color.fromRGBO(67, 142, 147, 0.2),
  355 + borderRadius: BorderRadius.circular(
  356 + ScreenUtil().setWidth(16)),
  357 + )),
  358 + Positioned(
  359 + top: ScreenUtil().setWidth(8),
  360 + left: ScreenUtil().setWidth(8),
  361 + child: Container(
  362 + width: ScreenUtil().setWidth(232 * 2),
  363 + height: ScreenUtil().setWidth(32 * 2),
  364 + decoration: BoxDecoration(
  365 + color:
  366 + Color.fromRGBO(125, 174, 177, 1),
  367 + borderRadius: BorderRadius.circular(
  368 + ScreenUtil().setWidth(8)),
  369 + ),
  370 + padding: EdgeInsets.symmetric(
  371 + horizontal:
  372 + ScreenUtil().setWidth(16)),
  373 + child: Row(
  374 + children: [
  375 + Image.asset(
  376 + Utils.getImgPath(
  377 + 'ordered_arrow_right'),
  378 + width:
  379 + ScreenUtil().setWidth(24 * 2),
  380 + ),
  381 + HEmptyView(32),
  382 + RoundButton(
  383 + text: '到店',
  384 + width: ScreenUtil()
  385 + .setWidth(36 * 2),
  386 + height: ScreenUtil()
  387 + .setWidth(24 * 2),
  388 + gradientStart:
  389 + MyColours.color_ffffff,
  390 + gradientEnd:
  391 + MyColours.color_ffffff,
  392 + textColor:
  393 + MyColours.color_260101,
  394 + isBold: true,
  395 + fontSize: 28,
  396 + radius:
  397 + ScreenUtil().setWidth(8)),
  398 + HEmptyView(44),
  399 + RoundButton(
  400 + text: '离店',
  401 + width: ScreenUtil()
  402 + .setWidth(36 * 2),
  403 + height: ScreenUtil()
  404 + .setWidth(24 * 2),
  405 + gradientStart:
  406 + MyColours.color_ffffff,
  407 + gradientEnd:
  408 + MyColours.color_ffffff,
  409 + textColor:
  410 + MyColours.color_260101,
  411 + isBold: true,
  412 + fontSize: 28,
  413 + radius:
  414 + ScreenUtil().setWidth(8)),
  415 + HEmptyView(44),
  416 + Text(
  417 + '取消预订',
  418 + style: TextStyle(
  419 + decoration:
  420 + TextDecoration.underline,
  421 + color: MyColours.color_ffffff,
  422 + fontSize:
  423 + ScreenUtil().setSp(28),
  424 + fontWeight: FontWeight.bold),
  425 + )
  426 + ],
  427 + ),
  428 + ))
  429 + ],
  430 + )
  431 + : Image.asset(
  432 + Utils.getImgPath(
  433 + canDo ? 'ordered_open' : 'ordered_off'),
  434 + width: ScreenUtil().setWidth(80),
  435 + )));
  436 + }))
  437 + // Positioned(
  438 + // right: ScreenUtil().setWidth(8),
  439 + // child: Image.asset(
  440 + // Utils.getImgPath(true ? 'ordered_open' : 'ordered_off'),
  441 + // width: ScreenUtil().setWidth(80),
  442 + // ))
306 ]); 443 ]);
307 // return Stack( 444 // return Stack(
308 // children: [ 445 // children: [
@@ -957,6 +957,7 @@ class NoteBookPageState extends State<NoteBookPage> { @@ -957,6 +957,7 @@ class NoteBookPageState extends State<NoteBookPage> {
957 bottom: ScreenUtil().setWidth(24)), 957 bottom: ScreenUtil().setWidth(24)),
958 child: NoteBookItemF( 958 child: NoteBookItemF(
959 model.notebooks[index], index), 959 model.notebooks[index], index),
  960 +
960 ); 961 );
961 }, childCount: model.notebooks.length), 962 }, childCount: model.notebooks.length),
962 // itemExtent: ScreenUtil().setWidth(112), 963 // itemExtent: ScreenUtil().setWidth(112),
  1 +import 'package:flutter/material.dart';
  2 +class ScaleAnimatedContent extends StatefulWidget {
  3 + final Widget child;
  4 + final bool show;
  5 +
  6 + const ScaleAnimatedContent({Key key, this.child, this.show = false})
  7 + : super(key: key);
  8 +
  9 + @override
  10 + ScaleAnimatedContentState createState() => ScaleAnimatedContentState();
  11 +}
  12 +
  13 +class ScaleAnimatedContentState extends State<ScaleAnimatedContent>
  14 + with TickerProviderStateMixin {
  15 + AnimationController animationController;
  16 + Animation<double> animation;
  17 +
  18 + @override
  19 + void initState() {
  20 + animationController = new AnimationController(
  21 + vsync: this,
  22 + duration: new Duration(milliseconds: 600),
  23 + );
  24 +
  25 + // animationSlideUp = new Tween(begin: 0.0,end: 1.0).animate(animationController);
  26 + animation = Tween(begin: 0.0, end: 1.0).animate(animationController);
  27 +
  28 + if (widget.show) {
  29 + animationController.forward();
  30 + }
  31 +
  32 + super.initState();
  33 + }
  34 +
  35 + @override
  36 + void didUpdateWidget(ScaleAnimatedContent oldWidget) {
  37 + if (widget != oldWidget) {
  38 + if (widget.show && !oldWidget.show) {
  39 + animationController.forward(from: 0.0);
  40 + } else if (!widget.show) {
  41 + animationController.reverse();
  42 + }
  43 + }
  44 + super.didUpdateWidget(oldWidget);
  45 + }
  46 +
  47 + @override
  48 + Widget build(BuildContext context) {
  49 + return ScaleTransition(
  50 + scale: animation,
  51 + child: widget.child,
  52 + );
  53 + }
  54 +
  55 + @override
  56 + void dispose() {
  57 + animationController.dispose();
  58 + super.dispose();
  59 + }
  60 +}
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 2
3 class MyColours { 3 class MyColours {
  4 +
  5 + static const Color color_8EBBBE = Color(0xff8EBBBE);
4 static const Color color_A78E44 = Color(0xffA78E44); 6 static const Color color_A78E44 = Color(0xffA78E44);
5 static const Color color_260101 = Color(0xff260101); 7 static const Color color_260101 = Color(0xff260101);
6 static const Color color_ED7B2F = Color(0xffED7B2F); 8 static const Color color_ED7B2F = Color(0xffED7B2F);