yuzhilin

fix:频道订阅逻辑优化

... ... @@ -7,7 +7,7 @@ export class CallBackMessage {
callbackId: string = ""; //callbackId
responseId: string = ""; //responseId
responseData: string = ""; //responseData
data?: string; //data of message
data?: object; //data of message
handlerName: string = ""; //name of handler
/**
... ...
... ... @@ -128,11 +128,11 @@ export class BridgeWebViewControl extends webview.WebviewController {
* native 主动调用JSBridge方法
* @param msg
*/
callHandle(handlerName: string, data: string, callBack: Callback) {
callHandle(handlerName: string, data: object, callBack: Callback) {
this.doSend(handlerName, data, callBack)
}
private doSend(handlerName: string, data: string, callBack: Callback) {
private doSend(handlerName: string, data: object, callBack: Callback) {
let msg: CallBackMessage = new CallBackMessage()
if (StringUtils.isNotEmpty(data)) {
msg.data = data
... ...
... ... @@ -119,7 +119,7 @@ export struct ImageAndTextWebComponent {
private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) {
Logger.debug('ImageAndTextWebComponent', 'jsCall_receiveAppData');
this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,
JSON.stringify(h5ReceiveAppData), (data: string) => {
h5ReceiveAppData, (data: string) => {
Logger.debug('ImageAndTextWebComponent', "from js data = " + data);
})
}
... ...
... ... @@ -39,7 +39,7 @@ export struct SpacialTopicPageComponent {
private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) {
this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,
JSON.stringify(h5ReceiveAppData), (data: string) => {
h5ReceiveAppData, (data: string) => {
})
}
... ... @@ -91,15 +91,16 @@ export struct SpacialTopicPageComponent {
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.padding({ bottom: 126 })
// .padding({ bottom: 76 })
if (!this.isPageEnd) {
detailedSkeleton()
}
//底部交互区
OperRowListView({ contentDetailData: this.contentDetailData[0],
publishCommentModel: this.publishCommentModel
})
OperRowListView({
contentDetailData: this.contentDetailData[0],
publishCommentModel: this.publishCommentModel
})
}
}.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
}
... ...
... ... @@ -250,10 +250,10 @@ struct ChannelDialog {
.fontSize(16)
.fontWeight(600)
.margin({ right: 4 })
Text(!this.isEditIng ? MY_CHANNEL_TIP1 : MY_CHANNEL_TIP2)
.fontSize(12)
.fontWeight(400)
.fontColor('#222222')
// Text(!this.isEditIng ? MY_CHANNEL_TIP1 : MY_CHANNEL_TIP2)
// .fontSize(12)
// .fontWeight(400)
// .fontColor('#222222')
}
Text(this.isEditIng ? EDIT_DOWN : EDIT_TEXT)
... ... @@ -276,9 +276,9 @@ struct ChannelDialog {
Row() {
Text(item.name)
.fontSize(14)
.fontColor(this.currentTopNavSelectedItem.channelId === item.channelId ? '#ED2800' : (item.homeChannel === '1' || item.movePermitted === 0 ? '#999999' : '#222222'))
.fontColor(this.currentTopNavSelectedItem.channelId === item.channelId ? '#ED2800' : (item.headlinesOn === 1 || item.movePermitted === 0 ? '#999999' : '#222222'))
if (this.isEditIng && item.delPermitted === 1) {
if (this.isEditIng && item.delPermitted === 1 && item.movePermitted === 1) {
Image($r('app.media.icon_audio_close'))
.width(12)
.margin({ left: 1 })
... ... @@ -287,12 +287,12 @@ struct ChannelDialog {
.width('100%')
.height('100%')
.justifyContent(FlexAlign.Center)
.backgroundColor(item.homeChannel === '1' || item.movePermitted === 0 ? '#F5F5F5' : '#ffffff')
.backgroundColor(item.headlinesOn === 1 || item.movePermitted === 0 ? '#F5F5F5' : '#ffffff')
}
.width('23%')
.height(40)
.border({
width: item.homeChannel === '1' ? 0 : 1,
width: item.headlinesOn === 1 || item.movePermitted === 0 ? 0 : 1,
color: '#EDEDED',
radius: 3
})
... ... @@ -303,7 +303,7 @@ struct ChannelDialog {
TapGesture()
.onAction((event?: GestureEvent) => {
if (this.isEditIng) {
if (item.delPermitted === 1) {
if (item.delPermitted === 1 && item.movePermitted === 1) {
this.delChannelItem(index)
}
} else {
... ...
... ... @@ -59,7 +59,6 @@ export struct TopNavigationComponent {
@State autoRefresh2Page: number = 0
// 当前底导index
@State navIndex: number = 0
@State animationDuration: number = 0
@State indicatorLeftMargin: number = 0
@State indicatorWidth: number = 0
... ... @@ -93,7 +92,8 @@ export struct TopNavigationComponent {
//defaultMyChannelList
defaultList.forEach(item => {
if (item.defaultPermitted === 1 || item.movePermitted === 0 || item.delPermitted === 0 || item.headlinesOn === 1) {
if (item.defaultPermitted === 1 || item.movePermitted === 0 || item.delPermitted === 0 ||
item.headlinesOn === 1) {
defaultMyChannelList.push(item);
}
if (item.defaultPermitted === 1) {
... ... @@ -136,13 +136,15 @@ export struct TopNavigationComponent {
}
//频道分类
if (item.myChannel === '1' && item.name !== '播报') {
_myChannelList.push(item)
_channelIds.push(item.channelId)
} else if (item.moreChannel === '1') {
this.moreChannelList.push(item)
} else if (item.localChannel === '1') {
this.localChannelList.push(item)
if (item.name !== '播报') { //暂时隐藏播报
if (item.myChannel === '1') {
_myChannelList.push(item)
_channelIds.push(item.channelId)
} else if (item.moreChannel === '1') {
this.moreChannelList.push(item)
} else if (item.localChannel === '1') {
this.localChannelList.push(item)
}
}
})
... ... @@ -169,7 +171,6 @@ export struct TopNavigationComponent {
return item.name === '版面'
}
build() {
Column() {
// 顶部搜索、日报logo、早晚报
... ... @@ -216,51 +217,51 @@ export struct TopNavigationComponent {
// 频道分类list
Stack({ alignContent: Alignment.TopEnd }) {
Tabs({ index: this.currentTopNavSelectedIndex, controller: this.tabsController }) {
ForEach(this.currentBottomNavName === '新闻' ? this.myChannelList : this.topNavList, (navItem: TopNavDTO, index: number) => {
TabContent() {
if (this.currentBottomNavName === '视频' && navItem.name === '视频') {
VideoChannelDetail({
bottomNavIndex: $_currentNavIndex,
topNavIndex: $currentTopNavSelectedIndex,
groupId: this.groupId + '',
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
})
}
else if (this.currentBottomNavName === '人民号' && navItem.name === '关注') {
PeopleShipMainComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
navIndex: index,
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
})
}
else
if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) {
PageComponent({
ForEach(this.currentBottomNavName === '新闻' ? this.myChannelList : this.topNavList,
(navItem: TopNavDTO, index: number) => {
TabContent() {
if (this.currentBottomNavName === '视频' && navItem.name === '视频') {
VideoChannelDetail({
bottomNavIndex: $_currentNavIndex,
topNavIndex: $currentTopNavSelectedIndex,
groupId: this.groupId + '',
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
})
} else if (this.currentBottomNavName === '人民号' && navItem.name === '关注') {
PeopleShipMainComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
navIndex: index,
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
autoRefresh: this.autoRefresh2Page
})
}
}
.tabBar(this.tabBarBuilder(navItem, index))
} else
if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) {
PageComponent({
currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
navIndex: index,
pageId: navItem.pageId + '',
channelId: navItem.channelId + '',
autoRefresh: this.autoRefresh2Page
})
}
}
.tabBar(this.tabBarBuilder(navItem, index))
}, (navItem: TopNavDTO) => JSON.stringify(navItem));
}, (navItem: TopNavDTO) => JSON.stringify(navItem));
}
.barHeight($r('app.float.top_tab_bar_height'))
.barMode(BarMode.Scrollable)
.vertical(false)
.barBackgroundColor(this.barBackgroundColor)
.onAreaChange((oldValue: Area,newValue: Area)=> {
.onAreaChange((oldValue: Area, newValue: Area) => {
let width = Number.parseFloat(newValue.width.toString())
this.tabsWidth = Number.isNaN(width) ? 0 : width
})
.animationDuration(this.animationDuration)
.onChange((index: number) => {
this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name
this.currentTopNavName =
this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name
Logger.info(TAG, `onChange index : ${index}`);
if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
!this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
... ... @@ -288,27 +289,27 @@ export struct TopNavigationComponent {
let targetIndexInfo = this.getTextInfo(targetIndex)
this.startAnimateTo(this.animationDuration, targetIndexInfo.left, targetIndexInfo.width)
})
.onAnimationEnd((index: number,event: TabsAnimationEvent) => {
.onAnimationEnd((index: number, event: TabsAnimationEvent) => {
if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
!this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
) {
return
}
// 切换动画结束时触发该回调。下划线动画停止。
let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event)
this.startAnimateTo(0,currentIndicatorInfo.left,currentIndicatorInfo.width)
// 切换动画结束时触发该回调。下划线动画停止。
let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event)
this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width)
})
.onGestureSwipe((index: number,event: TabsAnimationEvent) => {
.onGestureSwipe((index: number, event: TabsAnimationEvent) => {
if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
!this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
) {
return
}
// 在页面跟手滑动过程中,逐帧触发该回调。
let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event)
this.currentTopNavSelectedIndex = currentIndicatorInfo.index
this.indicatorLeftMargin = currentIndicatorInfo.left
this.indicatorWidth = currentIndicatorInfo.width
// 在页面跟手滑动过程中,逐帧触发该回调。
let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event)
this.currentTopNavSelectedIndex = currentIndicatorInfo.index
this.indicatorLeftMargin = currentIndicatorInfo.left
this.indicatorWidth = currentIndicatorInfo.width
})
// 分类列表最右侧频道设置
... ... @@ -351,8 +352,9 @@ export struct TopNavigationComponent {
.padding({ top: $r('app.float.top_tab_item_padding_top'), bottom: $r('app.float.top_tab_item_padding_bottom') })
.maxLines(this.MAX_LINE)
.id(index.toString())
.onAreaChange((oldValue: Area,newValue: Area) => {
if (this.currentTopNavSelectedIndex === index && (this.indicatorLeftMargin === 0 || this.indicatorWidth === 0)){
.onAreaChange((oldValue: Area, newValue: Area) => {
if (this.currentTopNavSelectedIndex === index &&
(this.indicatorLeftMargin === 0 || this.indicatorWidth === 0)) {
if (newValue.position.x != undefined) {
let positionX = Number.parseFloat(newValue.position.x.toString())
this.indicatorLeftMargin = Number.isNaN(positionX) ? 0 : positionX
... ... @@ -396,7 +398,8 @@ export struct TopNavigationComponent {
}
onTopNavigationDataUpdated() {
Logger.info(TAG, `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`);
Logger.info(TAG,
`onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`);
}
onAutoRefresh() {
... ... @@ -505,7 +508,7 @@ export struct TopNavigationComponent {
let indexInfo = this.getTextInfo(index)
let nextIndexInfo = this.getTextInfo(nextIndex)
let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth)
let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。
let currentIndex = swipeRatio > 0.5 ? nextIndex : index // 页面滑动超过一半,tabBar切换到下一页。
let currentLeft = indexInfo.left + (nextIndexInfo.left - indexInfo.left) * swipeRatio
let currentWidth = indexInfo.width + (nextIndexInfo.width - indexInfo.width) * swipeRatio
return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth }
... ...