王士厅

多图(图集)详情页评论、点赞增加角标,返回上一页,输入法开发部分

@@ -23,7 +23,7 @@ export { Pic } from './src/main/ets/bean/content/Pic' @@ -23,7 +23,7 @@ export { Pic } from './src/main/ets/bean/content/Pic'
23 23
24 export { InteractDataDTO } from './src/main/ets/bean/content/InteractDataDTO'; 24 export { InteractDataDTO } from './src/main/ets/bean/content/InteractDataDTO';
25 25
26 -export { InteractDataStatusBean, PhotoListBean } from './src/main/ets/bean/detail/MultiPictureDetailPageDTO'; 26 +export { InteractDataStatusBean, PhotoListBean, InputMethodProperty } from './src/main/ets/bean/detail/MultiPictureDetailPageDTO';
27 27
28 export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam'; 28 export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam';
29 29
@@ -17,4 +17,84 @@ export interface PhotoListBean { @@ -17,4 +17,84 @@ export interface PhotoListBean {
17 width: number; 17 width: number;
18 picPath: string; 18 picPath: string;
19 picDesc: string; 19 picDesc: string;
  20 +}
  21 +
  22 +export interface InputMethodProperty {
  23 + /**
  24 + * The name of input method
  25 + *
  26 + * @syscap SystemCapability.MiscServices.InputMethodFramework
  27 + * @since 8
  28 + * @deprecated since 9
  29 + * @useinstead inputMethod.InputMethodProperty#name
  30 + */
  31 + readonly packageName: string;
  32 + /**
  33 + * The id of input method
  34 + *
  35 + * @syscap SystemCapability.MiscServices.InputMethodFramework
  36 + * @since 8
  37 + * @deprecated since 9
  38 + * @useinstead inputMethod.InputMethodProperty#id
  39 + */
  40 + readonly methodId: string;
  41 + /**
  42 + * The name of input method
  43 + *
  44 + * @syscap SystemCapability.MiscServices.InputMethodFramework
  45 + * @since 9
  46 + */
  47 + readonly name: string;
  48 + /**
  49 + * The id of input method
  50 + *
  51 + * @syscap SystemCapability.MiscServices.InputMethodFramework
  52 + * @since 9
  53 + */
  54 + readonly id: string;
  55 + /**
  56 + * The label of input method
  57 + *
  58 + * @syscap SystemCapability.MiscServices.InputMethodFramework
  59 + * @since 9
  60 + */
  61 + readonly label?: string;
  62 + /**
  63 + * The label id of input method
  64 + *
  65 + * @type { ?number }
  66 + * @syscap SystemCapability.MiscServices.InputMethodFramework
  67 + * @since 10
  68 + */
  69 + readonly labelId?: number;
  70 + /**
  71 + * The icon of input method
  72 + *
  73 + * @syscap SystemCapability.MiscServices.InputMethodFramework
  74 + * @since 9
  75 + */
  76 + readonly icon?: string;
  77 + /**
  78 + * The icon id of input method
  79 + *
  80 + * @type { ?number }
  81 + * @syscap SystemCapability.MiscServices.InputMethodFramework
  82 + * @since 9
  83 + */
  84 + readonly iconId?: number;
  85 + /**
  86 + * The extra info of input method
  87 + *
  88 + * @type { object }
  89 + * @syscap SystemCapability.MiscServices.InputMethodFramework
  90 + * @since 9
  91 + */
  92 + /**
  93 + * The extra info of input method
  94 + *
  95 + * @type { ?object }
  96 + * @syscap SystemCapability.MiscServices.InputMethodFramework
  97 + * @since 10
  98 + */
  99 + extra?: object;
20 } 100 }
1 import { ToastUtils, Logger } from 'wdKit'; 1 import { ToastUtils, Logger } from 'wdKit';
  2 +import { InputMethodProperty } from 'wdBean';
  3 +import router from '@ohos.router';
  4 +import inputMethod from '@ohos.inputMethod';
