Skip to content

armgit / ente

Public Imported from GitHub
0

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

add no files empty state

AmanRajSinghMourya2036ef204354
diff --git a/mobile/apps/locker/lib/ui/components/save_to_locker_banner.dart b/mobile/apps/locker/lib/ui/components/save_to_locker_banner.dart
new file mode 100644
index 0000000000..619772ba4f
--- /dev/null
+++ b/mobile/apps/locker/lib/ui/components/save_to_locker_banner.dart
@@ -0,0 +1,111 @@
+import "package:ente_components/ente_components.dart";
+import "package:flutter/material.dart";
+import "package:flutter_svg/flutter_svg.dart";
+import "package:locker/l10n/l10n.dart";
+
+const _bannerHeight = 147.0;
+const _illustrationWidth = 198.0;
+const _illustrationHeight = 115.0;
+const _duckyWidth = 193.0;
+const _contentLeftInset = 25.0;
+const _contentRightReserve = 200.0;
+const _brandName = "Locker";
+
+const _titleStyle = TextStyle(
+ fontFamily: TextStyles.outfitFontFamily,
+ package: TextStyles.fontPackage,
+ fontWeight: FontWeight.w600,
+ fontSize: 24,
+ height: 24 / 24,
+ letterSpacing: -0.72,
+);
+
+class SaveToLockerBanner extends StatelessWidget {
+ const SaveToLockerBanner({super.key});
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+ return MediaQuery.withClampedTextScaling(
+ maxScaleFactor: 1.3,
+ child: Container(
+ width: double.infinity,
+ height: _bannerHeight,
+ clipBehavior: Clip.antiAlias,
+ decoration: BoxDecoration(
+ color: colors.primary,
+ borderRadius: BorderRadius.circular(Radii.button),
+ ),
+ child: Stack(
+ children: [
+ Positioned.fill(
+ child: SvgPicture.asset(
+ "assets/svg/save_to_locker_glyph.svg",
+ fit: BoxFit.cover,
+ ),
+ ),
+ Positioned(
+ right: 0,
+ bottom: 0,
+ child: SizedBox(
+ width: _illustrationWidth,
+ height: _illustrationHeight,
+ child: Stack(
+ children: [
+ Positioned(
+ right: 0,
+ bottom: 0,
+ child: Image.asset(
+ "assets/save_to_locker_ducky.png",
+ width: _duckyWidth,
+ height: _illustrationHeight,
+ ),
+ ),
+ Positioned.fill(
+ child: SvgPicture.asset(
+ "assets/svg/save_to_locker_stars.svg",
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ Align(
+ alignment: Alignment.centerLeft,
+ child: Padding(
+ padding: const EdgeInsets.only(
+ left: _contentLeftInset,
+ right: _contentRightReserve,
+ ),
+ child: Text.rich(
+ _titleSpan(
+ context.l10n.saveToLocker,
+ _titleStyle.copyWith(color: colors.specialWhite),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ TextSpan _titleSpan(String title, TextStyle style) {
+ final brandIndex = title.indexOf(_brandName);
+ if (brandIndex < 0) {
+ return TextSpan(text: title, style: style);
+ }
+ return TextSpan(
+ style: style,
+ children: [
+ TextSpan(text: title.substring(0, brandIndex)),
+ const TextSpan(
+ text: _brandName,
+ style: TextStyle(fontWeight: FontWeight.w700),
+ ),
+ TextSpan(text: title.substring(brandIndex + _brandName.length)),
+ ],
+ );
+ }
+}
diff --git a/mobile/apps/locker/lib/ui/components/save_to_locker_empty_state_widget.dart b/mobile/apps/locker/lib/ui/components/save_to_locker_empty_state_widget.dart
new file mode 100644
index 0000000000..5b63df9b1e
--- /dev/null
+++ b/mobile/apps/locker/lib/ui/components/save_to_locker_empty_state_widget.dart
@@ -0,0 +1,119 @@
+import "package:ente_components/ente_components.dart";
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:locker/ui/components/save_to_locker_banner.dart";
+import "package:locker/ui/pages/save_page.dart";
+
+const _optionSpacing = 10.0;
+const _optionIconSize = 20.0;
+const _optionPadding = EdgeInsets.symmetric(
+ horizontal: Spacing.md,
+ vertical: Spacing.xxl,
+);
+
+class SaveToLockerEmptyStateWidget extends StatelessWidget {
+ const SaveToLockerEmptyStateWidget({
+ super.key,
+ required this.onUploadDocument,
+ });
+
+ final Future<bool> Function() onUploadDocument;
+
+ @override
+ Widget build(BuildContext context) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ const SaveToLockerBanner(),
+ for (final option in saveOptions(context)) ...[
+ const SizedBox(height: _optionSpacing),
+ _SaveOptionTile(
+ title: option.title,
+ description: option.description,
+ icon: option.icon,
+ onTap: () => handleSaveOption(
+ context,
+ option.type,
+ onUploadDocument: onUploadDocument,
+ ),
+ ),
+ ],
+ ],
+ );
+ }
+}
+
+class _SaveOptionTile extends StatelessWidget {
+ const _SaveOptionTile({
+ required this.title,
+ required this.description,
+ required this.icon,
+ required this.onTap,
+ });
+
+ final String title;
+ final String description;
+ final List<List<dynamic>> icon;
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+ final borderRadius = BorderRadius.circular(Radii.button);
+ return Material(
+ color: colors.fillLight,
+ borderRadius: borderRadius,
+ clipBehavior: Clip.antiAlias,
+ child: InkWell(
+ borderRadius: borderRadius,
+ onTap: onTap,
+ child: Padding(
+ padding: _optionPadding,
+ child: Row(
+ children: [
+ SizedBox.square(
+ dimension: 36,
+ child: Center(
+ child: HugeIcon(
+ icon: icon,
+ color: colors.primary,
+ size: _optionIconSize,
+ ),
+ ),
+ ),
+ const SizedBox(width: Spacing.md),
+ Expanded(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Text(
+ title,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyles.body.copyWith(color: colors.textBase),
+ ),
+ const SizedBox(height: Spacing.xs),
+ Text(
+ description,
+ maxLines: 2,
+ overflow: TextOverflow.ellipsis,
+ style: TextStyles.mini.copyWith(color: colors.textLight),
+ ),
+ ],
+ ),
+ ),
+ const SizedBox(width: Spacing.md),
+ SizedBox.square(
+ dimension: 36,
+ child: Center(
+ child: Icon(Icons.chevron_right, color: colors.textBase),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+}