Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	features/feature/src/main/ets/view/MainView.ets
chenritian 2 miesięcy temu
rodzic
commit
09fdde046a

+ 2 - 0
commons/basic/Index.ets

@@ -1,3 +1,5 @@
+export { BackgroundPageModifier } from './src/main/ets/styles/AttributeModifier'
+
 export { pushMessageUtil } from './src/main/ets/utils/NoticeUtil'
 
 export { yTPreferences } from './src/main/ets/utils/YTPreferencesUtil'

+ 1 - 0
commons/basic/src/main/ets/apis/YTRequest.ets

@@ -60,6 +60,7 @@ instance.interceptors.response.use((response: AxiosResponse) => {
     return Promise.reject(response.data);
   }
 
+
   return response.data.data;
 }, (error: AxiosError) => {
   YTLog.error(error)

+ 172 - 0
commons/basic/src/main/ets/constants/StyleConstants.ets

@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2023 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Style constants for all features.
+ */
+export default class StyleConstants {
+  /**
+   *  Login logo component height of the parent 30.
+   */
+  static readonly LOGIN_LOGO_HEIGHT: string = '30%';
+  /**
+   *  Login bottom component height of the parent 50.
+   */
+  static readonly LOGIN_CENTER_HEIGHT: string = '50%';
+  /**
+   *  Login bottom component height of the parent 50.
+   */
+  static readonly LOGIN_BOTTOM_HEIGHT: string = '20%';
+  /**
+   * The width or height of the component is spread across the parent component.
+   */
+  static readonly FULL_PARENT: string = '100%';
+  /**
+   * The width of button.
+   */
+  static readonly BUTTON_WIDTH: string = '90%';
+  /**
+   * Grid columns of the 4.
+   */
+  static readonly GRID_COLUMNS: string = '1fr 1fr 1fr 1fr';
+  /**
+   * Grid rows of two the 2.
+   */
+  static readonly GRID_ROWS: string = '1fr 1fr';
+  /**
+   * Home grid height of the parent 15.9.
+   */
+  static readonly HOME_GRID_HEIGHT: string = '15.9%';
+  /**
+   * Bar width lg of the parent 7.5.
+   */
+  static readonly BAR_WIDTH_LG: string = '7.5%';
+  /**
+   * Bar default height of the parent 7.2.
+   */
+  static readonly BAR_DEFAULT_HEIGHT: string = '7.2%';
+  /**
+   * Bar height lg of the parent 50.
+   */
+  static readonly BAR_HEIGHT_LG: string = '50%';
+  /**
+   * Component common width of the parent 95.
+   */
+  static readonly COMMON_WIDTH: string = '95%';
+  /**
+   * Input length of the account.
+   */
+  static readonly INPUT_ACCOUNT_LENGTH: number = 11;
+  /**
+   *  Input length of the password.
+   */
+  static readonly INPUT_PASSWORD_LENGTH: number = 20;
+  /**
+   *  Left padding of the input box.
+   */
+  static readonly INPUT_PADDING_LEFT: number = 12;
+  /**
+   *  Layout weight of number 1.
+   */
+  static readonly WEIGHT_ONE: number = 1;
+  /**
+   * Common Spacing of Components.
+   */
+  static readonly COMMON_SPACE: number = 12;
+  /**
+   * Logo margin bottom of the parent 50.
+   */
+  static readonly LOGO_MARGIN_BOTTOM: number = 50;
+  /**
+   * Item space of the 12.
+   */
+  static readonly ITEM_SPACE: number = 12;
+  /**
+   * Grid aspect ratio of the 1.32.
+   */
+  static readonly GRID_ASPECT_RATIO: number = 1.32;
+  /**
+   * Swiper count of the 1.
+   */
+  static readonly SWIPER_COUNT_ONE: number = 1;
+  /**
+   * Swiper count of the 2.
+   */
+  static readonly SWIPER_COUNT_TWO: number = 2;
+  /**
+   * Swiper count of the 3.
+   */
+  static readonly SWIPER_COUNT_THREE: number = 3;
+  /**
+   * List column of the 2.
+   */
+  static readonly LIST_COLUMN_TWO: number = 2;
+  /**
+   * List column of the 3.
+   */
+  static readonly LIST_COLUMN_THREE: number = 3;
+  /**
+   * List column of the 4.
+   */
+  static readonly LIST_COLUMN_FOUR: number = 4;
+  /**
+   * Image list of the 12.
+   */
+  static readonly IMAGE_LIST_SPACE: number = 12;
+  /**
+   * Grid row columns sm of the 4.
+   */
+  static readonly COLUMNS_SM: number = 4;
+  /**
+   * Grid row columns md of the 8.
+   */
+  static readonly COLUMNS_MD: number = 8;
+  /**
+   * Grid row columns lg of the 12.
+   */
+  static readonly COLUMNS_LG: number = 12;
+  /**
+   * Grid gutter of the 12.
+   */
+  static readonly GRID_GUTTER: number = 12;
+  /**
+   * Grid col span sm of the 4.
+   */
+  static readonly SPAN_SM: number = 4;
+  /**
+   * Grid col span md of the 6.
+   */
+  static readonly SPAN_MD: number = 6;
+  /**
+   * Grid col span lg of the 8.
+   */
+  static readonly SPAN_LG: number = 8;
+  /**
+   * Grid col offset md of the 1.
+   */
+  static readonly OFFSET_MD: number = 1;
+  /**
+   * Grid col offset lg of the 2.
+   */
+  static readonly OFFSET_LG: number = 2;
+  /**
+   * 沉浸式状态栏闪避高度
+   */
+  static readonly TOP_HEIGHT: number = Number(AppStorage.get('safeTop'))
+  /**
+   * 沉浸式导航栏闪避高度
+   */
+  static readonly BOTTOM_HEIGHT: number = Number(AppStorage.get('bottomTop'))
+}

+ 43 - 0
commons/basic/src/main/ets/styles/AttributeModifier.ets

@@ -0,0 +1,43 @@
+import StyleConstants from '../constants/StyleConstants'
+
+export class BackgroundPageModifier implements AttributeModifier<CommonAttribute> {
+  isNeedImage: boolean
+  isNeedPaddingTop: boolean
+  isNeedPaddingBottom: boolean
+
+  constructor(isNeedImage: boolean, isNeedPaddingTop: boolean = true, isNeedPaddingBottom: boolean = true) {
+    this.isNeedImage = isNeedImage
+    this.isNeedPaddingTop = isNeedPaddingTop
+    this.isNeedPaddingBottom = isNeedPaddingBottom
+  }
+
+  applyNormalAttribute(instance: CommonAttribute): void {
+    if (this.isNeedImage) {
+      instance
+        .height(StyleConstants.FULL_PARENT)
+        .width(StyleConstants.FULL_PARENT)
+        .backgroundColor($r("app.color.theme_bg_color"))
+        // .backgroundImage($r("app.media.bgPage"))
+        .backgroundImageSize({ width: '100%', height: '100%' })//backgroundImageSize((ImageSize.Cover))
+        .backgroundImagePosition(Alignment.Center)
+        .padding({
+          top: this.isNeedPaddingTop ? StyleConstants.TOP_HEIGHT : 0,
+          bottom: this.isNeedPaddingBottom ? StyleConstants.BOTTOM_HEIGHT : 0,
+          left: 10,
+          right: 10
+        })
+    } else {
+      instance
+        .height(StyleConstants.FULL_PARENT)
+        .width(StyleConstants.FULL_PARENT)
+        .backgroundColor($r("app.color.theme_bg_color"))
+        .padding({
+          top: this.isNeedPaddingTop ? StyleConstants.TOP_HEIGHT : 0,
+          bottom: this.isNeedPaddingBottom ? StyleConstants.BOTTOM_HEIGHT : 0,
+          left: 10,
+          right: 10
+        })
+    }
+  }
+}
+

+ 2 - 2
commons/basic/src/main/ets/utils/YTPhotoHelper.ets

@@ -76,10 +76,10 @@ export class YTPhotoHelper {
   }
 
   //从相册选择图片
-  selectImage(success: (fullPath: string) => void) {
+  selectImage(success: (fullPath: string) => void, maxNumber: number = 1) {
     const option = new photoAccessHelper.PhotoSelectOptions()
     option.MIMEType = photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE
-    option.maxSelectNumber = 1
+    option.maxSelectNumber = maxNumber
     const picker = new photoAccessHelper.PhotoViewPicker()
     picker.select(option)
       .then(res => {

+ 4 - 0
commons/basic/src/main/resources/base/element/color.json

@@ -19,6 +19,10 @@
     {
       "name": "main_blank",
       "value": "#FF161718"
+    },
+    {
+      "name": "theme_bg_color",
+      "value": "#FF161718"
     }
   ]
 }

+ 32 - 45
features/feature/src/main/ets/view/MainView.ets

@@ -1,50 +1,37 @@
-import { DateOption, YTDateUtil, YTAddressSelectorDialog } from "basic"
-import { UnitType } from "basic/src/main/ets/datepicker/DatePickerEnums"
-import { promptAction } from "@kit.ArkUI"
-
 @Component
 export struct MainView {
-
   build() {
-    Text('打开日历')
-      .onClick(() => {
-        //以下内容都可以不传 有默认值
-        const date: Date = new Date()
-        const yTDateDialog = new YTAddressSelectorDialog(this.getUIContext())
-        let dateOption = new DateOption()//选项配置类
-        dateOption.date = date//当前日期  默认今天
-        dateOption.minDate = new Date(2000,0,1)//最小选择的日期 默认10年前的今天
-        dateOption.maxDate = new Date(2048,12,30)//最大选择的日期 默认10年后的今天
-        dateOption.unitType = UnitType.YEAR_MONTH_DAY//日期单位 默认年月日 可选年月、月日等组合
-        dateOption.confirm = (date: Date) => {//确认选择回调函数
-          console.log('确认', YTDateUtil.formatDate( date))
-          promptAction.openToast({message:YTDateUtil.formatDate( date)})
-        }
-        dateOption.headerLeftBuilder = wrapBuilder(headerLeftBuilder)//头部左侧按钮 默认返回按钮
-        dateOption.headerRightBuilder = wrapBuilder(headerLeftBuilder)//头部右侧按钮 默认确认按钮
-        dateOption.highlightBackgroundColor = Color.Pink//选中高亮背景色
-        dateOption.highlightBorderColor = Color.Red//选中高亮边框色
-        dateOption.textStyle = {//日期文字样式
-          font:{size:20,weight:400},
-          color:Color.Gray
-        }
-        dateOption.selectedTextStyle = {//选中日期文字样式
-          font:{size:25,weight:400},
-          color:Color.Yellow
-        }
-        yTDateDialog.show(dateOption)//设置好配置之后打开日历的函数
-      })
-  }
+    Column() {
+      Text('打开日历')
+        .onClick(() => {
+          //以下内容都可以不传 有默认值
+          const date: Date = new Date()
+          const yTDateDialog = new YTAddressSelectorDialog(this.getUIContext())
+          let dateOption = new DateOption()//选项配置类
+          dateOption.date = date//当前日期  默认今天
+          dateOption.minDate = new Date(2000,0,1)//最小选择的日期 默认10年前的今天
+          dateOption.maxDate = new Date(2048,12,30)//最大选择的日期 默认10年后的今天
+          dateOption.unitType = UnitType.YEAR_MONTH_DAY//日期单位 默认年月日 可选年月、月日等组合
+          dateOption.confirm = (date: Date) => {//确认选择回调函数
+            console.log('确认', YTDateUtil.formatDate( date))
+            promptAction.openToast({message:YTDateUtil.formatDate( date)})
+          }
+          dateOption.headerLeftBuilder = wrapBuilder(headerLeftBuilder)//头部左侧按钮 默认返回按钮
+          dateOption.headerRightBuilder = wrapBuilder(headerLeftBuilder)//头部右侧按钮 默认确认按钮
+          dateOption.highlightBackgroundColor = Color.Pink//选中高亮背景色
+          dateOption.highlightBorderColor = Color.Red//选中高亮边框色
+          dateOption.textStyle = {//日期文字样式
+            font:{size:20,weight:400},
+            color:Color.Gray
+          }
+          dateOption.selectedTextStyle = {//选中日期文字样式
+            font:{size:25,weight:400},
+            color:Color.Yellow
+          }
+          yTDateDialog.show(dateOption)//设置好配置之后打开日历的函数
+        })
+    }
+    .attributeModifier(new BackgroundPageModifier(true))
 
-}
-@Builder
-function headerLeftBuilder(){
-  Image($r('app.media.app_icon'))
-    .width(24)
-}
-
-@Builder
-function headerRightBuilder(){
-  Image($r("app.media.app_icon"))
-    .width(24)
+  }
 }

+ 2 - 1
products/entry/src/main/ets/pages/Index.ets

@@ -1,4 +1,4 @@
-import { BasicType, YTAvoid, yTRouter, yTToast, YTUserRequest } from 'basic';
+import { BackgroundPageModifier, BasicType, YTAvoid, yTRouter, yTToast, YTUserRequest } from 'basic';
 import { Mine } from 'user/src/main/ets/views/Mine';
 import { MainView, SecondView, ThirdView } from 'feature';
 
@@ -85,6 +85,7 @@ struct Index {
       .height('100%')
       .backgroundColor(Color.White)
 
+
     }
     .mode(NavigationMode.Stack)
     .hideToolBar(true)