header_error_widget.dart 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. const Divider(
  50. thickness: 2,
  51. height: 0,
  52. ),
  53. const Padding(padding: EdgeInsets.all(12)),
  54. ],
  55. ),
  56. );
  57. } else if (_error is StorageLimitExceededError) {
  58. return Container(
  59. margin: const EdgeInsets.only(top: 8),
  60. child: Column(
  61. children: [
  62. Row(
  63. mainAxisAlignment: MainAxisAlignment.center,
  64. crossAxisAlignment: CrossAxisAlignment.center,
  65. children: const [
  66. Icon(
  67. Icons.error_outline,
  68. color: Colors.orange,
  69. ),
  70. Padding(padding: EdgeInsets.all(4)),
  71. Text("Storage limit exceeded"),
  72. ],
  73. ),
  74. const Padding(padding: EdgeInsets.all(8)),
  75. Container(
  76. width: 400,
  77. height: 52,
  78. padding: const EdgeInsets.fromLTRB(80, 0, 80, 0),
  79. child: OutlinedButton(
  80. child: const Text("Upgrade"),
  81. onPressed: () {
  82. Navigator.of(context).push(
  83. MaterialPageRoute(
  84. builder: (BuildContext context) {
  85. return getSubscriptionPage();
  86. },
  87. ),
  88. );
  89. },
  90. ),
  91. ),
  92. const Padding(padding: EdgeInsets.all(12)),
  93. const Divider(
  94. thickness: 2,
  95. height: 0,
  96. ),
  97. const Padding(padding: EdgeInsets.all(12)),
  98. ],
  99. ),
  100. );
  101. } else {
  102. return Center(
  103. child: Column(
  104. children: [
  105. Icon(
  106. Icons.error_outline,
  107. color: Colors.red[400],
  108. ),
  109. const Padding(padding: EdgeInsets.all(4)),
  110. const Text(
  111. "We could not backup your data.\nWe will retry later.",
  112. style: TextStyle(height: 1.4),
  113. textAlign: TextAlign.center,
  114. ),
  115. const Padding(padding: EdgeInsets.all(8)),
  116. InkWell(
  117. child: OutlinedButton(
  118. style: OutlinedButton.styleFrom(
  119. backgroundColor:
  120. Theme.of(context).colorScheme.inverseTextColor,
  121. shape: RoundedRectangleBorder(
  122. borderRadius: BorderRadius.circular(10),
  123. ),
  124. padding: const EdgeInsets.fromLTRB(50, 16, 50, 16),
  125. side: BorderSide(
  126. width: 2,
  127. color: Colors.orange[600],
  128. ),
  129. ),
  130. child: Text(
  131. "Raise ticket",
  132. style: TextStyle(
  133. fontWeight: FontWeight.bold,
  134. fontSize: 14,
  135. color: Colors.orange[600],
  136. ),
  137. textAlign: TextAlign.center,
  138. ),
  139. onPressed: () {
  140. sendLogs(
  141. context,
  142. "Raise ticket",
  143. "support@ente.io",
  144. subject: "Backup failed",
  145. );
  146. },
  147. ),
  148. ),
  149. const Padding(padding: EdgeInsets.all(16)),
  150. const Divider(
  151. thickness: 2,
  152. height: 0,
  153. ),
  154. const Padding(padding: EdgeInsets.all(12)),
  155. ],
  156. ),
  157. );
  158. }
  159. }
  160. }