-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from nini22P/dev
v1.3.0
- Loading branch information
Showing
53 changed files
with
2,850 additions
and
1,204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ GeneratedPluginRegistrant.java | |
key.properties | ||
**/*.keystore | ||
**/*.jks | ||
|
||
/app/src/main/assets/flutter_assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
import 'package:iris/models/player.dart'; | ||
import 'package:iris/utils/logger.dart'; | ||
|
||
void useAppLifecycle(MediaPlayer player) { | ||
AppLifecycleState? appLifecycleState = useAppLifecycleState(); | ||
|
||
useEffect(() { | ||
try { | ||
if (appLifecycleState == AppLifecycleState.paused) { | ||
logger('App lifecycle state: paused'); | ||
player.saveProgress(); | ||
} | ||
} catch (e) { | ||
logger('App lifecycle state error: $e'); | ||
} | ||
return; | ||
}, [appLifecycleState]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import 'package:collection/collection.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
import 'package:flutter_zustand/flutter_zustand.dart'; | ||
import 'package:iris/models/file.dart'; | ||
import 'package:iris/models/storages/storage.dart'; | ||
import 'package:iris/store/use_play_queue_store.dart'; | ||
import 'package:iris/store/use_storage_store.dart'; | ||
import 'package:iris/utils/files_filter.dart'; | ||
|
||
FileItem? useCover(BuildContext context) { | ||
final playQueue = | ||
usePlayQueueStore().select(context, (state) => state.playQueue); | ||
final currentIndex = | ||
usePlayQueueStore().select(context, (state) => state.currentIndex); | ||
|
||
final int currentPlayIndex = useMemoized( | ||
() => playQueue.indexWhere((element) => element.index == currentIndex), | ||
[playQueue, currentIndex]); | ||
|
||
final PlayQueueItem? currentPlay = useMemoized( | ||
() => playQueue.isEmpty || currentPlayIndex < 0 | ||
? null | ||
: playQueue[currentPlayIndex], | ||
[playQueue, currentPlayIndex]); | ||
|
||
final localStorages = | ||
useStorageStore().select(context, (state) => state.localStorages); | ||
final storages = useStorageStore().select(context, (state) => state.storages); | ||
|
||
final List<String> dir = useMemoized( | ||
() => currentPlay?.file == null || currentPlay!.file.path.isEmpty | ||
? [] | ||
: ([...currentPlay.file.path]..removeLast()), | ||
[currentPlay?.file], | ||
); | ||
|
||
final Storage? storage = useMemoized( | ||
() => currentPlay?.file == null | ||
? null | ||
: [...localStorages, ...storages].firstWhereOrNull( | ||
(storage) => storage.id == currentPlay?.file.storageId), | ||
[currentPlay?.file, localStorages, storages]); | ||
|
||
final getCover = useMemoized(() async { | ||
if (currentPlay?.file.type != ContentType.audio) return null; | ||
|
||
final files = await storage?.getFiles(dir); | ||
|
||
if (files == null) return null; | ||
|
||
final images = filesFilter(files, [ContentType.image]); | ||
|
||
return images.firstWhereOrNull( | ||
(image) => image.name.split('.').first.toLowerCase() == 'cover') ?? | ||
images.firstOrNull; | ||
}, [currentPlay?.file, dir]); | ||
|
||
final cover = useFuture(getCover).data; | ||
|
||
return cover; | ||
} |
Oops, something went wrong.