소스 검색

Add support for custom bodyWidget in action content

Neeraj Gupta 2 년 전
부모
커밋
d369052b4d
2개의 변경된 파일19개의 추가작업 그리고 9개의 파일을 삭제
  1. 0 1
      lib/ui/actions/collection/collection_file_actions.dart
  2. 19 8
      lib/ui/components/action_sheet_widget.dart

+ 0 - 1
lib/ui/actions/collection/collection_file_actions.dart

@@ -50,7 +50,6 @@ extension CollectionFileActions on CollectionActions {
           isInAlert: true,
           isInAlert: true,
         ),
         ),
       ],
       ],
-      title: "Remove from album?",
       body: "Selected items will be removed from this album. Items which are "
       body: "Selected items will be removed from this album. Items which are "
           "only in this album will be moved to Uncategorized.",
           "only in this album will be moved to Uncategorized.",
       actionSheetType: ActionSheetType.defaultActionSheet,
       actionSheetType: ActionSheetType.defaultActionSheet,

+ 19 - 8
lib/ui/components/action_sheet_widget.dart

@@ -23,6 +23,7 @@ Future<ButtonAction?> showActionSheet({
   bool isDismissible = true,
   bool isDismissible = true,
   bool isCheckIconGreen = false,
   bool isCheckIconGreen = false,
   String? title,
   String? title,
+  Widget? bodyWidget,
   String? body,
   String? body,
   String? bodyHighlight,
   String? bodyHighlight,
 }) {
 }) {
@@ -36,6 +37,7 @@ Future<ButtonAction?> showActionSheet({
     builder: (_) {
     builder: (_) {
       return ActionSheetWidget(
       return ActionSheetWidget(
         title: title,
         title: title,
+        bodyWidget: bodyWidget,
         body: body,
         body: body,
         bodyHighlight: bodyHighlight,
         bodyHighlight: bodyHighlight,
         actionButtons: buttons,
         actionButtons: buttons,
@@ -48,6 +50,7 @@ Future<ButtonAction?> showActionSheet({
 
 
 class ActionSheetWidget extends StatelessWidget {
 class ActionSheetWidget extends StatelessWidget {
   final String? title;
   final String? title;
+  final Widget? bodyWidget;
   final String? body;
   final String? body;
   final String? bodyHighlight;
   final String? bodyHighlight;
   final List<ButtonWidget> actionButtons;
   final List<ButtonWidget> actionButtons;
@@ -59,6 +62,7 @@ class ActionSheetWidget extends StatelessWidget {
     required this.actionSheetType,
     required this.actionSheetType,
     required this.isCheckIconGreen,
     required this.isCheckIconGreen,
     this.title,
     this.title,
+    this.bodyWidget,
     this.body,
     this.body,
     this.bodyHighlight,
     this.bodyHighlight,
     super.key,
     super.key,
@@ -66,7 +70,8 @@ class ActionSheetWidget extends StatelessWidget {
 
 
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
-    final isTitleAndBodyNull = title == null && body == null;
+    final isTitleAndBodyNull =
+        title == null && bodyWidget == null && body == null;
     final blur = MediaQuery.of(context).platformBrightness == Brightness.light
     final blur = MediaQuery.of(context).platformBrightness == Brightness.light
         ? blurMuted
         ? blurMuted
         : blurBase;
         : blurBase;
@@ -125,14 +130,17 @@ class ActionSheetWidget extends StatelessWidget {
 
 
 class ContentContainerWidget extends StatelessWidget {
 class ContentContainerWidget extends StatelessWidget {
   final String? title;
   final String? title;
+  final Widget? bodyWidget;
   final String? body;
   final String? body;
   final String? bodyHighlight;
   final String? bodyHighlight;
   final ActionSheetType actionSheetType;
   final ActionSheetType actionSheetType;
   final bool isCheckIconGreen;
   final bool isCheckIconGreen;
+
   const ContentContainerWidget({
   const ContentContainerWidget({
     required this.actionSheetType,
     required this.actionSheetType,
     required this.isCheckIconGreen,
     required this.isCheckIconGreen,
     this.title,
     this.title,
+    this.bodyWidget,
     this.body,
     this.body,
     this.bodyHighlight,
     this.bodyHighlight,
     super.key,
     super.key,
@@ -141,6 +149,7 @@ class ContentContainerWidget extends StatelessWidget {
   @override
   @override
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
     final textTheme = getEnteTextTheme(context);
     final textTheme = getEnteTextTheme(context);
+    final bool bodyMissing = body == null && bodyWidget == null;
     return Column(
     return Column(
       mainAxisSize: MainAxisSize.min,
       mainAxisSize: MainAxisSize.min,
       //todo: set cross axis to center when icon should be shown in place of body
       //todo: set cross axis to center when icon should be shown in place of body
@@ -155,17 +164,19 @@ class ContentContainerWidget extends StatelessWidget {
                 style: textTheme.largeBold
                 style: textTheme.largeBold
                     .copyWith(color: textBaseDark), //constant color
                     .copyWith(color: textBaseDark), //constant color
               ),
               ),
-        title == null || body == null
+        title == null || bodyMissing
             ? const SizedBox.shrink()
             ? const SizedBox.shrink()
             : const SizedBox(height: 19),
             : const SizedBox(height: 19),
         actionSheetType == ActionSheetType.defaultActionSheet
         actionSheetType == ActionSheetType.defaultActionSheet
-            ? body == null
+            ? bodyMissing
                 ? const SizedBox.shrink()
                 ? const SizedBox.shrink()
-                : Text(
-                    body!,
-                    style: textTheme.body
-                        .copyWith(color: textMutedDark), //constant color
-                  )
+                : (bodyWidget != null
+                    ? bodyWidget!
+                    : Text(
+                        body!,
+                        style: textTheme.body
+                            .copyWith(color: textMutedDark), //constant color
+                      ))
             : Icon(
             : Icon(
                 Icons.check_outlined,
                 Icons.check_outlined,
                 size: 48,
                 size: 48,