array demo

This commit is contained in:
DevWiki 2024-09-25 19:23:07 +08:00
parent 9010489037
commit 4cb3badb4d
8 changed files with 149 additions and 8 deletions

View File

@ -8,7 +8,9 @@ import { BaseLocalStorage, ScreenUtil } from '@devwiki/base';
import { HomeItem, HomeItemGroup } from '../model/Home'; import { HomeItem, HomeItemGroup } from '../model/Home';
import { MyApp } from '../MyApp'; import { MyApp } from '../MyApp';
import('./animation/LoadingPage') import './animation/LoadingPage'
import './animation/ScaleRotatePage'
import { PageName } from './PageName';
@Entry @Entry
@Component @Component
@ -47,6 +49,7 @@ struct Index {
items: [ items: [
{ name: 'CompTransition', page: 'pages/animation/CompTransitionPage'}, { name: 'CompTransition', page: 'pages/animation/CompTransitionPage'},
{ name: 'Loading', page: 'pages/animation/LoadingPage'}, { name: 'Loading', page: 'pages/animation/LoadingPage'},
{ name: 'ScaleRotatePage', page: PageName.ScaleRotatePage },
] ]
}, },
// 多媒体 // 多媒体
@ -62,6 +65,7 @@ struct Index {
items: [ items: [
{name: "Scheme", page: 'pages/system/SchemePage'}, {name: "Scheme", page: 'pages/system/SchemePage'},
{name: "MVVM", page: 'pages/mvvm/HomePage'}, {name: "MVVM", page: 'pages/mvvm/HomePage'},
{name: "ArrayBind", page: 'pages/mvvm/ArrayBindPage'},
{name: "SetLanguage", page: 'pages/system/SetLanguagePage'} {name: "SetLanguage", page: 'pages/system/SetLanguagePage'}
] ]
}, },
@ -150,7 +154,11 @@ struct Index {
Divider().margin({ top: 2 }); Divider().margin({ top: 2 });
}.onClick(() => { }.onClick(() => {
if (item.page) { if (item.page) {
this.getUIContext().getRouter().pushUrl({url: item.page }) if (item.page.startsWith('pages/')) {
this.getUIContext().getRouter().pushUrl({url: item.page })
} else {
this.getUIContext().getRouter().pushNamedRoute({name: item.page })
}
} }
}) })
} }

View File

@ -0,0 +1,5 @@
export enum PageName {
ScaleRotatePage = 'animation/ScaleRotatePage'
}

View File

@ -0,0 +1,67 @@
import { PageName } from '../PageName';
@Component
@Entry({routeName: PageName.ScaleRotatePage})
struct ScaleRotatePage {
@State orderId:string = ''
@State rootJustifyContent: FlexAlign = FlexAlign.Start
@State showQRAnimation: boolean= false
@State qrColumnHeight: Length = ''
@State qrJustifyContent: FlexAlign = FlexAlign.Start
@State showBarcodeAnimation : boolean = false;
@State barcodeHeight: Length = ''
@State barcodeAngle: number = 0
@Builder
ScanBarCodeDialog(){
}
private ScanBarCodeDialogController: CustomDialogController = new CustomDialogController({
builder: this.ScanBarCodeDialog,
autoCancel: true,
alignment: DialogAlignment.Center,
customStyle: true,
openAnimation: {
}
})
build() {
Column(){
Text('Title')
Column(){
Image($r('app.media.ic_eye_off')).width(200).height(200).onClick(() =>{
})
Text('Order Id:' + this.orderId).visibility(this.showQRAnimation ? Visibility.Visible : Visibility.None)
}.width('100%').visibility(this.showBarcodeAnimation ? Visibility.None : Visibility.Visible)
.animation({
duration: 1000
})
Text('Order Id:' + this.orderId).visibility(this.showQRAnimation || this.showBarcodeAnimation ? Visibility.None : Visibility.Visible)
Column(){
Text('Order Id:' + this.orderId).visibility(this.showBarcodeAnimation ? Visibility.Visible : Visibility.None)
Image($r('app.media.ic_eye_off')).width(400).height(100).onClick(() =>{
})
}.visibility(this.showQRAnimation ? Visibility.None : Visibility.Visible)
.rotate({ centerX: '50%', centerY: '50%', angle: this.barcodeAngle})
.animation({
duration: 1000
})
}.width('100%').height('100%').alignItems(HorizontalAlign.Center).justifyContent(this.rootJustifyContent)
}
}

View File

