divider_widget.dart 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import 'package:flutter/material.dart';
  2. import 'package:photos/theme/ente_theme.dart';
  3. enum DividerType {
  4. solid,
  5. menu,
  6. menuNoIcon,
  7. bottomBar,
  8. }
  9. class DividerWidget extends StatelessWidget {
  10. final DividerType dividerType;
  11. final Color bgColor;
  12. final bool divColorHasBlur;
  13. final EdgeInsets? padding;
  14. const DividerWidget({
  15. required this.dividerType,
  16. this.bgColor = Colors.transparent,
  17. this.divColorHasBlur = true,
  18. this.padding,
  19. super.key,
  20. });
  21. @override
  22. Widget build(BuildContext context) {
  23. final dividerColor = divColorHasBlur
  24. ? getEnteColorScheme(context).blurStrokeFaint
  25. : getEnteColorScheme(context).strokeFaint;
  26. if (dividerType == DividerType.solid) {
  27. return Container(
  28. color: getEnteColorScheme(context).strokeFaint,
  29. width: double.infinity,
  30. height: 1,
  31. );
  32. }
  33. if (dividerType == DividerType.bottomBar) {
  34. return Container(
  35. color: dividerColor,
  36. width: double.infinity,
  37. height: 1,
  38. );
  39. }
  40. return Container(
  41. color: bgColor,
  42. padding: padding ?? EdgeInsets.zero,
  43. child: Row(
  44. children: [
  45. SizedBox(
  46. width: dividerType == DividerType.menu
  47. ? 48
  48. : dividerType == DividerType.menuNoIcon
  49. ? 16
  50. : 0,
  51. height: 1,
  52. ),
  53. Expanded(
  54. child: Container(
  55. color: dividerColor,
  56. height: 1,
  57. width: double.infinity,
  58. ),
  59. ),
  60. ],
  61. ),
  62. );
  63. }
  64. }