diff --git a/entry/src/main/ets/constant/Constant.ets b/entry/src/main/ets/constant/Constant.ets index aca2fa8fbdd40213fa99b9db244955a165fdf117..f0ab9db8c2b35fd539653530485768c6881ac1f4 100644 --- a/entry/src/main/ets/constant/Constant.ets +++ b/entry/src/main/ets/constant/Constant.ets @@ -25,11 +25,6 @@ export class CONSTANT { static FULL_SIZE = '100%'; static FIFTY_SIZE = '50%'; static EIGHTY_SIZE = '80%'; - // HZ list - static HZ_ZERO = 0; - static HZ_THIRTY = 30; - static HZ_SIXTY = 60; - static HZ_ONE_HUNDRED_AND_TWENTY = 120; // Rotate 360 static ROTATE = 360; // Add rotate num diff --git a/entry/src/main/ets/view/SampleUnitAVPlayView.ets b/entry/src/main/ets/view/SampleUnitAVPlayView.ets index 3fc029cba723cd2eb393387e5ba7130ac7e74962..0bb0eae439686e3b5aa979bc58cc4cf00ee7727c 100644 --- a/entry/src/main/ets/view/SampleUnitAVPlayView.ets +++ b/entry/src/main/ets/view/SampleUnitAVPlayView.ets @@ -46,10 +46,10 @@ export default struct SampleUnitAVPlayView { } display.on('foldStatusChange', () => { - if (display.getFoldStatus() === display.FoldStatus.FOLD_STATUS_EXPANDED) { - this.sliderWidth = px2vp(SURFACE_SIZE); - } else { + if (display.getFoldStatus() === display.FoldStatus.FOLD_STATUS_FOLDED) { this.sliderWidth = X_COMPONENT_WIDTH; + } else { + this.sliderWidth = px2vp(SURFACE_SIZE); } }); } @@ -70,14 +70,12 @@ export default struct SampleUnitAVPlayView { this.avPlayer.surfaceID = this.xComponentController.getXComponentSurfaceId(); }) .onVisibleAreaChange([0.0, 1.0], (isVisible: boolean, currentRatio: number) => { - if (isVisible && currentRatio === 1) { if (this.setTimeInstance) { clearTimeout(this.setTimeInstance) } this.setTimeInstance = setTimeout(() => { if (this.avPlayer && this.avPlayer.surfaceID !== '') { - if (this.currentSurfaceID) { if (this.avPlayer.surfaceID !== this.currentSurfaceID) { } @@ -95,6 +93,7 @@ export default struct SampleUnitAVPlayView { .height(this.xComponentHeight) .width(this.xComponentWidth) + Slider({ value: this.curTime, min: 0, max: 100 }) .enabled(false) .height(4) diff --git a/entry/src/main/ets/view/SampleUnitView.ets b/entry/src/main/ets/view/SampleUnitView.ets index 82523239f8de056d825b1bedb46698f015f66e13..0d3a682dfe77737e4837d0cbfbffa0786e9a5472 100644 --- a/entry/src/main/ets/view/SampleUnitView.ets +++ b/entry/src/main/ets/view/SampleUnitView.ets @@ -30,26 +30,18 @@ const STATIC_MARGIN = 8; const MINI_MARGIN = 4; // All types const TYPE_ENUM = ['av', 'pic', 'video']; -// Font weight +// Font weight. const FONT_WEIGHT = 400; // Border radius const BORDER_RADIUS = 5; -// Title unit item obj -const TITLE_UNIT_ITEM_OBJ = ['华商报', '昨天 19:21', '微博视频号'] -// Button unit item obj -const BUTTON_UNIT_ITEM_OBJ = [5, 18, 53] @Component export default struct SampleUnitView { - type: string = 'av'; - buttonUnit: ButtonUnitItem = - new ButtonUnitItem($r('app.media.share'), BUTTON_UNIT_ITEM_OBJ[0], $r('app.media.like'), BUTTON_UNIT_ITEM_OBJ[1], - $r('app.media.collect'), BUTTON_UNIT_ITEM_OBJ[2]); - areaUnit: TitleUnitItem = - new TitleUnitItem($r('app.media.huaShangBaoPic'), TITLE_UNIT_ITEM_OBJ[0], TITLE_UNIT_ITEM_OBJ[1], - TITLE_UNIT_ITEM_OBJ[2], $r('app.media.honour')); - textContext: string = ''; - imageArray: Resource[] = [$r("app.media.b")]; + @Prop areaUnit: TitleUnitItem; + @Prop buttonUnit: ButtonUnitItem; + @Prop type: string; + @Prop textContext: string; + @Prop imageArray: Resource[]; controller: VideoController = new VideoController(); avPlayer: AVPlayerItem = new AVPlayerItem(); diff --git a/entry/src/main/ets/viewmodel/BasicDataSource.ets b/entry/src/main/ets/viewmodel/BasicDataSource.ets index 20807e9b9df615bd747a81ae5adedf2f221a55e7..c56e29560ccc8db40481e4ab6906ae3fc18cf320 100644 --- a/entry/src/main/ets/viewmodel/BasicDataSource.ets +++ b/entry/src/main/ets/viewmodel/BasicDataSource.ets @@ -25,44 +25,6 @@ export class DataSource { return this.dataSource; } - pushData(): void { - let imageArray1: Resource[] = [$r("app.media.b")]; - let imageArray3: Resource[] = [$r("app.media.a"), $r("app.media.b"), $r("app.media.c")]; - let imageArray4: Resource[] = [$r("app.media.a"), $r("app.media.b"), $r("app.media.c"), $r("app.media.d")]; - let imageArray8: Resource[] = - [$r("app.media.a"), $r("app.media.b"), $r("app.media.c"), $r("app.media.d"), $r("app.media.e"), $r("app.media.f"), - $r("app.media.g"), $r("app.media.h")]; - let imageArray9: Resource[] = - [$r("app.media.a"), $r("app.media.b"), $r("app.media.c"), $r("app.media.d"), $r("app.media.e"), $r("app.media.f"), - $r("app.media.g"), $r("app.media.h"), $r("app.media.i")]; - let buttonUnit: ButtonUnitItem = - new ButtonUnitItem($r('app.media.share'), 5, $r('app.media.like'), 18, $r('app.media.collect'), 53); - let areaUnit: TitleUnitItem = - new TitleUnitItem($r('app.media.avatar'), '小鱼儿', '昨天', '', $r('app.media.honour'),); - let textContext = - '上面的示例中,用户与应用程序的交互触发了文本状态变更,状态变更引起了UI渲染,UI从“Hello World”变更为“Hello ArkUI”。' + - '在声明式UI编程框架中,UI是程序状态的运行结果,用户构建了一个UI模型,其中应用的运行时的状态是参数。当参数改变时,UI作为返回结果,也将进行对应的改变。这些运行时的状态变化所带来的UI的重新渲染,在ArkUI中统称为状态管理机制。' + - '自定义组件拥有变量,变量必须被装饰器装饰才可以成为状态变量,状态变量的改变会引起UI的渲染刷新。如果不使用状态变量,UI只能在初始化时渲染,后续将不会再刷新。 下图展示了State和View(UI)之间的关系。'; - this.dataSource.data.push(new SampleUnitItem('video', areaUnit, textContext, buttonUnit, imageArray1, - new VideoController(), new AVPlayerItem())); - this.dataSource.data.push(new SampleUnitItem('pic', areaUnit, textContext, buttonUnit, imageArray3, - new VideoController(), new AVPlayerItem())); - this.dataSource.data.push(new SampleUnitItem('pic', areaUnit, textContext, buttonUnit, imageArray4, - new VideoController(), new AVPlayerItem())); - this.dataSource.data.push(new SampleUnitItem('pic', areaUnit, textContext, buttonUnit, imageArray8, - new VideoController(), new AVPlayerItem())); - this.dataSource.data.push(new SampleUnitItem('pic', areaUnit, textContext, buttonUnit, imageArray9, - new VideoController(), new AVPlayerItem())); - this.dataSource.data.push(new SampleUnitItem('pic', areaUnit, textContext, buttonUnit, imageArray3, - new VideoController(), new AVPlayerItem())); - this.dataSource.data.push(new SampleUnitItem('av', areaUnit, textContext, buttonUnit, imageArray1, - new VideoController(), new AVPlayerItem())); - this.dataSource.data.push(new SampleUnitItem('pic', areaUnit, textContext, buttonUnit, imageArray1, - new VideoController(), new AVPlayerItem())); - this.dataSource.data.push(new SampleUnitItem('pic', areaUnit, textContext, buttonUnit, imageArray3, - new VideoController(), new AVPlayerItem())); - } - clear() { this.dataSource.data = []; } @@ -85,9 +47,11 @@ class BasicDataSource implements IDataSource { let buttonUnit: ButtonUnitItem = new ButtonUnitItem($r('app.media.share'), 5, $r('app.media.like'), 18, $r('app.media.collect'), 53); let areaUnit: TitleUnitItem = - new TitleUnitItem($r('app.media.avatar'), '小鱼儿', '昨天 19:12', '微博视频号', $r('app.media.honour'),); - let textContext = - '亲近大海,领悟海,体会到了海的心声,海自然与你共鸣,无需可以强求,也无需费力搜寻,海,始终都会以潮声与你相亲,以其海色伴你舒适。'; + new TitleUnitItem($r('app.media.avatar'), + getContext(this).resourceManager.getStringSync($r('app.string.show_netname')), + getContext(this).resourceManager.getStringSync($r('app.string.show_time')), + ); + let textContext = getContext(this).resourceManager.getStringSync($r('app.string.show_text')); let data: SampleUnitItem[] = [ new SampleUnitItem('video', areaUnit, textContext, buttonUnit, this.imageArray1, new VideoController(), diff --git a/entry/src/main/ets/viewmodel/TitleUnitItem.ets b/entry/src/main/ets/viewmodel/TitleUnitItem.ets index b46a92ed6c65caa6e4afe4ed71df2305625b7957..d24ef9350a2c614e498b12bb89ed61fe366e2435 100644 --- a/entry/src/main/ets/viewmodel/TitleUnitItem.ets +++ b/entry/src/main/ets/viewmodel/TitleUnitItem.ets @@ -17,14 +17,10 @@ export default class TitleUnitItem { public titlePic: Resource; public titleName: string; public titleTime: string; - public titleFrom: string; - public titleHonours: Resource; - constructor(titlePic: Resource, titleName: string, titleTime: string, titleFrom: string, titleHonours: Resource) { + constructor(titlePic: Resource, titleName: string, titleTime: string) { this.titlePic = titlePic; this.titleName = titleName; this.titleTime = titleTime; - this.titleFrom = titleFrom; - this.titleHonours = titleHonours; } } \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 4fd9a11f1e43b9c0047479c6ae998f3790794161..bfe2befdf3accf6be107cc3648a1d2fb6fafebb2 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -13,24 +13,16 @@ "value": "label" }, { - "name": "width_100", - "value": "100%" + "name": "show_text", + "value": "Close to the sea, understand the sea, experience the voice of the sea, the sea naturally resonates with you, no need to force, no need to search, the sea, will always be with the sound of the tide and you are comfortable with its sea color." }, { - "name": "height_100", - "value": "100%" + "name": "show_netname", + "value": "small fish" }, { - "name": "image_set_size_9_flex_width", - "value": "75%" - }, - { - "name": "image_set_size_4_flex_width", - "value": "50%" - }, - { - "name": "image_toast", - "value": "本图片仅展示,具体业务可自行实现" + "name": "show_time", + "value": "19:12 Yesterday" } ] } \ 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 21f3c1b11138251277d109a49e7f0e12b179e4d9..8984ec860b16e90d13f72e1016cc2c383709ffae 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -11,6 +11,18 @@ { "name": "EntryAbility_label", "value": "FluentBlog" + }, + { + "name": "show_text", + "value": "Close to the sea, understand the sea, experience the voice of the sea, the sea naturally resonates with you, no need to force, no need to search, the sea, will always be with the sound of the tide and you are comfortable with its sea color." + }, + { + "name": "show_netname", + "value": "small fish" + }, + { + "name": "show_time", + "value": "19:12 Yesterday" } ] } \ 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 67dfc5078b706845470752c6495844a9491c0c7a..75866f278b27b0ba7b2b410892827f0ee217c32c 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -11,6 +11,18 @@ { "name": "EntryAbility_label", "value": "流畅刷文章" + }, + { + "name": "show_text", + "value": "亲近大海,领悟海,体会到了海的心声,海自然与你共鸣,无需可以强求,也无需费力搜寻,海,始终都会以潮声与你相亲,以其海色伴你舒适。" + }, + { + "name": "show_netname", + "value": "小鱼儿" + }, + { + "name": "show_time", + "value": "昨天 19:12" } ] } \ No newline at end of file