walk_through.dart 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import 'package:flutter/material.dart';
  2. /// Description: guide页
  3. /// Time : 05/01/2023 Monday
  4. /// Author : liuyuqi.gov@msn.cn
  5. class Walkthrough extends StatefulWidget {
  6. final title;
  7. final content;
  8. final imageIcon;
  9. final imagecolor;
  10. /// 构造函数
  11. /// title: 标题
  12. /// content: 内容
  13. /// imageIcon: 图标
  14. /// imagecolor: 图标颜色
  15. Walkthrough(
  16. {this.title,
  17. this.content,
  18. this.imageIcon,
  19. this.imagecolor = Colors.redAccent});
  20. @override
  21. WalkthroughState createState() {
  22. return WalkthroughState();
  23. }
  24. }
  25. class WalkthroughState extends State<Walkthrough>
  26. with SingleTickerProviderStateMixin {
  27. late Animation animation;
  28. late AnimationController animationController;
  29. @override
  30. void initState() {
  31. super.initState();
  32. animationController =
  33. AnimationController(vsync: this, duration: Duration(milliseconds: 500));
  34. animation = Tween(begin: -250.0, end: 0.0).animate(
  35. CurvedAnimation(parent: animationController, curve: Curves.easeInOut));
  36. animation.addListener(() => setState(() {}));
  37. animationController.forward();
  38. }
  39. @override
  40. void dispose() {
  41. super.dispose();
  42. animationController.dispose();
  43. }
  44. @override
  45. Widget build(BuildContext context) {
  46. return Container(
  47. padding: const EdgeInsets.all(20.0),
  48. child: Material(
  49. animationDuration: Duration(milliseconds: 500),
  50. elevation: 2.0,
  51. borderRadius: BorderRadius.all(Radius.circular(5.0)),
  52. child: Column(
  53. mainAxisSize: MainAxisSize.min,
  54. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  55. children: <Widget>[
  56. Transform(
  57. transform: Matrix4.translationValues(animation.value, 0.0, 0.0),
  58. child: Text(
  59. widget.title,
  60. style: TextStyle(
  61. fontSize: 20.0,
  62. fontWeight: FontWeight.bold,
  63. color: Colors.black),
  64. ),
  65. ),
  66. Transform(
  67. transform: Matrix4.translationValues(animation.value, 0.0, 0.0),
  68. child: Text(widget.content,
  69. softWrap: true,
  70. textAlign: TextAlign.center,
  71. style: TextStyle(
  72. fontWeight: FontWeight.normal,
  73. fontSize: 15.0,
  74. color: Colors.black)),
  75. ),
  76. Icon(
  77. widget.imageIcon,
  78. size: 100.0,
  79. color: widget.imagecolor,
  80. )
  81. ],
  82. ),
  83. ),
  84. );
  85. }
  86. }