基础库
 
 
 
 
 

88 wiersze
2.6 KiB

  1. import 'package:shimmer/shimmer.dart';
  2. import 'package:flutter/material.dart';
  3. ///
  4. /// 登陆页面的骨架屏
  5. ///
  6. class LoginPageSkeleton extends StatelessWidget {
  7. @override
  8. Widget build(BuildContext context) {
  9. return Scaffold(
  10. body: Container(
  11. padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
  12. width: double.infinity,
  13. height: double.infinity,
  14. child: Column(
  15. crossAxisAlignment: CrossAxisAlignment.center,
  16. children: <Widget>[
  17. Container(
  18. height: 230,
  19. child: Column(
  20. children: <Widget>[
  21. /// logn
  22. Padding(padding: const EdgeInsets.only(top: 60), child: _logo()),
  23. /// appName
  24. Padding(padding: const EdgeInsets.only(top: 12), child: _appName()),
  25. ],
  26. ),
  27. ),
  28. /// btn
  29. Padding(padding: const EdgeInsets.only(top: 50, left: 28, right: 28), child: _shimmerWidget(width: 320, height: 40, radius: 20)),
  30. Padding(padding: const EdgeInsets.only(top: 8, left: 28, right: 28), child: _shimmerWidget(width: 320, height: 40, radius: 20)),
  31. /// 协议
  32. Padding(padding: const EdgeInsets.only(top: 9, left: 28, right: 28), child: _shimmerWidget(width: 250, height: 14, radius: 0)),
  33. Expanded(
  34. child: Column(
  35. mainAxisAlignment: MainAxisAlignment.end,
  36. children: <Widget>[
  37. Padding(padding: const EdgeInsets.only(bottom: 18), child: _shimmerWidget(width: 78, height: 18, radius: 0)),
  38. ],
  39. ),
  40. ),
  41. ],
  42. ),
  43. ),
  44. );
  45. }
  46. Widget _logo() {
  47. return Shimmer.fromColors(
  48. baseColor: Colors.grey[300],
  49. highlightColor: Colors.grey[100],
  50. child: Container(
  51. height: 80,
  52. width: 80,
  53. decoration: BoxDecoration(borderRadius: BorderRadius.circular(15), color: Colors.white),
  54. ),
  55. );
  56. }
  57. Widget _appName() {
  58. return Shimmer.fromColors(
  59. baseColor: Colors.grey[300],
  60. highlightColor: Colors.grey[100],
  61. child: Container(
  62. width: 90,
  63. height: 22.5,
  64. color: Colors.white,
  65. ),
  66. );
  67. }
  68. Widget _shimmerWidget({double width, double height, double radius = 0}) {
  69. return Shimmer.fromColors(
  70. baseColor: Colors.grey[300],
  71. highlightColor: Colors.grey[100],
  72. child: Container(
  73. width: width,
  74. height: height,
  75. decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(radius)),
  76. ),
  77. );
  78. }
  79. }