bookshelf_cloud_widget.dart 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import 'package:flutter/material.dart';
  2. import 'package:shuqi/public.dart';
  3. class BookshelfCloudWidget extends AnimatedWidget {
  4. final double width;
  5. BookshelfCloudWidget({required Animation<double> animation, required this.width}) : super(listenable: animation);
  6. @override
  7. Widget build(BuildContext context) {
  8. var width = Screen.width;
  9. final Animation<double> animation = listenable as Animation<double>;
  10. return Container(
  11. width: width,
  12. height: width * 0.73,
  13. child: Stack(
  14. alignment: AlignmentDirectional.bottomStart,
  15. children: <Widget>[
  16. Positioned(
  17. bottom: -30,
  18. child: Image.asset(
  19. 'assets/img/bookshelf_cloud_0.png',
  20. fit: BoxFit.cover,
  21. width: width,
  22. ),
  23. ),
  24. Positioned(
  25. bottom: animation.value * -5,
  26. child: Opacity(
  27. opacity: animation.value,
  28. child: Image.asset(
  29. 'assets/img/bookshelf_cloud_1.png',
  30. fit: BoxFit.cover,
  31. width: width,
  32. ),
  33. ),
  34. ),
  35. Positioned(
  36. bottom: (1 - animation.value) * -10,
  37. child: Opacity(
  38. opacity: animation.value,
  39. child: Image.asset(
  40. 'assets/img/bookshelf_cloud_2.png',
  41. fit: BoxFit.cover,
  42. width: width,
  43. ),
  44. ),
  45. ),
  46. Positioned(
  47. bottom: (animation.value - 0.5).abs() * -15,
  48. child: Opacity(
  49. opacity: (1.0 - animation.value),
  50. child: Image.asset(
  51. 'assets/img/bookshelf_cloud_3.png',
  52. fit: BoxFit.cover,
  53. width: width,
  54. ),
  55. ),
  56. ),
  57. ],
  58. ),
  59. );
  60. }
  61. }