107ac75b1Sopenharmony_ci/* 207ac75b1Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 307ac75b1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 407ac75b1Sopenharmony_ci * you may not use this file except in compliance with the License. 507ac75b1Sopenharmony_ci * You may obtain a copy of the License at 607ac75b1Sopenharmony_ci * 707ac75b1Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 807ac75b1Sopenharmony_ci * 907ac75b1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1007ac75b1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1107ac75b1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1207ac75b1Sopenharmony_ci * See the License for the specific language governing permissions and 1307ac75b1Sopenharmony_ci * limitations under the License. 1407ac75b1Sopenharmony_ci */ 1507ac75b1Sopenharmony_ci 1607ac75b1Sopenharmony_ci/** 1707ac75b1Sopenharmony_ci * ACE @ Web Helsinki 1807ac75b1Sopenharmony_ci * 1907ac75b1Sopenharmony_ci * eDSL version of this application 2007ac75b1Sopenharmony_ci * 2107ac75b1Sopenharmony_ci * ( unverified due to lack of working eDSL transpiler ) 2207ac75b1Sopenharmony_ci * 2307ac75b1Sopenharmony_ci * For comparison, the plain JS version of this app that works with ACE-Diff can be found here 2407ac75b1Sopenharmony_ci * 2507ac75b1Sopenharmony_ci * This is the ouput the eDSL transpiler should generate. 2607ac75b1Sopenharmony_ci */ 2707ac75b1Sopenharmony_cilet tasks: Array<any> = [ 2807ac75b1Sopenharmony_ci { label: "Wash the car" }, 2907ac75b1Sopenharmony_ci { label: "Buy some milk" }, 3007ac75b1Sopenharmony_ci { label: "Make the report" }, 3107ac75b1Sopenharmony_ci { label: "Buy flight tickets" }, 3207ac75b1Sopenharmony_ci { label: "Update profile" }, 3307ac75b1Sopenharmony_ci { label: "Change tyres" }, 3407ac75b1Sopenharmony_ci { label: "Walk the dog" }, 3507ac75b1Sopenharmony_ci { label: "Feed the dog" }, 3607ac75b1Sopenharmony_ci { label: "Paint the walls" }, 3707ac75b1Sopenharmony_ci { label: "Wash dishes" }, 3807ac75b1Sopenharmony_ci { label: "Water flowers" }, 3907ac75b1Sopenharmony_ci { label: "Call parents" }, 4007ac75b1Sopenharmony_ci { label: "Refactor: align_component.cpp" }, 4107ac75b1Sopenharmony_ci { label: "Refactor: align_component.h" }, 4207ac75b1Sopenharmony_ci { label: "Refactor: arc_component.cpp" }, 4307ac75b1Sopenharmony_ci { label: "Refactor: arc_component.h" }, 4407ac75b1Sopenharmony_ci { label: "Refactor: block_component.cpp" }, 4507ac75b1Sopenharmony_ci { label: "Refactor: block_component.h" }, 4607ac75b1Sopenharmony_ci { label: "Refactor: box_base_component.cpp" }, 4707ac75b1Sopenharmony_ci { label: "Refactor: box_base_component.h" }, 4807ac75b1Sopenharmony_ci { label: "Refactor: box_component.cpp" }, 4907ac75b1Sopenharmony_ci { label: "Refactor: box_component.h" }, 5007ac75b1Sopenharmony_ci { label: "Refactor: bubble_component.cpp" }, 5107ac75b1Sopenharmony_ci { label: "Refactor: bubble_component.h" }, 5207ac75b1Sopenharmony_ci { label: "Refactor: button_component.cpp" }, 5307ac75b1Sopenharmony_ci { label: "Refactor: button_component.h" }, 5407ac75b1Sopenharmony_ci { label: "Refactor: calendar_component.cpp" }, 5507ac75b1Sopenharmony_ci { label: "Refactor: calendar_component.h" }, 5607ac75b1Sopenharmony_ci { label: "Refactor: calendar_data_adapter.cpp" }, 5707ac75b1Sopenharmony_ci { label: "Refactor: calendar_data_adapter.h" }, 5807ac75b1Sopenharmony_ci { label: "Refactor: chart_component.cpp" }, 5907ac75b1Sopenharmony_ci { label: "Refactor: chart_component.h" }, 6007ac75b1Sopenharmony_ci { label: "Refactor: checkable_component.cpp" }, 6107ac75b1Sopenharmony_ci { label: "Refactor: checkable_component.h" }, 6207ac75b1Sopenharmony_ci { label: "Refactor: clip_component.cpp" }, 6307ac75b1Sopenharmony_ci { label: "Refactor: clip_component.h" }, 6407ac75b1Sopenharmony_ci { label: "Refactor: component.cpp" }, 6507ac75b1Sopenharmony_ci { label: "Refactor: component_group.h" }, 6607ac75b1Sopenharmony_ci { label: "Refactor: component.h" }, 6707ac75b1Sopenharmony_ci { label: "Refactor: composed_component.cpp" }, 6807ac75b1Sopenharmony_ci { label: "Refactor: composed_component.h" }, 6907ac75b1Sopenharmony_ci { label: "Refactor: constants.cpp" }, 7007ac75b1Sopenharmony_ci { label: "Refactor: constants.h" }, 7107ac75b1Sopenharmony_ci { label: "Refactor: sole_child_component.h" }, 7207ac75b1Sopenharmony_ci { label: "Refactor: stack_component.h" }, 7307ac75b1Sopenharmony_ci { label: "Refactor: stage_component.h" }, 7407ac75b1Sopenharmony_ci { label: "Refactor: swiper_component.h" }, 7507ac75b1Sopenharmony_ci { label: "Refactor: tab_bar_component.cpp" }, 7607ac75b1Sopenharmony_ci { label: "Refactor: tab_bar_component.h" }, 7707ac75b1Sopenharmony_ci { label: "Refactor: tab_bar_indicator_component.cpp" }, 7807ac75b1Sopenharmony_ci { label: "Refactor: tab_bar_indicator_component.h" }, 7907ac75b1Sopenharmony_ci { label: "Refactor: tab_bar_item_component.cpp" }, 8007ac75b1Sopenharmony_ci { label: "Refactor: tab_bar_item_component.h" }, 8107ac75b1Sopenharmony_ci { label: "Refactor: tab_content_component.cpp" }, 8207ac75b1Sopenharmony_ci { label: "Refactor: tab_content_component.h" }, 8307ac75b1Sopenharmony_ci { label: "Refactor: tab_controller.cpp" }, 8407ac75b1Sopenharmony_ci { label: "Refactor: tab_controller.h" }, 8507ac75b1Sopenharmony_ci { label: "Refactor: test" }, 8607ac75b1Sopenharmony_ci { label: "Refactor: text_component.cpp" }, 8707ac75b1Sopenharmony_ci { label: "Refactor: text_component.h" }, 8807ac75b1Sopenharmony_ci { label: "Refactor: text_field_component.cpp" }, 8907ac75b1Sopenharmony_ci { label: "Refactor: text_field_component.h" }, 9007ac75b1Sopenharmony_ci { label: "Refactor: text_field_controller.cpp" }, 9107ac75b1Sopenharmony_ci { label: "Refactor: text_field_controller.h" }, 9207ac75b1Sopenharmony_ci { label: "Refactor: text_overlay_component.cpp" }, 9307ac75b1Sopenharmony_ci { label: "Refactor: text_overlay_component.h" }, 9407ac75b1Sopenharmony_ci { label: "Refactor: text_span_component.cpp" }, 9507ac75b1Sopenharmony_ci { label: "Refactor: text_span_component.h" }, 9607ac75b1Sopenharmony_ci { label: "Refactor: texture_component.cpp" }, 9707ac75b1Sopenharmony_ci { label: "Refactor: texture_component.h" }, 9807ac75b1Sopenharmony_ci { label: "Refactor: toast_component.cpp" }, 9907ac75b1Sopenharmony_ci { label: "Refactor: toast_component.h" }, 10007ac75b1Sopenharmony_ci { label: "Refactor: toggle_component.cpp" }, 10107ac75b1Sopenharmony_ci { label: "Refactor: toggle_component.h" }, 10207ac75b1Sopenharmony_ci { label: "Refactor: touch_listener_component.h" }, 10307ac75b1Sopenharmony_ci { label: "Refactor: track_component.cpp" }, 10407ac75b1Sopenharmony_ci { label: "Refactor: track_component.h" }, 10507ac75b1Sopenharmony_ci { label: "Refactor: transform_component.cpp" }, 10607ac75b1Sopenharmony_ci { label: "Refactor: transform_component.h" }, 10707ac75b1Sopenharmony_ci { label: "Refactor: transition_component.cpp" }, 10807ac75b1Sopenharmony_ci { label: "Refactor: transition_component.h" }, 10907ac75b1Sopenharmony_ci { label: "Refactor: triangle_component.cpp" }, 11007ac75b1Sopenharmony_ci { label: "Refactor: triangle_component.h" }, 11107ac75b1Sopenharmony_ci { label: "Refactor: tween_component.cpp" }, 11207ac75b1Sopenharmony_ci { label: "Refactor: tween_component.h" }, 11307ac75b1Sopenharmony_ci { label: "Refactor: video_component.cpp" }, 11407ac75b1Sopenharmony_ci { label: "Refactor: video_component.h" }, 11507ac75b1Sopenharmony_ci { label: "Refactor: watch_slider_component.cpp" }, 11607ac75b1Sopenharmony_ci { label: "Refactor: watch_slider_component.h" }, 11707ac75b1Sopenharmony_ci { label: "Refactor: wrap_component.h" }, 11807ac75b1Sopenharmony_ci { /* not used */ } 11907ac75b1Sopenharmony_ci] 12007ac75b1Sopenharmony_ci 12107ac75b1Sopenharmony_ci// Add ID for each task 12207ac75b1Sopenharmony_citasks.forEach(function (item, index) { 12307ac75b1Sopenharmony_ci item.id = index 12407ac75b1Sopenharmony_ci tasks[index] = item 12507ac75b1Sopenharmony_ci}) 12607ac75b1Sopenharmony_ci 12707ac75b1Sopenharmony_cilet tasksCount: number = tasks.length - 1 12807ac75b1Sopenharmony_cilet screenCount: number = 20 12907ac75b1Sopenharmony_ci 13007ac75b1Sopenharmony_ci@Entry 13107ac75b1Sopenharmony_ci@Component 13207ac75b1Sopenharmony_cistruct RootView { 13307ac75b1Sopenharmony_ci @State idx: number = 0 13407ac75b1Sopenharmony_ci 13507ac75b1Sopenharmony_ci build() { 13607ac75b1Sopenharmony_ci Column () { 13707ac75b1Sopenharmony_ci Column() { 13807ac75b1Sopenharmony_ci Row() { 13907ac75b1Sopenharmony_ci Button("Next task") 14007ac75b1Sopenharmony_ci .onClick(() => { 14107ac75b1Sopenharmony_ci if (this.idx < tasksCount - screenCount) 14207ac75b1Sopenharmony_ci this.idx++ 14307ac75b1Sopenharmony_ci }) 14407ac75b1Sopenharmony_ci Button("Prev task") 14507ac75b1Sopenharmony_ci .onClick(() => { 14607ac75b1Sopenharmony_ci if (this.idx > 0) 14707ac75b1Sopenharmony_ci this.idx-- 14807ac75b1Sopenharmony_ci }) 14907ac75b1Sopenharmony_ci } 15007ac75b1Sopenharmony_ci } 15107ac75b1Sopenharmony_ci ForEach( 15207ac75b1Sopenharmony_ci /* first parameter is an expression of type array. 15307ac75b1Sopenharmony_ci the point of not just using an array here is to clarify ForEach can not just perate on the 15407ac75b1Sopenharmony_ci source array (as repeat implementation in ACE-Light did) */ 15507ac75b1Sopenharmony_ci tasks.slice(this.idx, this.idx + screenCount), 15607ac75b1Sopenharmony_ci 15707ac75b1Sopenharmony_ci /* the third, builder function take an item as input and creates a single View from it */ 15807ac75b1Sopenharmony_ci item => { 15907ac75b1Sopenharmony_ci Text((item.id + 1) + " : " + item.label) 16007ac75b1Sopenharmony_ci }, 16107ac75b1Sopenharmony_ci 16207ac75b1Sopenharmony_ci /* second parameter is an arrow function that takes an item as input 16307ac75b1Sopenharmony_ci and returns a persistent nique id (or key ) */ 16407ac75b1Sopenharmony_ci item => item.id 16507ac75b1Sopenharmony_ci ) // ForEach 16607ac75b1Sopenharmony_ci Text("--- Page navigation ---") 16707ac75b1Sopenharmony_ci Row() { 16807ac75b1Sopenharmony_ci Button("First") 16907ac75b1Sopenharmony_ci .onClick(() => this.idx = 0) 17007ac75b1Sopenharmony_ci Button("End") 17107ac75b1Sopenharmony_ci .onClick(() => this.idx = tasksCount - screenCount) 17207ac75b1Sopenharmony_ci } 17307ac75b1Sopenharmony_ci } 17407ac75b1Sopenharmony_ci } // build 17507ac75b1Sopenharmony_ci} // struct 176