Commit 4b83683952480c6c204867a269c8fd9a4897a660

Authored by wdn127929
1 parent c4e334ad

按钮动画

... ... @@ -3,6 +3,8 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/notebook.dart';
import 'package:one_key/pages/notebook/spread_widget.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
... ... @@ -10,6 +12,7 @@ import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
/**
* 详细模式
... ... @@ -27,7 +30,9 @@ class NoteBookItemF extends StatefulWidget {
}
}
class NoteBookItemFState extends State<NoteBookItemF> {
class NoteBookItemFState extends State<NoteBookItemF>
with SingleTickerProviderStateMixin {
bool _large = false;
_onOperateClick() {
if (widget.notebook.operationText == "通知客户") {
// String _nameStr = '';
... ... @@ -69,10 +74,27 @@ class NoteBookItemFState extends State<NoteBookItemF> {
}
}
_updateSize(bool cando) {
if (!cando) {
return;
}
setState(() {
_large = !_large;
});
}
@override
Widget build(BuildContext context) {
// TODO: implement build
Notebook notebook = widget.notebook;
UserModel userModel = Provider.of<UserModel>(context, listen: false);
bool canDo = true;
if (userModel.user.role_name != '管理员' &&
userModel.user.role_name != '店长' &&
notebook.uid != "null" &&
notebook.uid != userModel.user.openid) {
canDo = false;
}
Color bgColor = notebook.status == "2" || notebook.status == "1"
? MyColours.color_438E93
... ... @@ -297,12 +319,127 @@ class NoteBookItemFState extends State<NoteBookItemF> {
],
),
),
Positioned(
right: ScreenUtil().setWidth(8),
child: Image.asset(
Utils.getImgPath(true ? 'ordered_open' : 'ordered_off'),
width: ScreenUtil().setWidth(80),
))
child: StatefulBuilder(builder: (context, state) {
// return ScaleAnimatedContent(
// child: InkWell(
// onTap: () {
// state(() {
// show = !show;
// });
// },
// child: Image.asset(
// Utils.getImgPath(show ? 'ordered_open' : 'ordered_off'),
// width: ScreenUtil().setWidth(80),
// )),
// show: show,
// );
return InkWell(
onTap: () => _updateSize(canDo),
child: AnimatedSize(
curve: Curves.easeIn,
duration: Duration(microseconds: 30000),
vsync: this,
child: _large
? Stack(
children: [
Container(
width: ScreenUtil()
.setWidth(232 * 2 + 8 * 2),
height: ScreenUtil().setWidth(80),
decoration: BoxDecoration(
color:
Color.fromRGBO(67, 142, 147, 0.2),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(16)),
)),
Positioned(
top: ScreenUtil().setWidth(8),
left: ScreenUtil().setWidth(8),
child: Container(
width: ScreenUtil().setWidth(232 * 2),
height: ScreenUtil().setWidth(32 * 2),
decoration: BoxDecoration(
color:
Color.fromRGBO(125, 174, 177, 1),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(8)),
),
padding: EdgeInsets.symmetric(
horizontal:
ScreenUtil().setWidth(16)),
child: Row(
children: [
Image.asset(
Utils.getImgPath(
'ordered_arrow_right'),
width:
ScreenUtil().setWidth(24 * 2),
),
HEmptyView(32),
RoundButton(
text: '到店',
width: ScreenUtil()
.setWidth(36 * 2),
height: ScreenUtil()
.setWidth(24 * 2),
gradientStart:
MyColours.color_ffffff,
gradientEnd:
MyColours.color_ffffff,
textColor:
MyColours.color_260101,
isBold: true,
fontSize: 28,
radius:
ScreenUtil().setWidth(8)),
HEmptyView(44),
RoundButton(
text: '离店',
width: ScreenUtil()
.setWidth(36 * 2),
height: ScreenUtil()
.setWidth(24 * 2),
gradientStart:
MyColours.color_ffffff,
gradientEnd:
MyColours.color_ffffff,
textColor:
MyColours.color_260101,
isBold: true,
fontSize: 28,
radius:
ScreenUtil().setWidth(8)),
HEmptyView(44),
Text(
'取消预订',
style: TextStyle(
decoration:
TextDecoration.underline,
color: MyColours.color_ffffff,
fontSize:
ScreenUtil().setSp(28),
fontWeight: FontWeight.bold),
)
],
),
))
],
)
: Image.asset(
Utils.getImgPath(
canDo ? 'ordered_open' : 'ordered_off'),
width: ScreenUtil().setWidth(80),
)));
}))
// Positioned(
// right: ScreenUtil().setWidth(8),
// child: Image.asset(
// Utils.getImgPath(true ? 'ordered_open' : 'ordered_off'),
// width: ScreenUtil().setWidth(80),
// ))
]);
// return Stack(
// children: [
... ...
... ... @@ -957,6 +957,7 @@ class NoteBookPageState extends State<NoteBookPage> {
bottom: ScreenUtil().setWidth(24)),
child: NoteBookItemF(
model.notebooks[index], index),
);
}, childCount: model.notebooks.length),
// itemExtent: ScreenUtil().setWidth(112),
... ...
import 'package:flutter/material.dart';
class ScaleAnimatedContent extends StatefulWidget {
final Widget child;
final bool show;
const ScaleAnimatedContent({Key key, this.child, this.show = false})
: super(key: key);
@override
ScaleAnimatedContentState createState() => ScaleAnimatedContentState();
}
class ScaleAnimatedContentState extends State<ScaleAnimatedContent>
with TickerProviderStateMixin {
AnimationController animationController;
Animation<double> animation;
@override
void initState() {
animationController = new AnimationController(
vsync: this,
duration: new Duration(milliseconds: 600),
);
// animationSlideUp = new Tween(begin: 0.0,end: 1.0).animate(animationController);
animation = Tween(begin: 0.0, end: 1.0).animate(animationController);
if (widget.show) {
animationController.forward();
}
super.initState();
}
@override
void didUpdateWidget(ScaleAnimatedContent oldWidget) {
if (widget != oldWidget) {
if (widget.show && !oldWidget.show) {
animationController.forward(from: 0.0);
} else if (!widget.show) {
animationController.reverse();
}
}
super.didUpdateWidget(oldWidget);
}
@override
Widget build(BuildContext context) {
return ScaleTransition(
scale: animation,
child: widget.child,
);
}
@override
void dispose() {
animationController.dispose();
super.dispose();
}
}
... ...
import 'package:flutter/material.dart';
class MyColours {
static const Color color_8EBBBE = Color(0xff8EBBBE);
static const Color color_A78E44 = Color(0xffA78E44);
static const Color color_260101 = Color(0xff260101);
static const Color color_ED7B2F = Color(0xffED7B2F);
... ...