下拉界面优化修改:勿扰模式需开启进入该Slice,关闭则在下拉界面快捷关闭
authorluozheng <1732036298@qq.com>
Fri, 23 Aug 2024 07:32:17 +0000 (15:32 +0800)
committerluozheng <1732036298@qq.com>
Fri, 23 Aug 2024 07:32:17 +0000 (15:32 +0800)
code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp
code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h
code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp

index fd110dc..f186f55 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-08-20 19:16:00
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-22 18:57:46
+ * @LastEditTime: 2024-08-23 15:12:45
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp
  */
 #include "dnotdisturb/include/DnotDisturbModel.h"
@@ -50,7 +50,8 @@ namespace OHOS
             /*更新主界面下拉界面配置*/
             if(DropDownCardPage1::GetInstance() && DropDownCardPage1::GetInstance()->GetDropDownCardPage1_ToggleButton(DropDownCardPage1::toggleButton_DNOTDISTURB))
             {
-                DropDownCardPage1::GetInstance()->GetDropDownCardPage1_ToggleButton(DropDownCardPage1::toggleButton_DNOTDISTURB)->SetState(GetDoNotDisturbModeEnabled());
+                // DropDownCardPage1::GetInstance()->GetDropDownCardPage1_ToggleButton(DropDownCardPage1::toggleButton_DNOTDISTURB)->SetState(GetDoNotDisturbModeEnabled());
+                DropDownCardPage1::GetInstance()->UpdateDnotdisturbState(GetDoNotDisturbModeEnabled());
             }
             PullUpDownView::GetInstance()->UpdateDnotDisturbStatus(GetDoNotDisturbModeEnabled());
             /*更新主界面配置*/
index 0b9fa67..a424858 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-08-21 11:54:00
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-22 17:38:26
+ * @LastEditTime: 2024-08-23 15:00:47
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/include/dropdown/DropDownCardPage1.h
  */
 #ifndef __DROPDOWN_CARD_PAGE1_H__
@@ -49,6 +49,7 @@ namespace OHOS
         void ClearAll();
 
         UIToggleButton *GetDropDownCardPage1_ToggleButton(int index);
+        void UpdateDnotdisturbState(bool state);
 
     private:
         UIToggleButton *ToggleButtonInit(ToggleButtonConfig &toggleButtonConfig);
index cb118b0..acf9616 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-08-21 11:54:00
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-22 18:54:22
+ * @LastEditTime: 2024-08-23 15:26:00
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp
  */
 #include "main/include/dropdown/DropDownCardPage1.h"
@@ -122,8 +122,21 @@ namespace OHOS
         }
         else if (viewId == DROPDOWN_DNOTDISTURB_TOGGLEBUTTON_VIEWID) // 勿扰开关
         {
-            state = toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB]->GetState();
-            DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(state);
+            if (uapi_dev_runtime_get_sleep_monitoring_status())
+            {
+                return true;
+            }
+
+            if (DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled() == false)
+            {
+                NativeAbility::GetInstance().EnterSlice(VIEW_DNOTDISTURB);
+            }
+            else
+            {
+                state = toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB]->GetState();
+                UpdateDnotdisturbState(state);
+                DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(state);
+            }
         }
         else if (viewId == DROPDOWN_SETTING_TOGGLEBUTTON_VIEWID) // 设置
         {
@@ -181,7 +194,7 @@ namespace OHOS
             {220, 0, 100, 100, DROPDOWN_ALIPAY_TOGGLEBUTTON_VIEWID, DROPDOWN_ALIPAY_IMAGE, DROPDOWN_ALIPAY_IMAGE, true, true},
             {330, 0, 100, 100, DROPDOWN_SAVEPOWER_TOGGLEBUTTON_VIEWID, state_savepower ? DROPDOWN_SAVEPOWER_ON_IMAGE : DROPDOWN_SAVEPOWER_OFF_IMAGE, state_savepower ? DROPDOWN_SAVEPOWER_ON_IMAGE : DROPDOWN_SAVEPOWER_OFF_IMAGE, true, state_savepower},
             {55, 100, 100, 100, DROPDOWN_SLEEP_TOGGLEBUTTON_VIEWID, DROPDOWN_SLEEP_ON_IMAGE, DROPDOWN_SLEEP_OFF_IMAGE, true, state_sleep},
-            {165, 100, 100, 100, DROPDOWN_DNOTDISTURB_TOGGLEBUTTON_VIEWID, DROPDOWN_DNOTDISTURB_ON_IMAGE, DROPDOWN_DNOTDISTURB_OFF_IMAGE, true, state_dnotdisturb},
+            {165, 100, 100, 100, DROPDOWN_DNOTDISTURB_TOGGLEBUTTON_VIEWID, state_dnotdisturb ? DROPDOWN_DNOTDISTURB_ON_IMAGE : DROPDOWN_DNOTDISTURB_OFF_IMAGE, state_dnotdisturb ? DROPDOWN_DNOTDISTURB_ON_IMAGE : DROPDOWN_DNOTDISTURB_OFF_IMAGE, true, state_dnotdisturb},
             {275, 100, 100, 100, DROPDOWN_SETTING_TOGGLEBUTTON_VIEWID, DROPDOWN_SETTING_IMAGE, DROPDOWN_SETTING_IMAGE, true, true},
         };
 
@@ -217,4 +230,13 @@ namespace OHOS
     {
         return toggleButton[index];
     }
+
+    void DropDownCardPage1::UpdateDnotdisturbState(bool state)
+    {
+        if (toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB] != nullptr)
+        {
+            const char *ImageSrc = state ? DROPDOWN_DNOTDISTURB_ON_IMAGE : DROPDOWN_DNOTDISTURB_OFF_IMAGE;
+            toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB]->SetImages(ImageSrc, ImageSrc);
+        }
+    }
 }
\ No newline at end of file