π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add notification widget to packages/ui
AmanRajSinghMouryad5f8c9eb24fb
diff --git a/mobile/packages/ui/lib/components/notification_widget.dart b/mobile/packages/ui/lib/components/notification_widget.dartnew file mode 100644index 0000000000..fb4761fbc5--- /dev/null+++ b/mobile/packages/ui/lib/components/notification_widget.dart@@ -0,0 +1,265 @@+import "package:ente_ui/components/buttons/icon_button_widget.dart";+import "package:ente_ui/theme/colors.dart";+import "package:ente_ui/theme/ente_theme.dart";+import "package:ente_ui/theme/ente_theme_data.dart";+import "package:ente_ui/theme/text_style.dart";+import 'package:flutter/material.dart';+import "package:flutter_animate/flutter_animate.dart";++// CreateNotificationType enum+enum NotificationType {+ warning,+ banner,+ greenBanner,+ goldenBanner,+ notice,+}++class NotificationWidget extends StatelessWidget {+ final IconData startIcon;+ final IconData? actionIcon;+ final Widget? actionWidget;+ final String text;+ final String? subText;+ final GestureTapCallback onTap;+ final NotificationType type;+ final bool isBlackFriday;+ final TextStyle? mainTextStyle;++ const NotificationWidget({+ super.key,+ required this.startIcon,+ required this.actionIcon,+ required this.text,+ required this.onTap,+ this.mainTextStyle,+ this.isBlackFriday = false,+ this.subText,+ this.actionWidget,+ this.type = NotificationType.warning,+ });++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ EnteTextTheme textTheme = getEnteTextTheme(context);+ TextStyle mainTextStyle = this.mainTextStyle ?? darkTextTheme.bodyBold;+ TextStyle subTextStyle = darkTextTheme.miniMuted;+ LinearGradient? backgroundGradient;+ Color? backgroundColor;+ EnteColorScheme strokeColorScheme = darkScheme;+ List<BoxShadow>? boxShadow;+ switch (type) {+ case NotificationType.warning:+ backgroundColor = warning500;+ break;+ case NotificationType.banner:+ textTheme = getEnteTextTheme(context);+ backgroundColor = colorScheme.backgroundElevated2;+ mainTextStyle = textTheme.bodyBold;+ subTextStyle = textTheme.miniMuted;+ strokeColorScheme = colorScheme;+ boxShadow = [+ BoxShadow(color: Colors.black.withValues(alpha: 0.25), blurRadius: 1),+ ];+ break;+ case NotificationType.goldenBanner:+ backgroundGradient = LinearGradient(+ colors: [colorScheme.golden700, colorScheme.golden500],+ stops: const [0.25, 1],+ begin: Alignment.bottomCenter,+ end: Alignment.topCenter,+ );+ boxShadow = Theme.of(context).colorScheme.enteTheme.shadowMenu;+ break;+ case NotificationType.greenBanner:+ backgroundGradient = LinearGradient(+ colors: [+ getEnteColorScheme(context).primary700,+ getEnteColorScheme(context).primary500,+ ],+ stops: const [0.25, 1],+ begin: Alignment.bottomCenter,+ end: Alignment.topCenter,+ );+ boxShadow = Theme.of(context).colorScheme.enteTheme.shadowMenu;+ break;+ case NotificationType.notice:+ backgroundColor = colorScheme.backgroundElevated2;+ mainTextStyle = textTheme.bodyBold;+ subTextStyle = textTheme.miniMuted;+ strokeColorScheme = colorScheme;+ boxShadow = Theme.of(context).colorScheme.enteTheme.shadowMenu;+ break;+ }+ return Center(+ child: GestureDetector(+ onTap: onTap,+ child: Container(+ decoration: BoxDecoration(+ borderRadius: const BorderRadius.all(+ Radius.circular(8),+ ),+ boxShadow: boxShadow,+ color: backgroundColor,+ gradient: backgroundGradient,+ ),+ child: Padding(+ padding: EdgeInsets.symmetric(+ horizontal: 12,+ vertical: actionWidget != null ? 12 : 8,+ ),+ child: Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ isBlackFriday+ ? Icon(+ startIcon,+ size: 36,+ color: strokeColorScheme.strokeBase,+ )+ .animate(+ onPlay: (controller) =>+ controller.repeat(reverse: true),+ delay: 2000.ms,+ )+ .shake(+ duration: 500.ms,+ hz: 6,+ delay: 1600.ms,+ )+ .scale(+ duration: 500.ms,+ begin: const Offset(0.9, 0.9),+ end: const Offset(1.1, 1.1),+ delay: 1600.ms,+ // curve: Curves.easeInOut,+ )+ : Icon(+ startIcon,+ size: 36,+ color: strokeColorScheme.strokeBase,+ ),+ const SizedBox(width: 12),+ Expanded(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ text,+ style: mainTextStyle,+ textAlign: TextAlign.left,+ ),+ subText != null+ ? Text(+ subText!,+ style: subTextStyle,+ )+ : const SizedBox.shrink(),+ ],+ ),+ ),+ const SizedBox(width: 12),+ if (actionWidget != null)+ actionWidget!+ else if (actionIcon != null)+ IconButtonWidget(+ icon: actionIcon!,+ iconButtonType: IconButtonType.rounded,+ iconColor: strokeColorScheme.strokeBase,+ defaultColor: strokeColorScheme.fillFaint,+ pressedColor: strokeColorScheme.fillMuted,+ onTap: onTap,+ ),+ ],+ ),+ ),+ ),+ ),+ );+ }+}++class NotificationTipWidget extends StatelessWidget {+ final String name;+ const NotificationTipWidget(this.name, {super.key});++ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);+ return Container(+ padding: const EdgeInsets.fromLTRB(16, 12, 12, 12),+ decoration: BoxDecoration(+ border: Border.all(color: colorScheme.strokeFaint),+ borderRadius: const BorderRadius.all(Radius.circular(4)),+ ),+ child: Row(+ mainAxisAlignment: MainAxisAlignment.spaceBetween,+ children: [+ Flexible(+ flex: 12,+ child: Text(+ name,+ style: textTheme.miniFaint,+ ),+ ),+ Flexible(+ flex: 2,+ child: Icon(+ Icons.tips_and_updates_outlined,+ color: colorScheme.strokeFaint,+ size: 36,+ ),+ ),+ ],+ ),+ );+ }+}++class NotificationNoteWidget extends StatelessWidget {+ final String note;+ const NotificationNoteWidget(this.note, {super.key});+ @override+ Widget build(BuildContext context) {+ final colorScheme = getEnteColorScheme(context);+ final textTheme = getEnteTextTheme(context);+ return Container(+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),+ decoration: BoxDecoration(+ border: Border.all(color: colorScheme.strokeMuted),+ color: colorScheme.backgroundBase,+ borderRadius: const BorderRadius.all(Radius.circular(8)),+ ),+ child: Row(+ children: [+ Icon(+ Icons.info,+ color: colorScheme.strokeMuted,+ size: 36,+ ),+ const SizedBox(+ width: 12,+ ),+ Flexible(+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ "Note",+ style: textTheme.miniFaint,+ ),+ const SizedBox(height: 2),+ Text(+ note,+ style: textTheme.smallMuted,+ ),+ ],+ ),+ ),+ ],+ ),+ );+ }+}diff --git a/mobile/packages/ui/pubspec.lock b/mobile/packages/ui/pubspec.lockindex 187c952959..f76049e6c2 100644--- a/mobile/packages/ui/pubspec.lock+++ b/mobile/packages/ui/pubspec.lock@@ -73,6 +73,14 @@ packages:url: "https://pub.dev"source: hostedversion: "3.1.2"+ cronet_http:+ dependency: transitive+ description:+ name: cronet_http+ sha256: "1b99ad5ae81aa9d2f12900e5f17d3681f3828629bb7f7fe7ad88076a34209840"+ url: "https://pub.dev"+ source: hosted+ version: "1.5.0"cross_file:dependency: transitivedescription:@@ -97,6 +105,14 @@ packages:url: "https://pub.dev"source: hostedversion: "1.0.2"+ cupertino_http:+ dependency: transitive+ description:+ name: cupertino_http+ sha256: "72187f715837290a63479a5b0ae709f4fedad0ed6bd0441c275eceaa02d5abae"+ url: "https://pub.dev"+ source: hosted+ version: "2.3.0"device_info_plus:dependency: transitivedescription:@@ -174,6 +190,20 @@ packages:relative: truesource: pathversion: "1.0.0"+ ente_network:+ dependency: "direct overridden"+ description:+ path: "../network"+ relative: true+ source: path+ version: "1.0.0"+ ente_sharing:+ dependency: "direct overridden"+ description:+ path: "../sharing"+ relative: true+ source: path+ version: "1.0.0"ente_strings:dependency: "direct main"description:@@ -212,6 +242,14 @@ packages:url: "https://pub.dev"source: hostedversion: "1.3.3"+ fast_base58:+ dependency: transitive+ description:+ name: fast_base58+ sha256: "611f65633b734f27a850b51371b3eba993a5165650e12e8e7b02959f3768ba06"+ url: "https://pub.dev"+ source: hosted+ version: "0.2.1"ffi:dependency: transitivedescription:@@ -249,6 +287,14 @@ packages:description: fluttersource: sdkversion: "0.0.0"+ flutter_animate:+ dependency: "direct main"+ description:+ name: flutter_animate+ sha256: "7befe2d3252728afb77aecaaea1dec88a89d35b9b1d2eea6d04479e8af9117b5"+ url: "https://pub.dev"+ source: hosted+ version: "4.5.2"flutter_email_sender:dependency: transitivedescription:@@ -382,6 +428,14 @@ packages:url: "https://pub.dev"source: hostedversion: "3.1.2"+ flutter_shaders:+ dependency: transitive+ description:+ name: flutter_shaders+ sha256: "34794acadd8275d971e02df03afee3dee0f98dbfb8c4837082ad0034f612a3e2"+ url: "https://pub.dev"+ source: hosted+ version: "0.1.3"flutter_test:dependency: "direct dev"description: flutter@@ -440,6 +494,14 @@ packages:url: "https://pub.dev"source: hostedversion: "4.0.2"+ http_profile:+ dependency: transitive+ description:+ name: http_profile+ sha256: "7e679e355b09aaee2ab5010915c932cce3f2d1c11c3b2dc177891687014ffa78"+ url: "https://pub.dev"+ source: hosted+ version: "0.1.0"intl:dependency: transitivedescription:@@ -448,6 +510,14 @@ packages:url: "https://pub.dev"source: hostedversion: "0.20.2"+ jni:+ dependency: transitive+ description:+ name: jni+ sha256: d2c361082d554d4593c3012e26f6b188f902acd291330f13d6427641a92b3da1+ url: "https://pub.dev"+ source: hosted+ version: "0.14.2"js:dependency: transitivedescription:@@ -544,6 +614,30 @@ packages:url: "https://pub.dev"source: hostedversion: "3.0.0"+ native_dio_adapter:+ dependency: transitive+ description:+ name: native_dio_adapter+ sha256: "1c51bd42027861d27ccad462ba0903f5e3197461cc6d59a0bb8658cb5ad7bd01"+ url: "https://pub.dev"+ source: hosted+ version: "1.5.0"+ objective_c:+ dependency: transitive+ description:+ name: objective_c+ sha256: "9f034ba1eeca53ddb339bc8f4813cb07336a849cd735559b60cdc068ecce2dc7"+ url: "https://pub.dev"+ source: hosted+ version: "7.1.0"+ package_config:+ dependency: transitive+ description:+ name: package_config+ sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc+ url: "https://pub.dev"+ source: hosted+ version: "2.2.0"package_info_plus:dependency: transitivedescription:@@ -648,6 +742,14 @@ packages:url: "https://pub.dev"source: hostedversion: "6.0.3"+ pub_semver:+ dependency: transitive+ description:+ name: pub_semver+ sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585"+ url: "https://pub.dev"+ source: hosted+ version: "2.2.0"screen_retriever:dependency: transitivedescription:@@ -877,6 +979,14 @@ packages:url: "https://pub.dev"source: hostedversion: "1.4.0"+ ua_client_hints:+ dependency: transitive+ description:+ name: ua_client_hints+ sha256: "1b8759a46bfeab355252881df27f2604c01bded86aa2b578869fb1b638b23118"+ url: "https://pub.dev"+ source: hosted+ version: "1.4.1"url_launcher:dependency: transitivedescription:@@ -973,6 +1083,14 @@ packages:url: "https://pub.dev"source: hostedversion: "1.1.1"+ web_socket:+ dependency: transitive+ description:+ name: web_socket+ sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c"+ url: "https://pub.dev"+ source: hosted+ version: "1.0.1"win32:dependency: transitivedescription:diff --git a/mobile/packages/ui/pubspec.yaml b/mobile/packages/ui/pubspec.yamlindex ce4ff14c20..bff75fe7f2 100644--- a/mobile/packages/ui/pubspec.yaml+++ b/mobile/packages/ui/pubspec.yaml@@ -22,10 +22,11 @@ dependencies:expandable: ^5.0.1flutter:sdk: flutter+ flutter_animate: ^4.5.2flutter_inappwebview: ^6.1.4fluttertoast: ^8.1.1modal_bottom_sheet: ^3.0.0- shared_preferences: ^2.5.3+ shared_preferences: ^2.5.3window_manager: ^0.5.0dev_dependencies: