Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

update storage widget

AmanRajSinghMouryab078b6c1d925
diff --git a/mobile/apps/photos/lib/ui/payment/store_subscription_page.dart b/mobile/apps/photos/lib/ui/payment/store_subscription_page.dart
index ddc0bd29c4..64b8f61cb2 100644
--- a/mobile/apps/photos/lib/ui/payment/store_subscription_page.dart
+++ b/mobile/apps/photos/lib/ui/payment/store_subscription_page.dart
@@ -19,10 +19,8 @@ import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
import 'package:photos/ui/common/loading_widget.dart';
import 'package:photos/ui/common/progress_dialog.dart';
-import "package:photos/ui/components/captioned_text_widget.dart";
import "package:photos/ui/components/divider_widget.dart";
-import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
-import "package:photos/ui/components/title_bar_title_widget.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
import 'package:photos/ui/notification/toast.dart';
import 'package:photos/ui/payment/child_subscription_widget.dart';
import 'package:photos/ui/payment/subscription_common_widgets.dart';
@@ -170,7 +168,26 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
isDismissible: true,
);
return Scaffold(
- appBar: AppBar(),
+ backgroundColor: colorScheme.backgroundColour,
+ appBar: AppBar(
+ elevation: 0,
+ scrolledUnderElevation: 0,
+ backgroundColor: colorScheme.backgroundColour,
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: colorScheme.content,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ title: Text(
+ widget.isOnboarding
+ ? AppLocalizations.of(context).selectYourPlan
+ : "${AppLocalizations.of(context).subscription}${kDebugMode ? ' Store' : ''}",
+ style: textTheme.largeBold,
+ ),
+ centerTitle: true,
+ ),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -179,11 +196,6 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- TitleBarTitleWidget(
- title: widget.isOnboarding
- ? AppLocalizations.of(context).selectYourPlan
- : "${AppLocalizations.of(context).subscription}${kDebugMode ? ' Store' : ''}",
- ),
_isFreePlanUser() || !_hasLoadedData
? const SizedBox.shrink()
: Text(
@@ -300,9 +312,6 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
);
widgets.add(const DividerWidget(dividerType: DividerType.bottomBar));
widgets.add(const SizedBox(height: 20));
- } else {
- widgets.add(const DividerWidget(dividerType: DividerType.bottomBar));
- const SizedBox(height: 56);
}
if (_hasActiveSubscription &&
@@ -323,17 +332,13 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
widgets.add(
Padding(
padding: const EdgeInsets.fromLTRB(16, 40, 16, 4),
- child: MenuItemWidget(
- captionedTextWidget: const CaptionedTextWidget(
- title: "Manage payment method",
- ),
+ child: MenuItemWidgetNew(
+ title: "Manage payment method",
menuItemColor: colorScheme.fillFaint,
trailingWidget: Icon(
Icons.chevron_right_outlined,
color: colorScheme.strokeBase,
),
- singleBorderRadius: 4,
- alignCaptionedTextToLeft: true,
onTap: () async {
_onPlatformRestrictedPaymentDetailsClick();
},
@@ -351,19 +356,15 @@ class _StoreSubscriptionPageState extends State<StoreSubscriptionPage> {
widgets.add(
Padding(
padding: const EdgeInsets.fromLTRB(16, 2, 16, 2),
- child: MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: _isFreePlanUser()
- ? AppLocalizations.of(context).familyPlans
- : AppLocalizations.of(context).manageFamily,
- ),
+ child: MenuItemWidgetNew(
+ title: _isFreePlanUser()
+ ? AppLocalizations.of(context).familyPlans
+ : AppLocalizations.of(context).manageFamily,
menuItemColor: colorScheme.fillFaint,
trailingWidget: Icon(
Icons.chevron_right_outlined,
color: colorScheme.strokeBase,
),
- singleBorderRadius: 4,
- alignCaptionedTextToLeft: true,
onTap: () async {
unawaited(
_billingService.launchFamilyPortal(context, _userDetails),
diff --git a/mobile/apps/photos/lib/ui/payment/subscription_common_widgets.dart b/mobile/apps/photos/lib/ui/payment/subscription_common_widgets.dart
index 0fe473b4f3..1992e9931e 100644
--- a/mobile/apps/photos/lib/ui/payment/subscription_common_widgets.dart
+++ b/mobile/apps/photos/lib/ui/payment/subscription_common_widgets.dart
@@ -6,8 +6,7 @@ import 'package:photos/gateways/billing/models/subscription.dart';
import "package:photos/gateways/storage_bonus/models/bonus.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/captioned_text_widget.dart";
-import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";
+import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";
import 'package:photos/ui/payment/billing_questions_widget.dart';
class SubscriptionHeaderWidget extends StatefulWidget {
@@ -41,7 +40,7 @@ class _SubscriptionHeaderWidgetState extends State<SubscriptionHeaderWidget> {
);
} else {
return Padding(
- padding: const EdgeInsets.fromLTRB(16, 32, 16, 0),
+ padding: const EdgeInsets.symmetric(horizontal: 16),
child: RichText(
text: TextSpan(
children: [
@@ -159,17 +158,13 @@ class SubFaqWidget extends StatelessWidget {
final colorScheme = getEnteColorScheme(context);
return Padding(
padding: const EdgeInsets.fromLTRB(16, 2, 16, 2),
- child: MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: AppLocalizations.of(context).faqs,
- ),
+ child: MenuItemWidgetNew(
+ title: AppLocalizations.of(context).faqs,
menuItemColor: colorScheme.fillFaint,
trailingWidget: Icon(
Icons.chevron_right_outlined,
color: colorScheme.strokeBase,
),
- singleBorderRadius: 4,
- alignCaptionedTextToLeft: true,
onTap: () async {
// ignore: unawaited_futures
showModalBottomSheet<void>(
@@ -227,7 +222,7 @@ class _SubscriptionToggleState extends State<SubscriptionToggle> {
children: [
GestureDetector(
onTap: () {
- setIsYearly(false);
+ setIsYearly(true);
},
behavior: HitTestBehavior.opaque,
child: Container(
@@ -237,7 +232,7 @@ class _SubscriptionToggleState extends State<SubscriptionToggle> {
width: widthOfButton,
child: Center(
child: Text(
- AppLocalizations.of(context).monthly,
+ AppLocalizations.of(context).yearly,
style: textTheme.bodyFaint,
),
),
@@ -246,7 +241,7 @@ class _SubscriptionToggleState extends State<SubscriptionToggle> {
const SizedBox(width: spaceBetweenButtons),
GestureDetector(
onTap: () {
- setIsYearly(true);
+ setIsYearly(false);
},
behavior: HitTestBehavior.opaque,
child: Container(
@@ -256,7 +251,7 @@ class _SubscriptionToggleState extends State<SubscriptionToggle> {
width: widthOfButton,
child: Center(
child: Text(
- AppLocalizations.of(context).yearly,
+ AppLocalizations.of(context).monthly,
style: textTheme.bodyFaint,
),
),
@@ -267,7 +262,7 @@ class _SubscriptionToggleState extends State<SubscriptionToggle> {
AnimatedPositioned(
duration: const Duration(milliseconds: 350),
curve: Curves.easeInOutQuart,
- left: _isYearly ? widthOfButton + spaceBetweenButtons : 0,
+ left: _isYearly ? 0 : widthOfButton + spaceBetweenButtons,
child: Container(
padding: const EdgeInsets.symmetric(
vertical: 8,
diff --git a/mobile/apps/photos/lib/ui/payment/subscription_plan_widget.dart b/mobile/apps/photos/lib/ui/payment/subscription_plan_widget.dart
index 5e2638e9cc..33ed5f8c19 100644
--- a/mobile/apps/photos/lib/ui/payment/subscription_plan_widget.dart
+++ b/mobile/apps/photos/lib/ui/payment/subscription_plan_widget.dart
@@ -1,14 +1,12 @@
+import 'dart:math' as math;
+
import 'package:ente_pure_utils/ente_pure_utils.dart';
-import "package:flutter/foundation.dart";
import 'package:flutter/material.dart';
-import "package:flutter/scheduler.dart";
-import "package:flutter_animate/flutter_animate.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
-import "package:photos/theme/colors.dart";
import "package:photos/theme/ente_theme.dart";
-class SubscriptionPlanWidget extends StatefulWidget {
+class SubscriptionPlanWidget extends StatelessWidget {
const SubscriptionPlanWidget({
super.key,
required this.storage,
@@ -26,107 +24,137 @@ class SubscriptionPlanWidget extends StatefulWidget {
final bool isPopular;
final bool isOnboarding;
- @override
- State<SubscriptionPlanWidget> createState() => _SubscriptionPlanWidgetState();
-}
-
-class _SubscriptionPlanWidgetState extends State<SubscriptionPlanWidget> {
- late final PlatformDispatcher _platformDispatcher;
-
- @override
- void initState() {
- super.initState();
- _platformDispatcher = SchedulerBinding.instance.platformDispatcher;
- }
-
@override
Widget build(BuildContext context) {
- final brightness = _platformDispatcher.platformBrightness;
- final numAndUnit = convertBytesToNumberAndUnit(widget.storage);
+ final colorScheme = getEnteColorScheme(context);
+ final numAndUnit = convertBytesToNumberAndUnit(storage);
final String storageValue = numAndUnit.$1.toString();
- final String storageUnit = numAndUnit.$2;
+ final String storageUnit = numAndUnit.$2.toUpperCase();
+ final bool isSelected = isActive;
+
return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
- child: Container(
- decoration: BoxDecoration(
- color: backgroundElevated2Light,
- borderRadius: BorderRadius.circular(8),
- border: widget.isActive
- ? Border.all(
- color: getEnteColorScheme(context).primary700,
- width: brightness == Brightness.dark ? 1.5 : 1,
- strokeAlign: BorderSide.strokeAlignInside,
- )
- : null,
- boxShadow: [
- BoxShadow(
- color: Colors.black.withValues(alpha: 0.08),
- offset: const Offset(0, 4),
- blurRadius: 4,
+ padding: const EdgeInsets.only(
+ left: 16,
+ right: 16,
+ bottom: 12,
+ ),
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Container(
+ constraints: const BoxConstraints(minHeight: 72),
+ decoration: BoxDecoration(
+ color: isSelected ? colorScheme.greenLight : colorScheme.fill,
+ borderRadius: BorderRadius.circular(20),
+ border: isSelected
+ ? Border.all(color: colorScheme.greenBase, width: 2)
+ : null,
),
- ],
- ),
- child: Stack(
- children: [
- widget.isActive && !widget.isOnboarding
- ? Positioned(
- top: 0,
- right: 0,
- child: ClipRRect(
- borderRadius: const BorderRadius.only(
- topRight: Radius.circular(8),
- ),
- child: Image.asset(
- "assets/active_subscription.png",
- ),
- ),
- )
- : widget.isPopular
- ? ClipRRect(
- borderRadius: const BorderRadius.only(
- topLeft: Radius.circular(8),
- ),
- child: Image.asset(
- "assets/popular_subscription.png",
- ),
- )
- : const SizedBox.shrink(),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ crossAxisAlignment: CrossAxisAlignment.center,
children: [
- RichText(
- text: TextSpan(
- children: [
- TextSpan(
- text: storageValue,
- style: const TextStyle(
- fontSize: 40,
- fontWeight: FontWeight.w600,
- color: textBaseLight,
+ Expanded(
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: RichText(
+ text: TextSpan(
+ style: TextStyle(
+ color: colorScheme.contentDarker,
+ fontFamily: "Nunito",
+ fontWeight: FontWeight.w900,
),
- ),
- WidgetSpan(
- child: Transform.translate(
- offset: const Offset(2, -16),
- child: Text(
- storageUnit,
- style: getEnteTextTheme(context).h3.copyWith(
- color: textMutedLight,
- ),
+ children: [
+ TextSpan(
+ text: storageValue,
+ style: const TextStyle(
+ fontSize: 36,
+ height: 28 / 36,
+ letterSpacing: -1.8,
+ ),
),
- ),
+ const TextSpan(
+ text: " ",
+ style: TextStyle(
+ fontSize: 24,
+ height: 28 / 24,
+ letterSpacing: -0.96,
+ ),
+ ),
+ TextSpan(
+ text: storageUnit.isEmpty
+ ? ""
+ : storageUnit.substring(0, 1),
+ style: const TextStyle(
+ fontSize: 16,
+ height: 28 / 16,
+ letterSpacing: -0.64,
+ ),
+ ),
+ TextSpan(
+ text: storageUnit.length > 1
+ ? storageUnit.substring(1)
+ : "",
+ style: const TextStyle(
+ fontSize: 16,
+ height: 28 / 16,
+ ),
+ ),
+ ],
),
- ],
+ textAlign: TextAlign.left,
+ textHeightBehavior: const TextHeightBehavior(
+ applyHeightToFirstAscent: false,
+ applyHeightToLastDescent: false,
+ ),
+ ),
+ ),
+ ),
+ Flexible(
+ child: Align(
+ alignment: Alignment.centerRight,
+ child: _Price(
+ price: price,
+ period: period,
+ ),
),
),
- _Price(price: widget.price, period: widget.period),
],
),
),
- ],
- ),
+ ),
+ if (isPopular)
+ Positioned(
+ right: -8,
+ top: -4,
+ child: Transform.rotate(
+ angle: 8 * math.pi / 180,
+ child: Container(
+ decoration: BoxDecoration(
+ color: colorScheme.greenBase,
+ borderRadius: BorderRadius.circular(8),
+ ),
+ padding: const EdgeInsets.symmetric(
+ horizontal: 8,
+ vertical: 2,
+ ),
+ child: const Text(
+ "Most popular",
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ color: Colors.white,
+ fontFamily: "Nunito",
+ fontWeight: FontWeight.w800,
+ fontSize: 10,
+ height: 20 / 10,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
),
);
}
@@ -135,30 +163,50 @@ class _SubscriptionPlanWidgetState extends State<SubscriptionPlanWidget> {
class _Price extends StatelessWidget {
final String price;
final String period;
- const _Price({required this.price, required this.period});
+
+ const _Price({
+ required this.price,
+ required this.period,
+ });
@override
Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
final textTheme = getEnteTextTheme(context);
if (price.isEmpty) {
return Text(
"Free",
- style: textTheme.largeBold.copyWith(color: textBaseLight),
+ style: textTheme.bodyBold.copyWith(
+ color: colorScheme.contentDarker,
+ fontFamily: "Inter",
+ fontSize: 16,
+ height: 28 / 16,
+ ),
);
}
+
if (period == "month") {
- return Column(
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- Text(
- price + ' / ' + AppLocalizations.of(context).month,
- style: textTheme.largeBold.copyWith(color: textBaseLight),
- )
- .animate(delay: const Duration(milliseconds: 100))
- .fadeIn(duration: const Duration(milliseconds: 250)),
- ],
+ return Text.rich(
+ TextSpan(
+ style: textTheme.largeBold.copyWith(
+ color: colorScheme.contentDarker,
+ height: 1.1,
+ ),
+ children: [
+ TextSpan(text: price),
+ TextSpan(
+ text: "/${AppLocalizations.of(context).month}",
+ style: textTheme.small.copyWith(
+ color: colorScheme.contentLight,
+ ),
+ ),
+ ],
+ ),
+ textAlign: TextAlign.end,
);
- } else if (period == "year") {
+ }
+
+ if (period == "year") {
final currencySymbol = price[0];
final priceWithoutCurrency = price.substring(1);
final priceDouble = double.parse(priceWithoutCurrency);
@@ -172,38 +220,59 @@ class _Price extends StatelessWidget {
final bool isPlayStore = updateService.isPlayStoreFlavor();
return Column(
+ mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (isPlayStore)
- Text(
- price + " / " + AppLocalizations.of(context).yearShort,
- style: textTheme.largeBold.copyWith(color: textBaseLight),
+ Text.rich(
+ TextSpan(
+ style: textTheme.largeBold.copyWith(
+ color: colorScheme.contentDarker,
+ height: 1.1,
+ ),
+ children: [
+ TextSpan(text: price),
+ TextSpan(
+ text: "/${AppLocalizations.of(context).yearShort}",
+ style: textTheme.small.copyWith(
+ color: colorScheme.contentLight,
+ ),
+ ),
+ ],
+ ),
+ textAlign: TextAlign.end,
),
if (isPlayStore)
Text(
- currencySymbol +
- pricePerMonthString +
- ' / ' +
- AppLocalizations.of(context).month,
- style: textTheme.small.copyWith(color: textFaintLight),
+ "$currencySymbol$pricePerMonthString / ${AppLocalizations.of(context).month}",
+ style: textTheme.tiny.copyWith(color: colorScheme.contentLight),
+ textAlign: TextAlign.end,
),
if (!isPlayStore)
Text(
- currencySymbol +
- pricePerMonthString +
- ' / ' +
- AppLocalizations.of(context).month,
- style: textTheme.largeBold.copyWith(color: textBaseLight),
+ "$currencySymbol$pricePerMonthString / ${AppLocalizations.of(context).month}",
+ style: textTheme.largeBold.copyWith(
+ color: colorScheme.contentDarker,
+ ),
+ textAlign: TextAlign.end,
),
if (!isPlayStore)
- Text(
- price + " / " + AppLocalizations.of(context).yearShort,
- style: textTheme.small.copyWith(color: textFaintLight),
+ Text.rich(
+ TextSpan(
+ style: textTheme.tiny.copyWith(
+ color: colorScheme.contentLight,
+ ),
+ children: [
+ TextSpan(text: price),
+ TextSpan(
+ text: "/${AppLocalizations.of(context).yearShort}",
+ ),
+ ],
+ ),
+ textAlign: TextAlign.end,
),
],
- )
- .animate(delay: const Duration(milliseconds: 100))
- .fadeIn(duration: const Duration(milliseconds: 250));
+ );
} else {
assert(false, "Invalid period: $period");
return const Text("");