|
|
@@ -3,7 +3,7 @@ import { WebDavAccount } from '../viewmodel/WebDavAccount';
|
|
|
import { Song } from '../viewmodel/Song';
|
|
|
import { RemoteDriveManagerStates } from '../common/enums/RemoteDriveManagerStates';
|
|
|
import Logger from '../common/util/Logger';
|
|
|
-import { promptAction, router, window } from '@kit.ArkUI';
|
|
|
+import { promptAction, SymbolGlyphModifier,router, window } from '@kit.ArkUI';
|
|
|
import { CommonConstants } from '../common/constants/CommonConstants';
|
|
|
import { VideoItem } from '../viewmodel/VideoItem';
|
|
|
import { GlobalContext } from '../common/util/GlobalContext';
|
|
|
@@ -13,9 +13,12 @@ import { emitter } from '@kit.BasicServicesKit';
|
|
|
import { EventConstants } from '../common/constants/EventConstants';
|
|
|
import { LazyDataSource } from '../common/util/LazyDataSource';
|
|
|
import { PreferencesUtil } from '@pura/harmony-utils';
|
|
|
-import { ButtonFancyModifier, ShadowModifier, SymbolGlyphFancyModifier } from '../common/util/AttributeModifierUtil';
|
|
|
+import { ButtonFancyModifier,
|
|
|
+ MenuModifier,
|
|
|
+ ShadowModifier, SymbolGlyphFancyModifier } from '../common/util/AttributeModifierUtil';
|
|
|
import { getRemoteDriveAccountLabel, getRemoteDriveDisplayLabel, getRemoteDrivePlaylistPrefix } from '../common/util/RemoteDriveLabel';
|
|
|
import { RemoteDriveType } from '../common/enums/RemoteDriveType';
|
|
|
+import { Utility } from '../common/util/Utility';
|
|
|
|
|
|
/**
|
|
|
* 歌单播放事件数据
|
|
|
@@ -63,6 +66,10 @@ function decodeUrlEncodedString(encodedStr: string): string {
|
|
|
@Entry
|
|
|
@Component
|
|
|
export struct WebDavMainPage {
|
|
|
+ @StorageProp('animationState') animationState: AnimationStatus= AnimationStatus.Running
|
|
|
+ @State isNoJumpToHome: boolean = false //网盘播放不跳转首页
|
|
|
+ @State isSearchMode: boolean = false
|
|
|
+ @StorageLink('currentSong') currentSong: VideoItem | undefined = undefined;
|
|
|
@StorageProp('topSafeHeight') topSafeHeight: number = 0;
|
|
|
@State webdavManager: RemoteDriveManager = RemoteDriveManager.getInstance();
|
|
|
@State accounts: WebDavAccount[] = [];
|
|
|
@@ -82,6 +89,7 @@ export struct WebDavMainPage {
|
|
|
@State visibleFoldersState: FileInfo[] = []; // 改为普通状态变量
|
|
|
@State isShowFileName: boolean = false//是否显示文件名
|
|
|
@State isLongNameRoLL: boolean = true//长歌名滚动
|
|
|
+ @State sortType: number = 0 //默认排序方式
|
|
|
|
|
|
async onSwitchAccount(){
|
|
|
console.log('onecold 切换账户:', this.selectedAccount.name);
|
|
|
@@ -102,8 +110,13 @@ export struct WebDavMainPage {
|
|
|
this.breadcrumbs = this.webdavManager.getBreadcrumbs();
|
|
|
}
|
|
|
|
|
|
- updateListData(mList:Array<VideoItem>){
|
|
|
- this.dataSource.pushArrayData(mList)
|
|
|
+ updateListData(mList:Array<VideoItem>, noSort?: boolean){
|
|
|
+ this.songs = mList;
|
|
|
+ if (!noSort) {
|
|
|
+ this.sortType = PreferencesUtil.getNumberSync('webDavSortType', 0)
|
|
|
+ this.doSortType(this.sortType)
|
|
|
+ }
|
|
|
+ this.dataSource.pushArrayData(this.songs)
|
|
|
}
|
|
|
|
|
|
// 更新可见文件夹列表
|
|
|
@@ -154,9 +167,12 @@ export struct WebDavMainPage {
|
|
|
this.handleWebdavEvent(event);
|
|
|
};
|
|
|
|
|
|
+
|
|
|
aboutToAppear(): void {
|
|
|
this.isShowFileName = PreferencesUtil.getBooleanSync('isShowFileName', false)
|
|
|
this.isLongNameRoLL = PreferencesUtil.getBooleanSync('isLongNameRoLL', true)
|
|
|
+ this.sortType = PreferencesUtil.getNumberSync('webDavSortType', 0)
|
|
|
+ this.isNoJumpToHome = PreferencesUtil.getBooleanSync('isNoJumpToHome', true)
|
|
|
// 获取顶部安全区高度
|
|
|
this.getTopRectHeight();
|
|
|
|
|
|
@@ -348,10 +364,13 @@ export struct WebDavMainPage {
|
|
|
|
|
|
Logger.info(TAG, `heanup 发送WebDAV播放事件,只传递索引: ${index}`);
|
|
|
|
|
|
- // 跳转到首页播放器
|
|
|
- this.getUIContext()?.animateTo({ duration: 555 }, () => {
|
|
|
- this.mType = 0
|
|
|
- })
|
|
|
+ if(!this.isNoJumpToHome){
|
|
|
+ // 跳转到首页播放器
|
|
|
+ this.getUIContext()?.animateTo({ duration: 555 }, () => {
|
|
|
+ this.mType = 0
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
} catch (error) {
|
|
|
const err = error as Error;
|
|
|
Logger.error(TAG, '播放歌曲失败: ' + err.message);
|
|
|
@@ -499,6 +518,75 @@ export struct WebDavMainPage {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Builder
|
|
|
+ SortMenuBuilder() {
|
|
|
+ Menu() {
|
|
|
+
|
|
|
+ MenuItem({
|
|
|
+ symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.text_and_arrow_up')),
|
|
|
+ content: $r('app.string.sort_by_name')
|
|
|
+ })
|
|
|
+ .onClick(async () => {
|
|
|
+ this.doSortType(0)
|
|
|
+ PreferencesUtil.put("webDavSortType", 0)
|
|
|
+ this.updateListData(this.songs, true)
|
|
|
+ })
|
|
|
+ MenuItem({
|
|
|
+ symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.text_and_arrow_down')),
|
|
|
+ content: '按名称降序'
|
|
|
+ })
|
|
|
+ .onClick(async () => {
|
|
|
+ this.doSortType(1)
|
|
|
+ PreferencesUtil.put("webDavSortType", 1)
|
|
|
+ this.updateListData(this.songs, true)
|
|
|
+ })
|
|
|
+ MenuItem({
|
|
|
+ symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.clock')),
|
|
|
+ content: $r('app.string.sort_by_time')
|
|
|
+ })
|
|
|
+ .onClick(async () => {
|
|
|
+ this.doSortType(2)
|
|
|
+ PreferencesUtil.put("webDavSortType", 2)
|
|
|
+ this.updateListData(this.songs, true)
|
|
|
+ })
|
|
|
+
|
|
|
+ MenuItem({
|
|
|
+ symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.timer')),
|
|
|
+ content: '按添加时间降序'
|
|
|
+ })
|
|
|
+ .onClick(async () => {
|
|
|
+ this.doSortType(3)
|
|
|
+ PreferencesUtil.put("webDavSortType", 3)
|
|
|
+ this.updateListData(this.songs, true)
|
|
|
+ })
|
|
|
+ }.attributeModifier(new MenuModifier())
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ doSortType(index: number) {
|
|
|
+ switch (index) {
|
|
|
+ case 0:
|
|
|
+ Utility.doSortListAscending(this.songs,this.isShowFileName)
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ Utility.doSortListDescending(this.songs,this.isShowFileName)
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ this.songs.sort((a, b) => {
|
|
|
+ // If types are the same, sort by cTime in ascending order
|
|
|
+ return a.cTime.localeCompare(b.cTime);
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ this.songs.sort((a, b) => {
|
|
|
+ // If types are the same, sort by cTime in descending order
|
|
|
+ return b.cTime.localeCompare(a.cTime);
|
|
|
+ });
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Builder
|
|
|
topTitleBar(){
|
|
|
@@ -534,6 +622,50 @@ export struct WebDavMainPage {
|
|
|
.clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
|
|
|
|
|
|
+
|
|
|
+ //搜索按钮
|
|
|
+ if (!this.isSearchMode) {
|
|
|
+ Button({ type: ButtonType.Circle, stateEffect: true }) {
|
|
|
+ SymbolGlyph($r('sys.symbol.magnifyingglass'))
|
|
|
+ .attributeModifier(new SymbolGlyphFancyModifier(25, '', ''))
|
|
|
+ }
|
|
|
+ .attributeModifier(new ButtonFancyModifier(40, 40))
|
|
|
+ .animation({ duration: 300, curve: Curve.Ease })
|
|
|
+ .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
+ .attributeModifier(new ShadowModifier())
|
|
|
+ .zIndex(0)
|
|
|
+ .onClick(()=>{
|
|
|
+ this.isSearchMode = true
|
|
|
+ })
|
|
|
+ //排序按钮
|
|
|
+ Button({ type: ButtonType.Circle, stateEffect: true }) {
|
|
|
+ SymbolGlyph($r('sys.symbol.list_number'))
|
|
|
+ .attributeModifier(new SymbolGlyphFancyModifier(25, '', ''))
|
|
|
+ }
|
|
|
+ .attributeModifier(new ButtonFancyModifier(40, 40))
|
|
|
+ .animation({ duration: 300, curve: Curve.Ease })
|
|
|
+ .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
+ .bindMenu(this.SortMenuBuilder)
|
|
|
+ .attributeModifier(new ShadowModifier())
|
|
|
+ .zIndex(0)
|
|
|
+ //添加按钮
|
|
|
+ Button({ type: ButtonType.Circle, stateEffect: true }) {
|
|
|
+ SymbolGlyph($r('sys.symbol.plus'))
|
|
|
+ .attributeModifier(new SymbolGlyphFancyModifier(25, '', ''))
|
|
|
+ }
|
|
|
+ .attributeModifier(new ButtonFancyModifier(40, 40))
|
|
|
+ .animation({ duration: 300, curve: Curve.Ease })
|
|
|
+ .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.6 })
|
|
|
+ .onClick(() => {
|
|
|
+ this.createPlaylistFromCurrentWebDav();
|
|
|
+ })
|
|
|
+ .attributeModifier(new ShadowModifier())
|
|
|
+ .zIndex(0)
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
.padding({ top: this.topSafeHeight+10, left: 10, right: 10,bottom:2 })
|
|
|
@@ -633,31 +765,31 @@ export struct WebDavMainPage {
|
|
|
}
|
|
|
|
|
|
// 统计信息
|
|
|
- if (this.webDavFiles.length > 0) {
|
|
|
- Row() {
|
|
|
- Text(this.visibleFoldersState.length + ' 个文件夹, ' + this.songs.length + ' 首歌曲')
|
|
|
- .fontSize(13)
|
|
|
- .fontColor($r('app.color.index_tab_font_color'))
|
|
|
- .opacity(0.6)
|
|
|
- .layoutWeight(1)
|
|
|
- .textAlign(TextAlign.Start)
|
|
|
- Blank()
|
|
|
- Button('一键创建歌单',{ type: ButtonType.Capsule, stateEffect: true })
|
|
|
- .type(ButtonType.Normal)
|
|
|
- .fontSize(12)
|
|
|
- .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.8 })
|
|
|
- .backgroundColor(this.themeColor)
|
|
|
- .fontColor(Color.White)
|
|
|
- .padding({ left: 12, right: 12, top: 6, bottom: 6 })
|
|
|
- .borderRadius(16)
|
|
|
- .visibility(this.songs.length > 0 ? Visibility.Visible : Visibility.None)
|
|
|
- .onClick(() => {
|
|
|
- Logger.info(TAG, 'heanup 点击一键创建歌单按钮');
|
|
|
- this.createPlaylistFromCurrentWebDav();
|
|
|
- })
|
|
|
- }
|
|
|
- .padding({ left: 4, right: 4 })
|
|
|
- }
|
|
|
+ // if (this.webDavFiles.length > 0) {
|
|
|
+ // Row() {
|
|
|
+ // Text(this.visibleFoldersState.length + ' 个文件夹, ' + this.songs.length + ' 首歌曲')
|
|
|
+ // .fontSize(13)
|
|
|
+ // .fontColor($r('app.color.index_tab_font_color'))
|
|
|
+ // .opacity(0.6)
|
|
|
+ // .layoutWeight(1)
|
|
|
+ // .textAlign(TextAlign.Start)
|
|
|
+ // Blank()
|
|
|
+ // Button('一键创建歌单',{ type: ButtonType.Capsule, stateEffect: true })
|
|
|
+ // .type(ButtonType.Normal)
|
|
|
+ // .fontSize(12)
|
|
|
+ // .clickEffect({ level: ClickEffectLevel.MIDDLE,scale:0.8 })
|
|
|
+ // .backgroundColor(this.themeColor)
|
|
|
+ // .fontColor(Color.White)
|
|
|
+ // .padding({ left: 12, right: 12, top: 6, bottom: 6 })
|
|
|
+ // .borderRadius(16)
|
|
|
+ // .visibility(this.songs.length > 0 ? Visibility.Visible : Visibility.None)
|
|
|
+ // .onClick(() => {
|
|
|
+ // Logger.info(TAG, 'heanup 点击一键创建歌单按钮');
|
|
|
+ // this.createPlaylistFromCurrentWebDav();
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // .padding({ left: 4, right: 4 })
|
|
|
+ // }
|
|
|
}
|
|
|
.width('100%')
|
|
|
.padding(12)
|
|
|
@@ -790,37 +922,63 @@ export struct WebDavMainPage {
|
|
|
Text(this.isShowFileName?song.fileName :song.name)
|
|
|
.fontSize(15)
|
|
|
.textOverflow({ overflow: this.isLongNameRoLL?TextOverflow.MARQUEE:TextOverflow.Ellipsis })//超长滚动
|
|
|
- .fontColor($r('app.color.index_tab_font_color'))
|
|
|
+ .fontColor(this.currentSong?.filePath==song.filePath?this.themeColor:$r('app.color.index_tab_font_color'))
|
|
|
.maxLines(1)
|
|
|
+ .margin({ right: 20 })
|
|
|
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
|
|
|
|
Row(){
|
|
|
Text(song.artist+" ")
|
|
|
.fontSize(13)
|
|
|
- .fontColor($r('app.color.index_tab_font_color'))
|
|
|
+ .fontColor(this.currentSong?.filePath==song.filePath?this.themeColor:$r('app.color.index_tab_font_color'))
|
|
|
.opacity(0.6)
|
|
|
.maxLines(1)
|
|
|
.visibility(song.artist?Visibility.Visible:Visibility.None)
|
|
|
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
|
Text(decodeUrlEncodedString(song.size||"")+' '+song.cTime)
|
|
|
.fontSize(13)
|
|
|
- .fontColor($r('app.color.index_tab_font_color'))
|
|
|
+ .fontColor(this.currentSong?.filePath==song.filePath?this.themeColor:
|
|
|
+ $r('app.color.index_tab_font_color'))
|
|
|
.opacity(0.6)
|
|
|
.maxLines(1)
|
|
|
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
|
}
|
|
|
-
|
|
|
+ .margin({ right: 20 })
|
|
|
|
|
|
}
|
|
|
.alignItems(HorizontalAlign.Start)
|
|
|
- .layoutWeight(1)
|
|
|
|
|
|
- // 播放图标
|
|
|
- Image($r('app.media.ic_play'))
|
|
|
- .width(20)
|
|
|
- .height(20)
|
|
|
- .fillColor($r('app.color.index_tab_font_color'))
|
|
|
- .opacity(0.4)
|
|
|
+
|
|
|
+ Column() {
|
|
|
+ //多选按钮的Checkbox 先注释掉
|
|
|
+ // Checkbox({ name: 'checkbox' + index })
|
|
|
+ // .select(this.selectedFiles.some(x => x.filePath === item.filePath))
|
|
|
+ // .selectedColor(this.themeColor)
|
|
|
+ // .shape(CheckBoxShape.CIRCLE)
|
|
|
+ // .opacity(this.isMultiSelect ? 1 : 0)
|
|
|
+ // .animation({
|
|
|
+ // duration: 666,
|
|
|
+ // curve: 'Smooth' // 可选动画曲线
|
|
|
+ // })
|
|
|
+ // .visibility(this.isMultiSelect ? Visibility.Visible : Visibility.None)
|
|
|
+ // .onChange((checked: boolean) => this.handleFileSelection(item, checked))
|
|
|
+ // .margin({ left: 20, top: 8, bottom: 8,right:18 })
|
|
|
+ // .width(22)
|
|
|
+ // .height(22)
|
|
|
+
|
|
|
+
|
|
|
+ ImageAnimator()
|
|
|
+ .images(CommonConstants.IMAGE_FRAME_INFO)// 动画数组
|
|
|
+ .duration(1000)// 持续
|
|
|
+ .state(this.animationState)// 动画状态
|
|
|
+ .fillMode(FillMode.Forwards)
|
|
|
+ .width(18)
|
|
|
+ .margin({ right: 12, top: 8, bottom: 8 })
|
|
|
+ .visibility(this.currentSong?.filePath==song.filePath ? Visibility.Visible :
|
|
|
+ Visibility.None)
|
|
|
+ .height(18)
|
|
|
+ .iterations(-1) // 播放次数
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
.width('100%')
|