From ec2897d27f2fa25532bb6afca27e437596eb5a2a Mon Sep 17 00:00:00 2001 From: caoliwen1 <14658249+caoliwen1@user.noreply.gitee.com> Date: Fri, 6 Sep 2024 10:49:20 +0800 Subject: [PATCH] =?UTF-8?q?CustomDialogGathers=E6=B8=AF=E6=BE=B3=E5=8F=B0?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/common/constants/CommonConstants.ets | 17 -- .../main/ets/pages/BindContentCoverDemo.ets | 2 +- entry/src/main/ets/pages/BindSheet.ets | 4 +- entry/src/main/ets/pages/CustomCalendar.ets | 12 +- entry/src/main/ets/pages/Details.ets | 2 +- entry/src/main/ets/pages/Privacy.ets | 4 +- entry/src/main/ets/pages/Toast.ets | 2 +- .../ets/view/CustomCalendarPickerDialog.ets | 12 +- .../main/ets/viewmodel/BindContentModel.ets | 10 +- .../main/resources/base/element/float.json | 2 +- .../main/resources/base/element/string.json | 124 ++++++++++++ .../main/resources/en_US/element/string.json | 178 +++++++++++++++--- .../main/resources/zh_CN/element/string.json | 124 ++++++++++++ 13 files changed, 430 insertions(+), 63 deletions(-) diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/entry/src/main/ets/common/constants/CommonConstants.ets index 4f629e3..77abb07 100644 --- a/entry/src/main/ets/common/constants/CommonConstants.ets +++ b/entry/src/main/ets/common/constants/CommonConstants.ets @@ -185,23 +185,6 @@ export class CommonConstants { */ static readonly ONE_ZERO: number = 1.0; - /** - * Privacy pop-up window content 1. - */ - static readonly TEXT_ONE: string = '根据《常见类型移动互联网应用程序必要个人信息范围规定》,主要功能为购买商品,必要个人信息为:' + - '注册用户电话号码;收货人姓名、地址、联系电话;支付时间、支付金额、支付渠道等。请您在使用我们的服务前仔细阅读'; - - /** - * Privacy pop-up window content 2. - */ - static readonly TEXT_TWO: string = '。请您知悉,同意隐私政策仅代表您已了解应用提供功能,以及功能运行所需的必要个人信息。基于您的授权我们可能会获取您的位置等信息,您有权拒绝或取消授权;' + - '我们会采取业界先进的安全措施保护您的信息安全;未经您同意,我们不会从第三方处获取、共享或向其提供您的信息;您可以查询、更正、删除您的个人信息'; - - /** - * Edit. - */ - static readonly EDIT: string = '编辑'; - /** * Saturday. */ diff --git a/entry/src/main/ets/pages/BindContentCoverDemo.ets b/entry/src/main/ets/pages/BindContentCoverDemo.ets index 6051c7a..d11ac00 100644 --- a/entry/src/main/ets/pages/BindContentCoverDemo.ets +++ b/entry/src/main/ets/pages/BindContentCoverDemo.ets @@ -71,7 +71,7 @@ struct BindContentCoverDemo { secondaryText: item.cardNum }), operateItem: ({ - text: CommonConstants.EDIT + text: $r('app.string.edit') }) }) } diff --git a/entry/src/main/ets/pages/BindSheet.ets b/entry/src/main/ets/pages/BindSheet.ets index 79793d7..3490712 100644 --- a/entry/src/main/ets/pages/BindSheet.ets +++ b/entry/src/main/ets/pages/BindSheet.ets @@ -18,7 +18,7 @@ import { CommonConstants } from '../common/constants/CommonConstants'; @Component struct BindSheetDemo { @State isShowSheet: boolean = false; - private menuList: string[] = ['少放辣', '不需要辣', '需要一次性餐具', '多放辣', '不要香菜', '不要一次性餐具']; + private menuList: ResourceStr[] = [$r('app.string.spicy'), $r('app.string.spicy1'), $r('app.string.spicy2'), $r('app.string.spicy3'), $r('app.string.spicy4'), $r('app.string.spicy5')]; @Builder mySheet() { Column() { Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap }) { @@ -79,7 +79,7 @@ struct BindSheetDemo { .alignItems(VerticalAlign.Center) .padding({ left: $r('app.float.column_padding'), top: $r('app.float.column_padding'), bottom: $r('app.float.column_padding') }) .backgroundColor(Color.White) - .bindSheet(this.isShowSheet, this.mySheet(), { + .bindSheet($$this.isShowSheet, this.mySheet(), { height: $r('app.float.bind_sheet_height'), dragBar: false, showClose: false diff --git a/entry/src/main/ets/pages/CustomCalendar.ets b/entry/src/main/ets/pages/CustomCalendar.ets index 4e100ff..a2da74a 100644 --- a/entry/src/main/ets/pages/CustomCalendar.ets +++ b/entry/src/main/ets/pages/CustomCalendar.ets @@ -21,7 +21,7 @@ import { CommonConstants } from '../common/constants/CommonConstants'; @Entry @Component export struct CalendarView { - private week: string[] = ['日', '一', '二', '三', '四', '五', '六']; + private week: ResourceStr[] = [$r('app.string.sunday'), $r('app.string.monday'), $r('app.string.tuesday'), $r('app.string.wednesday'), $r('app.string.thursday'), $r('app.string.friday'), $r('app.string.saturday')]; @State currentMonth: number = 1; @State currentDay: number = 1; @State currentYear: number = 1; @@ -48,6 +48,12 @@ export struct CalendarView { onCancel() { } + getResourceString(resource: Resource): string { + let resourceString: string = ''; + resourceString = getContext(this).resourceManager.getStringSync(resource.id); + return resourceString; + } + @Builder calendarMainView() { Column({ space: CommonConstants.ELEMENTS_MARGIN_L }) { @@ -64,9 +70,9 @@ export struct CalendarView { .width(CommonConstants.ONE_HUNDRED_PERCENT) Row({ space: CommonConstants.ELEMENTS_MARGIN_M }) { - Text(`${this.dateModel.month}月${this.dateModel.day}日`) + Text(`${this.dateModel.month}${this.getResourceString($r('app.string.month'))}${this.dateModel.day}${this.getResourceString($r('app.string.day'))}`) .fontSize($r('app.float.text_size_headline')) - Text(`星期${this.week[this.dateModel.week]}`) + Text(this.week[this.dateModel.week]) .fontSize($r('app.float.text_size_body1')) } .justifyContent(FlexAlign.Start) diff --git a/entry/src/main/ets/pages/Details.ets b/entry/src/main/ets/pages/Details.ets index 3c5e00b..c832289 100644 --- a/entry/src/main/ets/pages/Details.ets +++ b/entry/src/main/ets/pages/Details.ets @@ -22,7 +22,7 @@ struct Details { build() { Row() { Column() { - Button('返回').onClick(() => { + Button($r('app.string.back')).onClick(() => { router.back(); }) } diff --git a/entry/src/main/ets/pages/Privacy.ets b/entry/src/main/ets/pages/Privacy.ets index afbb9b8..6bbb972 100644 --- a/entry/src/main/ets/pages/Privacy.ets +++ b/entry/src/main/ets/pages/Privacy.ets @@ -77,7 +77,7 @@ struct Privacy { Scroll(this.scroller) { Text() { - Span(CommonConstants.TEXT_ONE) + Span($r('app.string.word1')) Span($r('app.string.toast_text')) .fontColor(Color.Orange) .fontWeight(FontWeight.Bold) @@ -87,7 +87,7 @@ struct Privacy { url: 'pages/Details' }) }) - Span(CommonConstants.TEXT_TWO) + Span($r('app.string.word2')) } .fontSize($r('app.float.font_size1')) .padding({ diff --git a/entry/src/main/ets/pages/Toast.ets b/entry/src/main/ets/pages/Toast.ets index faf3c7d..819f1e3 100644 --- a/entry/src/main/ets/pages/Toast.ets +++ b/entry/src/main/ets/pages/Toast.ets @@ -35,7 +35,7 @@ struct CustomDialogExample { @Component struct CustomDialogUser { @State textValue: string = ''; - @State inputValue: string = '点击Toast'; + @State inputValue: ResourceStr = $r('app.string.click'); dialogController: CustomDialogController | null = new CustomDialogController({ builder: CustomDialogExample(), openAnimation: { diff --git a/entry/src/main/ets/view/CustomCalendarPickerDialog.ets b/entry/src/main/ets/view/CustomCalendarPickerDialog.ets index c08c20c..a9623f0 100644 --- a/entry/src/main/ets/view/CustomCalendarPickerDialog.ets +++ b/entry/src/main/ets/view/CustomCalendarPickerDialog.ets @@ -32,7 +32,13 @@ export struct CustomCalendarPickerDialog { @StorageLink('selectedDate') dateModel: DateModel = new DateModel(0, 0, 0, 0); controller: CustomDialogController; cancel: () => void = () => {}; - private week: string[] = ['日', '一', '二', '三', '四', '五', '六']; + private week: ResourceStr[] = [$r('app.string.ri'), $r('app.string.yi'), $r('app.string.er'), $r('app.string.san'), $r('app.string.si'), $r('app.string.wu'), $r('app.string.liu')]; + + getResourceString(resource: Resource): string { + let resourceString: string = ''; + resourceString = getContext(this).resourceManager.getStringSync(resource.id); + return resourceString; + } aboutToAppear() { this.currentMonthDay = getMonthDate(this.currentMonth, this.currentYear); @@ -46,12 +52,12 @@ export struct CustomCalendarPickerDialog { this.nextMonthDay = getMonthDate(this.nextMonth, this.nextYear); let months: Month[] = [ { - month: `${this.currentYear}年 ${this.currentMonth}月`, + month: `${this.currentYear}${this.getResourceString($r('app.string.year'))} ${this.currentMonth}${this.getResourceString($r('app.string.month'))}`, num: this.currentMonth, days: this.currentMonthDay }, { - month: `${this.nextYear}年 ${this.nextMonth}月`, + month: `${this.nextYear}${this.getResourceString($r('app.string.year'))} ${this.nextMonth}${this.getResourceString($r('app.string.month'))}`, num: this.nextMonth, days: this.nextMonthDay } diff --git a/entry/src/main/ets/viewmodel/BindContentModel.ets b/entry/src/main/ets/viewmodel/BindContentModel.ets index 55eb2b7..0a0b872 100644 --- a/entry/src/main/ets/viewmodel/BindContentModel.ets +++ b/entry/src/main/ets/viewmodel/BindContentModel.ets @@ -13,13 +13,13 @@ * limitations under the License. */ export interface PersonList { - name: string, + name: ResourceStr, cardNum: string } export const personList: PersonList[] = [ - { name: '王**', cardNum: '1234***********789' }, - { name: '宋*', cardNum: '2345***********789' }, - { name: '许**', cardNum: '3456***********789' }, - { name: '唐*', cardNum: '4567***********789' } + { name: $r('app.string.wang'), cardNum: '1234***********789' }, + { name: $r('app.string.song'), cardNum: '2345***********789' }, + { name: $r('app.string.xu'), cardNum: '3456***********789' }, + { name: $r('app.string.tang'), cardNum: '4567***********789' } ]; \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json index 8aa1302..9705ce1 100644 --- a/entry/src/main/resources/base/element/float.json +++ b/entry/src/main/resources/base/element/float.json @@ -134,7 +134,7 @@ }, { "name": "toast_width", - "value": "120vp" + "value": "150vp" }, { "name": "bottom_margin", diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 8e6540b..35a38aa 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -183,6 +183,130 @@ { "name": "button_five", "value": "close sheet1 sheet2" + }, + { + "name": "wang", + "value": "王**" + }, + { + "name": "song", + "value": "宋*" + }, + { + "name": "xu", + "value": "许**" + }, + { + "name": "tang", + "value": "唐*" + }, + { + "name": "spicy", + "value": "少放辣" + }, + { + "name": "spicy1", + "value": "不需要辣" + }, + { + "name": "spicy2", + "value": "需要一次性餐具" + }, + { + "name": "spicy3", + "value": "多放辣" + }, + { + "name": "spicy4", + "value": "不要香菜" + }, + { + "name": "spicy5", + "value": "不要一次性餐具" + }, + { + "name": "click", + "value": "点击Toast" + }, + { + "name": "back", + "value": "返回" + }, + { + "name": "word1", + "value": "根据《常见类型移动互联网应用程序必要个人信息范围规定》,主要功能为购买商品,必要个人信息为:注册用户电话号码;收货人姓名、地址、联系电话;支付时间、支付金额、支付渠道等。请您在使用我们的服务前仔细阅读" + }, + { + "name": "word2", + "value": "。请您知悉,同意隐私政策仅代表您已了解应用提供功能,以及功能运行所需的必要个人信息。基于您的授权我们可能会获取您的位置等信息,您有权拒绝或取消授权;我们会采取业界先进的安全措施保护您的信息安全;未经您同意,我们不会从第三方处获取、共享或向其提供您的信息;您可以查询、更正、删除您的个人信息" + }, + { + "name": "ri", + "value": "日" + }, + { + "name": "yi", + "value": "一" + }, + { + "name": "er", + "value": "二" + }, + { + "name": "san", + "value": "三" + }, + { + "name": "si", + "value": "四" + }, + { + "name": "wu", + "value": "五" + }, + { + "name": "liu", + "value": "六" + }, + { + "name": "year", + "value": "年" + }, + { + "name": "month", + "value": "月" + }, + { + "name": "day", + "value": "日" + }, + { + "name": "sunday", + "value": "星期日" + }, + { + "name": "monday", + "value": "星期一" + }, + { + "name": "tuesday", + "value": "星期二" + }, + { + "name": "wednesday", + "value": "星期三" + }, + { + "name": "thursday", + "value": "星期四" + }, + { + "name": "friday", + "value": "星期五" + }, + { + "name": "saturday", + "value": "星期六" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json index 1857d1c..af78288 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "customized pop-up window set" + "value": "Customized pop-up window set" }, { "name": "departure", @@ -22,11 +22,11 @@ }, { "name": "check_ticket", - "value": "check ticket" + "value": "Check ticket" }, { "name": "departure_date", - "value": "departure date" + "value": "Departure date" }, { "name": "button_text", @@ -50,15 +50,15 @@ }, { "name": "index_name", - "value": "custom pop-up window collection" + "value": "Custom pop-up window collection" }, { "name": "scroll_option", - "value": "sliding selection popup" + "value": "Sliding selection popup" }, { "name": "select_person", - "value": "choose a rider" + "value": "Choose a rider" }, { "name": "add_person", @@ -66,15 +66,15 @@ }, { "name": "edit", - "value": "edit" + "value": "Edit" }, { "name": "confirmed", - "value": "confirm" + "value": "Confirm" }, { "name": "confirm_order", - "value": "confirm Order" + "value": "Confirm Order" }, { "name": "start_time", @@ -82,7 +82,7 @@ }, { "name": "start_string", - "value": "departure station" + "value": "Departure" }, { "name": "car_name", @@ -98,71 +98,195 @@ }, { "name": "end_name", - "value": "terminal" + "value": "Terminal" }, { "name": "button_select", - "value": "choose a rider" + "value": "Choose a rider" }, { "name": "dialog_name", - "value": "modal pop-up window" + "value": "Modal pop-up window" }, { "name": "tastes", - "value": "taste and tableware" + "value": "Taste and tableware" }, { "name": "choose_flavors", - "value": "choose your ordering flavors and tableware" + "value": "Choose flavors and cutlery" }, { "name": "bind_sheet_dialog", - "value": "semi-modal pop-up window" + "value": "Semi-modal pop-up window" }, { "name": "login", - "value": "login successfully !" + "value": "Login successfully !" }, { "name": "toast_dialog", - "value": "toast pop-up window" + "value": "Toast pop-up window" }, { "name": "button_name1", - "value": "privacy popup" + "value": "Privacy popup" }, { "name": "button_name2", - "value": "kind tips" + "value": "Kind tips" }, { "name": "two_level_dialog", - "value": "two-level semi-modal + full-screen pop-up window" + "value": "Two semi-modal + full-screen window" }, { "name": "toast_text", - "value": "privacy Policy" + "value": "Privacy Policy" }, { "name": "disagree", - "value": "disagree" + "value": "Disagree" }, { "name": "agreed", - "value": "agree" + "value": "Agree" }, { "name": "toast_private_dialog", - "value": "privacy Agreement pop-up window" + "value": "Privacy Agreement pop-up window" }, { "name": "full_screen", - "value": "full screen pop-up window" + "value": "Full screen pop-up window" }, { "name": "calendar_dialog", - "value": "custom calendar picker popup" + "value": "Custom calendar picker popup" + }, + { + "name": "wang", + "value": "wang**" + }, + { + "name": "song", + "value": "song*" + }, + { + "name": "xu", + "value": "xu**" + }, + { + "name": "tang", + "value": "tang*" + }, + { + "name": "spicy", + "value": "Less spicy" + }, + { + "name": "spicy1", + "value": "No need for spicy" + }, + { + "name": "spicy2", + "value": "Need disposable cutlery" + }, + { + "name": "spicy3", + "value": "Extra spicy" + }, + { + "name": "spicy4", + "value": "No cilantro" + }, + { + "name": "spicy5", + "value": "No disposable utensils" + }, + { + "name": "click", + "value": "Click Toast" + }, + { + "name": "back", + "value": "Back" + }, + { + "name": "word1", + "value": "According to the Provisions on the Scope of Necessary Personal Information for Common Types of Mobile Internet Applications, the main function is to purchase goods, and the necessary personal information is: telephone number of registered users; Name, address and telephone number of the consignee; Payment time, payment amount, payment channel, etc. Please read carefully before using our services" + }, + { + "name": "word2", + "value": ". Please note that agreeing to the Privacy policy only means that you have understood the functions provided by the App and the necessary personal information required for the function to operate. Based on your authorization, we may obtain your location and other information, and you have the right to refuse or cancel the authorization; We will take the industry's advanced security measures to protect your information security; We will not obtain, share or provide your information from third parties without your consent; You can query, correct and delete your personal information" + }, + { + "name": "ri", + "value": "Sun" + }, + { + "name": "yi", + "value": "Mon" + }, + { + "name": "er", + "value": "Tue" + }, + { + "name": "san", + "value": "Wed" + }, + { + "name": "si", + "value": "Thu" + }, + { + "name": "wu", + "value": "Fri" + }, + { + "name": "liu", + "value": "Sat" + }, + { + "name": "year", + "value": "year" + }, + { + "name": "month", + "value": "month" + }, + { + "name": "day", + "value": "day" + }, + { + "name": "sunday", + "value": "Sunday" + }, + { + "name": "monday", + "value": "Monday" + }, + { + "name": "tuesday", + "value": "Tuesday" + }, + { + "name": "wednesday", + "value": "Wednesday" + }, + { + "name": "thursday", + "value": "Thursday" + }, + { + "name": "friday", + "value": "Friday" + }, + { + "name": "saturday", + "value": "Saturday" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index 7638715..db7ba4b 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -163,6 +163,130 @@ { "name": "calendar_dialog", "value": "自定义日历选择器弹窗" + }, + { + "name": "wang", + "value": "王**" + }, + { + "name": "song", + "value": "宋*" + }, + { + "name": "xu", + "value": "许**" + }, + { + "name": "tang", + "value": "唐*" + }, + { + "name": "spicy", + "value": "少放辣" + }, + { + "name": "spicy1", + "value": "不需要辣" + }, + { + "name": "spicy2", + "value": "需要一次性餐具" + }, + { + "name": "spicy3", + "value": "多放辣" + }, + { + "name": "spicy4", + "value": "不要香菜" + }, + { + "name": "spicy5", + "value": "不要一次性餐具" + }, + { + "name": "click", + "value": "点击Toast" + }, + { + "name": "back", + "value": "返回" + }, + { + "name": "word1", + "value": "根据《常见类型移动互联网应用程序必要个人信息范围规定》,主要功能为购买商品,必要个人信息为:注册用户电话号码;收货人姓名、地址、联系电话;支付时间、支付金额、支付渠道等。请您在使用我们的服务前仔细阅读" + }, + { + "name": "word2", + "value": "。请您知悉,同意隐私政策仅代表您已了解应用提供功能,以及功能运行所需的必要个人信息。基于您的授权我们可能会获取您的位置等信息,您有权拒绝或取消授权;我们会采取业界先进的安全措施保护您的信息安全;未经您同意,我们不会从第三方处获取、共享或向其提供您的信息;您可以查询、更正、删除您的个人信息" + }, + { + "name": "ri", + "value": "日" + }, + { + "name": "yi", + "value": "一" + }, + { + "name": "er", + "value": "二" + }, + { + "name": "san", + "value": "三" + }, + { + "name": "si", + "value": "四" + }, + { + "name": "wu", + "value": "五" + }, + { + "name": "liu", + "value": "六" + }, + { + "name": "year", + "value": "年" + }, + { + "name": "month", + "value": "月" + }, + { + "name": "day", + "value": "日" + }, + { + "name": "sunday", + "value": "星期日" + }, + { + "name": "monday", + "value": "星期一" + }, + { + "name": "tuesday", + "value": "星期二" + }, + { + "name": "wednesday", + "value": "星期三" + }, + { + "name": "thursday", + "value": "星期四" + }, + { + "name": "friday", + "value": "星期五" + }, + { + "name": "saturday", + "value": "星期六" } ] } \ No newline at end of file -- Gitee