|
@@ -22,6 +22,8 @@ import { setNavidromePlaylist } from '../common/util/NavidromePlaylistStore';
|
|
|
import { navidromeApi, NavidromeSong } from '../common/network/NavidromeApi';
|
|
import { navidromeApi, NavidromeSong } from '../common/network/NavidromeApi';
|
|
|
import { ServerLogUtil } from '../common/util/ServerLogUtil';
|
|
import { ServerLogUtil } from '../common/util/ServerLogUtil';
|
|
|
import { RemoteDriveManager } from '../common/util/RemoteDriveManager';
|
|
import { RemoteDriveManager } from '../common/util/RemoteDriveManager';
|
|
|
|
|
+import { SettingPage } from '../pages/SettingPage';
|
|
|
|
|
+
|
|
|
const NAVIDROME_PLAYLIST_ID = 'navidrome-playlist';
|
|
const NAVIDROME_PLAYLIST_ID = 'navidrome-playlist';
|
|
|
const NAVIDROME_SEARCH_LIMIT = 500;
|
|
const NAVIDROME_SEARCH_LIMIT = 500;
|
|
|
|
|
|
|
@@ -47,6 +49,15 @@ interface CachePreviewInfo {
|
|
|
|
|
|
|
|
@Component
|
|
@Component
|
|
|
export struct NavidromePage {
|
|
export struct NavidromePage {
|
|
|
|
|
+ @State isShowTitleBar: boolean = true //是否显示分类导航条
|
|
|
|
|
+ private scroller: Scroller = new Scroller()
|
|
|
|
|
+ private prevOffsetY: number = 0; // 记录上一次的Y轴偏移量
|
|
|
|
|
+ @State autoHideTitle: boolean = true //滚动自动隐藏标题栏
|
|
|
|
|
+ @State isCustomizeBg: boolean = false //自定义背景界面
|
|
|
|
|
+ @StorageProp('isLandscape') isLandscape: boolean = false;
|
|
|
|
|
+ @State blurValue: number = 0 //背景模糊
|
|
|
|
|
+ @State bgBrightness: number = 0 //背景亮度
|
|
|
|
|
+ @State customizeBgPath: string | undefined = '';
|
|
|
@Link mType: number;
|
|
@Link mType: number;
|
|
|
@Link offsetX: number;
|
|
@Link offsetX: number;
|
|
|
@Link isShowDrawer: boolean;
|
|
@Link isShowDrawer: boolean;
|
|
@@ -67,7 +78,7 @@ export struct NavidromePage {
|
|
|
@State isAlbumPageLoading: boolean = false;
|
|
@State isAlbumPageLoading: boolean = false;
|
|
|
@StorageProp('isDarkMode') isDarkMode: boolean = false;
|
|
@StorageProp('isDarkMode') isDarkMode: boolean = false;
|
|
|
@StorageLink('currentSong') currentSong: VideoItem | undefined = undefined;
|
|
@StorageLink('currentSong') currentSong: VideoItem | undefined = undefined;
|
|
|
- @StorageProp('topRectHeight') topRectHeight: number = 0;
|
|
|
|
|
|
|
+ @StorageProp('topSafeHeight') topSafeHeight: number = 0;
|
|
|
@State @Watch('onTabSelectedIndexesChanged') tabSelectedIndexes: number[] = [0];
|
|
@State @Watch('onTabSelectedIndexesChanged') tabSelectedIndexes: number[] = [0];
|
|
|
@StorageProp('themeColor') themeColor: string =
|
|
@StorageProp('themeColor') themeColor: string =
|
|
|
PreferencesUtil.getStringSync('THEME_COLOR', CommonConstants.DEFAULT_THEME_COLOR);
|
|
PreferencesUtil.getStringSync('THEME_COLOR', CommonConstants.DEFAULT_THEME_COLOR);
|
|
@@ -158,9 +169,25 @@ export struct NavidromePage {
|
|
|
await this.refreshNavidromeData(true);
|
|
await this.refreshNavidromeData(true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- aboutToAppear() {
|
|
|
|
|
|
|
+ initSetting(){
|
|
|
|
|
+ this.isCustomizeBg = PreferencesUtil.getBooleanSync(SettingPage.IS_CUSTOMIZE_BG, false)
|
|
|
|
|
+ this.customizeBgPath = PreferencesUtil.getStringSync(SettingPage.IS_CUSTOMIZE_BG_PATH, '')
|
|
|
|
|
+ this.blurValue = PreferencesUtil.getNumberSync(SettingPage.CUSTOMIZE_BG_BLUR, 0)
|
|
|
|
|
+ this.bgBrightness = PreferencesUtil.getNumberSync(SettingPage.BG_BRIGHTNESS, 0)
|
|
|
this.isNoJumpToHome = PreferencesUtil.getBooleanSync('isNoJumpToHome', true)
|
|
this.isNoJumpToHome = PreferencesUtil.getBooleanSync('isNoJumpToHome', true)
|
|
|
this.sortType = PreferencesUtil.getNumberSync('navidromeSortType', 0);
|
|
this.sortType = PreferencesUtil.getNumberSync('navidromeSortType', 0);
|
|
|
|
|
+ this.isShowTitleBar = PreferencesUtil.getBooleanSync(SettingPage.IS_SHOW_TITLTBAR, true)
|
|
|
|
|
+ this.autoHideTitle = PreferencesUtil.getBooleanSync('autoHideTitle', true)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ aboutToAppear() {
|
|
|
|
|
+ this.initSetting()
|
|
|
|
|
+ let eventSetting: emitter.InnerEvent = { eventId: 333 }
|
|
|
|
|
+ // 监听广播事件(通用设置配置更新)
|
|
|
|
|
+ emitter.on(eventSetting, (eventData: emitter.EventData) => {
|
|
|
|
|
+ this.initSetting()
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
this.refreshNavidromeData();
|
|
this.refreshNavidromeData();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -803,7 +830,7 @@ export struct NavidromePage {
|
|
|
.padding({ left: 25, right: 25, top: 5, bottom: 5 })
|
|
.padding({ left: 25, right: 25, top: 5, bottom: 5 })
|
|
|
}
|
|
}
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
- .padding({ top: this.topRectHeight + 5 })
|
|
|
|
|
|
|
+ .padding({ top: this.topSafeHeight + 5 })
|
|
|
// .backgroundColor($r('app.color.start_window_background'))
|
|
// .backgroundColor($r('app.color.start_window_background'))
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1441,6 +1468,7 @@ export struct NavidromePage {
|
|
|
}
|
|
}
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
.layoutWeight(1)
|
|
.layoutWeight(1)
|
|
|
|
|
+ .padding({top:this.topSafeHeight+98})
|
|
|
.justifyContent(FlexAlign.Center)
|
|
.justifyContent(FlexAlign.Center)
|
|
|
} else {
|
|
} else {
|
|
|
if (this.selectedTab === 0 && this.filterType !== NavFilterType.None) {
|
|
if (this.selectedTab === 0 && this.filterType !== NavFilterType.None) {
|
|
@@ -1449,14 +1477,14 @@ export struct NavidromePage {
|
|
|
.fontSize(13)
|
|
.fontSize(13)
|
|
|
.fontColor(this.themeColor)
|
|
.fontColor(this.themeColor)
|
|
|
.layoutWeight(1)
|
|
.layoutWeight(1)
|
|
|
- Button('清除筛选')
|
|
|
|
|
|
|
+ Button('返回')
|
|
|
.type(ButtonType.Capsule)
|
|
.type(ButtonType.Capsule)
|
|
|
.backgroundColor(this.themeColor)
|
|
.backgroundColor(this.themeColor)
|
|
|
.fontSize(12)
|
|
.fontSize(12)
|
|
|
.onClick(() => this.clearFilter())
|
|
.onClick(() => this.clearFilter())
|
|
|
}
|
|
}
|
|
|
.width('90%')
|
|
.width('90%')
|
|
|
- .padding({ left: 16, right: 16, top: 12, bottom: 2 })
|
|
|
|
|
|
|
+ .padding({ left: 16, right: 16, top: this.topSafeHeight+118, bottom: 2 })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (this.isSearchMode && this.selectedTab === 0 && this.searchText.length > 0 && this.isSearchLoading) {
|
|
if (this.isSearchMode && this.selectedTab === 0 && this.searchText.length > 0 && this.isSearchLoading) {
|
|
@@ -1486,7 +1514,7 @@ export struct NavidromePage {
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
.layoutWeight(1)
|
|
.layoutWeight(1)
|
|
|
} else {
|
|
} else {
|
|
|
- List({ space: 8 }) {
|
|
|
|
|
|
|
+ List({scroller:this.scroller, space: 8 }) {
|
|
|
if (this.selectedTab === 0) {
|
|
if (this.selectedTab === 0) {
|
|
|
ForEach(this.getVisibleSongs(), (item: VideoItem, index: number) => {
|
|
ForEach(this.getVisibleSongs(), (item: VideoItem, index: number) => {
|
|
|
ListItem() {
|
|
ListItem() {
|
|
@@ -1507,12 +1535,32 @@ export struct NavidromePage {
|
|
|
}, (album: NavidromeRestAlbum) => album.id)
|
|
}, (album: NavidromeRestAlbum) => album.id)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ .onScrollFrameBegin((offset: number) => {
|
|
|
|
|
+ // 获取当前滚动偏移量
|
|
|
|
|
+ if(this.autoHideTitle){
|
|
|
|
|
+ const currentOffsetY = this.scroller.currentOffset().yOffset;
|
|
|
|
|
+ // 判断滚动方向
|
|
|
|
|
+ if (currentOffsetY > this.prevOffsetY) {
|
|
|
|
|
+ console.log("onecold 向上滚动");
|
|
|
|
|
+ this.isShowTitleBar = false
|
|
|
|
|
+ } else if (currentOffsetY < this.prevOffsetY) {
|
|
|
|
|
+ console.log("onecold 向下滚动");
|
|
|
|
|
+ this.isShowTitleBar = true
|
|
|
|
|
+ }
|
|
|
|
|
+ // 更新前一次偏移量
|
|
|
|
|
+ this.prevOffsetY = currentOffsetY;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return { offsetRemain: offset };
|
|
|
|
|
+ })
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
|
|
+ .height('100%')
|
|
|
.layoutWeight(1)
|
|
.layoutWeight(1)
|
|
|
.cachedCount(3)
|
|
.cachedCount(3)
|
|
|
.padding({ top: 5, bottom: 5 })
|
|
.padding({ top: 5, bottom: 5 })
|
|
|
.listDirection(Axis.Vertical)
|
|
.listDirection(Axis.Vertical)
|
|
|
- .contentEndOffset(this.bottomSafeHeight+70)
|
|
|
|
|
|
|
+ .contentEndOffset(this.bottomSafeHeight+70)
|
|
|
|
|
+ .contentStartOffset(this.topSafeHeight + 98)
|
|
|
.scrollBar(BarState.Auto)
|
|
.scrollBar(BarState.Auto)
|
|
|
.edgeEffect(EdgeEffect.Spring)
|
|
.edgeEffect(EdgeEffect.Spring)
|
|
|
.onReachEnd(() => {
|
|
.onReachEnd(() => {
|
|
@@ -1549,18 +1597,29 @@ export struct NavidromePage {
|
|
|
|
|
|
|
|
Stack() {
|
|
Stack() {
|
|
|
Column() {
|
|
Column() {
|
|
|
- this.buildContentView();
|
|
|
|
|
|
|
+ this.buildContentView()
|
|
|
}
|
|
}
|
|
|
- .padding({top:this.topRectHeight+98})
|
|
|
|
|
-
|
|
|
|
|
|
|
+ .height('100%')
|
|
|
Column() {
|
|
Column() {
|
|
|
this.topTitleBar()
|
|
this.topTitleBar()
|
|
|
}
|
|
}
|
|
|
|
|
+ .visibility(this.isShowTitleBar?Visibility.Visible:
|
|
|
|
|
+ this.autoHideTitle?Visibility.None:Visibility.Visible)
|
|
|
|
|
+ .animation({
|
|
|
|
|
+ duration: 500,
|
|
|
|
|
+ curve: Curve.Friction // 可选动画曲线
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
.alignContent(Alignment.Top)
|
|
.alignContent(Alignment.Top)
|
|
|
.width('100%')
|
|
.width('100%')
|
|
|
.height('100%')
|
|
.height('100%')
|
|
|
|
|
+ .backgroundImage(this.isCustomizeBg?this.customizeBgPath:$r('app.color.start_window_background'))
|
|
|
|
|
+ .backgroundImageSize(this.isLandscape?{width:'100%'}:{ height: '100%'})
|
|
|
|
|
+ .backgroundImagePosition(Alignment.Center)
|
|
|
|
|
+ .backdropBlur(this.blurValue)
|
|
|
|
|
+ .backgroundBrightness({rate:this.isCustomizeBg?0.1:0,lightUpDegree:this.bgBrightness})
|
|
|
|
|
+ .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|