浏览代码

Feature: close bottom sheet system added to usershortcut component actions.

lfabl 1 周之前
父节点
当前提交
7d5a40c9ae
共有 2 个文件被更改,包括 18 次插入3 次删除
  1. 14 2
      src/components/userShortcut/index.tsx
  2. 4 1
      src/components/userShortcut/type.ts

+ 14 - 2
src/components/userShortcut/index.tsx

@@ -32,6 +32,7 @@ import Button from "../button";
 import Text from "../text";
 
 const UserShortcut = ({
+    isCloseBottomSheetOnLogoutPress = true,
     isShowLoginButtonWhenNoSession = true,
     isShowRegisterButton = false,
     isWorkWithCoreComplex = true,
@@ -337,10 +338,19 @@ const UserShortcut = ({
                 {
                     actionButtons?.map((buttonProps, index) => {
                         return <Button
+                            {...buttonProps}
+                            onPress={() => {
+                                if(buttonProps.isCloseBottomSheetOnPress !== false) {
+                                    setIsBottomSheetOpen(false);
+                                }
+
+                                if(buttonProps.onPress) {
+                                    buttonProps.onPress();
+                                }
+                            }}
                             spreadBehaviour="stretch"
                             type="neutral"
                             key={index}
-                            {...buttonProps}
                         />;
                     })
                 }
@@ -349,7 +359,9 @@ const UserShortcut = ({
                         <Button
                             title={localize("logout" as keyof NCoreUIKit.Translation)}
                             onPress={async () => {
-                                setIsBottomSheetOpen(false);
+                                if(isCloseBottomSheetOnLogoutPress) {
+                                    setIsBottomSheetOpen(false);
+                                }
 
                                 let response;
                                 let error;

+ 4 - 1
src/components/userShortcut/type.ts

@@ -35,10 +35,13 @@ interface IUserShortcutProps {
     statusColor?: keyof NCoreUIKit.TextContentColors;
     spreadBehaviour?: UserShortcutSpreadBehaviour;
     variant?: "default" | "compact" | "drawer";
+    isCloseBottomSheetOnLogoutPress?: boolean;
     isShowLoginButtonWhenNoSession?: boolean;
+    actionButtons?: (IButtonProps & {
+        isCloseBottomSheetOnPress?: boolean;
+    })[];
     isWorkWithCoreComplex?: boolean;
     isShowRegisterButton?: boolean;
-    actionButtons?: IButtonProps[];
     isShowLogoutButton?: boolean;
     onRegisterPress?: () => void;
     isShowArrowButton?: boolean;