2 5
3 export interface OperationItem { 6 export interface OperationItem {
4 icon: Resource; 7 icon: Resource;
@@ -25,7 +28,6 @@ export struct OperRowListView { @@ -25,7 +28,6 @@ export struct OperRowListView {
25 { 28 {
26 icon: $r('app.media.ic_collect_uncheck'), 29 icon: $r('app.media.ic_collect_uncheck'),
27 text: "收藏", 30 text: "收藏",
28 - num: 662,  
29 }, 31 },
30 { 32 {
31 icon: $r('app.media.ic_share'), 33 icon: $r('app.media.ic_share'),
@@ -54,8 +56,8 @@ export struct OperRowListView { @@ -54,8 +56,8 @@ export struct OperRowListView {
54 }) 56 })
55 .alignItems(HorizontalAlign.Center) 57 .alignItems(HorizontalAlign.Center)
56 .hoverEffect(HoverEffect.Scale) 58 .hoverEffect(HoverEffect.Scale)
57 - .onClick((event: ClickEvent) => {  
58 - ToastUtils.showToast('体验版,本功能暂未开发', 1000); 59 + .onClick(() => {
  60 + router.back();
59 }) 61 })
60 TextInput({placeholder:'说两句...'}) 62 TextInput({placeholder:'说两句...'})
61 .placeholderColor('#999999') 63 .placeholderColor('#999999')
@@ -71,6 +73,9 @@ export struct OperRowListView { @@ -71,6 +73,9 @@ export struct OperRowListView {
71 .width('61.5%') 73 .width('61.5%')
72 .height(30) 74 .height(30)
73 .borderRadius(0) 75 .borderRadius(0)
  76 + .onClick(() => {
  77 + this.buildInputMethod()
  78 + })
74 } 79 }
75 .width('45.5%') 80 .width('45.5%')
76 .alignItems(VerticalAlign.Center) 81 .alignItems(VerticalAlign.Center)
@@ -78,7 +83,7 @@ export struct OperRowListView { @@ -78,7 +83,7 @@ export struct OperRowListView {
78 Flex({ justifyContent: FlexAlign.SpaceAround, alignItems:ItemAlign.Center }) { 83 Flex({ justifyContent: FlexAlign.SpaceAround, alignItems:ItemAlign.Center }) {
79 ForEach(this.operationList, (item: OperationItem, index: number) => { 84 ForEach(this.operationList, (item: OperationItem, index: number) => {
80 this.buildOperationItem(item, index) 85 this.buildOperationItem(item, index)
81 - }, (item: OperationItem, index: number) => JSON.stringify(item)) 86 + }, (item: OperationItem) => JSON.stringify(item))
82 } 87 }
83 .width('54.5%') 88 .width('54.5%')
84 } 89 }
@@ -95,18 +100,84 @@ export struct OperRowListView { @@ -95,18 +100,84 @@ export struct OperRowListView {
95 @Builder 100 @Builder
96 buildOperationItem(item: OperationItem, index: number) { 101 buildOperationItem(item: OperationItem, index: number) {
97 Column() { 102 Column() {
98 - Image(item.icon)  
99 - .width(24)  
100 - .height(24)  
101 - .aspectRatio(1)  
102 - .interpolation(ImageInterpolation.High) 103 + RelativeContainer() {
  104 + Row() {
  105 + Image(item.icon)
  106 + .width(24)
  107 + .height(24)
  108 + .aspectRatio(1)
  109 + .interpolation(ImageInterpolation.High)
  110 + }
  111 + .alignRules({
  112 + center: { anchor: '__container__', align: VerticalAlign.Center },
  113 + middle: { anchor: '__container__', align: HorizontalAlign.Center }
  114 + })
  115 + .id(`e_row1_${index}`)
  116 + if(item.num) {
  117 + Row() {
  118 + Image($r('app.media.corner_mark'))
  119 + .width(25)
  120 + .height(12)
  121 + .interpolation(ImageInterpolation.High)
  122 + }
  123 + .alignRules({
  124 + top: { anchor: `e_row1_${index}`, align: VerticalAlign.Top },
  125 + left: { anchor: `e_row1_${index}`, align: HorizontalAlign.Center }
  126 + })
  127 + .id(`e_row2_${index}`)
  128 +
  129 + Row() {
  130 + Text('99+')
  131 + .fontSize(8)
  132 + .textAlign(TextAlign.Center)
  133 + .fontColor(Color.White)
  134 + .lineHeight(12)
  135 + }
  136 + .alignRules({
  137 + top: { anchor: `e_row2_${index}`, align: VerticalAlign.Top },
  138 + middle: { anchor: `e_row2_${index}`, align: HorizontalAlign.Center }
  139 + })
  140 + .id(`e_row3_${index}`)
  141 + }
  142 + }
  143 + .id(`e_icon_${index}`)
103 } 144 }
104 .margin(5) 145 .margin(5)
105 .alignItems(HorizontalAlign.Center) 146 .alignItems(HorizontalAlign.Center)
106 .hoverEffect(HoverEffect.Scale) 147 .hoverEffect(HoverEffect.Scale)
107 - .onClick((event: ClickEvent) => { 148 + .onClick(() => {
108 Logger.info(TAG, `buildOperationItem onClick event index: ${index}`); 149 Logger.info(TAG, `buildOperationItem onClick event index: ${index}`);
109 ToastUtils.showToast('体验版,本功能暂未开发', 1000); 150 ToastUtils.showToast('体验版,本功能暂未开发', 1000);
110 }) 151 })
111 } 152 }
  153 +
  154 + /**
  155 + * 输入法
  156 + */
  157 +
  158 + private buildInputMethod() {
  159 + let im = inputMethod.getCurrentInputMethod();
  160 + let prop: InputMethodProperty = {
  161 + packageName: im.packageName,
  162 + methodId: im.methodId,
  163 + name: im.name,
  164 + id: im.id,
  165 + extra: {}
  166 + }
  167 + try{
  168 + inputMethod.switchInputMethod(prop, (err, result) => {
  169 + if (err !== undefined) {
  170 + console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
  171 + return;
  172 + }
  173 + if (result) {
  174 + console.info('Succeeded in switching inputmethod.');
  175 + } else {
  176 + console.error('Failed to switchInputMethod.');
  177 + }
  178 + });
  179 + } catch(err) {
  180 + console.error('Failed to switchInputMethod: ' + JSON.stringify(err));
  181 + }
  182 + }
112 } 183 }