|
@@ -31,6 +31,8 @@ import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
|
import { DialogHelper } from '@pura/harmony-dialog';
|
|
import { DialogHelper } from '@pura/harmony-dialog';
|
|
|
import UserUtil from '../common/util/UserUtil';
|
|
import UserUtil from '../common/util/UserUtil';
|
|
|
import json from '@ohos.util.json';
|
|
import json from '@ohos.util.json';
|
|
|
|
|
+import { UserCenter } from './UserCenter';
|
|
|
|
|
+import { ScanFilePage } from './ScanFilePage';
|
|
|
|
|
|
|
|
|
|
|
|
|
const TAG = 'NewIndex'; // 日志标签
|
|
const TAG = 'NewIndex'; // 日志标签
|
|
@@ -59,7 +61,7 @@ struct NewIndex{
|
|
|
/** Y 轴偏移量(预留) */
|
|
/** Y 轴偏移量(预留) */
|
|
|
@State offsetY: number = 0;
|
|
@State offsetY: number = 0;
|
|
|
/** 主内容类型(0:本地音乐,1:网络内容) */
|
|
/** 主内容类型(0:本地音乐,1:网络内容) */
|
|
|
- @State mType:number = 0
|
|
|
|
|
|
|
+ @Provide mType:number = 0
|
|
|
/** 模式类型(如歌手、专辑等) */
|
|
/** 模式类型(如歌手、专辑等) */
|
|
|
@Provide modeType:number = 0
|
|
@Provide modeType:number = 0
|
|
|
/** 是否为零状态(预留) */
|
|
/** 是否为零状态(预留) */
|
|
@@ -223,104 +225,157 @@ struct NewIndex{
|
|
|
emitter.off(888);
|
|
emitter.off(888);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 构建主页面结构,包括顶部横线、主内容区和抽屉菜单
|
|
|
|
|
- */
|
|
|
|
|
|
|
+
|
|
|
build() {
|
|
build() {
|
|
|
- Stack({ alignContent: Alignment.TopStart }) {
|
|
|
|
|
- // 顶部横线
|
|
|
|
|
- Column(){
|
|
|
|
|
- Line()
|
|
|
|
|
- .width('100%')
|
|
|
|
|
- .height(1)
|
|
|
|
|
|
|
+ SideBarContainer(SideBarContainerType.AUTO) {
|
|
|
|
|
+ Column() {
|
|
|
|
|
+ this.getLeftView()
|
|
|
}
|
|
}
|
|
|
- .backgroundColor($r('app.color.title_bar_bg'))
|
|
|
|
|
- .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
|
|
|
|
|
- // 主内容区
|
|
|
|
|
|
|
+ // .backgroundColor(Color.Transparent)
|
|
|
|
|
+
|
|
|
Column() {
|
|
Column() {
|
|
|
Stack(){
|
|
Stack(){
|
|
|
- // 本地音乐内容区
|
|
|
|
|
|
|
+ // 本地音乐内容区
|
|
|
LocalMusic()
|
|
LocalMusic()
|
|
|
.visibility(this.mType===0?Visibility.Visible:Visibility.None)
|
|
.visibility(this.mType===0?Visibility.Visible:Visibility.None)
|
|
|
// 网络内容区
|
|
// 网络内容区
|
|
|
- StreamContent()
|
|
|
|
|
|
|
+ UserCenter()
|
|
|
.visibility(this.mType===1?Visibility.Visible:Visibility.None)
|
|
.visibility(this.mType===1?Visibility.Visible:Visibility.None)
|
|
|
|
|
+ ScanFilePage()
|
|
|
|
|
+ .visibility(this.mType===2?Visibility.Visible:Visibility.None)
|
|
|
|
|
+ SettingPage()
|
|
|
|
|
+ .visibility(this.mType===3?Visibility.Visible:Visibility.None)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+ .showControlButton(false)
|
|
|
|
|
+ .minContentWidth(0)
|
|
|
|
|
+ .sideBarWidth(this.isBigScreen()?300:270)
|
|
|
|
|
+ .autoHide(true)
|
|
|
|
|
+ .showSideBar($$this.isShowDrawer)
|
|
|
|
|
+ .onChange((value: boolean) => {
|
|
|
|
|
+ this.isShowDrawer= value
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ isBigScreen(){
|
|
|
|
|
+ if(this.currentWidthBreakpoint == WidthBreakpoint.WIDTH_LG){
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+ if (DeviceUtil.getDeviceType() === resourceManager.DeviceType.DEVICE_TYPE_PHONE
|
|
|
|
|
+ && this.currentWidthBreakpoint === WidthBreakpoint.WIDTH_SM
|
|
|
|
|
+ &&this.currentHeightBreakpoint == HeightBreakpoint.HEIGHT_LG) {
|
|
|
|
|
+ return false
|
|
|
|
|
+ }else{
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建主页面结构,包括顶部横线、主内容区和抽屉菜单
|
|
|
|
|
+ */
|
|
|
|
|
+ // build() {
|
|
|
|
|
+ // Stack({ alignContent: Alignment.TopStart }) {
|
|
|
|
|
+ // // // 顶部横线
|
|
|
|
|
+ // // Column(){
|
|
|
|
|
+ // // Line()
|
|
|
|
|
+ // // .width('100%')
|
|
|
|
|
+ // // .height(1)
|
|
|
|
|
+ // // }
|
|
|
|
|
+ // // .backgroundColor($r('app.color.title_bar_bg'))
|
|
|
|
|
+ // // .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
|
|
|
|
|
+ // // 主内容区
|
|
|
|
|
+ // Column() {
|
|
|
|
|
+ // Stack(){
|
|
|
|
|
+ // // 本地音乐内容区
|
|
|
|
|
+ // LocalMusic()
|
|
|
|
|
+ // .visibility(this.mType===0?Visibility.Visible:Visibility.None)
|
|
|
|
|
+ // // 网络内容区
|
|
|
|
|
+ // StreamContent()
|
|
|
|
|
+ // .visibility(this.mType===1?Visibility.Visible:Visibility.None)
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // .width('100%')
|
|
|
|
|
+ // .height('100%')
|
|
|
|
|
+ // .justifyContent(FlexAlign.Start)
|
|
|
|
|
+ // .backgroundColor($r('app.color.bottom_control_background'))
|
|
|
|
|
+ //
|
|
|
|
|
+ // // 侧边抽屉菜单
|
|
|
|
|
+ // if(this.isShowDrawer){
|
|
|
|
|
+ // this.getLeftView()
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ @Builder
|
|
|
|
|
+ getLeftView(){
|
|
|
|
|
+ Column() {
|
|
|
|
|
+ Column() {
|
|
|
|
|
+ // 抽屉顶部背景图
|
|
|
|
|
+ Image($r('app.media.bg_music'))
|
|
|
|
|
+ .width('100%')
|
|
|
|
|
+ .visibility(this.isCoverOpacity()?Visibility.None:Visibility.Visible)
|
|
|
|
|
+ .height(180)
|
|
|
|
|
+ .borderRadius({
|
|
|
|
|
+ topLeft: 0,
|
|
|
|
|
+ topRight : 20,
|
|
|
|
|
+ bottomLeft: 0,
|
|
|
|
|
+ bottomRight: 0
|
|
|
|
|
+ })
|
|
|
|
|
+ // 动态生成抽屉菜单内容
|
|
|
|
|
+ this.getDrawerView()
|
|
|
|
|
+ }
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
.height('100%')
|
|
.height('100%')
|
|
|
- .justifyContent(FlexAlign.Start)
|
|
|
|
|
- .backgroundColor($r('app.color.bottom_control_background'))
|
|
|
|
|
-
|
|
|
|
|
- // 侧边抽屉菜单
|
|
|
|
|
- if(this.isShowDrawer){
|
|
|
|
|
- Column() {
|
|
|
|
|
- Column() {
|
|
|
|
|
- // 抽屉顶部背景图
|
|
|
|
|
- Image($r('app.media.bg_music'))
|
|
|
|
|
- .width('100%')
|
|
|
|
|
- .visibility(this.isCoverOpacity()?Visibility.None:Visibility.Visible)
|
|
|
|
|
- .height(180)
|
|
|
|
|
- .borderRadius({
|
|
|
|
|
- topLeft: 0,
|
|
|
|
|
- topRight : 20,
|
|
|
|
|
- bottomLeft: 0,
|
|
|
|
|
- bottomRight: 0
|
|
|
|
|
- })
|
|
|
|
|
- // 动态生成抽屉菜单内容
|
|
|
|
|
- this.getDrawerView()
|
|
|
|
|
|
|
+ .onClick((event:ClickEvent)=>{
|
|
|
|
|
+ // 阻止事件冒泡
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ // .width(this.currentBreakpoint !== BreakpointTypeEnum.SM?'36%':'70%')
|
|
|
|
|
+ .height('100%')
|
|
|
|
|
+ .borderRadius({
|
|
|
|
|
+ topLeft: 0,
|
|
|
|
|
+ topRight : 20,
|
|
|
|
|
+ bottomLeft: 0,
|
|
|
|
|
+ bottomRight: 20
|
|
|
|
|
+ })
|
|
|
|
|
+ // .backgroundColor($r('app.color.silvery'))
|
|
|
|
|
+ .backgroundColor($r('app.color.index_background'))
|
|
|
|
|
+ .alignItems(HorizontalAlign.Start)
|
|
|
|
|
+ .onClick((event:ClickEvent)=>{
|
|
|
|
|
+ // 点击抽屉外部关闭抽屉
|
|
|
|
|
+ animateTo({ duration: 555 }, () => {
|
|
|
|
|
+ this.isShowDrawer = false
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ .translate({ x: this.offsetX, y: 0, z: 0 })
|
|
|
|
|
+ .transition({ type: TransitionType.Insert, translate: { x: -DisplayUtil.getWidth(), y: 0 } })
|
|
|
|
|
+ .transition({ type: TransitionType.Delete, translate: { x: -DisplayUtil.getWidth(), y: 0 } })
|
|
|
|
|
+ .gesture(
|
|
|
|
|
+ PanGesture()
|
|
|
|
|
+ .onActionUpdate((event:GestureEvent)=>{
|
|
|
|
|
+ // 手势滑动更新抽屉偏移
|
|
|
|
|
+ if(event.offsetX<0){
|
|
|
|
|
+ this.offsetX = event.offsetX;
|
|
|
}
|
|
}
|
|
|
- .width('100%')
|
|
|
|
|
- .height('100%')
|
|
|
|
|
- .onClick((event:ClickEvent)=>{
|
|
|
|
|
- // 阻止事件冒泡
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- .width(this.currentBreakpoint !== BreakpointTypeEnum.SM?'36%':'70%')
|
|
|
|
|
- .height('100%')
|
|
|
|
|
- .borderRadius({
|
|
|
|
|
- topLeft: 0,
|
|
|
|
|
- topRight : 20,
|
|
|
|
|
- bottomLeft: 0,
|
|
|
|
|
- bottomRight: 20
|
|
|
|
|
})
|
|
})
|
|
|
- .backgroundColor($r('app.color.silvery'))
|
|
|
|
|
- .alignItems(HorizontalAlign.Start)
|
|
|
|
|
- .onClick((event:ClickEvent)=>{
|
|
|
|
|
- // 点击抽屉外部关闭抽屉
|
|
|
|
|
- animateTo({ duration: 555 }, () => {
|
|
|
|
|
- this.isShowDrawer = false
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- .translate({ x: this.offsetX, y: 0, z: 0 })
|
|
|
|
|
- .transition({ type: TransitionType.Insert, translate: { x: -DisplayUtil.getWidth(), y: 0 } })
|
|
|
|
|
- .transition({ type: TransitionType.Delete, translate: { x: -DisplayUtil.getWidth(), y: 0 } })
|
|
|
|
|
- .gesture(
|
|
|
|
|
- PanGesture()
|
|
|
|
|
- .onActionUpdate((event:GestureEvent)=>{
|
|
|
|
|
- // 手势滑动更新抽屉偏移
|
|
|
|
|
- if(event.offsetX<0){
|
|
|
|
|
- this.offsetX = event.offsetX;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ .onActionEnd(() => {
|
|
|
|
|
+ // 手势结束判断是否关闭抽屉
|
|
|
|
|
+ if(this.offsetX<-DisplayUtil.getWidth()/15){
|
|
|
|
|
+ animateTo({ duration: 555 }, () => {
|
|
|
|
|
+ this.isShowDrawer = false
|
|
|
})
|
|
})
|
|
|
- .onActionEnd(() => {
|
|
|
|
|
- // 手势结束判断是否关闭抽屉
|
|
|
|
|
- if(this.offsetX<-DisplayUtil.getWidth()/15){
|
|
|
|
|
- animateTo({ duration: 555 }, () => {
|
|
|
|
|
- this.isShowDrawer = false
|
|
|
|
|
- })
|
|
|
|
|
- }else{
|
|
|
|
|
- animateTo({ duration: 555 }, () => {
|
|
|
|
|
- this.isShowDrawer = true
|
|
|
|
|
- this.offsetX = 0
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }else{
|
|
|
|
|
+ animateTo({ duration: 555 }, () => {
|
|
|
|
|
+ this.isShowDrawer = true
|
|
|
|
|
+ this.offsetX = 0
|
|
|
})
|
|
})
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -330,7 +385,7 @@ struct NewIndex{
|
|
|
@Builder
|
|
@Builder
|
|
|
getDrawerView(){
|
|
getDrawerView(){
|
|
|
List({space: 0, scroller: this.scroller}){
|
|
List({space: 0, scroller: this.scroller}){
|
|
|
- ForEach(this.isShowSponsorship?mainViewModel.getDrawerData2():mainViewModel.getDrawerData(),(item: ItemData,index:number)=>{
|
|
|
|
|
|
|
+ ForEach(mainViewModel.getDrawerData2(),(item: ItemData,index:number)=>{
|
|
|
ListItem(){
|
|
ListItem(){
|
|
|
Button({ type: ButtonType.Capsule, stateEffect: true }) {
|
|
Button({ type: ButtonType.Capsule, stateEffect: true }) {
|
|
|
Row() {
|
|
Row() {
|
|
@@ -341,20 +396,20 @@ struct NewIndex{
|
|
|
.fontSize(22)
|
|
.fontSize(22)
|
|
|
.fontColor([this.themeColor])
|
|
.fontColor([this.themeColor])
|
|
|
.alignSelf(ItemAlign.Center)
|
|
.alignSelf(ItemAlign.Center)
|
|
|
- .margin({ left: 2 })
|
|
|
|
|
|
|
+ .margin({ left: 25 })
|
|
|
}else {
|
|
}else {
|
|
|
Image(item.img as Resource)
|
|
Image(item.img as Resource)
|
|
|
.height(22)
|
|
.height(22)
|
|
|
.alignSelf(ItemAlign.Center)
|
|
.alignSelf(ItemAlign.Center)
|
|
|
.fillColor(this.themeColor)
|
|
.fillColor(this.themeColor)
|
|
|
- .margin({ left: 2 })
|
|
|
|
|
|
|
+ .margin({ left: 25 })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 菜单标题
|
|
// 菜单标题
|
|
|
Text(item.title)
|
|
Text(item.title)
|
|
|
.margin({ left: 10, right: 20 })
|
|
.margin({ left: 10, right: 20 })
|
|
|
.fontSize(15)
|
|
.fontSize(15)
|
|
|
- .fontColor($r('app.color.index_tab_font_color'))
|
|
|
|
|
|
|
+ .fontColor(this.mType ==index?this.themeColor:$r('app.color.index_tab_font_color'))
|
|
|
.fontWeight(480)
|
|
.fontWeight(480)
|
|
|
Blank()
|
|
Blank()
|
|
|
// 右侧箭头
|
|
// 右侧箭头
|
|
@@ -373,22 +428,27 @@ struct NewIndex{
|
|
|
switch (item.id) {
|
|
switch (item.id) {
|
|
|
case MainViewModel.MENU_MUSIC:
|
|
case MainViewModel.MENU_MUSIC:
|
|
|
this.mType = 0
|
|
this.mType = 0
|
|
|
- animateTo({ duration: 555 }, () => {
|
|
|
|
|
- this.isShowDrawer = false
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if(!this.isBigScreen()){
|
|
|
|
|
+ animateTo({ duration: 555 }, () => {
|
|
|
|
|
+ this.isShowDrawer = false
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
break
|
|
break
|
|
|
case MainViewModel.MENU_FILE_SCAN:
|
|
case MainViewModel.MENU_FILE_SCAN:
|
|
|
- router.pushUrl({
|
|
|
|
|
- url: 'pages/ScanFilePage'
|
|
|
|
|
- });
|
|
|
|
|
- break
|
|
|
|
|
- case MainViewModel.MENU_HOME:
|
|
|
|
|
- this.mType = 0
|
|
|
|
|
- this.modeType = 0
|
|
|
|
|
- animateTo({ duration: 555 }, () => {
|
|
|
|
|
- this.isShowDrawer = false
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ this.mType=2
|
|
|
|
|
+ if(!this.isBigScreen()){
|
|
|
|
|
+ animateTo({ duration: 555 }, () => {
|
|
|
|
|
+ this.isShowDrawer = false
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
break
|
|
break
|
|
|
|
|
+ // case MainViewModel.MENU_HOME:
|
|
|
|
|
+ // this.mType = 0
|
|
|
|
|
+ // this.modeType = 0
|
|
|
|
|
+ // animateTo({ duration: 555 }, () => {
|
|
|
|
|
+ // this.isShowDrawer = false
|
|
|
|
|
+ // })
|
|
|
|
|
+ // break
|
|
|
case MainViewModel.MENU_MIEDIA_KU:
|
|
case MainViewModel.MENU_MIEDIA_KU:
|
|
|
this.modeType = 1
|
|
this.modeType = 1
|
|
|
animateTo({ duration: 555 }, () => {
|
|
animateTo({ duration: 555 }, () => {
|
|
@@ -408,9 +468,15 @@ struct NewIndex{
|
|
|
})
|
|
})
|
|
|
break
|
|
break
|
|
|
case MainViewModel.MENU_SETTING:
|
|
case MainViewModel.MENU_SETTING:
|
|
|
- router.pushUrl({
|
|
|
|
|
- url: 'pages/SettingPage'
|
|
|
|
|
- }, router.RouterMode.Single);
|
|
|
|
|
|
|
+ this.mType=3
|
|
|
|
|
+ if(!this.isBigScreen()){
|
|
|
|
|
+ animateTo({ duration: 555 }, () => {
|
|
|
|
|
+ this.isShowDrawer = false
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ // router.pushUrl({
|
|
|
|
|
+ // url: 'pages/SettingPage'
|
|
|
|
|
+ // }, router.RouterMode.Single);
|
|
|
break
|
|
break
|
|
|
case MainViewModel.MENU_VIP:
|
|
case MainViewModel.MENU_VIP:
|
|
|
router.pushUrl({
|
|
router.pushUrl({
|
|
@@ -418,9 +484,15 @@ struct NewIndex{
|
|
|
}, router.RouterMode.Single);
|
|
}, router.RouterMode.Single);
|
|
|
break
|
|
break
|
|
|
case MainViewModel.MENU_USER:
|
|
case MainViewModel.MENU_USER:
|
|
|
- router.pushUrl({
|
|
|
|
|
- url: 'pages/UserCenter'
|
|
|
|
|
- }, router.RouterMode.Single);
|
|
|
|
|
|
|
+ this.mType=1
|
|
|
|
|
+ if(!this.isBigScreen()){
|
|
|
|
|
+ animateTo({ duration: 555 }, () => {
|
|
|
|
|
+ this.isShowDrawer = false
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ // router.pushUrl({
|
|
|
|
|
+ // url: 'pages/UserCenter'
|
|
|
|
|
+ // }, router.RouterMode.Single);
|
|
|
break
|
|
break
|
|
|
case MainViewModel.MENU_NET_CONNECT:
|
|
case MainViewModel.MENU_NET_CONNECT:
|
|
|
this.mType = 1
|
|
this.mType = 1
|
|
@@ -493,9 +565,12 @@ struct NewIndex{
|
|
|
|
|
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
- .width('100%')
|
|
|
|
|
|
|
+ .width('86%')
|
|
|
|
|
+ .borderRadius(20)
|
|
|
|
|
+ .margin({bottom:20,left:10,right:10,top:10})
|
|
|
.alignListItem(ListItemAlign.Center)
|
|
.alignListItem(ListItemAlign.Center)
|
|
|
.layoutWeight(1)
|
|
.layoutWeight(1)
|
|
|
|
|
+ .backgroundColor($r('app.color.silvery'))
|
|
|
.edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
|
|
.edgeEffect(EdgeEffect.None) // 必须设置列表为滑动到边缘无效果
|
|
|
}
|
|
}
|
|
|
|
|
|