Showing
3 changed files
with
381 additions
and
297 deletions
| @@ -10,259 +10,18 @@ const MORE_CHANNEL: string = '更多频道' | @@ -10,259 +10,18 @@ const MORE_CHANNEL: string = '更多频道' | ||
| 10 | const LOCAL_CHANNEL: string = '地方频道' | 10 | const LOCAL_CHANNEL: string = '地方频道' |
| 11 | 11 | ||
| 12 | @CustomDialog | 12 | @CustomDialog |
| 13 | -struct CustomDialogExample { | ||
| 14 | - @State indexSettingArray: Array<string> = ['推荐', '热点'] | 13 | +struct ChannelDialog { |
| 15 | @State indexSettingTabIndex: number = 1 | 14 | @State indexSettingTabIndex: number = 1 |
| 16 | - @State myChannelList: Array<TopNavDTO> = [ | ||
| 17 | - { | ||
| 18 | - channelId: 0, | ||
| 19 | - channelStyle: 1, | ||
| 20 | - channelType: 1, | ||
| 21 | - defaultPermitted: 1, | ||
| 22 | - delPermitted: 1, | ||
| 23 | - fontCColor: '#000000', | ||
| 24 | - fontColor: '#000000', | ||
| 25 | - headlinesOn: 0, | ||
| 26 | - homeChannel: '1', | ||
| 27 | - iconCUrl: '', | ||
| 28 | - iconCUrlSize: '', | ||
| 29 | - iconUrl: '', | ||
| 30 | - iconUrlSize: '', | ||
| 31 | - localChannel: '', | ||
| 32 | - moreChannel: '', | ||
| 33 | - movePermitted: 0, | ||
| 34 | - myChannel: '1', | ||
| 35 | - name: '推荐', | ||
| 36 | - num: 0, | ||
| 37 | - pageId: 21212, | ||
| 38 | - pageType: '', | ||
| 39 | - underlineCColor: '' | ||
| 40 | - }, | ||
| 41 | - { | ||
| 42 | - channelId: 1, | ||
| 43 | - channelStyle: 1, | ||
| 44 | - channelType: 1, | ||
| 45 | - defaultPermitted: 1, | ||
| 46 | - delPermitted: 1, | ||
| 47 | - fontCColor: '#000000', | ||
| 48 | - fontColor: '#000000', | ||
| 49 | - headlinesOn: 0, | ||
| 50 | - homeChannel: '1', | ||
| 51 | - iconCUrl: '', | ||
| 52 | - iconCUrlSize: '', | ||
| 53 | - iconUrl: '', | ||
| 54 | - iconUrlSize: '', | ||
| 55 | - localChannel: '', | ||
| 56 | - moreChannel: '', | ||
| 57 | - movePermitted: 0, | ||
| 58 | - myChannel: '1', | ||
| 59 | - name: '热点', | ||
| 60 | - num: 0, | ||
| 61 | - pageId: 21212, | ||
| 62 | - pageType: '', | ||
| 63 | - underlineCColor: '' | ||
| 64 | - }, | ||
| 65 | - { | ||
| 66 | - channelId: 2, | ||
| 67 | - channelStyle: 1, | ||
| 68 | - channelType: 1, | ||
| 69 | - defaultPermitted: 1, | ||
| 70 | - delPermitted: 1, | ||
| 71 | - fontCColor: '#000000', | ||
| 72 | - fontColor: '#000000', | ||
| 73 | - headlinesOn: 0, | ||
| 74 | - homeChannel: '', | ||
| 75 | - iconCUrl: '', | ||
| 76 | - iconCUrlSize: '', | ||
| 77 | - iconUrl: '', | ||
| 78 | - iconUrlSize: '', | ||
| 79 | - localChannel: '', | ||
| 80 | - moreChannel: '', | ||
| 81 | - movePermitted: 0, | ||
| 82 | - myChannel: '1', | ||
| 83 | - name: '视频', | ||
| 84 | - num: 0, | ||
| 85 | - pageId: 21212, | ||
| 86 | - pageType: '', | ||
| 87 | - underlineCColor: '' | ||
| 88 | - }, | ||
| 89 | - { | ||
| 90 | - channelId: 3, | ||
| 91 | - channelStyle: 1, | ||
| 92 | - channelType: 1, | ||
| 93 | - defaultPermitted: 1, | ||
| 94 | - delPermitted: 1, | ||
| 95 | - fontCColor: '#000000', | ||
| 96 | - fontColor: '#000000', | ||
| 97 | - headlinesOn: 0, | ||
| 98 | - homeChannel: '', | ||
| 99 | - iconCUrl: '', | ||
| 100 | - iconCUrlSize: '', | ||
| 101 | - iconUrl: '', | ||
| 102 | - iconUrlSize: '', | ||
| 103 | - localChannel: '', | ||
| 104 | - moreChannel: '', | ||
| 105 | - movePermitted: 0, | ||
| 106 | - myChannel: '1', | ||
| 107 | - name: '云课堂', | ||
| 108 | - num: 0, | ||
| 109 | - pageId: 21212, | ||
| 110 | - pageType: '', | ||
| 111 | - underlineCColor: '' | ||
| 112 | - }, | ||
| 113 | - | ||
| 114 | - ] | ||
| 115 | - @State moreChannelList: Array<TopNavDTO> = [ | ||
| 116 | - { | ||
| 117 | - channelId: 4, | ||
| 118 | - channelStyle: 1, | ||
| 119 | - channelType: 1, | ||
| 120 | - defaultPermitted: 1, | ||
| 121 | - delPermitted: 1, | ||
| 122 | - fontCColor: '#000000', | ||
| 123 | - fontColor: '#000000', | ||
| 124 | - headlinesOn: 0, | ||
| 125 | - homeChannel: '', | ||
| 126 | - iconCUrl: '', | ||
| 127 | - iconCUrlSize: '', | ||
| 128 | - iconUrl: '', | ||
| 129 | - iconUrlSize: '', | ||
| 130 | - localChannel: '', | ||
| 131 | - moreChannel: '1', | ||
| 132 | - movePermitted: 0, | ||
| 133 | - myChannel: '', | ||
| 134 | - name: '房产', | ||
| 135 | - num: 0, | ||
| 136 | - pageId: 21212, | ||
| 137 | - pageType: '', | ||
| 138 | - underlineCColor: '' | ||
| 139 | - }, | ||
| 140 | - { | ||
| 141 | - channelId: 5, | ||
| 142 | - channelStyle: 1, | ||
| 143 | - channelType: 1, | ||
| 144 | - defaultPermitted: 1, | ||
| 145 | - delPermitted: 1, | ||
| 146 | - fontCColor: '#000000', | ||
| 147 | - fontColor: '#000000', | ||
| 148 | - headlinesOn: 0, | ||
| 149 | - homeChannel: '', | ||
| 150 | - iconCUrl: '', | ||
| 151 | - iconCUrlSize: '', | ||
| 152 | - iconUrl: '', | ||
| 153 | - iconUrlSize: '', | ||
| 154 | - localChannel: '', | ||
| 155 | - moreChannel: '1', | ||
| 156 | - movePermitted: 0, | ||
| 157 | - myChannel: '', | ||
| 158 | - name: '生态', | ||
| 159 | - num: 0, | ||
| 160 | - pageId: 21212, | ||
| 161 | - pageType: '', | ||
| 162 | - underlineCColor: '' | ||
| 163 | - }, | ||
| 164 | - { | ||
| 165 | - channelId: 6, | ||
| 166 | - channelStyle: 1, | ||
| 167 | - channelType: 1, | ||
| 168 | - defaultPermitted: 1, | ||
| 169 | - delPermitted: 1, | ||
| 170 | - fontCColor: '#000000', | ||
| 171 | - fontColor: '#000000', | ||
| 172 | - headlinesOn: 0, | ||
| 173 | - homeChannel: '', | ||
| 174 | - iconCUrl: '', | ||
| 175 | - iconCUrlSize: '', | ||
| 176 | - iconUrl: '', | ||
| 177 | - iconUrlSize: '', | ||
| 178 | - localChannel: '', | ||
| 179 | - moreChannel: '1', | ||
| 180 | - movePermitted: 0, | ||
| 181 | - myChannel: '', | ||
| 182 | - name: '健康', | ||
| 183 | - num: 0, | ||
| 184 | - pageId: 21212, | ||
| 185 | - pageType: '', | ||
| 186 | - underlineCColor: '' | ||
| 187 | - } | ||
| 188 | - ] | ||
| 189 | - @State localChannelList: Array<TopNavDTO> = [ | ||
| 190 | - { | ||
| 191 | - channelId: 7, | ||
| 192 | - channelStyle: 1, | ||
| 193 | - channelType: 1, | ||
| 194 | - defaultPermitted: 1, | ||
| 195 | - delPermitted: 1, | ||
| 196 | - fontCColor: '#000000', | ||
| 197 | - fontColor: '#000000', | ||
| 198 | - headlinesOn: 0, | ||
| 199 | - homeChannel: '', | ||
| 200 | - iconCUrl: '', | ||
| 201 | - iconCUrlSize: '', | ||
| 202 | - iconUrl: '', | ||
| 203 | - iconUrlSize: '', | ||
| 204 | - localChannel: '1', | ||
| 205 | - moreChannel: '', | ||
| 206 | - movePermitted: 0, | ||
| 207 | - myChannel: '', | ||
| 208 | - name: '北京', | ||
| 209 | - num: 0, | ||
| 210 | - pageId: 21212, | ||
| 211 | - pageType: '', | ||
| 212 | - underlineCColor: '' | ||
| 213 | - }, | ||
| 214 | - { | ||
| 215 | - channelId: 8, | ||
| 216 | - channelStyle: 1, | ||
| 217 | - channelType: 1, | ||
| 218 | - defaultPermitted: 1, | ||
| 219 | - delPermitted: 1, | ||
| 220 | - fontCColor: '#000000', | ||
| 221 | - fontColor: '#000000', | ||
| 222 | - headlinesOn: 0, | ||
| 223 | - homeChannel: '', | ||
| 224 | - iconCUrl: '', | ||
| 225 | - iconCUrlSize: '', | ||
| 226 | - iconUrl: '', | ||
| 227 | - iconUrlSize: '', | ||
| 228 | - localChannel: '1', | ||
| 229 | - moreChannel: '', | ||
| 230 | - movePermitted: 0, | ||
| 231 | - myChannel: '', | ||
| 232 | - name: '上海', | ||
| 233 | - num: 0, | ||
| 234 | - pageId: 21212, | ||
| 235 | - pageType: '', | ||
| 236 | - underlineCColor: '' | ||
| 237 | - }, | ||
| 238 | - { | ||
| 239 | - channelId: 9, | ||
| 240 | - channelStyle: 1, | ||
| 241 | - channelType: 1, | ||
| 242 | - defaultPermitted: 1, | ||
| 243 | - delPermitted: 1, | ||
| 244 | - fontCColor: '#000000', | ||
| 245 | - fontColor: '#000000', | ||
| 246 | - headlinesOn: 0, | ||
| 247 | - homeChannel: '', | ||
| 248 | - iconCUrl: '', | ||
| 249 | - iconCUrlSize: '', | ||
| 250 | - iconUrl: '', | ||
| 251 | - iconUrlSize: '', | ||
| 252 | - localChannel: '1', | ||
| 253 | - moreChannel: '', | ||
| 254 | - movePermitted: 0, | ||
| 255 | - myChannel: '', | ||
| 256 | - name: '江苏', | ||
| 257 | - num: 0, | ||
| 258 | - pageId: 21212, | ||
| 259 | - pageType: '', | ||
| 260 | - underlineCColor: '' | ||
| 261 | - } | ||
| 262 | - ] | ||
| 263 | @State isEditIng: boolean = false | 15 | @State isEditIng: boolean = false |
| 16 | + @Link currentTopNavSelectedIndex : number | ||
| 17 | + @Link myChannelList: Array<TopNavDTO> | ||
| 18 | + @Link moreChannelList: Array<TopNavDTO> | ||
| 19 | + @Link localChannelList: Array<TopNavDTO> | ||
| 20 | + @Link indexSettingArray: Array<string> | ||
| 21 | + @Link topNavList: Array<TopNavDTO> | ||
| 264 | myChannelItemEditHandle = (index: number): void => { | 22 | myChannelItemEditHandle = (index: number): void => { |
| 265 | let item = this.myChannelList.splice(index, 1)[0] | 23 | let item = this.myChannelList.splice(index, 1)[0] |
| 24 | + console.info(`itemitemitem${JSON.stringify(item)}`) | ||
| 266 | if (item.moreChannel === '1') { | 25 | if (item.moreChannel === '1') { |
| 267 | this.moreChannelList.unshift(item) | 26 | this.moreChannelList.unshift(item) |
| 268 | } | 27 | } |
| @@ -271,10 +30,6 @@ struct CustomDialogExample { | @@ -271,10 +30,6 @@ struct CustomDialogExample { | ||
| 271 | } | 30 | } |
| 272 | } | 31 | } |
| 273 | controller?: CustomDialogController | 32 | controller?: CustomDialogController |
| 274 | - cancel: () => void = () => { | ||
| 275 | - } | ||
| 276 | - confirm: () => void = () => { | ||
| 277 | - } | ||
| 278 | 33 | ||
| 279 | build() { | 34 | build() { |
| 280 | Column() { | 35 | Column() { |
| @@ -353,20 +108,27 @@ struct CustomDialogExample { | @@ -353,20 +108,27 @@ struct CustomDialogExample { | ||
| 353 | Row() { | 108 | Row() { |
| 354 | Text(item.name) | 109 | Text(item.name) |
| 355 | .fontSize(14) | 110 | .fontSize(14) |
| 356 | - .fontColor(item.homeChannel === '1' ? '#999999': '#222222') | 111 | + .fontColor( this.currentTopNavSelectedIndex === index ? '#ED2800' : (item.homeChannel === '1' ? '#999999' : '#222222')) |
| 357 | 112 | ||
| 358 | if (this.isEditIng && item.myChannel !== '1') { | 113 | if (this.isEditIng && item.myChannel !== '1') { |
| 359 | Image($r('app.media.icon_audio_close')) | 114 | Image($r('app.media.icon_audio_close')) |
| 360 | .width(12) | 115 | .width(12) |
| 361 | .margin({ left: 1 }) | 116 | .margin({ left: 1 }) |
| 362 | - .onClick(() => { | ||
| 363 | - this.myChannelItemEditHandle(index) | ||
| 364 | - }) | ||
| 365 | } | 117 | } |
| 366 | } | 118 | } |
| 367 | - .width('100%').height('100%') | 119 | + .width('100%') |
| 120 | + .height('100%') | ||
| 368 | .justifyContent(FlexAlign.Center) | 121 | .justifyContent(FlexAlign.Center) |
| 369 | - .backgroundColor(item.homeChannel === '1' ? '#F5F5F5': '') | 122 | + .backgroundColor(item.homeChannel === '1' ? '#F5F5F5' : '') |
| 123 | + .onClick(() => { | ||
| 124 | + if (this.isEditIng) { | ||
| 125 | + if(item.myChannel !== '1'){ | ||
| 126 | + this.myChannelItemEditHandle(index) | ||
| 127 | + } | ||
| 128 | + }else{ | ||
| 129 | + this.controller?.close() | ||
| 130 | + } | ||
| 131 | + }) | ||
| 370 | } | 132 | } |
| 371 | .width(80) | 133 | .width(80) |
| 372 | .height(40) | 134 | .height(40) |
| @@ -396,18 +158,18 @@ struct CustomDialogExample { | @@ -396,18 +158,18 @@ struct CustomDialogExample { | ||
| 396 | ForEach(this.moreChannelList, (item: TopNavDTO, index: number) => { | 158 | ForEach(this.moreChannelList, (item: TopNavDTO, index: number) => { |
| 397 | GridCol() { | 159 | GridCol() { |
| 398 | Row() { | 160 | Row() { |
| 399 | - Image($r('app.media.add_icon')) | ||
| 400 | - .width(12) | ||
| 401 | - .margin({ right: 1 }) | ||
| 402 | - .onClick(() => { | ||
| 403 | - this.myChannelList.push(this.moreChannelList.splice(index, 1)[0]) | ||
| 404 | - }) | ||
| 405 | Text(item.name) | 161 | Text(item.name) |
| 406 | .fontSize(14) | 162 | .fontSize(14) |
| 163 | + | ||
| 164 | + Image($r('app.media.add_icon')) | ||
| 165 | + .width(12) | ||
| 166 | + .margin({ left: 1 }) | ||
| 407 | } | 167 | } |
| 408 | .width('100%').height('100%') | 168 | .width('100%').height('100%') |
| 409 | .justifyContent(FlexAlign.Center) | 169 | .justifyContent(FlexAlign.Center) |
| 410 | - | 170 | + .onClick(() => { |
| 171 | + this.myChannelList.push(this.moreChannelList.splice(index, 1)[0]) | ||
| 172 | + }) | ||
| 411 | } | 173 | } |
| 412 | .width(80) | 174 | .width(80) |
| 413 | .height(40) | 175 | .height(40) |
| @@ -445,13 +207,12 @@ struct CustomDialogExample { | @@ -445,13 +207,12 @@ struct CustomDialogExample { | ||
| 445 | Image($r('app.media.add_icon')) | 207 | Image($r('app.media.add_icon')) |
| 446 | .width(12) | 208 | .width(12) |
| 447 | .margin({ left: 1 }) | 209 | .margin({ left: 1 }) |
| 448 | - .onClick(() => { | ||
| 449 | - this.myChannelList.push(this.localChannelList.splice(index, 1)[0]) | ||
| 450 | - }) | ||
| 451 | } | 210 | } |
| 452 | .width('100%').height('100%') | 211 | .width('100%').height('100%') |
| 453 | .justifyContent(FlexAlign.Center) | 212 | .justifyContent(FlexAlign.Center) |
| 454 | - | 213 | + .onClick(() => { |
| 214 | + this.myChannelList.push(this.localChannelList.splice(index, 1)[0]) | ||
| 215 | + }) | ||
| 455 | } | 216 | } |
| 456 | .width(80) | 217 | .width(80) |
| 457 | .height(40) | 218 | .height(40) |
| @@ -473,28 +234,292 @@ struct CustomDialogExample { | @@ -473,28 +234,292 @@ struct CustomDialogExample { | ||
| 473 | .padding(16) | 234 | .padding(16) |
| 474 | .backgroundColor('#ffffff') | 235 | .backgroundColor('#ffffff') |
| 475 | } | 236 | } |
| 237 | + | ||
| 238 | + onTopNavigationDataUpdated() { | ||
| 239 | + } | ||
| 476 | } | 240 | } |
| 477 | 241 | ||
| 478 | @Entry | 242 | @Entry |
| 479 | @Component | 243 | @Component |
| 480 | struct ChannelSubscriptionLayout { | 244 | struct ChannelSubscriptionLayout { |
| 481 | - @State textValue: string = '' | ||
| 482 | - @State inputValue: string = 'click me' | 245 | + //当前选中的频道 |
| 246 | + @Prop currentTopNavSelectedIndex?: number; | ||
| 247 | + | ||
| 248 | + @State indexSettingArray: Array<string> = ['推荐', '热点'] | ||
| 249 | + @State myChannelList: Array<TopNavDTO> = [ | ||
| 250 | + // { | ||
| 251 | + // channelId: 0, | ||
| 252 | + // channelStyle: 1, | ||
| 253 | + // channelType: 1, | ||
| 254 | + // defaultPermitted: 1, | ||
| 255 | + // delPermitted: 1, | ||
| 256 | + // fontCColor: '#000000', | ||
| 257 | + // fontColor: '#000000', | ||
| 258 | + // headlinesOn: 0, | ||
| 259 | + // homeChannel: '1', | ||
| 260 | + // iconCUrl: '', | ||
| 261 | + // iconCUrlSize: '', | ||
| 262 | + // iconUrl: '', | ||
| 263 | + // iconUrlSize: '', | ||
| 264 | + // localChannel: '', | ||
| 265 | + // moreChannel: '', | ||
| 266 | + // movePermitted: 0, | ||
| 267 | + // myChannel: '1', | ||
| 268 | + // name: '推荐', | ||
| 269 | + // num: 0, | ||
| 270 | + // pageId: 21212, | ||
| 271 | + // pageType: '', | ||
| 272 | + // underlineCColor: '' | ||
| 273 | + // }, | ||
| 274 | + // { | ||
| 275 | + // channelId: 1, | ||
| 276 | + // channelStyle: 1, | ||
| 277 | + // channelType: 1, | ||
| 278 | + // defaultPermitted: 1, | ||
| 279 | + // delPermitted: 1, | ||
| 280 | + // fontCColor: '#000000', | ||
| 281 | + // fontColor: '#000000', | ||
| 282 | + // headlinesOn: 0, | ||
| 283 | + // homeChannel: '1', | ||
| 284 | + // iconCUrl: '', | ||
| 285 | + // iconCUrlSize: '', | ||
| 286 | + // iconUrl: '', | ||
| 287 | + // iconUrlSize: '', | ||
| 288 | + // localChannel: '', | ||
| 289 | + // moreChannel: '', | ||
| 290 | + // movePermitted: 0, | ||
| 291 | + // myChannel: '1', | ||
| 292 | + // name: '热点', | ||
| 293 | + // num: 0, | ||
| 294 | + // pageId: 21212, | ||
| 295 | + // pageType: '', | ||
| 296 | + // underlineCColor: '' | ||
| 297 | + // }, | ||
| 298 | + // { | ||
| 299 | + // channelId: 2, | ||
| 300 | + // channelStyle: 1, | ||
| 301 | + // channelType: 1, | ||
| 302 | + // defaultPermitted: 1, | ||
| 303 | + // delPermitted: 1, | ||
| 304 | + // fontCColor: '#000000', | ||
| 305 | + // fontColor: '#000000', | ||
| 306 | + // headlinesOn: 0, | ||
| 307 | + // homeChannel: '', | ||
| 308 | + // iconCUrl: '', | ||
| 309 | + // iconCUrlSize: '', | ||
| 310 | + // iconUrl: '', | ||
| 311 | + // iconUrlSize: '', | ||
| 312 | + // localChannel: '', | ||
| 313 | + // moreChannel: '', | ||
| 314 | + // movePermitted: 0, | ||
| 315 | + // myChannel: '1', | ||
| 316 | + // name: '视频', | ||
| 317 | + // num: 0, | ||
| 318 | + // pageId: 21212, | ||
| 319 | + // pageType: '', | ||
| 320 | + // underlineCColor: '' | ||
| 321 | + // }, | ||
| 322 | + // { | ||
| 323 | + // channelId: 3, | ||
| 324 | + // channelStyle: 1, | ||
| 325 | + // channelType: 1, | ||
| 326 | + // defaultPermitted: 1, | ||
| 327 | + // delPermitted: 1, | ||
| 328 | + // fontCColor: '#000000', | ||
| 329 | + // fontColor: '#000000', | ||
| 330 | + // headlinesOn: 0, | ||
| 331 | + // homeChannel: '', | ||
| 332 | + // iconCUrl: '', | ||
| 333 | + // iconCUrlSize: '', | ||
| 334 | + // iconUrl: '', | ||
| 335 | + // iconUrlSize: '', | ||
| 336 | + // localChannel: '', | ||
| 337 | + // moreChannel: '', | ||
| 338 | + // movePermitted: 0, | ||
| 339 | + // myChannel: '1', | ||
| 340 | + // name: '云课堂', | ||
| 341 | + // num: 0, | ||
| 342 | + // pageId: 21212, | ||
| 343 | + // pageType: '', | ||
| 344 | + // underlineCColor: '' | ||
| 345 | + // }, | ||
| 346 | + ] | ||
| 347 | + @State moreChannelList: Array<TopNavDTO> = [ | ||
| 348 | + // { | ||
| 349 | + // channelId: 4, | ||
| 350 | + // channelStyle: 1, | ||
| 351 | + // channelType: 1, | ||
| 352 | + // defaultPermitted: 1, | ||
| 353 | + // delPermitted: 1, | ||
| 354 | + // fontCColor: '#000000', | ||
| 355 | + // fontColor: '#000000', | ||
| 356 | + // headlinesOn: 0, | ||
| 357 | + // homeChannel: '', | ||
| 358 | + // iconCUrl: '', | ||
| 359 | + // iconCUrlSize: '', | ||
| 360 | + // iconUrl: '', | ||
| 361 | + // iconUrlSize: '', | ||
| 362 | + // localChannel: '', | ||
| 363 | + // moreChannel: '1', | ||
| 364 | + // movePermitted: 0, | ||
| 365 | + // myChannel: '', | ||
| 366 | + // name: '房产', | ||
| 367 | + // num: 0, | ||
| 368 | + // pageId: 21212, | ||
| 369 | + // pageType: '', | ||
| 370 | + // underlineCColor: '' | ||
| 371 | + // }, | ||
| 372 | + // { | ||
| 373 | + // channelId: 5, | ||
| 374 | + // channelStyle: 1, | ||
| 375 | + // channelType: 1, | ||
| 376 | + // defaultPermitted: 1, | ||
| 377 | + // delPermitted: 1, | ||
| 378 | + // fontCColor: '#000000', | ||
| 379 | + // fontColor: '#000000', | ||
| 380 | + // headlinesOn: 0, | ||
| 381 | + // homeChannel: '', | ||
| 382 | + // iconCUrl: '', | ||
| 383 | + // iconCUrlSize: '', | ||
| 384 | + // iconUrl: '', | ||
| 385 | + // iconUrlSize: '', | ||
| 386 | + // localChannel: '', | ||
| 387 | + // moreChannel: '1', | ||
| 388 | + // movePermitted: 0, | ||
| 389 | + // myChannel: '', | ||
| 390 | + // name: '生态', | ||
| 391 | + // num: 0, | ||
| 392 | + // pageId: 21212, | ||
| 393 | + // pageType: '', | ||
| 394 | + // underlineCColor: '' | ||
| 395 | + // }, | ||
| 396 | + // { | ||
| 397 | + // channelId: 6, | ||
| 398 | + // channelStyle: 1, | ||
| 399 | + // channelType: 1, | ||
| 400 | + // defaultPermitted: 1, | ||
| 401 | + // delPermitted: 1, | ||
| 402 | + // fontCColor: '#000000', | ||
| 403 | + // fontColor: '#000000', | ||
| 404 | + // headlinesOn: 0, | ||
| 405 | + // homeChannel: '', | ||
| 406 | + // iconCUrl: '', | ||
| 407 | + // iconCUrlSize: '', | ||
| 408 | + // iconUrl: '', | ||
| 409 | + // iconUrlSize: '', | ||
| 410 | + // localChannel: '', | ||
| 411 | + // moreChannel: '1', | ||
| 412 | + // movePermitted: 0, | ||
| 413 | + // myChannel: '', | ||
| 414 | + // name: '健康', | ||
| 415 | + // num: 0, | ||
| 416 | + // pageId: 21212, | ||
| 417 | + // pageType: '', | ||
| 418 | + // underlineCColor: '' | ||
| 419 | + // } | ||
| 420 | + ] | ||
| 421 | + @State localChannelList: Array<TopNavDTO> = [ | ||
| 422 | + // { | ||
| 423 | + // channelId: 7, | ||
| 424 | + // channelStyle: 1, | ||
| 425 | + // channelType: 1, | ||
| 426 | + // defaultPermitted: 1, | ||
| 427 | + // delPermitted: 1, | ||
| 428 | + // fontCColor: '#000000', | ||
| 429 | + // fontColor: '#000000', | ||
| 430 | + // headlinesOn: 0, | ||
| 431 | + // homeChannel: '', | ||
| 432 | + // iconCUrl: '', | ||
| 433 | + // iconCUrlSize: '', | ||
| 434 | + // iconUrl: '', | ||
| 435 | + // iconUrlSize: '', | ||
| 436 | + // localChannel: '1', | ||
| 437 | + // moreChannel: '', | ||
| 438 | + // movePermitted: 0, | ||
| 439 | + // myChannel: '', | ||
| 440 | + // name: '北京', | ||
| 441 | + // num: 0, | ||
| 442 | + // pageId: 21212, | ||
| 443 | + // pageType: '', | ||
| 444 | + // underlineCColor: '' | ||
| 445 | + // }, | ||
| 446 | + // { | ||
| 447 | + // channelId: 8, | ||
| 448 | + // channelStyle: 1, | ||
| 449 | + // channelType: 1, | ||
| 450 | + // defaultPermitted: 1, | ||
| 451 | + // delPermitted: 1, | ||
| 452 | + // fontCColor: '#000000', | ||
| 453 | + // fontColor: '#000000', | ||
| 454 | + // headlinesOn: 0, | ||
| 455 | + // homeChannel: '', | ||
| 456 | + // iconCUrl: '', | ||
| 457 | + // iconCUrlSize: '', | ||
| 458 | + // iconUrl: '', | ||
| 459 | + // iconUrlSize: '', | ||
| 460 | + // localChannel: '1', | ||
| 461 | + // moreChannel: '', | ||
| 462 | + // movePermitted: 0, | ||
| 463 | + // myChannel: '', | ||
| 464 | + // name: '上海', | ||
| 465 | + // num: 0, | ||
| 466 | + // pageId: 21212, | ||
| 467 | + // pageType: '', | ||
| 468 | + // underlineCColor: '' | ||
| 469 | + // }, | ||
| 470 | + // { | ||
| 471 | + // channelId: 9, | ||
| 472 | + // channelStyle: 1, | ||
| 473 | + // channelType: 1, | ||
| 474 | + // defaultPermitted: 1, | ||
| 475 | + // delPermitted: 1, | ||
| 476 | + // fontCColor: '#000000', | ||
| 477 | + // fontColor: '#000000', | ||
| 478 | + // headlinesOn: 0, | ||
| 479 | + // homeChannel: '', | ||
| 480 | + // iconCUrl: '', | ||
| 481 | + // iconCUrlSize: '', | ||
| 482 | + // iconUrl: '', | ||
| 483 | + // iconUrlSize: '', | ||
| 484 | + // localChannel: '1', | ||
| 485 | + // moreChannel: '', | ||
| 486 | + // movePermitted: 0, | ||
| 487 | + // myChannel: '', | ||
| 488 | + // name: '江苏', | ||
| 489 | + // num: 0, | ||
| 490 | + // pageId: 21212, | ||
| 491 | + // pageType: '', | ||
| 492 | + // underlineCColor: '' | ||
| 493 | + // } | ||
| 494 | + ] | ||
| 495 | + // 顶导数据 | ||
| 496 | + @State topNavList: TopNavDTO[] = [] | ||
| 483 | dialogController: CustomDialogController | null = new CustomDialogController({ | 497 | dialogController: CustomDialogController | null = new CustomDialogController({ |
| 484 | - builder: CustomDialogExample({ | ||
| 485 | - cancel: () => { | ||
| 486 | - this.onCancel() | ||
| 487 | - }, | ||
| 488 | - confirm: () => { | ||
| 489 | - this.onAccept() | ||
| 490 | - }, | 498 | + builder: ChannelDialog({ |
| 499 | + currentTopNavSelectedIndex:this.currentTopNavSelectedIndex, | ||
| 500 | + indexSettingArray: this.indexSettingArray, | ||
| 501 | + topNavList: this.topNavList, | ||
| 502 | + myChannelList: this.myChannelList, | ||
| 503 | + moreChannelList: this.moreChannelList, | ||
| 504 | + localChannelList: this.localChannelList, | ||
| 491 | }), | 505 | }), |
| 492 | cancel: this.exitApp, | 506 | cancel: this.exitApp, |
| 493 | - autoCancel: true, | ||
| 494 | alignment: DialogAlignment.TopEnd, | 507 | alignment: DialogAlignment.TopEnd, |
| 495 | customStyle: true, | 508 | customStyle: true, |
| 496 | }) | 509 | }) |
| 497 | - | 510 | + aboutToAppear() { |
| 511 | + this.topNavList.forEach((item,index)=>{ | ||
| 512 | + if(item.myChannel === '1'){ | ||
| 513 | + this.myChannelList.push(item) | ||
| 514 | + } | ||
| 515 | + if(item.moreChannel === '1'){ | ||
| 516 | + this.moreChannelList.push(item) | ||
| 517 | + } | ||
| 518 | + if(item.localChannel === '1'){ | ||
| 519 | + this.localChannelList.push(item) | ||
| 520 | + } | ||
| 521 | + }) | ||
| 522 | + } | ||
| 498 | aboutToDisappear() { | 523 | aboutToDisappear() { |
| 499 | this.dialogController = null // 将dialogController置空 | 524 | this.dialogController = null // 将dialogController置空 |
| 500 | } | 525 | } |
| @@ -514,12 +539,17 @@ struct ChannelSubscriptionLayout { | @@ -514,12 +539,17 @@ struct ChannelSubscriptionLayout { | ||
| 514 | build() { | 539 | build() { |
| 515 | Row() { | 540 | Row() { |
| 516 | Image($r('app.media.channel_button')) | 541 | Image($r('app.media.channel_button')) |
| 517 | - .onClick(() => { | ||
| 518 | - if (this.dialogController != null) { | ||
| 519 | - this.dialogController.open() | ||
| 520 | - } | ||
| 521 | - }).width($r('app.float.top_tab_bar_height')) | ||
| 522 | - }.backgroundColor('#ffffff') | 542 | + .width(18) |
| 543 | + } | ||
| 544 | + .width(36) | ||
| 545 | + .height(30) | ||
| 546 | + .justifyContent(FlexAlign.Center) | ||
| 547 | + .backgroundColor('#ffffff') | ||
| 548 | + .onClick(() => { | ||
| 549 | + if (this.dialogController != null) { | ||
| 550 | + this.dialogController.open() | ||
| 551 | + } | ||
| 552 | + }) | ||
| 523 | } | 553 | } |
| 524 | } | 554 | } |
| 525 | 555 |
| @@ -3,6 +3,7 @@ import { LazyDataSource, Logger } from 'wdKit'; | @@ -3,6 +3,7 @@ import { LazyDataSource, Logger } from 'wdKit'; | ||
| 3 | import { WDRouterRule } from 'wdRouter'; | 3 | import { WDRouterRule } from 'wdRouter'; |
| 4 | import { PageComponent } from './PageComponent'; | 4 | import { PageComponent } from './PageComponent'; |
| 5 | import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout' | 5 | import { ChannelSubscriptionLayout } from './ChannelSubscriptionLayout' |
| 6 | + | ||
| 6 | const TAG = 'TopNavigationComponent'; | 7 | const TAG = 'TopNavigationComponent'; |
| 7 | 8 | ||
| 8 | /** | 9 | /** |
| @@ -16,8 +17,48 @@ export struct TopNavigationComponent { | @@ -16,8 +17,48 @@ export struct TopNavigationComponent { | ||
| 16 | // 顶导数据 | 17 | // 顶导数据 |
| 17 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] | 18 | @State @Watch('onTopNavigationDataUpdated') topNavList: TopNavDTO[] = [] |
| 18 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); | 19 | @State compList: LazyDataSource<CompDTO> = new LazyDataSource(); |
| 20 | + @State handledTopNavList: TopNavDTO[] = [] | ||
| 19 | readonly MAX_LINE: number = 1; | 21 | readonly MAX_LINE: number = 1; |
| 20 | 22 | ||
| 23 | + topNavListHandle() { | ||
| 24 | + let defaultMyChannelList: TopNavDTO[] = [] | ||
| 25 | + this.handledTopNavList = [...this.topNavList] | ||
| 26 | + this.handledTopNavList.sort((a, b) => { | ||
| 27 | + return a.num - b.num; | ||
| 28 | + }); | ||
| 29 | + Logger.info(TAG, `aboutToAppear this.handledTopNavListsort : ${JSON.stringify(this.handledTopNavList)}`); | ||
| 30 | + for (let i = 0; i < this.handledTopNavList.length; i++) { | ||
| 31 | + if (this.handledTopNavList[i].defaultPermitted === 0 || this.handledTopNavList[i].movePermitted === 0 || this.handledTopNavList[i].delPermitted === 0 || this.handledTopNavList[i].headlinesOn === 1) { | ||
| 32 | + defaultMyChannelList.push(this.handledTopNavList.splice(i, 1)[0]); | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + Logger.info(TAG, `aboutToAppear defaultMyChannelListsort : ${JSON.stringify(defaultMyChannelList)}`); | ||
| 37 | + | ||
| 38 | + for (const element of defaultMyChannelList) { | ||
| 39 | + element.myChannel = '1' | ||
| 40 | + if (element.defaultPermitted === 1) { | ||
| 41 | + element.homeChannel = '1' | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + this.handledTopNavList.unshift(...defaultMyChannelList) | ||
| 45 | + for (let i = 0; i < this.handledTopNavList.length; i++) { | ||
| 46 | + if(this.handledTopNavList[i].channelType === 2){ | ||
| 47 | + this.handledTopNavList[i].localChannel = '1' | ||
| 48 | + } | ||
| 49 | + if(i>=11){ | ||
| 50 | + if(this.handledTopNavList[i].channelType === 1){ | ||
| 51 | + this.handledTopNavList[i].moreChannel = '1' | ||
| 52 | + } | ||
| 53 | + }else{ | ||
| 54 | + if(this.handledTopNavList[i].channelType === 1 && this.handledTopNavList[i].myChannel !== '1'){ | ||
| 55 | + this.handledTopNavList[i].moreChannel = '1' | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + console.info(`handledTopNavList:${JSON.stringify(this.handledTopNavList)}`) | ||
| 60 | + } | ||
| 61 | + | ||
| 21 | build() { | 62 | build() { |
| 22 | Column() { | 63 | Column() { |
| 23 | RelativeContainer() { | 64 | RelativeContainer() { |
| @@ -44,8 +85,10 @@ export struct TopNavigationComponent { | @@ -44,8 +85,10 @@ export struct TopNavigationComponent { | ||
| 44 | .height(30) | 85 | .height(30) |
| 45 | .width(123) | 86 | .width(123) |
| 46 | .id('search') | 87 | .id('search') |
| 47 | - .alignRules({ left: { anchor: "__container__", align: HorizontalAlign.Start }, | ||
| 48 | - center: { anchor: "__container__", align: VerticalAlign.Center } }) | 88 | + .alignRules({ |
| 89 | + left: { anchor: "__container__", align: HorizontalAlign.Start }, | ||
| 90 | + center: { anchor: "__container__", align: VerticalAlign.Center } | ||
| 91 | + }) | ||
| 49 | 92 | ||
| 50 | Image($r('app.media.icon_ren_min_ri_bao')) | 93 | Image($r('app.media.icon_ren_min_ri_bao')) |
| 51 | .width(72) | 94 | .width(72) |
| @@ -60,8 +103,10 @@ export struct TopNavigationComponent { | @@ -60,8 +103,10 @@ export struct TopNavigationComponent { | ||
| 60 | WDRouterRule.jumpWithAction(taskAction) | 103 | WDRouterRule.jumpWithAction(taskAction) |
| 61 | }) | 104 | }) |
| 62 | .id('ren_min') | 105 | .id('ren_min') |
| 63 | - .alignRules({ middle: { anchor: "__container__", align: HorizontalAlign.Center }, | ||
| 64 | - center: { anchor: "__container__", align: VerticalAlign.Center } }) | 106 | + .alignRules({ |
| 107 | + middle: { anchor: "__container__", align: HorizontalAlign.Center }, | ||
| 108 | + center: { anchor: "__container__", align: VerticalAlign.Center } | ||
| 109 | + }) | ||
| 65 | 110 | ||
| 66 | Stack({ alignContent: Alignment.Center }) { | 111 | Stack({ alignContent: Alignment.Center }) { |
| 67 | Image($r('app.media.background_read_paper_home')) | 112 | Image($r('app.media.background_read_paper_home')) |
| @@ -83,8 +128,10 @@ export struct TopNavigationComponent { | @@ -83,8 +128,10 @@ export struct TopNavigationComponent { | ||
| 83 | .height(30) | 128 | .height(30) |
| 84 | .width(124) | 129 | .width(124) |
| 85 | .id('read') | 130 | .id('read') |
| 86 | - .alignRules({ right: { anchor: "__container__", align: HorizontalAlign.End }, | ||
| 87 | - center: { anchor: "__container__", align: VerticalAlign.Center } }) | 131 | + .alignRules({ |
| 132 | + right: { anchor: "__container__", align: HorizontalAlign.End }, | ||
| 133 | + center: { anchor: "__container__", align: VerticalAlign.Center } | ||
| 134 | + }) | ||
| 88 | .onClick((event: ClickEvent) => { | 135 | .onClick((event: ClickEvent) => { |
| 89 | 136 | ||
| 90 | let taskAction: Action = { | 137 | let taskAction: Action = { |
| @@ -99,10 +146,11 @@ export struct TopNavigationComponent { | @@ -99,10 +146,11 @@ export struct TopNavigationComponent { | ||
| 99 | .width('100%') | 146 | .width('100%') |
| 100 | .height(40) | 147 | .height(40) |
| 101 | .visibility(this._currentNavIndex == 0 ? Visibility.Visible : Visibility.None) | 148 | .visibility(this._currentNavIndex == 0 ? Visibility.Visible : Visibility.None) |
| 102 | - Stack({alignContent:Alignment.TopEnd}){ | 149 | + |
| 150 | + Stack({ alignContent: Alignment.TopEnd }) { | ||
| 103 | 151 | ||
| 104 | Tabs() { | 152 | Tabs() { |
| 105 | - ForEach(this.topNavList, (navItem: TopNavDTO, index: number) => { | 153 | + ForEach(this.handledTopNavList, (navItem: TopNavDTO, index: number) => { |
| 106 | TabContent() { | 154 | TabContent() { |
| 107 | PageComponent({ | 155 | PageComponent({ |
| 108 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, | 156 | currentTopNavSelectedIndex: $currentTopNavSelectedIndex, |
| @@ -121,8 +169,11 @@ export struct TopNavigationComponent { | @@ -121,8 +169,11 @@ export struct TopNavigationComponent { | ||
| 121 | Logger.info(TAG, `onChange index : ${index}`); | 169 | Logger.info(TAG, `onChange index : ${index}`); |
| 122 | this.currentTopNavSelectedIndex = index; | 170 | this.currentTopNavSelectedIndex = index; |
| 123 | }) | 171 | }) |
| 124 | - | ||
| 125 | - ChannelSubscriptionLayout() | 172 | + |
| 173 | + ChannelSubscriptionLayout({ | ||
| 174 | + topNavList: this.handledTopNavList, | ||
| 175 | + currentTopNavSelectedIndex: this.currentTopNavSelectedIndex | ||
| 176 | + }) | ||
| 126 | } | 177 | } |
| 127 | 178 | ||
| 128 | } | 179 | } |
| @@ -149,6 +200,7 @@ export struct TopNavigationComponent { | @@ -149,6 +200,7 @@ export struct TopNavigationComponent { | ||
| 149 | minWidth: $r('app.float.top_tab_item_min_width'), | 200 | minWidth: $r('app.float.top_tab_item_min_width'), |
| 150 | maxWidth: $r('app.float.top_tab_item_max_width') | 201 | maxWidth: $r('app.float.top_tab_item_max_width') |
| 151 | }) | 202 | }) |
| 203 | + // .margin({ right: 36 }) | ||
| 152 | // .backgroundColor(Color.Black) | 204 | // .backgroundColor(Color.Black) |
| 153 | .padding({ | 205 | .padding({ |
| 154 | left: $r('app.float.top_tab_item_padding_horizontal'), | 206 | left: $r('app.float.top_tab_item_padding_horizontal'), |
| @@ -156,9 +208,11 @@ export struct TopNavigationComponent { | @@ -156,9 +208,11 @@ export struct TopNavigationComponent { | ||
| 156 | bottom: $r('app.float.top_tab_item_padding_bottom') | 208 | bottom: $r('app.float.top_tab_item_padding_bottom') |
| 157 | }) | 209 | }) |
| 158 | .id(`col_tabBar${index}`) | 210 | .id(`col_tabBar${index}`) |
| 211 | + | ||
| 159 | } | 212 | } |
| 160 | 213 | ||
| 161 | aboutToAppear() { | 214 | aboutToAppear() { |
| 215 | + this.topNavListHandle() | ||
| 162 | Logger.info(TAG, `aboutToAppear this.topNavList : ${JSON.stringify(this.topNavList)}`); | 216 | Logger.info(TAG, `aboutToAppear this.topNavList : ${JSON.stringify(this.topNavList)}`); |
| 163 | } | 217 | } |
| 164 | 218 |
-
Please register or login to post a comment