header_error_widget.dart 4.9 KB

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