header_error_widget.dart 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import 'package:flutter/material.dart';
  2. import 'package:photos/core/errors.dart';
  3. import 'package:photos/ente_theme_data.dart';
  4. import 'package:photos/ui/payment/subscription.dart';
  5. import 'package:photos/utils/email_util.dart';
  6. class HeaderErrorWidget extends StatelessWidget {
  7. final Error? _error;
  8. const HeaderErrorWidget({Key? key, required Error? error})
  9. : _error = error,
  10. super(key: key);
  11. @override
  12. Widget build(BuildContext context) {
  13. if (_error is NoActiveSubscriptionError) {
  14. return Container(
  15. margin: const EdgeInsets.only(top: 8),
  16. child: Column(
  17. children: [
  18. Row(
  19. mainAxisAlignment: MainAxisAlignment.center,
  20. crossAxisAlignment: CrossAxisAlignment.center,
  21. children: const [
  22. Icon(
  23. Icons.error_outline,
  24. color: Colors.orange,
  25. ),
  26. Padding(padding: EdgeInsets.all(4)),
  27. Text("Your subscription has expired"),
  28. ],
  29. ),
  30. const Padding(padding: EdgeInsets.all(8)),
  31. Container(
  32. width: 400,
  33. height: 52,
  34. padding: const EdgeInsets.fromLTRB(80, 0, 80, 0),
  35. child: OutlinedButton(
  36. child: const Text("Subscribe"),
  37. onPressed: () {
  38. Navigator.of(context).push(
  39. MaterialPageRoute(
  40. builder: (BuildContext context) {
  41. return getSubscriptionPage();
  42. },
  43. ),
  44. );
  45. },
  46. ),
  47. ),
  48. const Padding(padding: EdgeInsets.all(12)),
  49. ],
  50. ),
  51. );
  52. } else if (_error is StorageLimitExceededError) {
  53. return Container(
  54. margin: const EdgeInsets.only(top: 8),
  55. child: Column(
  56. children: [
  57. Row(
  58. mainAxisAlignment: MainAxisAlignment.center,
  59. crossAxisAlignment: CrossAxisAlignment.center,
  60. children: const [
  61. Icon(
  62. Icons.error_outline,
  63. color: Colors.orange,
  64. ),
  65. Padding(padding: EdgeInsets.all(4)),
  66. Text("Storage limit exceeded"),
  67. ],
  68. ),
  69. const Padding(padding: EdgeInsets.all(8)),
  70. Container(
  71. width: 400,
  72. height: 52,
  73. padding: const EdgeInsets.fromLTRB(80, 0, 80, 0),
  74. child: OutlinedButton(
  75. child: const Text(
  76. "Upgrade",
  77. style: TextStyle(height: 1.1),
  78. ),
  79. onPressed: () {
  80. Navigator.of(context).push(
  81. MaterialPageRoute(
  82. builder: (BuildContext context) {
  83. return getSubscriptionPage();
  84. },
  85. ),
  86. );
  87. },
  88. ),
  89. ),
  90. const Padding(padding: EdgeInsets.all(12)),
  91. ],
  92. ),
  93. );
  94. } else {
  95. return Center(
  96. child: Column(
  97. children: [
  98. const SizedBox(height: 8),
  99. Icon(
  100. Icons.error_outline,
  101. color: Colors.red[400],
  102. ),
  103. const Padding(padding: EdgeInsets.all(4)),
  104. const Text(
  105. "We could not backup your data.\nWe will retry later.",
  106. style: TextStyle(height: 1.4),
  107. textAlign: TextAlign.center,
  108. ),
  109. const Padding(padding: EdgeInsets.all(8)),
  110. InkWell(
  111. child: OutlinedButton(
  112. style: OutlinedButton.styleFrom(
  113. backgroundColor:
  114. Theme.of(context).colorScheme.inverseTextColor,
  115. shape: RoundedRectangleBorder(
  116. borderRadius: BorderRadius.circular(10),
  117. ),
  118. padding: const EdgeInsets.fromLTRB(50, 16, 50, 16),
  119. side: BorderSide(
  120. width: 2,
  121. color: Colors.orange[600]!,
  122. ),
  123. ),
  124. child: Text(
  125. "Raise ticket",
  126. style: TextStyle(
  127. fontWeight: FontWeight.bold,
  128. fontSize: 14,
  129. color: Colors.orange[600],
  130. ),
  131. textAlign: TextAlign.center,
  132. ),
  133. onPressed: () {
  134. sendLogs(
  135. context,
  136. "Raise ticket",
  137. "support@ente.io",
  138. subject: "Backup failed",
  139. );
  140. },
  141. ),
  142. ),
  143. const Padding(padding: EdgeInsets.all(12)),
  144. ],
  145. ),
  146. );
  147. }
  148. }
  149. }