Skip to content

armgit / ente

Public Imported from GitHub
0

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

[localization] Add usage labels and descriptions for family breakdown in English localization

AmanRajSinghMourya0e6534666c27
diff --git a/mobile/apps/locker/lib/l10n/app_en.arb b/mobile/apps/locker/lib/l10n/app_en.arb
index afec68a735..b119fa41bc 100644
--- a/mobile/apps/locker/lib/l10n/app_en.arb
+++ b/mobile/apps/locker/lib/l10n/app_en.arb
@@ -904,5 +904,21 @@
"pleaseLoginAgain": "Please login again",
"language": "Language",
"selectLanguage": "Select language",
- "general": "General"
+ "general": "General",
+ "usageYou": "You",
+ "@usageYou": {
+ "description": "Label for user's personal usage in family breakdown"
+ },
+ "usageFamily": "Family",
+ "@usageFamily": {
+ "description": "Label for family usage in family breakdown"
+ },
+ "itemsStored": "Items stored",
+ "@itemsStored": {
+ "description": "Label for the usage card showing items stored count"
+ },
+ "of_": "of",
+ "@of_": {
+ "description": "Word 'of' used in 'X of Y' format for item count"
+ }
}
diff --git a/mobile/apps/locker/lib/l10n/app_localizations.dart b/mobile/apps/locker/lib/l10n/app_localizations.dart
index a731cb7773..0bfab04d12 100644
--- a/mobile/apps/locker/lib/l10n/app_localizations.dart
+++ b/mobile/apps/locker/lib/l10n/app_localizations.dart
@@ -2679,6 +2679,30 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'General'**
String get general;
+
+ /// Label for user's personal usage in family breakdown
+ ///
+ /// In en, this message translates to:
+ /// **'You'**
+ String get usageYou;
+
+ /// Label for family usage in family breakdown
+ ///
+ /// In en, this message translates to:
+ /// **'Family'**
+ String get usageFamily;
+
+ /// Label for the usage card showing items stored count
+ ///
+ /// In en, this message translates to:
+ /// **'Items stored'**
+ String get itemsStored;
+
+ /// Word 'of' used in 'X of Y' format for item count
+ ///
+ /// In en, this message translates to:
+ /// **'of'**
+ String get of_;
}
class _AppLocalizationsDelegate
diff --git a/mobile/apps/locker/lib/l10n/app_localizations_en.dart b/mobile/apps/locker/lib/l10n/app_localizations_en.dart
index 75c3643546..014a42226a 100644
--- a/mobile/apps/locker/lib/l10n/app_localizations_en.dart
+++ b/mobile/apps/locker/lib/l10n/app_localizations_en.dart
@@ -1560,4 +1560,16 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get general => 'General';
+
+ @override
+ String get usageYou => 'You';
+
+ @override
+ String get usageFamily => 'Family';
+
+ @override
+ String get itemsStored => 'Items stored';
+
+ @override
+ String get of_ => 'of';
}
diff --git a/mobile/apps/locker/lib/ui/components/usage_card_widget.dart b/mobile/apps/locker/lib/ui/components/usage_card_widget.dart
index db6525c6d2..6f46336817 100644
--- a/mobile/apps/locker/lib/ui/components/usage_card_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/usage_card_widget.dart
@@ -1,112 +1,261 @@
import "package:ente_accounts/models/user_details.dart";
-import 'package:ente_ui/components/loading_widget.dart';
-import 'package:ente_ui/theme/ente_theme.dart';
-import 'package:flutter/material.dart';
-import "package:hugeicons/hugeicons.dart";
-import 'package:intl/intl.dart';
+import "package:ente_ui/components/loading_widget.dart";
+import "package:ente_ui/theme/colors.dart";
+import "package:ente_ui/theme/ente_theme.dart";
+import "package:flutter/material.dart";
+import "package:intl/intl.dart";
import "package:locker/l10n/l10n.dart";
import "package:locker/states/user_details_state.dart";
class UsageCardWidget extends StatelessWidget {
- static const _defaultMaxFileCount = 100;
-
const UsageCardWidget({
super.key,
});
@override
Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
final inheritedDetails = InheritedUserDetails.of(context);
final userDetails = inheritedDetails?.userDetails;
final isCached = inheritedDetails?.isCached ?? false;
+ final isLoading = userDetails is! UserDetails || isCached;
- final maxFileCount =
- userDetails?.getLockerFileLimit() ?? _defaultMaxFileCount;
- final usedCount =
- (userDetails is UserDetails && !isCached) ? userDetails.fileCount : 0;
- final progress = maxFileCount > 0 ? usedCount / maxFileCount : 0.0;
-
- return Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 20,
- ),
- decoration: BoxDecoration(
- color: colorScheme.primary700,
- borderRadius: BorderRadius.circular(20),
- ),
- child: Row(
- children: [
- Container(
- width: 40,
- height: 40,
- decoration: BoxDecoration(
- color: Colors.black.withValues(alpha: 0.04),
- borderRadius: BorderRadius.circular(12),
+ return ClipRRect(
+ borderRadius: BorderRadius.circular(20),
+ child: Container(
+ decoration: BoxDecoration(
+ gradient: const LinearGradient(
+ colors: [
+ Color.fromRGBO(21, 21, 21, 1),
+ Color.fromRGBO(43, 43, 43, 1),
+ ],
+ begin: Alignment.bottomCenter,
+ end: Alignment.topCenter,
+ ),
+ borderRadius: BorderRadius.circular(20),
+ ),
+ child: Stack(
+ children: [
+ Positioned.fill(
+ child: CustomPaint(
+ painter: _DotsPainter(),
+ size: Size.infinite,
+ ),
),
- padding: const EdgeInsets.all(8.0),
- child: const HugeIcon(
- icon: HugeIcons.strokeRoundedCloudUpload,
- color: Colors.white,
+ Padding(
+ padding: const EdgeInsets.all(16),
+ child: _UsageContent(
+ userDetails: userDetails,
+ isLoading: isLoading,
+ ),
),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
+class _DotsPainter extends CustomPainter {
+ static const double _dotRadius = 2.0;
+ static const double _horizontalSpacing = 24.0;
+ static const double _verticalSpacing = 24.0;
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ final paint = Paint()
+ ..color = Colors.white.withValues(alpha: 0.08)
+ ..style = PaintingStyle.fill;
+
+ final horizontalCount = (size.width / _horizontalSpacing).ceil() + 1;
+ final verticalCount = (size.height / _verticalSpacing).ceil() + 1;
+
+ for (int row = 0; row < verticalCount; row++) {
+ for (int col = 0; col < horizontalCount; col++) {
+ final x = col * _horizontalSpacing + (_horizontalSpacing / 2);
+ final y = row * _verticalSpacing + (_verticalSpacing / 2);
+
+ if (x <= size.width + _dotRadius && y <= size.height + _dotRadius) {
+ canvas.drawCircle(Offset(x, y), _dotRadius, paint);
+ }
+ }
+ }
+ }
+
+ @override
+ bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
+}
+
+class _UsageContent extends StatelessWidget {
+ final UserDetails? userDetails;
+ final bool isLoading;
+
+ static const Color _youColor = Color.fromRGBO(8, 194, 373, 1);
+ static const Color _familyColor = Color.fromRGBO(244, 217, 59, 1);
+
+ const _UsageContent({
+ required this.userDetails,
+ required this.isLoading,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final textTheme = getEnteTextTheme(context);
+ final colorScheme = getEnteColorScheme(context);
+
+ final maxFileCount =
+ userDetails?.getLockerFileLimit().clamp(1, double.maxFinite).toInt() ??
+ 100;
+ final userFileCount = userDetails?.fileCount ?? 0;
+
+ // TODO: Aman enable family breakdown when API provides family file count data.
+ const showFamilyBreakup = false;
+
+ final familyTotalFileCount =
+ showFamilyBreakup ? _getFamilyTotalFileCount() : userFileCount;
+
+ final userProgress =
+ isLoading ? 0.0 : (userFileCount / maxFileCount).clamp(0.0, 1.0);
+ final familyProgress =
+ isLoading ? 0.0 : (familyTotalFileCount / maxFileCount).clamp(0.0, 1.0);
+
+ final formattedUsed = NumberFormat().format(userFileCount);
+ final formattedMax = NumberFormat().format(maxFileCount);
+
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ context.l10n.itemsStored,
+ style: textTheme.brandSmall.copyWith(
+ color: textMutedDark,
+ fontSize: 16,
),
- const SizedBox(width: 12),
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisSize: MainAxisSize.min,
+ ),
+ const SizedBox(height: 4),
+ if (isLoading)
+ const SizedBox(
+ height: 40,
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: EnteLoadingWidget(
+ size: 24,
+ padding: 0,
+ color: textBaseDark,
+ ),
+ ),
+ )
+ else
+ RichText(
+ text: TextSpan(
+ style: textTheme.h2Bold.copyWith(
+ color: textBaseDark,
+ fontFamily: 'Montserrat',
+ fontWeight: FontWeight.w500,
+ ),
children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- context.l10n.usage,
- style: textTheme.bodyBold.copyWith(
- color: Colors.white,
- ),
- ),
- userDetails is UserDetails && !isCached
- ? Text(
- context.l10n.fileCount(
- NumberFormat().format(usedCount),
- NumberFormat().format(maxFileCount),
- ),
- style: textTheme.smallMuted.copyWith(
- color: Colors.white,
- ),
- )
- : const SizedBox(
- width: 14,
- height: 14,
- child: EnteLoadingWidget(
- size: 14,
- padding: 0,
- color: Colors.white,
- ),
- ),
- ],
- ),
- const SizedBox(height: 8),
- ClipRRect(
- borderRadius: BorderRadius.circular(2),
- child: SizedBox(
- height: 6,
- child: LinearProgressIndicator(
- value: progress,
- backgroundColor: Colors.white.withValues(alpha: 0.2),
- valueColor: const AlwaysStoppedAnimation<Color>(
- Colors.white,
- ),
- ),
+ TextSpan(text: formattedUsed),
+ TextSpan(
+ text: " ${context.l10n.of_} ",
+ style: textTheme.h2Bold.copyWith(
+ color: textMutedDark,
+ fontFamily: 'Montserrat',
+ fontWeight: FontWeight.w500,
),
),
+ TextSpan(text: formattedMax),
],
),
),
- ],
- ),
+ const SizedBox(height: 16),
+ SizedBox(
+ height: 8,
+ child: Stack(
+ children: [
+ Container(
+ width: double.infinity,
+ height: 8,
+ decoration: BoxDecoration(
+ color: const Color.fromRGBO(193, 193, 193, 0.11),
+ borderRadius: BorderRadius.circular(4),
+ ),
+ ),
+ if (showFamilyBreakup)
+ LayoutBuilder(
+ builder: (context, constraints) {
+ return Container(
+ width: constraints.maxWidth * familyProgress,
+ height: 8,
+ decoration: BoxDecoration(
+ color: _familyColor,
+ borderRadius: BorderRadius.circular(4),
+ ),
+ );
+ },
+ ),
+ LayoutBuilder(
+ builder: (context, constraints) {
+ return Container(
+ width: constraints.maxWidth * userProgress,
+ height: 8,
+ decoration: BoxDecoration(
+ color: showFamilyBreakup
+ ? _youColor
+ : colorScheme.primary700,
+ borderRadius: BorderRadius.circular(4),
+ ),
+ );
+ },
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(height: 12),
+ if (showFamilyBreakup && !isLoading)
+ Row(
+ children: [
+ Container(
+ width: 8,
+ height: 8,
+ decoration: const BoxDecoration(
+ shape: BoxShape.circle,
+ color: _youColor,
+ ),
+ ),
+ const SizedBox(width: 4),
+ Text(
+ context.l10n.usageYou,
+ style: textTheme.miniBold.copyWith(color: textBaseDark),
+ ),
+ const SizedBox(width: 16),
+ Container(
+ width: 8,
+ height: 8,
+ decoration: const BoxDecoration(
+ shape: BoxShape.circle,
+ color: _familyColor,
+ ),
+ ),
+ const SizedBox(width: 4),
+ Text(
+ context.l10n.usageFamily,
+ style: textTheme.miniBold.copyWith(color: textBaseDark),
+ ),
+ ],
+ )
+ else
+ const SizedBox(height: 4),
+ ],
);
}
+
+ bool _shouldShowFamilyBreakup() {
+ if (userDetails == null) return false;
+ if (!userDetails!.isPartOfFamily()) return false;
+ return userDetails!.familyMemberStorageLimit() == null;
+ }
+
+ int _getFamilyTotalFileCount() {
+ return userDetails?.fileCount ?? 0;
+ }
}