code_error_widget.dart 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import 'package:ente_auth/ente_theme_data.dart';
  2. import 'package:ente_auth/l10n/l10n.dart';
  3. import 'package:ente_auth/services/update_service.dart';
  4. import 'package:ente_auth/ui/common/gradient_button.dart';
  5. import 'package:ente_auth/ui/linear_progress_widget.dart';
  6. import 'package:ente_auth/ui/settings/app_update_dialog.dart';
  7. import 'package:ente_auth/utils/toast_util.dart';
  8. import 'package:flutter/material.dart';
  9. class CodeErrorWidget extends StatelessWidget {
  10. const CodeErrorWidget({super.key});
  11. @override
  12. Widget build(BuildContext context) {
  13. return Container(
  14. height: 132,
  15. width: double.infinity,
  16. decoration: BoxDecoration(
  17. color: Theme.of(context).colorScheme.codeCardBackgroundColor,
  18. borderRadius: BorderRadius.circular(8),
  19. ),
  20. margin: const EdgeInsets.only(
  21. left: 16,
  22. right: 16,
  23. bottom: 8,
  24. top: 8,
  25. ),
  26. child: ClipRRect(
  27. borderRadius: BorderRadius.circular(8),
  28. child: Column(
  29. crossAxisAlignment: CrossAxisAlignment.start,
  30. children: [
  31. const SizedBox(
  32. height: 3,
  33. child: LinearProgressWidget(
  34. color: Color(0xFFF53434),
  35. fractionOfStorage: 1,
  36. ),
  37. ),
  38. const SizedBox(height: 24),
  39. Row(
  40. children: [
  41. const SizedBox(width: 8),
  42. const Align(
  43. alignment: Alignment.center,
  44. child: Icon(
  45. Icons.info,
  46. size: 18,
  47. color: Color(0xFFF53434),
  48. ),
  49. ),
  50. const SizedBox(width: 8),
  51. Text(
  52. context.l10n.error,
  53. style: const TextStyle(
  54. fontSize: 18,
  55. fontWeight: FontWeight.w600,
  56. color: Color(0xFFF53434),
  57. ),
  58. ),
  59. ],
  60. ),
  61. const SizedBox(height: 8),
  62. Padding(
  63. padding: const EdgeInsets.symmetric(horizontal: 8.0),
  64. child: Text(
  65. context.l10n.somethingWentWrongUpdateApp,
  66. style: const TextStyle(
  67. fontSize: 14,
  68. fontWeight: FontWeight.w500,
  69. ),
  70. ),
  71. ),
  72. const SizedBox(height: 12),
  73. Row(
  74. mainAxisAlignment: MainAxisAlignment.end,
  75. children: [
  76. SizedBox(
  77. width: 76,
  78. height: 28,
  79. child: GradientButton(
  80. text: context.l10n.update,
  81. fontSize: 10,
  82. onTap: () async {
  83. try {
  84. await UpdateService.instance.shouldUpdate();
  85. assert(
  86. UpdateService.instance.getLatestVersionInfo() != null,
  87. );
  88. await showDialog(
  89. context: context,
  90. builder: (BuildContext context) {
  91. return AppUpdateDialog(
  92. UpdateService.instance.getLatestVersionInfo(),
  93. );
  94. },
  95. barrierColor: Colors.black.withOpacity(0.85),
  96. );
  97. } catch (e) {
  98. showToast(
  99. context,
  100. context.l10n.updateNotAvailable,
  101. );
  102. }
  103. },
  104. borderWidth: 0.6,
  105. borderRadius: 6,
  106. ),
  107. ),
  108. const SizedBox(width: 6),
  109. ],
  110. ),
  111. ],
  112. ),
  113. ),
  114. );
  115. }
  116. }