code_success_screen.dart 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import "package:flutter/material.dart";
  2. import "package:flutter_animate/flutter_animate.dart";
  3. import "package:photos/models/api/storage_bonus/storage_bonus.dart";
  4. import "package:photos/models/user_details.dart";
  5. import "package:photos/theme/ente_theme.dart";
  6. import "package:photos/ui/components/captioned_text_widget.dart";
  7. import "package:photos/ui/components/icon_button_widget.dart";
  8. import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
  9. import "package:photos/ui/components/title_bar_title_widget.dart";
  10. import "package:photos/ui/components/title_bar_widget.dart";
  11. import "package:photos/ui/growth/referral_code_widget.dart";
  12. import "package:photos/ui/growth/storage_details_screen.dart";
  13. import "package:photos/utils/navigation_util.dart";
  14. import "package:photos/utils/share_util.dart";
  15. class CodeSuccessScreen extends StatelessWidget {
  16. final ReferralView referralView;
  17. final UserDetails userDetails;
  18. const CodeSuccessScreen(this.referralView, this.userDetails, {super.key});
  19. @override
  20. Widget build(BuildContext context) {
  21. final colorScheme = getEnteColorScheme(context);
  22. final textStyle = getEnteTextTheme(context);
  23. return Scaffold(
  24. body: CustomScrollView(
  25. primary: false,
  26. slivers: <Widget>[
  27. TitleBarWidget(
  28. flexibleSpaceTitle: const TitleBarTitleWidget(
  29. title: "Code applied",
  30. ),
  31. actionIcons: [
  32. IconButtonWidget(
  33. icon: Icons.close_outlined,
  34. iconButtonType: IconButtonType.secondary,
  35. onTap: () {
  36. Navigator.pop(context);
  37. },
  38. ),
  39. ],
  40. ),
  41. SliverList(
  42. delegate: SliverChildBuilderDelegate(
  43. (delegateBuildContext, index) {
  44. return Padding(
  45. padding: const EdgeInsets.symmetric(
  46. horizontal: 12,
  47. vertical: 6,
  48. ),
  49. child: Padding(
  50. padding: const EdgeInsets.symmetric(vertical: 12.0),
  51. child: Column(
  52. crossAxisAlignment: CrossAxisAlignment.center,
  53. children: [
  54. Icon(
  55. Icons.check,
  56. color: colorScheme.primary500,
  57. size: 96,
  58. )
  59. .animate()
  60. .scaleXY(
  61. begin: 0.5,
  62. end: 1,
  63. duration: 750.ms,
  64. curve: Curves.easeInOutCubic,
  65. delay: 250.ms,
  66. )
  67. .fadeIn(
  68. duration: 500.ms,
  69. curve: Curves.easeInOutCubic,
  70. ),
  71. Text(
  72. "${referralView.planInfo.storageInGB} GB",
  73. style: textStyle.h2Bold,
  74. ),
  75. Text(
  76. "Claimed",
  77. style: textStyle.body
  78. .copyWith(color: colorScheme.textMuted),
  79. ),
  80. const SizedBox(height: 32),
  81. MenuItemWidget(
  82. captionedTextWidget: const CaptionedTextWidget(
  83. title: "Details",
  84. ),
  85. menuItemColor: colorScheme.fillFaint,
  86. trailingWidget: Icon(
  87. Icons.chevron_right_outlined,
  88. color: colorScheme.strokeBase,
  89. ),
  90. singleBorderRadius: 8,
  91. alignCaptionedTextToLeft: true,
  92. onTap: () async {
  93. routeToPage(
  94. context,
  95. StorageDetailsScreen(referralView, userDetails),
  96. );
  97. },
  98. ),
  99. const SizedBox(height: 32),
  100. InkWell(
  101. onTap: () {
  102. shareText(
  103. "ente referral code: ${referralView.code} \n\nApply it in Settings → General → Referrals to get ${referralView.planInfo.storageInGB} GB free after you signup for a paid plan\n\nhttps://ente.io",
  104. );
  105. },
  106. child: Container(
  107. width: double.infinity,
  108. decoration: BoxDecoration(
  109. border: Border.all(
  110. color: colorScheme.strokeFaint,
  111. width: 1,
  112. ),
  113. borderRadius: BorderRadius.circular(8),
  114. ),
  115. child: Padding(
  116. padding: const EdgeInsets.symmetric(
  117. vertical: 12,
  118. horizontal: 12,
  119. ),
  120. child: Column(
  121. crossAxisAlignment: CrossAxisAlignment.center,
  122. children: [
  123. Text(
  124. "Claim more!",
  125. style: textStyle.body,
  126. ),
  127. const SizedBox(height: 8),
  128. Text(
  129. "${referralView.planInfo.storageInGB} GB each time someone signs up for a paid plan and applies your code",
  130. style: textStyle.small
  131. .copyWith(color: colorScheme.textMuted),
  132. textAlign: TextAlign.center,
  133. ),
  134. const SizedBox(height: 16),
  135. ReferralCodeWidget(referralView.code),
  136. const SizedBox(height: 16),
  137. Text(
  138. "They also get ${referralView.planInfo.storageInGB} GB",
  139. style: textStyle.small
  140. .copyWith(color: colorScheme.textMuted),
  141. textAlign: TextAlign.center,
  142. ),
  143. ],
  144. ),
  145. ),
  146. ),
  147. )
  148. ],
  149. ),
  150. ),
  151. );
  152. },
  153. childCount: 1,
  154. ),
  155. ),
  156. ],
  157. ),
  158. );
  159. }
  160. }