diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/app.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/Application/MyAbilityStage.ts similarity index 69% rename from ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/app.ets rename to ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/Application/MyAbilityStage.ts index 2a3b6238737330f469fc124b0669aacd9a376056..396606ff7396988f0849e54a294700ad86e22678 100644 --- a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/app.ets +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/Application/MyAbilityStage.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 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 @@ -13,11 +13,10 @@ * limitations under the License. */ -export default { - onCreate() { - console.info('Application onCreate') - }, - onDestroy() { - console.info('Application onDestroy') - }, -} +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/model/FoodData.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/MainAbility/MainAbility.ts similarity index 35% rename from ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/model/FoodData.ets rename to ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/MainAbility/MainAbility.ts index 3507f35acc12ccf9db1cde864dcfbf8eb4fc15c2..57de34db38a9e6ea30c5426da7a3ec987c22d76b 100644 --- a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/model/FoodData.ets +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 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 @@ -13,35 +13,39 @@ * limitations under the License. */ -export enum Category { - Fruit, - Vegetable, - Nut, - Seafood, - Dessert -} +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + console.log("[Demo] MainAbility onWindowStageCreate") -let NextId = 0; -export class FoodData { - id: string; - name: string; - image: Resource - category: Category; - calories: number; - protein: number; - fat: number; - carbohydrates: number; - vitaminC: number; - - constructor(name: string, image: Resource, category: Category, calories: number, protein: number, fat: number, carbohydrates: number, vitaminC: number) { - this.id = `${ NextId++ }`; - this.name = name; - this.image = image; - this.category = category; - this.calories = calories; - this.protein = protein; - this.fat = fat; - this.carbohydrates = carbohydrates; - this.vitaminC = vitaminC; - } -} \ No newline at end of file + windowStage.loadContent("pages/Home", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)) + return + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }) + } + + onWindowStageDestroy() { + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + console.log("[Demo] MainAbility onBackground") + } +} diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/common/BreakpointSystem.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/common/BreakpointSystem.ets new file mode 100644 index 0000000000000000000000000000000000000000..0bed39d5c142a39f402bd7fb21b192ec4fef3239 --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/common/BreakpointSystem.ets @@ -0,0 +1,67 @@ +import mediaQuery from '@ohos.mediaquery' + +export class BreakPointType { + sm: T + md: T + lg: T + + constructor(sm: T, md: T, lg: T) { + this.sm = sm + this.md = md + this.lg = lg + } + + GetValue(currentBreakPoint: string) { + if (currentBreakPoint === 'sm') { + return this.sm + } else if (currentBreakPoint === 'md') { + return this.md + } else if (currentBreakPoint === 'lg') { + return this.lg + } else { + return undefined + } + } +} + +export class BreakpointSystem { + private currentBreakpoint: string = 'md' + private smListener: any + private mdListener: any + private lgListener: any + + private updateCurrentBreakpoint(breakpoint: string) { + console.log('currentBreakpoint:' + this.currentBreakpoint) + if (this.currentBreakpoint !== breakpoint) { + this.currentBreakpoint = breakpoint + AppStorage.Set('currentBreakpoint', this.currentBreakpoint) + } + } + + public register() { + this.smListener = mediaQuery.matchMediaSync("(800 { + if (mediaQueryResult.matches) { + this.updateCurrentBreakpoint('sm') + } + }) + this.mdListener = mediaQuery.matchMediaSync("(1200 { + if (mediaQueryResult.matches) { + this.updateCurrentBreakpoint('md') + } + }) + this.lgListener = mediaQuery.matchMediaSync("(2500 { + if (mediaQueryResult.matches) { + this.updateCurrentBreakpoint('lg') + } + }) + } + + public unregister() { + this.smListener.off('change', this.smListener) + this.mdListener.off('change', this.mdListener) + this.lgListener.off('change', this.lgListener) + } +} \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/common/Constants.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/common/Constants.ets new file mode 100644 index 0000000000000000000000000000000000000000..b01c9d30053f9b5839c31a7e8d2f303c13e63b0d --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/common/Constants.ets @@ -0,0 +1 @@ +export let APP_THEME_COLOR: string = '#73CD57' \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/model/FoodDataModels.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/model/FoodDataModels.ets deleted file mode 100644 index fd6fa8304ea7b7d9ed7c26fb95d0101b801b4338..0000000000000000000000000000000000000000 --- a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/model/FoodDataModels.ets +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2021 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. - */ - -import { FoodData, Category } from './FoodData' - -const FoodComposition: any[] = [ - { 'name': 'Tomato', 'image': $r('app.media.Tomato'), 'category': Category.Vegetable, 'calories': 17, 'protein': 0.9, 'fat': 0.2, 'carbohydrates': 3.9, 'vitaminC': 17.8 }, - { 'name': 'Walnut', 'image': $r('app.media.Walnut'), 'category': Category.Nut, 'calories': 654 , 'protein': 15, 'fat': 65, 'carbohydrates': 14, 'vitaminC': 1.3 }, - { 'name': 'Cucumber', 'image': $r('app.media.Cucumber'), 'category': Category.Vegetable, 'calories': 30, 'protein': 3, 'fat': 0, 'carbohydrates': 1.9, 'vitaminC': 2.1 }, - { 'name': 'Blueberry', 'image': $r('app.media.Blueberry'), 'category': Category.Fruit, 'calories': 57, 'protein': 0.7, 'fat': 0.3, 'carbohydrates': 14, 'vitaminC': 9.7 }, - { 'name': 'Crab', 'image': $r('app.media.Crab'), 'category': Category.Seafood, 'calories': 97, 'protein': 19, 'fat': 1.5, 'carbohydrates': 0, 'vitaminC': 7.6 }, - { 'name': 'IceCream', 'image': $r('app.media.IceCream'), 'category': Category.Dessert, 'calories': 207, 'protein': 3.5, 'fat': 11, 'carbohydrates': 24, 'vitaminC': 0.6 }, - { 'name': 'Onion', 'image': $r('app.media.Onion'), 'category': Category.Vegetable, 'calories': 39, 'protein': 1.1, 'fat': 0.1, 'carbohydrates': 9, 'vitaminC': 7.4 }, - { 'name': 'Mushroom', 'image': $r('app.media.Mushroom'), 'category': Category.Vegetable, 'calories': 22, 'protein': 3.1, 'fat': 0.3, 'carbohydrates': 3.3, 'vitaminC': 2.1 }, - { 'name': 'Kiwi', 'image': $r('app.media.Kiwi'), 'category': Category.Fruit, 'calories': 60 , 'protein': 1.1, 'fat': 0.5, 'carbohydrates': 15, 'vitaminC': 20.5 }, - { 'name': 'Pitaya', 'image': $r('app.media.Pitaya'), 'category': Category.Fruit, 'calories': 60, 'protein': 1.2, 'fat': 0, 'carbohydrates': 10, 'vitaminC': 60.9 }, - { 'name': 'Avocado', 'image': $r('app.media.Avocado'), 'category': Category.Fruit, 'calories': 160, 'protein': 2, 'fat': 15, 'carbohydrates': 9, 'vitaminC': 10 }, - { 'name': 'Strawberry', 'image': $r('app.media.Strawberry'), 'category': Category.Fruit, 'calories': 32, 'protein': 0.7, 'fat': 0.3, 'carbohydrates': 8, 'vitaminC': 58.8 } -] - -export function initializeOnStartup(): Array { - let FoodDataArray: Array = [] - FoodComposition.forEach(item => { - FoodDataArray.push(new FoodData(item.name, item.image, item.category, item.calories, item.protein, item.fat, item.carbohydrates, item.vitaminC)); - }) - return FoodDataArray; -} diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/pages/FoodDetail.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/pages/FoodDetail.ets deleted file mode 100644 index 09519bad99f0e4f21b3d53621e2f3f5c2493c3b5..0000000000000000000000000000000000000000 --- a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/pages/FoodDetail.ets +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2021 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. - */ - -import Curves from '@ohos.curves' -import router from '@system.router' -import { FoodData, Category } from '../model/FoodData' - -@Component -struct PageTitle { - build() { - Flex({ alignItems: ItemAlign.Start }) { - Image($r('app.media.Back')) - .width(21.8) - .height(19.6) - Text('Food Detail') - .fontSize(21.8) - .margin({ left: 17.4 }) - } - .height(61) - .backgroundColor('#FFedf2f5') - .padding({ top: 13, bottom: 15, left: 28.3 }) - .onClick(() => { - router.back() - }) - } -} - -@Component -struct FoodImageDisplay { - private foodItem: FoodData - build() { - Stack({ alignContent: Alignment.BottomStart }) { - Image(this.foodItem.image) - .objectFit(ImageFit.Contain) - .sharedTransition(this.foodItem.id, { duration: 1000, curve: Curves.cubicBezier(0.2, 0.2, 0.1, 1.0), delay: 100}) - Text(this.foodItem.name) - .fontSize(26) - .fontWeight(500) - .margin({ left: 26, bottom: 17.4 }) - } - .backgroundColor('#FFedf2f5') - .height(357) - } -} - -@Component -struct ContentTable { - private foodItem: FoodData - @Builder IngredientItem(title:string, colorValue: string, name: string, value: string) { - Flex() { - Text(title) - .fontSize(17.4) - .fontWeight(FontWeight.Bold) - .layoutWeight(1) - Flex({ alignItems: ItemAlign.Center }) { - Circle({ width: 6, height: 6 }) - .margin({ right: 12 }) - .fill(colorValue) - Text(name) - .fontSize(17.4) - .flexGrow(1) - Text(value) - .fontSize(17.4) - } - .layoutWeight(2) - } - } - - build() { - Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { - this.IngredientItem('Calories', '#FFf54040', 'Calories', this.foodItem.calories + 'kcal') - this.IngredientItem('Nutrition', '#FFcccccc', 'Protein', this.foodItem.protein + 'g') - this.IngredientItem(' ', '#FFf5d640', 'Fat', this.foodItem.fat + 'g') - this.IngredientItem(' ', '#FF9e9eff', 'Carbohydrates', this.foodItem.carbohydrates + 'g') - this.IngredientItem(' ', '#FF53f540', 'VitaminC', this.foodItem.vitaminC + 'mg') - } - .padding({ top: 20, right: 20, left: 20 }) - .height(250) - } -} - -@Entry -@Component -struct FoodDetail { - private foodItem: FoodData = router.getParams().foodId - build() { - Column() { - Stack({ alignContent: Alignment.TopStart }) { - FoodImageDisplay({ foodItem: this.foodItem }) - PageTitle() - } - ContentTable({ foodItem: this.foodItem }) - } - .alignItems(HorizontalAlign.Center) - } -} \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/mock/MockData.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/mock/MockData.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1a2d34806996aa238295e370ba77c91080a4919 --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/mock/MockData.ets @@ -0,0 +1,281 @@ +/* + * Copyright (c) 2021 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. + */ + +import { FoodInfo, Category, OneMealStatisticsInfo, MealFoodInfo, DietRecord } from '../model/DataModels' +import router from '@ohos.router' + +const DEBUG = true + +const FoodComposition: any[] = [ + { + 'id': '1', + 'name': 'Tomato', + 'image': $r('app.media.Tomato'), + 'category': Category.Vegetable, + 'calories': 15, + 'protein': 0.9, + 'fat': 0.2, + 'carbohydrates': 3.3, + 'vitaminC': 14.0 + }, + { + 'id': '2', + 'name': 'Walnut', + 'image': $r('app.media.Walnut'), + 'category': Category.Nut, + 'calories': 646, + 'protein': 14.9, + 'fat': 58.8, + 'carbohydrates': 19.1, + 'vitaminC': 1.0 + }, + { + 'id': '3', + 'name': 'Cucumber', + 'image': $r('app.media.Cucumber'), + 'category': Category.Vegetable, + 'calories': 16, + 'protein': 0.8, + 'fat': 0.2, + 'carbohydrates': 2.9, + 'vitaminC': 9.0 + }, + { + 'id': '4', + 'name': 'Blueberry', + 'image': $r('app.media.Blueberry'), + 'category': Category.Fruit, + 'calories': 57, + 'protein': 0.7, + 'fat': 0.3, + 'carbohydrates': 14.5, + 'vitaminC': 9.7 + }, + { + 'id': '5', + 'name': 'Crab', + 'image': $r('app.media.Crab'), + 'category': Category.Seafood, + 'calories': 97, + 'protein': 19, + 'fat': 1.5, + 'carbohydrates': 0, + 'vitaminC': 7.6 + }, + { + 'id': '6', + 'name': 'IceCream', + 'image': $r('app.media.IceCream'), + 'category': Category.Dessert, + 'calories': 150, + 'protein': 3.5, + 'fat': 11, + 'carbohydrates': 24, + 'vitaminC': 0.6 + }, + { + 'id': '7', + 'name': 'Onion', + 'image': $r('app.media.Onion'), + 'category': Category.Vegetable, + 'calories': 40, + 'protein': 1.1, + 'fat': 0.2, + 'carbohydrates': 9, + 'vitaminC': 8.0 + }, + { + 'id': '8', + 'name': 'Mushroom', + 'image': $r('app.media.Mushroom'), + 'category': Category.Vegetable, + 'calories': 20, + 'protein': 3.1, + 'fat': 0.3, + 'carbohydrates': 3.3, + 'vitaminC': 206 + }, + { + 'id': '9', + 'name': 'Kiwi', + 'image': $r('app.media.Kiwi'), + 'category': Category.Fruit, + 'calories': 61, + 'protein': 0.8, + 'fat': 0.6, + 'carbohydrates': 14.5, + 'vitaminC': 62 + }, + { + 'id': '10', + 'name': 'Pitaya', + 'image': $r('app.media.Pitaya'), + 'category': Category.Fruit, + 'calories': 55, + 'protein': 1.1, + 'fat': 0.2, + 'carbohydrates': 13.3, + 'vitaminC': 3.0 + }, + { + 'id': '11', + 'name': 'Avocado', + 'image': $r('app.media.Avocado'), + 'category': Category.Fruit, + 'calories': 171, + 'protein': 2.0, + 'fat': 15.3, + 'carbohydrates': 7.4, + 'vitaminC': 8.0 + }, + { + 'id': '12', + 'name': 'Strawberry', + 'image': $r('app.media.Strawberry'), + 'category': Category.Fruit, + 'calories': 32, + 'protein': 1.0, + 'fat': 0.2, + 'carbohydrates': 7.1, + 'vitaminC': 47.0 + }, + { + 'id': '0', + 'name': '', + 'image': '', + 'category': '', + 'calories': 0, + 'protein': 0, + 'fat': 0, + 'carbohydrates': 0, + 'vitaminC': 0 + } +] + +export function getDietRecords(): Array { + let records = AppStorage.Get>('dietRecords') + + if (DEBUG && records === undefined) { + return [ + { "id": "0", "name": "", "mealTime": "Breakfast", weight: 0 }, + { "id": "0", "name": "", "mealTime": "Lunch", weight: 0 }, + { "id": "0", "name": "", "mealTime": "Dinner", weight: 0 }, + { "id": "0", "name": "", "mealTime": "Supper", weight: 0 }, + { "id": "2", "name": "Walnut", "mealTime": "Lunch", weight: 200 }, + { "id": "3", "name": "Cucumber", "mealTime": "Dinner", weight: 200 }, + { "id": "11", "name": "Avocado", "mealTime": "Lunch", weight: 200 }, + { "id": "12", "name": "Strawberry", "mealTime": "Dinner", weight: 200 } + ] + } else { + return records + } +} + +export function updateDietWeight(recordId: string, weight: number) { + let dietRecords = getDietRecords() + let index = dietRecords.findIndex((record) => { + return record.id === recordId + }) + dietRecords[index].weight = weight + AppStorage.SetOrCreate>('dietRecords', dietRecords) +} + +export function statistics(): Array { + console.log('statistics') + let dietRecords = getDietRecords() + const mealMap = new Map() + dietRecords.forEach((item, index) => { + let oneMealStatisticsInfo: OneMealStatisticsInfo = mealMap.get(item.mealTime) + if (oneMealStatisticsInfo === undefined) { + oneMealStatisticsInfo = new OneMealStatisticsInfo(item.mealTime) + } + var foodInfo = FoodComposition.find((food) => { + return food.name === item.name + }) + var calories = foodInfo.calories * item.weight + var protein = foodInfo.protein * item.weight + var fat = foodInfo.fat * item.weight + var carbohydrates = foodInfo.carbohydrates * item.weight + oneMealStatisticsInfo.mealFoods.push(new MealFoodInfo(item.id, foodInfo.name, foodInfo.image, calories, protein, fat, carbohydrates, item.weight)) + oneMealStatisticsInfo.totalFat += fat + oneMealStatisticsInfo.totalCalories += calories + oneMealStatisticsInfo.totalCarbohydrates += carbohydrates + oneMealStatisticsInfo.totalProtein += protein + mealMap.set(item.mealTime, oneMealStatisticsInfo) + }) + + return Array.from(mealMap.values()) +} + +export function initializeOnStartup(): Array { + let FoodDataArray: Array = [] + FoodComposition.forEach(item => { + FoodDataArray.push(new FoodInfo(item.name, item.image, item.category, item.calories, item.protein, item.fat, item.carbohydrates, item.vitaminC)); + }) + return FoodDataArray; +} + +export function getSortedFoodData(): Array { + var letter_reg = /^[A-Z]$/ + var list = new Array() + for (var i = 0;i < FoodComposition.length; i++) { + + list['#'] = new Array() + + var letter = FoodComposition[i].name.substr(0, 1).toUpperCase() + + if (!letter_reg.test(letter)) { + letter = '#' + } + + if (!(letter in list)) { + list[letter] = new Array() + } + + var item = FoodComposition[i] + list[letter].push(new FoodInfo(item.name, item.image, item.category, item.calories, item.protein, item.fat, item.carbohydrates, item.vitaminC)) + } + + var result = new Array() + for (var key in list) { + result.push({ + letter: key, + list: list[key] + }) + } + result.sort(function (x, y) { + return x.letter.charCodeAt(0) - y.letter.charCodeAt(0) + }) + + var last_arr = result[0] + result.splice(0, 1) + result.push(last_arr) + + var resultList = [] + for (var i = 0; i < result.length; i++) { + resultList.push(result[i].letter) + resultList = resultList.concat(result[i].list) + } + console.log('liuao11111' + JSON.stringify(resultList)) + return resultList +} + +export function getFoodInfo(): FoodInfo { + if (DEBUG) { + return new FoodInfo('Tomato', $r("app.media.Tomato"), Category.Vegetable, 17, 0.9, 0.2, 3.9, 17.8) + } else { + router.getParams()['foodId'] + } +} \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/model/DataModels.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/model/DataModels.ets new file mode 100644 index 0000000000000000000000000000000000000000..88bc7dba89fe95b4500b931d4dd09b842c489ed5 --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/model/DataModels.ets @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2022 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. + */ + +export enum Category { + Fruit = 'Fruit', + Vegetable = 'Vegetable', + Nut = 'Nut', + Seafood = 'Seafood', + Dessert = 'Dessert' +} + +export class CategoryInfo { + Fruit: string | Resource + Vegetable: string | Resource + Nut: string | Resource + Seafood: string | Resource + Dessert: string | Resource + + constructor(Fruit: string | Resource, Vegetable: string | Resource, Nut: string | Resource, Seafood: string | Resource, Dessert: string | Resource) { + this.Fruit = Fruit + this.Vegetable = Vegetable + this.Nut = Nut + this.Seafood = Seafood + this.Dessert = Dessert + } +} + +let NextId = 0 + +@Observed +export class FoodInfo { + id: string + name: string | Resource + image: Resource + category: Category + calories: number + protein: number + fat: number + carbohydrates: number + vitaminC: number + intakeValue: number + + constructor(name: string | Resource, image: Resource, category: Category, calories: number, protein: number, fat: number, carbohydrates: number, vitaminC: number) { + this.id = `${NextId++}` + this.name = name + this.image = image + this.category = category + this.calories = calories + this.protein = protein + this.fat = fat + this.carbohydrates = carbohydrates + this.vitaminC = vitaminC + this.intakeValue = 0 + } +} + +export class DietRecord { + id: string + name: string | Resource + mealTime: string | Resource + weight: number + + constructor(id: string, name: string | Resource, mealTime: string | Resource, weight: number) { + this.id = id + this.name = name + this.mealTime = mealTime + this.weight = weight + } +} + +@Observed +export class OneMealStatisticsInfo { + mealTime: string | Resource + mealFoods: Array = [] + totalCalories: number = 0 + totalFat: number = 0 + totalCarbohydrates: number = 0 + totalProtein: number = 0 + + constructor(mealTime: string | Resource) { + this.mealTime = mealTime + } +} + +export class MealFoodInfo { + recordId: string + name: string | Resource + image: Resource + calories: number + protein: number + fat: number + carbohydrates: number + weight: number + + constructor(recordId: string, name: string | Resource, image: Resource, calories: number, protein: number, fat: number, carbohydrates: number, weight: number) { + this.recordId = recordId + this.name = name + this.image = image + this.calories = calories + this.protein = protein + this.fat = fat + this.carbohydrates = carbohydrates + this.weight = weight + } +} \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/CustomCounter.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/CustomCounter.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9effcc6b2886e8c74e04c76daa687527d7705f8 --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/CustomCounter.ets @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2022 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. + */ + +@Preview +@Component +struct DecIcon { + private click: () => void = undefined + + build() { + Stack() { + Line() + .startPoint([0, 0]) + .endPoint([12, 0]) + .stroke(Color.White) + .strokeWidth(2) + .strokeLineCap(LineCapStyle.Round) + } + .borderRadius(10) + .backgroundColor('#35BD6A') + .width(20) + .height(20) + .opacity(0.4) + .onClick(() => { + this.click() + }) + } +} + +@Preview +@Component +struct IncIcon { + private readonly click: () => void = undefined + + build() { + Stack() { + Line() + .startPoint([0, 0]) + .endPoint([0, 12]) + .stroke(Color.White) + .strokeWidth(2) + .strokeLineCap(LineCapStyle.Round) + } + .borderRadius(10) + .backgroundColor('#35BD6A') + .width(20) + .height(20) + .onClick(() => { + this.click() + }) + } +} + +@Component +export struct CustomCounter { + @Prop value: string + private onDec: () => void = undefined + private onInc: () => void = undefined + + build() { + Row() { + DecIcon({ click: this.onDec }) + Text(this.value).margin({ left: 11, right: 11 }) + IncIcon({ click: this.onInc }) + } + } +} + +@Preview +@Entry +@Component +struct PreviewCustomCounter { + @State weight: number = 50 + + build() { + Row() { + CustomCounter({ + value: this.weight + 'g', + onDec: () => { + this.weight -= 50 + }, + onInc: () => { + this.weight += 50 + } + }) + } + } +} \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/DietRecord.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/DietRecord.ets new file mode 100644 index 0000000000000000000000000000000000000000..35cb2a612d18faabe9595873c146c5b969f365d9 --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/DietRecord.ets @@ -0,0 +1,382 @@ +/* + * Copyright (c) 2022 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. + */ + +import { OneMealStatisticsInfo, MealFoodInfo } from '../model/DataModels' +import { statistics, updateDietWeight } from '../mock/MockData' +import { BreakPointType } from '../common/BreakpointSystem' +import { CustomCounter } from './CustomCounter' + +class ElementsItem { + public elements: string | Resource + public weight: number + public color: string + public heat: string | Resource + + constructor(elements: string | Resource, weight: number, color: string, heat: string | Resource) { + this.elements = elements + this.weight = weight + this.color = color + this.heat = heat + } +} + +function GetColor(value: number): string { + if (value / 1000 > 100) { + return '#FD9A42' + } else { + return '#73CD57' + } +} + +@Component +struct Histogram { + @Consume("dietData") dietData: Array + private title: string | Resource + private legend: ElementsItem[] + @BuilderParam content: any + @BuilderParam legendComponent: any + private mealTime: Resource[] = [$r("app.string.meal_time_break"), $r("app.string.meal_time_lunch"), $r("app.string.meal_time_dinner"), $r("app.string.meal_time_supper")] + + build() { + Column() { + Row() { + Text(this.title) + .textAlign(TextAlign.Start) + .fontSize(24) + .fontColor('#000000') + .fontFamily('HarmonyHeTi-Medium') + } + .width('100%') + .height(46) + + Stack({ alignContent: Alignment.Bottom }) { + Column() { + ForEach(new Array(6), (item) => { + Divider() + .strokeWidth(1) + .color('#D8d8d8') + }) + } + .height('100%') + .margin({ top: 10 }) + .justifyContent(FlexAlign.SpaceBetween) + + Column() { + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Start }) { + ForEach(this.dietData, (item, index) => { + Column() { + this.content(item) + Text(item.mealTime).fontSize(14) + .fontColor('#7E7E7E') + .fontFamily('HarmonyHeTi') + .margin({ top: 10 }) + } + .justifyContent(FlexAlign.End) + .height('100%') + }) + } + } + .height(216) + } + .height(190) + + Row() { + ForEach(this.legend, item => { + Row() { + Rect({ width: 9, height: 9, radius: 9 }).fill(item.color).margin({ right: 18 }) + this.legendComponent(item) + } + }) + } + .justifyContent(FlexAlign.SpaceEvenly) + .width('100%') + .margin({ top: 50 }) + } + .height('100%') + .padding({ left: 32, right: 32 }) + .borderRadius(12) + .backgroundColor('#FFFFFF') + } +} + +@Component +struct NutritionHistogramContent { + @Consume("dietData") dietData: Array + private legend: ElementsItem[] = [ + new ElementsItem($r("app.string.diet_record_fat"), 50, '#FFD339', ''), + new ElementsItem($r("app.string.diet_record_protein"), 50, '#FD9A42', ''), + new ElementsItem($r("app.string.diet_record_carbohydrates"), 50, '#73CD57', '') + ] + + @Builder legendComponent(item) { + Column() { + Text(item.elements).fontSize(12).fontColor('#18181A').fontFamily('HarmonyHeTi') + Text(item.weight + 'g').fontSize(12).fontColor('#7E7E7E').fontFamily('HarmonyHeTi') + } + } + + @Builder content(item) { + Circle({ width: item.totalFat == 0 ? 0 : 14, height: item.totalFat == 0 ? 0 : 14 }) + .fill('#FD9A42') + .margin({ bottom: -7 }) + Rect({ width: 14, height: item.totalFat / 200 }).fill('#FD9A42').margin({ bottom: -7 }) + Circle({ width: item.totalProtein == 0 ? 0 : 14, height: item.totalProtein == 0 ? 0 : 14 }) + .fill('#FBD44E') + .margin({ bottom: -7 }) + Rect({ width: 14, height: item.totalProtein / 200 }) + .fill('#FBD44E') + .margin({ bottom: item.totalCarbohydrates == 0 ? 7 : -7 }) + Circle({ width: item.totalCarbohydrates == 0 ? 0 : 14, height: item.totalCarbohydrates == 0 ? 0 : 14 }) + .fill('#73CD57') + .margin({ bottom: -7 }) + Rect({ width: 14, height: item.totalCarbohydrates / 200 }).fill('#73CD57').margin({ bottom: -10 }) + } + + build() { + Row() { + Histogram({ + title: $r("app.string.nutrition_element"), + content: this.content, + legend: this.legend, + legendComponent: this.legendComponent + }) + } + } +} + +@Component +struct HeatHistogramContent { + private legend: ElementsItem[] = [ + new ElementsItem('', 50, '#FD9A42', $r("app.string.high_calorie")), + new ElementsItem('', 50, '#73CD57', $r("app.string.medium_low_calories")), + ] + + @Builder legendComponent(item) { + Column() { + Text(item.heat).fontSize(12).fontColor('#18181A').fontFamily('HarmonyHeTi') + } + } + + @Builder content(item) { + Circle({ width: item.totalCalories == 0 ? 0 : 14, height: item.totalCalories == 0 ? 0 : 14 }) + .fill(GetColor(item.totalCalories)) + .margin({ bottom: -7 }) + Rect({ width: 14, height: item.totalCalories / 1000 }).fill(GetColor(item.totalCalories)).margin({ bottom: -10 }) + } + + build() { + Row() { + Histogram({ + title: $r("app.string.diet_record_calorie"), + content: this.content, + legend: this.legend, + legendComponent: this.legendComponent + }) + } + } +} + +@Component +struct MealFoodDetail { + @Consume("dataChange") notifyDataChange: number + @State shown: boolean = true + @State translateX: number = 0 + private mealFoodInfo: MealFoodInfo + private panTranslateX: number = 300 + + build() { + if (this.shown) { + if (this.mealFoodInfo.weight != 0) { + Row() { + Row() { + Image(this.mealFoodInfo.image) + .width(50) + .height(50) + + Column() { + Text(this.mealFoodInfo.name) + .fontSize(16) + .fontColor('#444444') + .fontFamily('HarmonyHeTi') + .margin({ bottom: 4 }) + Text(this.mealFoodInfo.calories / 100 + 'kcal') + .fontSize(11) + .fontColor('#A3A3A3') + .fontFamily('HarmonyHeTi') + }.alignItems(HorizontalAlign.Start) + + Blank() + CustomCounter({ + value: this.mealFoodInfo.weight + 'g', + onDec: () => { + if (this.mealFoodInfo.weight > 0) { + this.mealFoodInfo.weight -= 50 + updateDietWeight(this.mealFoodInfo.recordId, this.mealFoodInfo.weight) + this.notifyDataChange++ + } + }, + onInc: () => { + this.mealFoodInfo.weight += 50 + updateDietWeight(this.mealFoodInfo.recordId, this.mealFoodInfo.weight) + this.notifyDataChange++ + } + }) + } + .width('100%') + + Image($r("app.media.ic_public_delete")) + .backgroundColor('#E84026') + .objectFit(ImageFit.ScaleDown) + .borderRadius(20) + .margin({ left: 50 }) + .size({ width: 40, height: 40 }) + .onClick(() => { + animateTo({ duration: 400 }, () => { + this.shown = false + }) + }) + } + .transition({ type: TransitionType.Delete, translate: { x: -350, y: 0 }, opacity: 0 }) + .translate({ x: this.translateX }) + .width('100%') + .height(70) + .gesture( + PanGesture() + .onActionStart(() => { + }) + .onActionEnd(() => { + + }) + .onActionUpdate((event: GestureEvent) => { + console.log('x:' + event.offsetX) + if (event.offsetX < 0) { + if (event.offsetX < -100) { + this.translateX = (event.offsetX * Math.exp(-1.848)) - 100 + } else { + this.translateX = event.offsetX + } + } + }) + ) + } + } + } +} + + +@Component +struct MealCard { + @ObjectLink mealInfo: OneMealStatisticsInfo + + build() { + Column() { + if (this.mealInfo.mealFoods.length > 1) { + Text(this.mealInfo.mealTime) + .fontSize(24) + .fontColor('#000000') + .fontFamily('HarmonyHeTi-Medium') + .height(56) + .width('100%') + .backgroundColor('#FFFFFF') + .padding({ left: 16, right: 16 }) + + ForEach(this.mealInfo.mealFoods, (mealItem) => { + MealFoodDetail({ mealFoodInfo: mealItem }) + }) + } + + } + .backgroundColor('#FFFFFF') + .borderRadius(12) + .padding({ left: 16, right: 16 }) + .margin(12) + } +} + +@Component +struct DietDetails { + @Consume("dietData") dietData: Array + @StorageProp('currentBreakpoint') currentBreakpoint: string = 'md' + + build() { + Scroll() { + Column() { + Swiper() { + HeatHistogramContent() + NutritionHistogramContent() + } + .displayCount(new BreakPointType(1, 2, 2).GetValue(this.currentBreakpoint)) + .itemSpace(12) + .height(400) + .width('100%') + .indicatorStyle({ selectedColor: '#35BD6A' }) + .indicator(new BreakPointType(true, false, false).GetValue(this.currentBreakpoint)) + + ForEach(this.dietData, (item) => { + MealCard({ mealInfo: item }) + }) + } + } + .backgroundColor('#EDF2F5') + } +} + +@Component +struct NoRecord { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start }) { + + Text('Record') + .fontSize(26) + .padding({ left: 26, top: 12 }) + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Image($r("app.media.NoRecord")) + .height(130) + .width(130) + Text('No record, please return index page to add.') + .fontSize(15) + .fontColor('rgba(0, 0,0,0.4)') + } + .width('100%') + } + .width('100%') + } +} + +@Entry +@Component +export struct Records { + @Provide("dietData") dietStatisticsData: Array = [] + @Provide("dataChange") @Watch('onDataChange') listenDataChange: number = 0 + + onDataChange() { + console.log('onDataChange') + this.dietStatisticsData = statistics() + } + + aboutToAppear() { + this.dietStatisticsData = statistics() + } + + build() { + Column() { + if (this.dietStatisticsData.length === 0) { + NoRecord() + } else { + DietDetails() + } + } + } +} \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/FoodDetail.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/FoodDetail.ets new file mode 100644 index 0000000000000000000000000000000000000000..5567f8bc332375434ba2f8c522c7f863b39e107b --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/FoodDetail.ets @@ -0,0 +1,499 @@ +/* + * Copyright (c) 2022 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. + */ + +import router from '@ohos.router' +import { APP_THEME_COLOR } from '../common/Constants' +import { BreakPointType } from '../common/BreakpointSystem' +import { FoodInfo, Category, DietRecord } from '../model/DataModels' +import Curves from '@ohos.curves' + +@Styles function cardStyle () { + .height('100%') + .padding({ top: 20, right: 20, left: 20 }) + .backgroundColor(Color.White) + .borderRadius(12) +} + +@Component +struct PageTitle { + private foodDetail: Resource = $r("app.string.title_food_detail") + + build() { + Row() { + Image($r('app.media.Back')) + .width(20) + .height(20) + .onClick(() => { + router.back() + }) + Text(this.foodDetail) + .fontSize(22) + .margin({ left: 20 }) + } + .padding(12) + .width('100%') + } +} + +@Component +struct FoodImageDisplay { + private foodItem: FoodInfo + + build() { + Stack({ alignContent: Alignment.BottomStart }) { + Image(this.foodItem.image) + .objectFit(ImageFit.Contain) + Text(this.foodItem.name) + .fontSize(26) + .fontWeight(500) + .margin({ left: 26, bottom: 18 }) + } + .height(358) + } +} + +@Component +struct CaloriesProgress { + private foodItem: FoodInfo + private averageCalories: number = 0 + private totalCalories: number = 0 + private highCalories: boolean = false + + aboutToAppear() { + switch (this.foodItem.category) { + case Category.Vegetable: + this.averageCalories = 26 + break + case Category.Fruit: + this.averageCalories = 60 + break + case Category.Nut: + this.averageCalories = 606 + break + case Category.Seafood: + this.averageCalories = 56 + break + case Category.Dessert: + this.averageCalories = 365 + break + } + this.totalCalories = this.averageCalories * 2 + this.highCalories = this.foodItem.calories < this.averageCalories + } + + build() { + Column() { + Row() { + Text($r("app.string.diet_record_calorie")) + .fontSize(26) + Text('per 100g') + .fontSize(13) + .fontColor('rgba(0,0,0,0.6)') + } + .justifyContent(FlexAlign.SpaceBetween) + .width("100%") + + Row() { + Text(this.foodItem.calories.toString()) + .fontColor(this.highCalories ? "rgba(238,88,76,1)" : "rgba(115,205,87,1)") + .fontSize(65) + Text('kcal') + .fontSize(20) + .margin({ bottom: 10 }) + } + .margin({ top: 25, bottom: 15 }) + .alignItems(VerticalAlign.Bottom) + + if (this.highCalories) { + Text($r("app.string.high_calorie_food")) + .fontSize(13) + .fontColor("rgba(49,49,49,1)") + } else { + Text($r("app.string.low_calorie_food")) + .fontSize(13) + .fontColor("rgba(49,49,49,1)") + } + Progress({ value: this.foodItem.calories, total: this.totalCalories, style: ProgressStyle.Linear }) + .style({ strokeWidth: 24 }) + .color(this.highCalories ? Color.Orange : Color.Green) + .margin({ top: 15 }) + } + .cardStyle() + } +} + +class NutritionElement { + element: string | Resource + weight: number + percent: number + beginAngle: number + endAngle: number + color: string + + constructor(element: string | Resource, weight: number, color: string) { + this.element = element + this.weight = weight + this.color = color + } +} + +@Component +struct NutritionPieChart { + private CIRCLE_RADIUS = 80 + private foodItem: FoodInfo + private elementsList: NutritionElement[] + private settings: RenderingContextSettings = new RenderingContextSettings(true) + private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) + + build() { + Column() { + Row() { + Text($r("app.string.nutrition_element")) + .fontSize(26) + Text('per 100g') + .fontSize(13) + .fontColor('rgba(0,0,0,0.6)') + } + .width("100%") + .justifyContent(FlexAlign.SpaceBetween) + + Canvas(this.context) + .height(this.CIRCLE_RADIUS * 2) + .aspectRatio(1) + .margin({ top: 30, bottom: 32 }) + .onReady(() => { + this.elementsList.forEach((item) => { + this.context.beginPath() + this.context.moveTo(this.CIRCLE_RADIUS, this.CIRCLE_RADIUS) + this.context.arc(this.CIRCLE_RADIUS, this.CIRCLE_RADIUS, this.CIRCLE_RADIUS, item.beginAngle, item.endAngle) + this.context.fillStyle = item.color + this.context.fill() + }) + }) + + Row() { + ForEach(this.elementsList, item => { + Row({ space: 4 }) { + Circle({ width: 8, height: 8 }).fill(item.color) + Text(item.element).fontSize(12) + Text(item.weight + 'g').fontSize(12) + } + }) + } + .width('100%') + .justifyContent(FlexAlign.SpaceAround) + } + .cardStyle() + } +} + +@Component +struct NutritionPercent { + private foodItem: FoodInfo + private elementsList: NutritionElement[] + + build() { + Column() { + Row() { + Text($r("app.string.nutrition_element")) + .fontSize(26) + Text('per 100g') + .fontSize(13) + .fontColor('rgba(0,0,0,0.6)') + } + .width("100%") + .height(26) + .justifyContent(FlexAlign.SpaceBetween) + + Row() { + ForEach(this.elementsList, item => { + Column() { + Stack({ alignContent: Alignment.Center }) { + Progress({ value: item.percent, type: ProgressType.Ring }) + .style({ strokeWidth: 10 }) + .color(item.color) + .margin(4) + Text(item.percent + '%').fontSize(17) + } + + Text(item.element) + .fontSize(10) + .margin({ top: 24 }) + Text(item.weight.toString() + 'g') + .fontSize(13) + .fontColor('rgba(0,0,0,0.6)') + }.layoutWeight(1) + + }) + } + .width('100%') + .margin({ top: 68 }) + } + .cardStyle() + } +} + +@Component +struct NutritionData { + private foodItem: FoodInfo + private values: number[] = [] + private totalValue: number = 0 + + aboutToAppear() { + this.values.push(this.foodItem.carbohydrates) + this.values.push(this.foodItem.fat) + this.values.push(this.foodItem.protein) + this.totalValue = this.foodItem.carbohydrates + this.foodItem.fat + this.foodItem.protein + } + + @Builder Lable(title: string, colorValue: string) { + Row() { + Circle({ width: 6, height: 6 }).fill(colorValue).margin({ right: 10 }) + Text(title) + } + .margin({ top: 15 }) + } + + build() { + Column() { + Row() { + Text($r("app.string.nutrition_element")) + .fontSize(26) + Text('per 100g') + .fontSize(13) + .fontColor('rgba(0,0,0,0.6)') + } + .width("100%") + .height(30) + .justifyContent(FlexAlign.SpaceBetween) + + Row() { + Row() { + DataPanel({ values: this.values, max: this.totalValue }) + .closeEffect(true) + .width(150) + .height(150) + } + .margin({ right: 10 }) + + Column() { + this.Lable("carbohydrates", "#FFA500") + this.Lable("Protein", "#FF8C00") + this.Lable("carbohydrates", "#FF0000") + } + .margin({ top: 30, left: 30 }) + } + .margin({ top: 24 }) + } + .backgroundColor(Color.White) + .padding({ top: 20, right: 20, left: 20 }) + } +} + +@Component +struct ContentTable { + private foodItem: FoodInfo + + @Builder IngredientItem(title: Resource | string, colorValue: string, name: Resource | string, value: string) { + Flex() { + Text(title) + .fontSize(18) + .fontWeight(FontWeight.Bold) + .layoutWeight(1) + Flex({ alignItems: ItemAlign.Center }) { + Circle({ width: 6, height: 6 }) + .margin({ right: 12 }) + .fill(colorValue) + Text(name) + .fontSize(18) + .flexGrow(1) + Text(value) + .fontSize(18) + } + .layoutWeight(2) + } + .margin({ bottom: 20 }) + } + + build() { + Column() { + this.IngredientItem($r("app.string.diet_record_calorie"), '#FFf54040', $r("app.string.diet_record_calorie"), this.foodItem.calories + 'kcal') + Column() { + this.IngredientItem($r("app.string.diet_record_nutrition"), '#FFcccccc', $r("app.string.diet_record_nutrition"), this.foodItem.protein + 'g') + this.IngredientItem(' ', '#FFf5d640', $r("app.string.diet_record_fat"), this.foodItem.fat + 'g') + this.IngredientItem(' ', '#FF9e9eff', $r("app.string.diet_record_carbohydrates"), this.foodItem.carbohydrates + 'g') + this.IngredientItem(' ', '#FF53f540', $r("app.string.diet_record_vitaminC"), this.foodItem.vitaminC + 'mg') + } + .justifyContent(FlexAlign.Start) + .margin({ top: 20 }) + } + .cardStyle() + } +} + +@CustomDialog +struct Record { + private foodItem: FoodInfo + private controller: CustomDialogController + private select: number = 1 + private mileType: string[] = ['早餐', '午餐', '晚餐', '夜宵'] + private foodWeight: string[] = ['25', '50', '100', '150', '200', '250', '300', '350', '400', '450', '500'] + private mealTime: string = '' + private mealWeight: number = 0 + + build() { + Column() { + Row({ space: 6 }) { + Column() { + Text(this.foodItem.name) + .fontSize(30) + .maxLines(1) + Text(this.foodItem.calories.toString() + 'kcal') + .fontSize(16) + .fontColor('rgba(0,0,0,0.4)') + .margin({ top: 2 }) + } + .layoutWeight(1) + .justifyContent(FlexAlign.Center) + + TextPicker({ range: this.mileType, selected: this.select }) + .layoutWeight(1) + .linearGradient({ + angle: 0, + direction: GradientDirection.Top, + colors: [[0xfdfdfd, 0.0], [0xe0e0e0, 0.5], [0xfdfdfd, 1]], + }) + .onChange((value: string) => { + this.mealTime = value + }) + + TextPicker({ range: this.foodWeight, selected: this.select }) + .layoutWeight(1) + .linearGradient({ + angle: 0, + direction: GradientDirection.Top, + colors: [[0xfdfdfd, 0.0], [0xe0e0e0, 0.5], [0xfdfdfd, 1]], + }) + .onChange((value: string) => { + this.mealWeight = Number(value) + }) + } + .height(128) + + Button($r("app.string.button_food_detail_complete"), { type: ButtonType.Capsule, stateEffect: true }) + .height(43) + .width('100%') + .margin({ top: 33, left: 72, right: 72 }) + .backgroundColor(APP_THEME_COLOR) + .onClick(() => { + let dietRecordData = new DietRecord(this.foodItem.id, this.foodItem.name, this.mealTime, this.mealWeight) + let dietRecordsList = AppStorage.Get>('dietRecords') + if (dietRecordsList == undefined) { + dietRecordsList = [] + } + dietRecordsList.push(dietRecordData) + AppStorage.SetOrCreate>('dietRecords', dietRecordsList) + this.controller.close() + }) + } + .cardStyle() + .height(254) + .width('90%') + } +} + +@Entry +@Component +struct FoodDetail { + @StorageProp('currentBreakpoint') currentBreakpoint: string = 'md' + private foodItem: any = router.getParams()['foodId'] + private elementsList: NutritionElement[] + dialogController: CustomDialogController = new CustomDialogController({ + builder: Record({ foodItem: this.foodItem }), + autoCancel: true, + alignment: DialogAlignment.Bottom, + offset: { dx: 0, dy: -20 }, + customStyle: true + }) + @State imageScale: number = 1 + @State imageBgColorA: number = 0 + + aboutToAppear() { + let total = this.foodItem.protein + this.foodItem.fat + this.foodItem.carbohydrates + this.elementsList = [ + new NutritionElement($r("app.string.diet_record_protein"), this.foodItem.protein, '#ff9421'), + new NutritionElement($r("app.string.diet_record_fat"), this.foodItem.fat, '#ffd100'), + new NutritionElement($r("app.string.diet_record_carbohydrates"), this.foodItem.carbohydrates, '#4cd041') + ] + let lastEndAngle = -0.5 * Math.PI + this.elementsList.forEach((value) => { + let percent = value.weight / total + value.percent = Math.round(percent * 100) + value.beginAngle = lastEndAngle + value.endAngle = (percent * 2 * Math.PI) + lastEndAngle + lastEndAngle = value.endAngle + return value + }) + } + + build() { + Scroll() { + Column() { + PageTitle() + Stack({ alignContent: Alignment.BottomStart }) { + Image(this.foodItem.image) + .sharedTransition(this.foodItem.id, { + duration: 1000, + curve: Curves.cubicBezier(0.2, 0.2, 0.1, 1.0), + delay: 100 + }) + .backgroundColor(`rgba(255,255,255,${this.imageBgColorA})`) + .objectFit(ImageFit.Contain) + Text(this.foodItem.name) + .fontSize(26) + .fontWeight(500) + .margin({ left: 26, bottom: 18 }) + } + .height(this.currentBreakpoint == 'lg' ? 166 : 310) + + Swiper() { + ContentTable({ foodItem: this.foodItem }) + CaloriesProgress({ foodItem: this.foodItem }) + NutritionPercent({ foodItem: this.foodItem, elementsList: this.elementsList }) + NutritionPieChart({ foodItem: this.foodItem, elementsList: this.elementsList }) + } + .indicator(new BreakPointType(true, false, false).GetValue(this.currentBreakpoint)) + .displayCount(new BreakPointType(1, 2, 3).GetValue(this.currentBreakpoint)) + .clip(new Rect().width("100%").height("100%").radiusWidth(15).radiusHeight(15)) + .itemSpace(20) + .height(330) + .indicatorStyle({ selectedColor: '#35BD6A' }) + .margin({ top: 10, right: 10, left: 10 }) + + Button($r("app.string.button_food_detail_record"), { type: ButtonType.Capsule, stateEffect: true }) + .height(42) + .width('80%') + .margin({ top: 30 }) + .backgroundColor(APP_THEME_COLOR) + .onClick(() => { + this.dialogController.open() + }) + } + .height("100%") + .backgroundColor('#FFedf2f5') + .alignItems(HorizontalAlign.Center) + } + } +} \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/pages/FoodCategoryList.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/Home.ets similarity index 30% rename from ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/pages/FoodCategoryList.ets rename to ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/Home.ets index 9392b8d22f490366a811b45c6b8086fad1d90d1b..48b2bad5606ed60c19a902cebce702b0c7804558 100644 --- a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/pages/FoodCategoryList.ets +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/Home.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 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 @@ -13,14 +13,18 @@ * limitations under the License. */ +import router from '@ohos.router' import Curves from '@ohos.curves' -import router from '@system.router' -import { Category, FoodData } from '../model/FoodData' -import { initializeOnStartup } from '../model/FoodDataModels' +import { APP_THEME_COLOR } from '../common/Constants' +import { BreakpointSystem, BreakPointType } from '../common/BreakpointSystem' +import { FoodInfo } from '../model/DataModels' +import { initializeOnStartup, getSortedFoodData } from '../mock/MockData' +import { Records } from './DietRecord' @Component struct FoodListItem { - private foodItem: FoodData + private foodItem: FoodInfo + build() { Navigator({ target: 'pages/FoodDetail' }) { Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { @@ -30,15 +34,20 @@ struct FoodListItem { .autoResize(false) .height(40) .width(40) - .sharedTransition(this.foodItem.id, { duration: 1000, curve: Curves.cubicBezier(0.2, 0.2, 0.1, 1.0), delay: 100}) - + .sharedTransition(this.foodItem.id, { + duration: 1000, + curve: Curves.cubicBezier(0.2, 0.2, 0.1, 1.0), + delay: 100 + }) } .backgroundColor('#FFf1f3f5') .margin({ right: 16 }) + .borderRadius(6) + Text(this.foodItem.name) .fontSize(14) .flexGrow(1) - Text(this.foodItem.calories + ' kcal') + Text(this.foodItem.calories + 'kcal') .fontSize(14) } .height(64) @@ -48,86 +57,101 @@ struct FoodListItem { } } - @Component -struct FoodList { - private foodItems: FoodData[] +struct ListModeFoods { + private foodItems: FoodInfo[] = getSortedFoodData() + build() { Column() { Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Text('Food List') + Text($r("app.string.all_food_list")) .fontSize(20) .margin({ left: 20 }) } - .height('7%') - .backgroundColor('#FFf1f3f5') + .height(56) + .backgroundColor('#FF1f3f5') + List() { - ForEach(this.foodItems, item => { + ForEach(this.foodItems, (item) => { ListItem() { - FoodListItem({ foodItem: item }) + if (item.id !== undefined) { + FoodListItem({ foodItem: item }) + } else { + Text(item) + .fontSize(14) + .height(48) + .margin({ left: 24 }) + } } - }, item => item.id.toString()) - }.height('93%') + }) + } + .layoutWeight(1) } } } @Component struct FoodGridItem { - private foodItem: FoodData + private foodItem: FoodInfo + build() { Column() { - Row() { + if (this.foodItem.name != '') { Image(this.foodItem.image) .objectFit(ImageFit.Contain) + .backgroundColor('#f1f3f5') .height(152) - .width('100%') - .sharedTransition(this.foodItem.id, { duration: 1000, curve: Curves.cubicBezier(0.2, 0.2, 0.1, 1.0), delay: 100}) - }.backgroundColor('#FFf1f3f5') - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Text(this.foodItem.name) - .fontSize(14) - .flexGrow(1) - .padding({ left: 8 }) - Text(this.foodItem.calories + 'kcal') - .fontSize(14) - .margin({ right: 6 }) + .sharedTransition(this.foodItem.id, { + duration: 1000, + curve: Curves.cubicBezier(0.2, 0.2, 0.1, 1.0), + delay: 100 + }) + Row() { + Text(this.foodItem.name) + .fontSize(14) + Blank() + Text(this.foodItem.calories + 'kcal') + .fontSize(14) + .fontColor(0x99000000) + } + .padding({ left: 12, right: 12 }) + .width('100%') + .height(32) + .backgroundColor('#E5E5E5') } - .height(32) - .width('100%') - .backgroundColor('#FFe5e5e5') } .height(184) - .width('100%') + .clip(new Rect({ width: '100%', height: '100%', radius: 12 })) .onClick(() => { - router.push({ uri: 'pages/FoodDetail', params: { foodId: this.foodItem } }) + router.push({ url: 'pages/FoodDetail', params: { foodId: this.foodItem } }) }) } } @Component struct FoodGrid { - private foodItems: FoodData[] + @StorageProp('currentBreakpoint') currentBreakpoint: string = 'md' + private foodItems: FoodInfo[] private gridRowTemplate: string = '' private heightValue: number aboutToAppear() { - var rows = Math.round(this.foodItems.length / 2); - this.gridRowTemplate = '1fr '.repeat(rows); - this.heightValue = rows * 192 - 8; + var rows = Math.round(this.foodItems.length / 2) + this.gridRowTemplate = '1fr '.repeat(rows) + this.heightValue = rows * 192 - 8 } build() { Scroll() { Grid() { - ForEach(this.foodItems, (item: FoodData) => { + ForEach(this.foodItems, (item: FoodInfo) => { GridItem() { FoodGridItem({ foodItem: item }) } - }, (item: FoodData) => item.id.toString()) + }, (item: FoodInfo) => item.id.toString()) } .rowsTemplate(this.gridRowTemplate) - .columnsTemplate('1fr 1fr') + .columnsTemplate(new BreakPointType('1fr 1fr', '1fr 1fr 1fr', '1fr 1fr 1fr 1fr').GetValue(this.currentBreakpoint)) .columnsGap(8) .rowsGap(8) .height(this.heightValue) @@ -138,63 +162,125 @@ struct FoodGrid { } @Component -struct FoodCategory { - private foodItems: FoodData[] - build() { - Stack() { - Tabs() { - TabContent() { - FoodGrid({ foodItems: this.foodItems }) - }.tabBar('All') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Vegetable)) }) - }.tabBar('Vegetable') - - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Fruit)) }) - }.tabBar('Fruit') +struct CategoryModeFoods { + private foodItems: FoodInfo[] = initializeOnStartup() + private FoodType: Resource[] = [$r("app.string.food_type_fruit"), $r("app.string.food_type_vegetable"), $r("app.string.food_type_nut"), $r("app.string.food_type_seafood"), $r("app.string.food_type_dessert")] + @State currentIndex: number = 0 - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Nut)) }) - }.tabBar('Nut') + @Builder TabBuilder(value: string, index: number) { + Row() { + Text(value) + .fontColor(this.currentIndex === index ? 'rgba(0,0,0,0.9)' : 'rgba(0,0,0,0.6)') + .fontSize(this.currentIndex === index ? 24 : 18) + .margin({ top: 2 }) + } + .height(56) + } - TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Seafood)) }) - }.tabBar('Seafood') + build() { + Tabs() { + TabContent() { + FoodGrid({ foodItems: this.foodItems }) + }.tabBar(this.TabBuilder('All', 0)) + ForEach(this.FoodType, (foodCategory, index) => { TabContent() { - FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === Category.Dessert)) }) - }.tabBar('Dessert') - } - .barWidth(280) - .barMode(BarMode.Scrollable) + FoodGrid({ foodItems: this.foodItems.filter(item => (item.category === foodCategory)) }) + }.tabBar(this.TabBuilder(foodCategory, index + 1)) + }) } + .barMode(BarMode.Scrollable) + .onChange((index) => { + this.currentIndex = index + }) } } -@Entry @Component -struct FoodCategoryList { - private foodItems: FoodData[] = initializeOnStartup() - @State private showList: boolean = false +struct FoodDetail { + @State isCategoryMode: boolean = true build() { Column() { Stack({ alignContent: Alignment.TopEnd }) { - if (this.showList) { - FoodList({ foodItems: this.foodItems }) + if (this.isCategoryMode) { + CategoryModeFoods() } else { - FoodCategory({ foodItems: this.foodItems }) + ListModeFoods() } - Image($r('app.media.Switch')) - .height(24) - .width(24) - .margin({ top: 15, right: 10 }) - .onClick(() => { - this.showList = !this.showList - }) + Row() { + Image($r("app.media.Switch")) + .height(24) + .width(24) + .margin({ left: 24, right: 24 }) + } + .height(56) + .backgroundColor(this.isCategoryMode ? Color.White : '#f1f3f5') + .onClick(() => { + this.isCategoryMode = !this.isCategoryMode + }) } - }.height('100%') + } } } + +@Entry +@Component +struct Home { + @State currentIndex: number = 0 + @State pageOpacity: number = 0 + + private GetTabBarColor(index: number) { + return this.currentIndex == index ? APP_THEME_COLOR : '#999999' + } + + @Builder BottomBarItemBuilder(name: Resource, icon: Resource, index: number) { + Flex({ + direction: new BreakPointType(FlexDirection.Column, FlexDirection.Row, FlexDirection.Column).GetValue(this.currentBreakpoint), + justifyContent: FlexAlign.Center, + alignItems: ItemAlign.Center + }) { + Image(icon) + .height(24) + .width(24) + .fillColor(this.GetTabBarColor(index)) + Text(name) + .margin(new BreakPointType({ top: 4 }, { left: 8 }, { top: 4 }).GetValue(this.currentBreakpoint)) + .fontSize(11) + .fontColor(this.GetTabBarColor(index)) + } + .width('100%') + .height('100%') + } + + @StorageProp('currentBreakpoint') currentBreakpoint: string = 'md' + private breakpointSystem: BreakpointSystem = new BreakpointSystem() + + aboutToAppear() { + this.breakpointSystem.register() + } + + aboutToDisappear() { + this.breakpointSystem.unregister() + } + + build() { + Tabs({ + barPosition: new BreakPointType(BarPosition.End, BarPosition.End, BarPosition.Start).GetValue(this.currentBreakpoint) + }) { + TabContent() { + FoodDetail() + }.tabBar(this.BottomBarItemBuilder($r("app.string.tab_bar_home"), $r("app.media.ic_bottom_home"), 0)) + + TabContent() { + Records() + }.tabBar(this.BottomBarItemBuilder($r("app.string.tab_bar_record"), $r("app.media.ic_bottom_record"), 1)) + } + .vertical(new BreakPointType(false, false, true).GetValue(this.currentBreakpoint)) + .barWidth(new BreakPointType('100%', '100%', '56vp').GetValue(this.currentBreakpoint)) + .barHeight(new BreakPointType('56vp', '56vp', '60%').GetValue(this.currentBreakpoint)) + .onChange((index) => { + this.currentIndex = index + }) + } +} \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/pages/Logo.ets b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/Logo.ets similarity index 94% rename from ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/pages/Logo.ets rename to ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/Logo.ets index 271b186a8512b4ab9505d87d63bbb85adf0aa5d8..97f7521ad7eb7534b17a787326df1ea8944346c5 100644 --- a/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/default/pages/Logo.ets +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/ets/pages/Logo.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 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 @@ -53,10 +53,10 @@ struct Logo { duration: 1000, curve: this.curve1, delay: 100, - onFinish: () =>{ + onFinish: () => { setTimeout(() => { - router.replace({ uri: 'pages/FoodCategoryList' }) - }, 1000); + router.replace({ uri: 'pages/Home' }) + }, 1000) } }, () => { this.opacityValue = 1 diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/java/ohos/samples/etsdrawingandanimation/MainAbility.java b/ETSUI/eTSDrawingAndAnimation/entry/src/main/java/ohos/samples/etsdrawingandanimation/MainAbility.java deleted file mode 100644 index 6c2c489563b2eedd91008231732ad2e7d6e8a96c..0000000000000000000000000000000000000000 --- a/ETSUI/eTSDrawingAndAnimation/entry/src/main/java/ohos/samples/etsdrawingandanimation/MainAbility.java +++ /dev/null @@ -1,16 +0,0 @@ -package ohos.samples.etsdrawingandanimation; - -import ohos.ace.ability.AceAbility; -import ohos.aafwk.content.Intent; - -public class MainAbility extends AceAbility { - @Override - public void onStart(Intent intent) { - super.onStart(intent); - } - - @Override - public void onStop() { - super.onStop(); - } -} diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/java/ohos/samples/etsdrawingandanimation/MyApplication.java b/ETSUI/eTSDrawingAndAnimation/entry/src/main/java/ohos/samples/etsdrawingandanimation/MyApplication.java deleted file mode 100644 index 32cd05f5f652c5ad963684c28670a1ca421abc57..0000000000000000000000000000000000000000 --- a/ETSUI/eTSDrawingAndAnimation/entry/src/main/java/ohos/samples/etsdrawingandanimation/MyApplication.java +++ /dev/null @@ -1,10 +0,0 @@ -package ohos.samples.etsdrawingandanimation; - -import ohos.aafwk.ability.AbilityPackage; - -public class MyApplication extends AbilityPackage { - @Override - public void onInitialize() { - super.onInitialize(); - } -} diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/element/color.json b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/element/string.json b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/element/string.json index 3440475e7cbd0420317843d6131c278bd48a8ece..91ccb778b9f4264b25a5489a75c53515ebaf05e8 100644 --- a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/element/string.json +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/element/string.json @@ -1,12 +1,16 @@ { "string": [ { - "name": "entry_MainAbility", + "name": "entry_desc", "value": "Healthy Diet" }, { - "name": "mainability_description", + "name": "MainAbility_desc", "value": "ETS_Empty Ability" + }, + { + "name": "MainAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Avocado.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Avocado.png new file mode 100644 index 0000000000000000000000000000000000000000..a2848b10707f0f4f1c6a661826d822e678b3cceb Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Avocado.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Back.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Back.png new file mode 100644 index 0000000000000000000000000000000000000000..2b0806c99ba80ca8bd23cf65f0b8eebf01dcb460 Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Back.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Blueberry.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Blueberry.png new file mode 100644 index 0000000000000000000000000000000000000000..a07421e575d4d41e718ace47c16aaba8ac0755ac Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Blueberry.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Crab.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Crab.png new file mode 100644 index 0000000000000000000000000000000000000000..b71a627013711964e4d5d3b271e9311a2b525f65 Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Crab.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Cucumber.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Cucumber.png new file mode 100644 index 0000000000000000000000000000000000000000..6dd74778e8d76e29a269fdd0155084292504ef61 Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Cucumber.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/IceCream.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/IceCream.png new file mode 100644 index 0000000000000000000000000000000000000000..13a867424f48674c3e95590ec9887d38cd00fbfd Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/IceCream.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Index.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Index.png new file mode 100644 index 0000000000000000000000000000000000000000..5c57223a5862f70e9d2ad17e1890fd1093c92097 Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Index.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/IndexGray.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/IndexGray.png new file mode 100644 index 0000000000000000000000000000000000000000..942ecebf349f33b47cdc3eb12848f6cc3d4699f1 Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/IndexGray.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Kiwi.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Kiwi.png new file mode 100644 index 0000000000000000000000000000000000000000..f22fb4328a9850ddd526d165964096c1bb9778a7 Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Kiwi.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Mushroom.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Mushroom.png new file mode 100644 index 0000000000000000000000000000000000000000..3e984ee10df7a0ff4dae4558f17f2c6c7b89075f Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Mushroom.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/NoRecord.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/NoRecord.png new file mode 100644 index 0000000000000000000000000000000000000000..724b2e1a37f43c954e599e64d34e61e3826b8e5e Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/NoRecord.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Onion.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Onion.png new file mode 100644 index 0000000000000000000000000000000000000000..9c1c5a81c2ff9717df20fcec6a7a8e128b41f1ee Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Onion.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Pitaya.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Pitaya.png new file mode 100644 index 0000000000000000000000000000000000000000..2770b34deb402ab0639e861fb83e4c8a5865bf59 Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Pitaya.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Statistics.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Statistics.png new file mode 100644 index 0000000000000000000000000000000000000000..28099adabd59be84757231da8c47daf7bfc11a04 Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Statistics.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/StatisticsGray.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/StatisticsGray.png new file mode 100644 index 0000000000000000000000000000000000000000..018f9c3177561e7aa7795e0e6975a2c30054c3cf Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/StatisticsGray.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Strawberry.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Strawberry.png new file mode 100644 index 0000000000000000000000000000000000000000..a8d239456cdac76fa31e919768151ed6e74cae44 Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Strawberry.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Switch.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Switch.png new file mode 100644 index 0000000000000000000000000000000000000000..51aa0fc19aeb19ee0599d09f9802fd1f344818ec Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Switch.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Tomato.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Tomato.png new file mode 100644 index 0000000000000000000000000000000000000000..93ad983d4862485684c34cfcf1632569a13ae5a1 Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Tomato.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Walnut.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Walnut.png new file mode 100644 index 0000000000000000000000000000000000000000..8187a4209586dae8522fb494386cc9d64aba95df Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/Walnut.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/ic_bottom_home.svg b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/ic_bottom_home.svg new file mode 100644 index 0000000000000000000000000000000000000000..c74324a979a1b8ab7237ca210338a679d91db169 --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/ic_bottom_home.svg @@ -0,0 +1 @@ + Public/ic_public_home_filled \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/ic_bottom_record.svg b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/ic_bottom_record.svg new file mode 100644 index 0000000000000000000000000000000000000000..b3041818d9f2c6b1d9a830d71c41b78e44e3a8b3 --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/ic_bottom_record.svg @@ -0,0 +1 @@ + Public/ic_public_notes_filled \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/ic_public_delete.svg b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/ic_public_delete.svg new file mode 100644 index 0000000000000000000000000000000000000000..5e69d92bec10119023e8d891648ecce85d6507be --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/ic_public_delete.svg @@ -0,0 +1,31 @@ + + + Public/ic_public_delete + + + + + + + + + + \ No newline at end of file diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/icon.png b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/base/media/icon.png differ diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/en_GB/element/string.json b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/en_GB/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b9447490b825687343c4b2d09e4ed2587d4dcbbf --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/en_GB/element/string.json @@ -0,0 +1,125 @@ +{ + "string": [ + { + "name": "tab_bar_home", + "value": "Home" + }, + { + "name": "tab_bar_record", + "value": "Records" + }, + { + "name": "diet_record_calorie", + "value": "Calories" + }, + { + "name": "diet_record_nutrition", + "value": "Nutrition" + }, + { + "name": "nutrition_element", + "value": "Nutrition Element" + }, + { + "name": "high_calorie", + "value": "High-Calories" + }, + { + "name": "medium_low_calories", + "value": "Medium-Low-Calories" + }, + { + "name": "low_calorie", + "value": "Low-Calories" + }, + { + "name": "low_calorie_food", + "value": "Low-Calories-Food" + }, + { + "name": "high_calorie_food", + "value": "High-Calories-Food" + }, + { + "name": "diet_record_fat", + "value": "Fat" + }, + { + "name": "diet_record_protein", + "value": "Protein" + }, + { + "name": "diet_record_vitaminC", + "value": "VitaminC" + }, + { + "name": "diet_record_carbohydrates", + "value": "Carbohydrates" + }, + { + "name": "title_food_detail", + "value": "Food Detail" + }, + { + "name": "button_food_detail_complete", + "value": "Complete" + }, + { + "name": "button_food_detail_record", + "value": "Record" + }, + { + "name": "all_food_list", + "value": "Food List" + }, + { + "name": "food_type", + "value": "Fruit" + }, + { + "name": "meal_time_break", + "value": "Break" + }, + { + "name": "meal_time_lunch", + "value": "Lunch" + }, + { + "name": "meal_time_dinner", + "value": "Dinner" + }, + { + "name": "meal_time_supper", + "value": "Supper" + } + ] +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/zh_CN/element/string.json b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1b00f1d21cf539a45dcec0055e07f5485d09bb33 --- /dev/null +++ b/ETSUI/eTSDrawingAndAnimation/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,118 @@ + { + "string": [ + { + "name": "tab_bar_home", + "value": "主页" + }, + { + "name": "tab_bar_record", + "value": "记录" + }, + { + "name": "diet_record_calorie", + "value": "热量" + }, + { + "name": "diet_record_nutrition", + "value": "营养" + }, + { + "name": "nutrition_element", + "value": "营养元素" + }, + { + "name": "high_calorie", + "value": "高热量" + }, + { + "name": "medium_low_calories", + "value": "中低热量" + }, + { + "name": "low_calorie", + "value": "低热量" + }, + { + "name": "low_calorie_food", + "value": "低热量食物" + }, + { + "name": "high_calorie_food", + "value": "高热量食物" + }, + { + "name": "diet_record_fat", + "value": "脂肪" + }, + { + "name": "diet_record_protein", + "value": "蛋白质" + }, + { + "name": "diet_record_vitaminC", + "value": "维他命C" + }, + { + "name": "diet_record_carbohydrates", + "value": "碳水" + }, + { + "name": "title_food_detail", + "value": "食物详情" + }, + { + "name": "button_food_detail_complete", + "value": "完成" + }, + { + "name": "button_food_detail_record", + "value": "记录" + }, + { + "name": "all_food_list", + "value": "全部" + }, + { + "name": "meal_time_break", + "value": "早餐" + }, + { + "name": "meal_time_lunch", + "value": "午餐" + }, + { + "name": "meal_time_dinner", + "value": "晚餐" + }, + { + "name": "meal_time_supper", + "value": "夜宵" + } + ] +} + + + + + + + + + + + + + + + + + + + + + + + + + +