Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
wangyujian_wd
2024-03-22 18:52:35 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
38c23792807fa751cf3cd377d26e2c43cb594687
38c23792
1 parent
6c3115d8
feat:
1)电子报-日历选择/图片报刊/文字报刊切换更新数据时,联动交互优化;
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
74 deletions
sight_harmony/features/wdComponent/src/main/ets/components/ENewspaperPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/dialog/ENewspaperListDialog.ets
sight_harmony/features/wdComponent/src/main/ets/components/ENewspaperPageComponent.ets
View file @
38c2379
...
...
@@ -66,6 +66,29 @@ export struct ENewspaperPageComponent {
offset: { dx: 0, dy: 0 }
})
async aboutToAppear() {
//获取宽高尺寸
this.screenWidth = this.displayTool.width
this.picWidth = this.screenWidth - vp2px(52)
this.picHeight = this.picWidth * 566 / 378
//注册字体
font.registerFont({
familyName: 'BebasNeue_Regular',
familySrc: $rawfile('font/BebasNeue_Regular.otf')
})
this.getNewspaperTime()
this.getNewspaperList()
}
aboutToDisappear() {
// if (this.calendarDialogController) {
// this.calendarDialogController = null
// }
// if (this.listDialogController) {
// this.listDialogController = null
// }
}
build() {
RelativeContainer() {
RelativeContainer() {
...
...
@@ -245,26 +268,11 @@ export struct ENewspaperPageComponent {
.id('e_newspaper_container')
}
async aboutToAppear() {
//获取宽高尺寸
this.screenWidth = this.displayTool.width
this.picWidth = this.screenWidth - vp2px(52)
this.picHeight = this.picWidth * 566 / 378
//注册字体
font.registerFont({
familyName: 'BebasNeue_Regular',
familySrc: $rawfile('font/BebasNeue_Regular.otf')
})
this.getNewspaperTime()
this.getNewspaperList()
}
private async getNewspaperTime() {
let newspaperTimes = await NewspaperViewModel.getNewspaperTime(this.calendarDate)
if (newspaperTimes && newspaperTimes.length > 0) {
this.calendarDate = newspaperTimes[0].date
this.currentPageNum = '01'
this.swiperIndex = 0
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/dialog/ENewspaperListDialog.ets
View file @
38c2379
...
...
@@ -12,16 +12,6 @@ export struct ENewspaperListDialog {
@State scrollIndex: number = 0
newspaperListBean: NewspaperListBean = {} as NewspaperListBean
private listScroller: Scroller = new Scroller();
//watch监听报纸页码回调
onCurrentPageNumUpdated(): void {
console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum)
let _scrollIndex = Number.parseInt(this.currentPageNum)
console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "_swiperIndex:", _scrollIndex)
this.scrollIndex = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex
this.listScroller.scrollToIndex(this.scrollIndex)
}
//文字版选择弹框
pageListDialogController: CustomDialogController = new CustomDialogController({
builder: ENewspaperPageDialog({
...
...
@@ -37,6 +27,29 @@ export struct ENewspaperListDialog {
// 那么此处需要将指向自己的controller放在所有controller的后面
listDialogController: CustomDialogController
//watch监听报纸页码回调
onCurrentPageNumUpdated(): void {
console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "currentPageNum:", this.currentPageNum)
let _scrollIndex = Number.parseInt(this.currentPageNum)
console.log("ENewspaperListDialog-onCurrentPageNumUpdated", "_scrollIndex:", _scrollIndex)
this.scrollIndex = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex
this.listScroller.scrollToIndex(this.scrollIndex)
}
aboutToAppear(): void {
console.log("ENewspaperListDialog-aboutToAppear", "currentPageNum:", this.currentPageNum)
let _scrollIndex = Number.parseInt(this.currentPageNum)
console.log("ENewspaperListDialog-aboutToAppear", "_scrollIndex:", _scrollIndex)
this.scrollIndex = _scrollIndex > 0 ? _scrollIndex - 1 : _scrollIndex
// this.listScroller.scrollToIndex(this.scrollIndex)
}
aboutToDisappear() {
// if (this.pageListDialogController) {
// this.pageListDialogController = null
// }
}
build() {
Column() {
Row()
...
...
@@ -80,57 +93,61 @@ export struct ENewspaperListDialog {
.margin({ top: 20, left: 16, right: 16 })
.objectFit(ImageFit.Contain)
List({ scroller: this.listScroller }) {
List({ scroller: this.listScroller
, initialIndex: this.scrollIndex
}) {
ForEach(this.newspaperListBean?.list, (item: NewspaperListItemBean, index: number) => {
ForEach(item.items, (positionItem: NewspaperPositionItemBean, itemIndex: number) => {
ListItem() {
Column() {
if (itemIndex == 0) {
Text(item.pageNum + item.pageName)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_ED2800'))
.fontWeight(600)
.margin({ top: 16, bottom: 16 })
.maxLines(1)
}
if (positionItem.shortTitle) {
Text(positionItem.shortTitle)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.maxLines(2)
ListItem() {
List() {
ForEach(item.items, (positionItem: NewspaperPositionItemBean, itemIndex: number) => {
ListItem() {
Column() {
if (itemIndex == 0) {
Text(item.pageNum + item.pageName)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_ED2800'))
.fontWeight(600)
.margin({ top: 16, bottom: 16 })
.maxLines(1)
}
if (positionItem.shortTitle) {
Text(positionItem.shortTitle)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.maxLines(2)
}
if (positionItem.title) {
Text(positionItem.title)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.margin({ top: 8 })
.maxLines(2)
}
if (positionItem.downTitle) {
Text(positionItem.downTitle)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.margin({ top: 8 })
.maxLines(2)
}
if (positionItem.newsTxt) {
Text(positionItem.newsTxt)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_999999'))
.margin({ top: 15, bottom: 15 })
.maxLines(5)
}
}
.alignItems(HorizontalAlign.Start)
}
if (positionItem.title) {
Text(positionItem.title)
.fontSize($r('app.float.font_size_17'))
.fontColor($r('app.color.color_222222'))
.margin({ top: 8 })
.maxLines(2)
}
if (positionItem.downTitle) {
Text(positionItem.downTitle)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_222222'))
.fontWeight(600)
.margin({ top: 8 })
.maxLines(2)
}
if (positionItem.newsTxt) {
Text(positionItem.newsTxt)
.fontSize($r('app.float.font_size_14'))
.fontColor($r('app.color.color_999999'))
.margin({ top: 15, bottom: 15 })
.maxLines(5)
}
}
.alignItems(HorizontalAlign.Start)
})
}
})
}
})
}
.width('100%')
...
...
@@ -141,7 +158,17 @@ export struct ENewspaperListDialog {
color: '#EDEDED'
})
.onScrollIndex((firstIndex: number) => {
this.updateCurrentPageNum(firstIndex)
console.log('firstIndex', firstIndex)
})
.onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
console.info('first' + firstIndex)
console.info('last' + lastIndex)
console.info('center' + centerIndex)
// this.updateCurrentPageNum(firstIndex)
this.currentPageNum = `${centerIndex < 9 ? '0' + (centerIndex + 1) : centerIndex + 1}`
})
.onScroll((scrollOffset: number, scrollState: ScrollState) => {
console.info(`onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset)
})
}
.width('100%')
...
...
@@ -157,7 +184,7 @@ export struct ENewspaperListDialog {
for (let item of itemBean.items) {
index++
if (index == firstIndex) {
//
this.currentPageNum = itemBean.pageNum
this.currentPageNum = itemBean.pageNum
return
}
}
...
...
Please
register
or
login
to post a comment