loading.dart 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import 'package:fis_ui/define.dart';
  2. import 'package:fis_ui/values/icons.dart';
  3. import 'package:flutter/material.dart';
  4. import 'text_liquid_fill.dart';
  5. class LoadingWidget extends StatelessWidget implements FWidget {
  6. const LoadingWidget({
  7. Key? key,
  8. this.text,
  9. this.margin,
  10. this.backgroundColor = Colors.white,
  11. }) : super(key: key);
  12. final String? text;
  13. final EdgeInsetsGeometry? margin;
  14. final Color backgroundColor;
  15. @override
  16. Widget build(BuildContext context) {
  17. final child = TextLiquidFill(
  18. text: '',
  19. child: const Icon(FIcons.logo, size: 60),
  20. loadUntil: 1.0,
  21. waveColor: Theme.of(context).primaryColor,
  22. waveDuration: const Duration(milliseconds: 1500),
  23. loadDuration: const Duration(milliseconds: 1000),
  24. boxBackgroundColor: backgroundColor,
  25. boxWidth: 78.0,
  26. boxHeight: 78.0,
  27. loop: true,
  28. );
  29. final card = Card(
  30. color: backgroundColor,
  31. elevation: 0,
  32. shape: RoundedRectangleBorder(
  33. borderRadius: BorderRadius.circular(8),
  34. side: BorderSide(color: Colors.grey.shade400),
  35. ),
  36. child: Padding(
  37. padding: const EdgeInsets.only(left: 20, right: 32),
  38. child: Row(
  39. mainAxisSize: MainAxisSize.min,
  40. children: [
  41. child,
  42. if (text != null && text!.isNotEmpty) ...[
  43. const SizedBox(width: 8),
  44. Flexible(
  45. child: Text(
  46. text!,
  47. style: TextStyle(
  48. fontSize: 14,
  49. fontFamily:
  50. Theme.of(context).textTheme.displayLarge?.fontFamily,
  51. ),
  52. ),
  53. ),
  54. ]
  55. ],
  56. ),
  57. ),
  58. );
  59. if (margin == null) {
  60. return card;
  61. } else {
  62. return Container(
  63. child: card,
  64. margin: margin,
  65. );
  66. }
  67. }
  68. }