@ -0,0 +1,25 @@
@Entry
@Component
export struct ArrayBindPage {
@State firstDatas: string[] = ["1"];
@State secondDatas: string[] = ["2"]
build() {
Column(){
Text(this.firstDatas[0]);
Text(this.secondDatas[0]).margin({top: 16})
Button("Change").margin({top: 16}).onClick(() => {
let first = this.firstDatas;
this.changeFirstIndex(first);
this.changeFirstIndex(this.secondDatas);
})
}.width('100%').height('100%')
}
changeFirstIndex(datas: string[]) {
datas[0] = '111'
}
}

View File

@ -3,6 +3,8 @@ import { Log } from '@devwiki/base/Index';
import { APIError, APIHeader, APIQuery, APIRequestMethod, Organization } from './APIModel'; import { APIError, APIHeader, APIQuery, APIRequestMethod, Organization } from './APIModel';
import { APIRequest } from './APIModel'; import { APIRequest } from './APIModel';
import { APIResult } from './APIModel'; import { APIResult } from './APIModel';
import axios from '@ohos/axios';
import { Axios } from '@ohos/axios';
const TAG = '[RestAPI]' const TAG = '[RestAPI]'

View File

@ -0,0 +1,33 @@
import { pasteboard } from '@kit.BasicServicesKit';
class PasteboardUtil {
static async copyData(data: string, type: CopyDataType) {
try {
if (!data) {
return;
}
let mineType = pasteboard.MIMETYPE_TEXT_PLAIN;
if (type === CopyDataType.URI) {
mineType = pasteboard.MIMETYPE_TEXT_URI;
} else if (type === CopyDataType.HTML) {
mineType = pasteboard.MIMETYPE_TEXT_HTML;
}
const pasteData: pasteboard.PasteData = pasteboard.createData(mineType, data);
const systemPasteboard: pasteboard.SystemPasteboard = pasteboard.getSystemPasteboard();
await systemPasteboard.setData(pasteData);
} catch (err) {
console.error('Failed to set PasteData.');
}
}
}
export enum CopyDataType {
TEXT,
URI,
HTML
}

View File

@ -18,6 +18,7 @@
"pages/media/PhotoPage", "pages/media/PhotoPage",
"pages/mvvm/HomePage", "pages/mvvm/HomePage",
"pages/mvvm/ArrayBindPage",
"pages/net/TcpSocketPage", "pages/net/TcpSocketPage",
"pages/net/RestAPIPage", "pages/net/RestAPIPage",

View File

@ -7,13 +7,13 @@
"name": "default", "name": "default",
"type": "HarmonyOS", "type": "HarmonyOS",
"material": { "material": {
"certpath": "build_script/sign/HM4Demo.cer", "certpath": "C:\\Users\\zyz\\.ohos\\config\\default_HMDemo_i5yHT0lu8Bugf7Se0a-mWm67_DsSdIYAWNVACnIC98c=.cer",
"storePassword": "0000001B9C6223E8C618FEFD3D871B066F744A4E9C03C09D8ED7E7C7ECE6C1F53A54A6748EC341B960E492", "storePassword": "0000001B17961DDECEBACEACD9CAA1E45CB0BEF5D5A935C253F2AB99644951676ED1B6F102D2B5AD8BCBA2",
"keyAlias": "debugKey", "keyAlias": "debugKey",
"keyPassword": "0000001B63515E7120BC166D17A66B98A717DE9B06276194E4317B5317F70EA2835B8AD262B9DD4FD6AB55", "keyPassword": "0000001B72605A837A1D1827D656F3D157F771A9B6DEC8B264626F1EFBBDA8FF65464F416F4B5C7F9FA84F",
"profile": "build_script/sign/HM4Demo.p7b", "profile": "C:\\Users\\zyz\\.ohos\\config\\default_HMDemo_i5yHT0lu8Bugf7Se0a-mWm67_DsSdIYAWNVACnIC98c=.p7b",
"signAlg": "SHA256withECDSA", "signAlg": "SHA256withECDSA",
"storeFile": "build_script/sign/HM4Demo.p12" "storeFile": "C:\\Users\\zyz\\.ohos\\config\\default_HMDemo_i5yHT0lu8Bugf7Se0a-mWm67_DsSdIYAWNVACnIC98c=.p12"
} }
} }
], ],
@ -22,7 +22,7 @@
{ {
"name": "default", "name": "default",
"signingConfig": "default", "signingConfig": "default",
"compatibleSdkVersion": "4.0.0(10)", "compatibleSdkVersion": "5.0.0(12)",
"runtimeOS": "HarmonyOS", "runtimeOS": "HarmonyOS",
} }
], ],