subscription_plan_widget.dart 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'package:flutter/material.dart';
  2. import 'package:photos/utils/data_util.dart';
  3. class SubscriptionPlanWidget extends StatelessWidget {
  4. const SubscriptionPlanWidget({
  5. Key key,
  6. @required this.storage,
  7. @required this.price,
  8. @required this.period,
  9. this.isActive = false,
  10. }) : super(key: key);
  11. final int storage;
  12. final String price;
  13. final String period;
  14. final bool isActive;
  15. String _displayPrice() {
  16. final result = price + (period.isNotEmpty ? " / " + period : "");
  17. return result.isNotEmpty ? result : "Trial plan";
  18. }
  19. @override
  20. Widget build(BuildContext context) {
  21. final Color textColor = isActive ? Colors.white : Colors.black;
  22. return Container(
  23. width: double.infinity,
  24. color: Theme.of(context).colorScheme.onPrimary,
  25. padding: EdgeInsets.symmetric(horizontal: isActive ? 8 : 16, vertical: 4),
  26. child: Container(
  27. decoration: BoxDecoration(
  28. color: isActive
  29. ? const Color(0xFF22763F)
  30. : const Color.fromRGBO(240, 240, 240, 1.0),
  31. gradient: isActive
  32. ? const LinearGradient(
  33. begin: Alignment.centerLeft,
  34. end: Alignment.centerRight,
  35. colors: [
  36. Color(0xFF2CD267),
  37. Color(0xFF1DB954),
  38. ],
  39. )
  40. : null,
  41. ),
  42. // color: Colors.yellow,
  43. padding:
  44. EdgeInsets.symmetric(horizontal: isActive ? 22 : 20, vertical: 18),
  45. child: Column(
  46. children: [
  47. Row(
  48. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  49. children: [
  50. Text(
  51. convertBytesToReadableFormat(storage),
  52. style: Theme.of(context)
  53. .textTheme
  54. .headline6
  55. .copyWith(color: textColor),
  56. ),
  57. Text(
  58. _displayPrice(),
  59. style: Theme.of(context).textTheme.headline6.copyWith(
  60. color: textColor,
  61. fontWeight: FontWeight.normal,
  62. ),
  63. ),
  64. ],
  65. ),
  66. ],
  67. ),
  68. ),
  69. );
  70. }
  71. }