Skip to content

armgit / ente

Public Imported from GitHub
0

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

add GetStartedBanner component for onboarding experience

AmanRajSinghMourya96aeed99b025
diff --git a/mobile/apps/photos/lib/ui/components/banners/get_started_banner.dart b/mobile/apps/photos/lib/ui/components/banners/get_started_banner.dart
new file mode 100644
index 0000000000..79e5938f71
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/components/banners/get_started_banner.dart
@@ -0,0 +1,136 @@
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/generated/l10n.dart";
+import "package:photos/models/typedefs.dart";
+
+class GetStartedBanner extends StatelessWidget {
+ final FutureVoidCallback onGetStarted;
+ final VoidCallback? onDismiss;
+
+ const GetStartedBanner({
+ super.key,
+ required this.onGetStarted,
+ this.onDismiss,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ const titleStyle = TextStyle(
+ fontFamily: "Montserrat",
+ fontWeight: FontWeight.bold,
+ fontSize: 16,
+ letterSpacing: -1,
+ color: Colors.white,
+ );
+
+ const descriptionStyle = TextStyle(
+ fontFamily: "Montserrat",
+ fontWeight: FontWeight.w600,
+ fontSize: 12,
+ height: 1.3,
+ color: Color.fromRGBO(255, 255, 255, 0.79),
+ );
+
+ const buttonTextStyle = TextStyle(
+ fontFamily: "Montserrat",
+ fontWeight: FontWeight.w600,
+ fontSize: 10,
+ color: Colors.black,
+ );
+
+ return Container(
+ height: 156,
+ clipBehavior: Clip.hardEdge,
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(16),
+ gradient: const LinearGradient(
+ begin: Alignment.centerLeft,
+ end: Alignment.centerRight,
+ transform: GradientRotation(0.19),
+ colors: [
+ Color.fromRGBO(4, 122, 23, 1),
+ Color.fromRGBO(8, 194, 37, 1),
+ Color.fromRGBO(72, 240, 98, 1),
+ ],
+ stops: [0.0264, 0.5255, 1.0],
+ ),
+ ),
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(16),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Expanded(
+ child: Text(
+ AppLocalizations.of(context).moreThanJustAGallery,
+ style: titleStyle,
+ ),
+ ),
+ if (onDismiss != null)
+ GestureDetector(
+ onTap: onDismiss,
+ behavior: HitTestBehavior.opaque,
+ child: const Padding(
+ padding: EdgeInsets.only(left: 8),
+ child: HugeIcon(
+ icon: HugeIcons.strokeRoundedCancel01,
+ color: Colors.white,
+ size: 20,
+ strokeWidth: 2,
+ ),
+ ),
+ ),
+ ],
+ ),
+ const SizedBox(height: 4),
+ ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 235),
+ child: Text(
+ AppLocalizations.of(context).encryptedBackupDescription,
+ style: descriptionStyle,
+ ),
+ ),
+ const Spacer(),
+ GestureDetector(
+ onTap: onGetStarted,
+ child: Container(
+ height: 36,
+ padding: const EdgeInsets.symmetric(horizontal: 24),
+ decoration: BoxDecoration(
+ color: Colors.white,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Center(
+ widthFactor: 1,
+ child: Text(
+ AppLocalizations.of(context).getStarted,
+ style: buttonTextStyle,
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ Positioned(
+ right: 32,
+ bottom: 16,
+ child: IgnorePointer(
+ child: Image.asset(
+ "assets/ducky_get_started.png",
+ height: 108,
+ fit: BoxFit.contain,
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/home/header_widget.dart b/mobile/apps/photos/lib/ui/home/header_widget.dart
index 830542cac6..3299ca39d7 100644
--- a/mobile/apps/photos/lib/ui/home/header_widget.dart
+++ b/mobile/apps/photos/lib/ui/home/header_widget.dart
@@ -1,7 +1,9 @@
-import 'package:flutter/widgets.dart';
+import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:photos/service_locator.dart';
import "package:photos/services/wrapped/wrapped_service.dart";
+import "package:photos/ui/components/banners/get_started_banner.dart";
+import "package:photos/ui/home/landing_page_widget.dart";
import "package:photos/ui/home/memories/memories_widget.dart";
import 'package:photos/ui/home/status_bar_widget.dart';
import "package:photos/ui/wrapped/rewind_banner.dart";
@@ -18,11 +20,13 @@ class HeaderWidget extends StatefulWidget {
class _HeaderWidgetState extends State<HeaderWidget> {
final Logger _logger = Logger("Header");
late WrappedEntryState _wrappedState;
+ bool _bannerDismissed = false;
@override
void initState() {
super.initState();
_wrappedState = wrappedService.state;
+ _bannerDismissed = localSettings.isOfflineGetStartedBannerDismissed;
wrappedService.stateListenable.addListener(_onWrappedStateChanged);
}
@@ -45,12 +49,34 @@ class _HeaderWidgetState extends State<HeaderWidget> {
});
}
+ Future<void> _onDismissBanner() async {
+ await localSettings.setOfflineGetStartedBannerDismissed(true);
+ setState(() {
+ _bannerDismissed = true;
+ });
+ }
+
@override
Widget build(BuildContext context) {
_logger.info("Building header widget");
final bool showWrappedBanner = wrappedService.shouldShowHomeBanner;
+ final bool showGetStartedBanner = isOfflineMode && !_bannerDismissed;
final List<Widget> children = <Widget>[
const StatusBarWidget(),
+ if (showGetStartedBanner)
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 2, vertical: 8),
+ child: GetStartedBanner(
+ onGetStarted: () async {
+ await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (_) => const LandingPageWidget(),
+ ),
+ );
+ },
+ onDismiss: _onDismissBanner,
+ ),
+ ),
const MemoriesWidget(),
];
if (showWrappedBanner) {