Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0aee098d46 | ||
|
|
3289ce0fbc | ||
|
|
8ef0d2e25c | ||
|
|
c4a51e0fb9 | ||
|
|
9819c4f495 | ||
|
|
1ebc2a85d1 | ||
|
|
0159c18497 | ||
|
|
0b1b18fd35 | ||
|
|
4dc7101f39 | ||
|
|
3bfc24bf9b | ||
|
|
d307f8c99d | ||
|
|
ec054fce46 | ||
|
|
b25df3b411 | ||
|
|
57bdb3997e | ||
|
|
6647cf25b0 | ||
|
|
1e6a1af1cf | ||
|
|
637a3e9e37 | ||
|
|
ad4b23b18b | ||
|
|
582809427e | ||
|
|
df09d2249d | ||
|
|
c2cca423d7 |
+2
-2
@@ -1,6 +1,6 @@
|
||||
cask "plezy" do
|
||||
version "1.17.0"
|
||||
sha256 "6c113c19f550c01bead3263e9f6afd9e066673a631b665fd94761ed54731b41f"
|
||||
version "1.18.2"
|
||||
sha256 "83739e8c298e19eefc1e54b1c3d054da99ad03874dbf07e069fcad0f5f264fb6"
|
||||
|
||||
url "https://github.com/edde746/plezy/releases/download/#{version}/plezy-macos.dmg"
|
||||
name "Plezy"
|
||||
|
||||
@@ -80,10 +80,9 @@ dependencies {
|
||||
implementation("androidx.tvprovider:tvprovider:1.0.0")
|
||||
|
||||
// Media3 ExoPlayer for Android
|
||||
implementation("androidx.media3:media3-exoplayer:1.5.1")
|
||||
implementation("androidx.media3:media3-ui:1.5.1")
|
||||
implementation("androidx.media3:media3-common:1.5.1")
|
||||
implementation("androidx.media3:media3-session:1.5.1")
|
||||
implementation("androidx.media3:media3-exoplayer:1.9.2")
|
||||
implementation("androidx.media3:media3-ui:1.9.2")
|
||||
implementation("androidx.media3:media3-common:1.9.2")
|
||||
|
||||
// FFmpeg audio decoder for unsupported codecs (ALAC, DTS, TrueHD, etc.)
|
||||
implementation("org.jellyfin.media3:media3-ffmpeg-decoder:1.9.0+1")
|
||||
|
||||
@@ -6,21 +6,24 @@ default_platform(:android)
|
||||
platform :android do
|
||||
desc "Build and deploy to Google Play Store"
|
||||
lane :release do
|
||||
# Build the Flutter app
|
||||
sh("cd #{ENV['PWD']}/.. && flutter build appbundle --dart-define=ENABLE_IN_APP_REVIEW=true")
|
||||
|
||||
# Get version code from pubspec.yaml
|
||||
# Get version from pubspec.yaml
|
||||
pubspec_path = "#{ENV['PWD']}/../pubspec.yaml"
|
||||
pubspec_content = File.read(pubspec_path)
|
||||
version_match = pubspec_content.match(/version:\s*(.+)\+(\d+)/)
|
||||
|
||||
if version_match
|
||||
version_name = version_match[1].strip
|
||||
version_code = version_match[2].to_i
|
||||
UI.message("Using version code: #{version_code}")
|
||||
UI.message("Using version: #{version_name}+#{version_code}")
|
||||
else
|
||||
UI.user_error!("Could not extract version code from pubspec.yaml")
|
||||
UI.user_error!("Could not extract version from pubspec.yaml")
|
||||
end
|
||||
|
||||
debug_info_dir = "../build/debug-info/#{version_name}+#{version_code}"
|
||||
|
||||
# Build the Flutter app
|
||||
sh("cd #{ENV['PWD']}/.. && flutter build appbundle --dart-define=ENABLE_IN_APP_REVIEW=true --obfuscate --split-debug-info=#{debug_info_dir}/aab")
|
||||
|
||||
upload_to_play_store(
|
||||
track: "production",
|
||||
release_status: "completed",
|
||||
@@ -28,8 +31,14 @@ platform :android do
|
||||
aab: "../build/app/outputs/bundle/release/app-release.aab"
|
||||
)
|
||||
|
||||
# Build split-per-ABI APKs for Amazon Appstore (doesn't accept AABs)
|
||||
sh("cd #{ENV['PWD']}/.. && flutter build apk --release --split-per-abi --obfuscate --split-debug-info=#{debug_info_dir}/apk")
|
||||
|
||||
upload_to_amazon_appstore(
|
||||
apk: "../build/app/outputs/bundle/release/app-release.aab",
|
||||
apk_paths: [
|
||||
"../build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk",
|
||||
"../build/app/outputs/flutter-apk/app-arm64-v8a-release.apk"
|
||||
],
|
||||
overwrite_upload: true,
|
||||
overwrite_upload_mode: 'reuse'
|
||||
)
|
||||
|
||||
@@ -236,6 +236,11 @@ class MpvPlayerCore: NSObject {
|
||||
return cstr.map { String(cString: $0) }
|
||||
}
|
||||
|
||||
func setLogLevel(_ level: String) {
|
||||
guard let mpv = mpv else { return }
|
||||
mpv_request_log_messages(mpv, level)
|
||||
}
|
||||
|
||||
func observeProperty(_ name: String, format: String) {
|
||||
guard mpv != nil else { return }
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ class MpvPlayerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, MpvPlayerD
|
||||
case "updateFrame":
|
||||
handleUpdateFrame(result: result)
|
||||
|
||||
case "setLogLevel":
|
||||
handleSetLogLevel(call: call, result: result)
|
||||
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
@@ -218,6 +221,16 @@ class MpvPlayerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler, MpvPlayerD
|
||||
}
|
||||
}
|
||||
|
||||
private func handleSetLogLevel(call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
guard let args = call.arguments as? [String: Any],
|
||||
let level = args["level"] as? String else {
|
||||
result(FlutterError(code: "INVALID_ARGS", message: "Missing 'level'", details: nil))
|
||||
return
|
||||
}
|
||||
playerCore?.setLogLevel(level)
|
||||
result(nil)
|
||||
}
|
||||
|
||||
// MARK: - MpvPlayerDelegate
|
||||
|
||||
func onPropertyChange(name: String, value: Any?) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -51,7 +51,8 @@
|
||||
"exitConfirmTitle": "App beenden?",
|
||||
"exitConfirmMessage": "Möchtest du die App wirklich beenden?",
|
||||
"dontAskAgain": "Nicht erneut fragen",
|
||||
"exit": "Beenden"
|
||||
"exit": "Beenden",
|
||||
"viewAll": "Alle anzeigen"
|
||||
},
|
||||
"screens": {
|
||||
"licenses": "Lizenzen",
|
||||
@@ -266,7 +267,8 @@
|
||||
"confirmDelete": "Sind Sie sicher, dass Sie dieses Element aus Ihrem Dateisystem löschen möchten?",
|
||||
"deleteMultipleWarning": "Mehrere Elemente können gelöscht werden.",
|
||||
"mediaDeletedSuccessfully": "Medienelement erfolgreich gelöscht",
|
||||
"mediaFailedToDelete": "Löschen des Medienelements fehlgeschlagen"
|
||||
"mediaFailedToDelete": "Löschen des Medienelements fehlgeschlagen",
|
||||
"rate": "Bewerten"
|
||||
},
|
||||
"accessibility": {
|
||||
"mediaCardMovie": "${title}, Film",
|
||||
@@ -339,7 +341,9 @@
|
||||
"unknown": "Ein Fehler ist aufgetreten: ${error}"
|
||||
},
|
||||
"chapters": "Kapitel",
|
||||
"noChaptersAvailable": "Keine Kapitel verfügbar"
|
||||
"noChaptersAvailable": "Keine Kapitel verfügbar",
|
||||
"queue": "Queue",
|
||||
"noQueueItems": "No items in queue"
|
||||
},
|
||||
"userStatus": {
|
||||
"admin": "Eigentümer",
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
"exitConfirmTitle": "Exit app?",
|
||||
"exitConfirmMessage": "Are you sure you want to exit?",
|
||||
"dontAskAgain": "Don't ask again",
|
||||
"exit": "Exit"
|
||||
"exit": "Exit",
|
||||
"viewAll": "View All"
|
||||
},
|
||||
"screens": {
|
||||
"licenses": "Licenses",
|
||||
@@ -266,7 +267,8 @@
|
||||
"confirmDelete": "Are you sure you want to delete this item from your filesystem?",
|
||||
"deleteMultipleWarning": "Multiple items may be deleted.",
|
||||
"mediaDeletedSuccessfully": "Media item deleted successfully",
|
||||
"mediaFailedToDelete": "Failed to delete media item"
|
||||
"mediaFailedToDelete": "Failed to delete media item",
|
||||
"rate": "Rate"
|
||||
},
|
||||
"accessibility": {
|
||||
"mediaCardMovie": "${title}, movie",
|
||||
@@ -339,7 +341,9 @@
|
||||
"unknown": "An error occurred: ${error}"
|
||||
},
|
||||
"chapters": "Chapters",
|
||||
"noChaptersAvailable": "No chapters available"
|
||||
"noChaptersAvailable": "No chapters available",
|
||||
"queue": "Queue",
|
||||
"noQueueItems": "No items in queue"
|
||||
},
|
||||
"userStatus": {
|
||||
"admin": "Admin",
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
"exitConfirmTitle": "¿Salir de la app?",
|
||||
"exitConfirmMessage": "¿Estás seguro de que quieres salir?",
|
||||
"dontAskAgain": "No volver a preguntar",
|
||||
"exit": "Salir"
|
||||
"exit": "Salir",
|
||||
"viewAll": "Ver todo"
|
||||
},
|
||||
"screens": {
|
||||
"licenses": "Licencias",
|
||||
@@ -266,7 +267,8 @@
|
||||
"confirmDelete": "¿Estás seguro de que quieres eliminar este elemento de tu sistema de archivos?",
|
||||
"deleteMultipleWarning": "Es posible que se eliminen varios elementos.",
|
||||
"mediaDeletedSuccessfully": "Elemento multimedia eliminado con éxito",
|
||||
"mediaFailedToDelete": "Error al eliminar el elemento multimedia"
|
||||
"mediaFailedToDelete": "Error al eliminar el elemento multimedia",
|
||||
"rate": "Calificar"
|
||||
},
|
||||
"accessibility": {
|
||||
"mediaCardMovie": "${title}, película",
|
||||
@@ -339,7 +341,9 @@
|
||||
"unknown": "Ocurrió un error: ${error}"
|
||||
},
|
||||
"chapters": "Capítulos",
|
||||
"noChaptersAvailable": "No hay capítulos disponibles"
|
||||
"noChaptersAvailable": "No hay capítulos disponibles",
|
||||
"queue": "Queue",
|
||||
"noQueueItems": "No items in queue"
|
||||
},
|
||||
"userStatus": {
|
||||
"admin": "Administrador",
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
"exitConfirmTitle": "Quitter l'application ?",
|
||||
"exitConfirmMessage": "Êtes-vous sûr de vouloir quitter ?",
|
||||
"dontAskAgain": "Ne plus demander",
|
||||
"exit": "Quitter"
|
||||
"exit": "Quitter",
|
||||
"viewAll": "Tout afficher"
|
||||
},
|
||||
"screens": {
|
||||
"licenses": "Licenses",
|
||||
@@ -266,7 +267,8 @@
|
||||
"confirmDelete": "Êtes-vous sûr de vouloir supprimer cet élément de votre système de fichiers?",
|
||||
"deleteMultipleWarning": "Plusieurs éléments peuvent être supprimés.",
|
||||
"mediaDeletedSuccessfully": "Élément média supprimé avec succès",
|
||||
"mediaFailedToDelete": "Échec de la suppression de l'élément média"
|
||||
"mediaFailedToDelete": "Échec de la suppression de l'élément média",
|
||||
"rate": "Noter"
|
||||
},
|
||||
"accessibility": {
|
||||
"mediaCardMovie": "${title}, film",
|
||||
@@ -339,7 +341,9 @@
|
||||
"unknown": "Une erreur s'est produite : ${error}"
|
||||
},
|
||||
"chapters": "Chapitres",
|
||||
"noChaptersAvailable": "Aucun chapitre disponible"
|
||||
"noChaptersAvailable": "Aucun chapitre disponible",
|
||||
"queue": "Queue",
|
||||
"noQueueItems": "No items in queue"
|
||||
},
|
||||
"userStatus": {
|
||||
"admin": "Admin",
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
"exitConfirmTitle": "Uscire dall'app?",
|
||||
"exitConfirmMessage": "Sei sicuro di voler uscire?",
|
||||
"dontAskAgain": "Non chiedere più",
|
||||
"exit": "Esci"
|
||||
"exit": "Esci",
|
||||
"viewAll": "Mostra tutto"
|
||||
},
|
||||
"screens": {
|
||||
"licenses": "Licenze",
|
||||
@@ -266,7 +267,8 @@
|
||||
"confirmDelete": "Sei sicuro di voler eliminare questo elemento dal tuo filesystem?",
|
||||
"deleteMultipleWarning": "Potrebbero essere eliminati più elementi.",
|
||||
"mediaDeletedSuccessfully": "Elemento multimediale eliminato con successo",
|
||||
"mediaFailedToDelete": "Impossibile eliminare l'elemento multimediale"
|
||||
"mediaFailedToDelete": "Impossibile eliminare l'elemento multimediale",
|
||||
"rate": "Valuta"
|
||||
},
|
||||
"accessibility": {
|
||||
"mediaCardMovie": "${title}, film",
|
||||
@@ -339,7 +341,9 @@
|
||||
"unknown": "Si è verificato un errore: ${error}"
|
||||
},
|
||||
"chapters": "Capitoli",
|
||||
"noChaptersAvailable": "Nessun capitolo disponibile"
|
||||
"noChaptersAvailable": "Nessun capitolo disponibile",
|
||||
"queue": "Queue",
|
||||
"noQueueItems": "No items in queue"
|
||||
},
|
||||
"userStatus": {
|
||||
"admin": "Admin",
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
"exitConfirmTitle": "앱을 종료하시겠습니까?",
|
||||
"exitConfirmMessage": "정말 종료하시겠습니까?",
|
||||
"dontAskAgain": "다시 묻지 않기",
|
||||
"exit": "종료"
|
||||
"exit": "종료",
|
||||
"viewAll": "모두 보기"
|
||||
},
|
||||
"screens": {
|
||||
"licenses": "라이선스",
|
||||
@@ -266,7 +267,8 @@
|
||||
"confirmDelete": "파일 시스템에서 이 항목을 삭제하시겠습니까?",
|
||||
"deleteMultipleWarning": "여러 항목이 삭제될 수 있습니다.",
|
||||
"mediaDeletedSuccessfully": "미디어 항목이 성공적으로 삭제되었습니다",
|
||||
"mediaFailedToDelete": "미디어 항목 삭제 실패"
|
||||
"mediaFailedToDelete": "미디어 항목 삭제 실패",
|
||||
"rate": "평가"
|
||||
},
|
||||
"accessibility": {
|
||||
"mediaCardMovie": "${title}, 영화",
|
||||
@@ -339,7 +341,9 @@
|
||||
"unknown": "오류가 발생했습니다: ${error}"
|
||||
},
|
||||
"chapters": "챕터",
|
||||
"noChaptersAvailable": "사용 가능한 챕터가 없습니다"
|
||||
"noChaptersAvailable": "사용 가능한 챕터가 없습니다",
|
||||
"queue": "Queue",
|
||||
"noQueueItems": "No items in queue"
|
||||
},
|
||||
"userStatus": {
|
||||
"admin": "관리자",
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
"exitConfirmTitle": "App afsluiten?",
|
||||
"exitConfirmMessage": "Weet je zeker dat je wilt afsluiten?",
|
||||
"dontAskAgain": "Niet meer vragen",
|
||||
"exit": "Afsluiten"
|
||||
"exit": "Afsluiten",
|
||||
"viewAll": "Alles weergeven"
|
||||
},
|
||||
"screens": {
|
||||
"licenses": "Licenties",
|
||||
@@ -266,7 +267,8 @@
|
||||
"confirmDelete": "Weet je zeker dat je dit item van je bestandssysteem wilt verwijderen?",
|
||||
"deleteMultipleWarning": "Meerdere items kunnen worden verwijderd.",
|
||||
"mediaDeletedSuccessfully": "Media-item succesvol verwijderd",
|
||||
"mediaFailedToDelete": "Verwijderen van media-item mislukt"
|
||||
"mediaFailedToDelete": "Verwijderen van media-item mislukt",
|
||||
"rate": "Beoordelen"
|
||||
},
|
||||
"accessibility": {
|
||||
"mediaCardMovie": "${title}, film",
|
||||
@@ -339,7 +341,9 @@
|
||||
"unknown": "Er is een fout opgetreden: ${error}"
|
||||
},
|
||||
"chapters": "Hoofdstukken",
|
||||
"noChaptersAvailable": "Geen hoofdstukken beschikbaar"
|
||||
"noChaptersAvailable": "Geen hoofdstukken beschikbaar",
|
||||
"queue": "Queue",
|
||||
"noQueueItems": "No items in queue"
|
||||
},
|
||||
"userStatus": {
|
||||
"admin": "Beheerder",
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
/// To regenerate, run: `dart run slang`
|
||||
///
|
||||
/// Locales: 9
|
||||
/// Strings: 6669 (741 per locale)
|
||||
/// Strings: 6705 (745 per locale)
|
||||
///
|
||||
/// Built on 2026-02-18 at 03:36 UTC
|
||||
/// Built on 2026-02-20 at 23:08 UTC
|
||||
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint, unused_import
|
||||
|
||||
@@ -149,6 +149,7 @@ class _TranslationsCommonDe implements TranslationsCommonEn {
|
||||
@override String get exitConfirmMessage => 'Möchtest du die App wirklich beenden?';
|
||||
@override String get dontAskAgain => 'Nicht erneut fragen';
|
||||
@override String get exit => 'Beenden';
|
||||
@override String get viewAll => 'Alle anzeigen';
|
||||
}
|
||||
|
||||
// Path: screens
|
||||
@@ -400,6 +401,7 @@ class _TranslationsMediaMenuDe implements TranslationsMediaMenuEn {
|
||||
@override String get deleteMultipleWarning => 'Mehrere Elemente können gelöscht werden.';
|
||||
@override String get mediaDeletedSuccessfully => 'Medienelement erfolgreich gelöscht';
|
||||
@override String get mediaFailedToDelete => 'Löschen des Medienelements fehlgeschlagen';
|
||||
@override String get rate => 'Bewerten';
|
||||
}
|
||||
|
||||
// Path: accessibility
|
||||
@@ -488,6 +490,8 @@ class _TranslationsVideoControlsDe implements TranslationsVideoControlsEn {
|
||||
@override late final _TranslationsVideoControlsPipErrorsDe pipErrors = _TranslationsVideoControlsPipErrorsDe._(_root);
|
||||
@override String get chapters => 'Kapitel';
|
||||
@override String get noChaptersAvailable => 'Keine Kapitel verfügbar';
|
||||
@override String get queue => 'Queue';
|
||||
@override String get noQueueItems => 'No items in queue';
|
||||
}
|
||||
|
||||
// Path: userStatus
|
||||
@@ -1276,6 +1280,7 @@ extension on TranslationsDe {
|
||||
'common.exitConfirmMessage' => 'Möchtest du die App wirklich beenden?',
|
||||
'common.dontAskAgain' => 'Nicht erneut fragen',
|
||||
'common.exit' => 'Beenden',
|
||||
'common.viewAll' => 'Alle anzeigen',
|
||||
'screens.licenses' => 'Lizenzen',
|
||||
'screens.switchProfile' => 'Profil wechseln',
|
||||
'screens.subtitleStyling' => 'Untertitel-Stil',
|
||||
@@ -1473,6 +1478,7 @@ extension on TranslationsDe {
|
||||
'mediaMenu.deleteMultipleWarning' => 'Mehrere Elemente können gelöscht werden.',
|
||||
'mediaMenu.mediaDeletedSuccessfully' => 'Medienelement erfolgreich gelöscht',
|
||||
'mediaMenu.mediaFailedToDelete' => 'Löschen des Medienelements fehlgeschlagen',
|
||||
'mediaMenu.rate' => 'Bewerten',
|
||||
'accessibility.mediaCardMovie' => ({required Object title}) => '${title}, Film',
|
||||
'accessibility.mediaCardShow' => ({required Object title}) => '${title}, Serie',
|
||||
'accessibility.mediaCardEpisode' => ({required Object title, required Object episodeInfo}) => '${title}, ${episodeInfo}',
|
||||
@@ -1538,6 +1544,8 @@ extension on TranslationsDe {
|
||||
'videoControls.pipErrors.unknown' => ({required Object error}) => 'Ein Fehler ist aufgetreten: ${error}',
|
||||
'videoControls.chapters' => 'Kapitel',
|
||||
'videoControls.noChaptersAvailable' => 'Keine Kapitel verfügbar',
|
||||
'videoControls.queue' => 'Queue',
|
||||
'videoControls.noQueueItems' => 'No items in queue',
|
||||
'userStatus.admin' => 'Eigentümer',
|
||||
'userStatus.restricted' => 'Eingeschränkt',
|
||||
'userStatus.protected' => 'Geschützt',
|
||||
@@ -1736,12 +1744,12 @@ extension on TranslationsDe {
|
||||
'liveTv.allChannels' => 'Alle Kanäle',
|
||||
'liveTv.now' => 'Jetzt',
|
||||
'liveTv.today' => 'Heute',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.midnight' => 'Mitternacht',
|
||||
'liveTv.overnight' => 'Nacht',
|
||||
'liveTv.morning' => 'Morgen',
|
||||
'liveTv.daytime' => 'Tagsüber',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Abend',
|
||||
'liveTv.lateNight' => 'Spätnacht',
|
||||
'liveTv.whatsOn' => 'Jetzt im TV',
|
||||
|
||||
@@ -248,6 +248,9 @@ class TranslationsCommonEn {
|
||||
|
||||
/// en: 'Exit'
|
||||
String get exit => 'Exit';
|
||||
|
||||
/// en: 'View All'
|
||||
String get viewAll => 'View All';
|
||||
}
|
||||
|
||||
// Path: screens
|
||||
@@ -856,6 +859,9 @@ class TranslationsMediaMenuEn {
|
||||
|
||||
/// en: 'Failed to delete media item'
|
||||
String get mediaFailedToDelete => 'Failed to delete media item';
|
||||
|
||||
/// en: 'Rate'
|
||||
String get rate => 'Rate';
|
||||
}
|
||||
|
||||
// Path: accessibility
|
||||
@@ -1065,6 +1071,12 @@ class TranslationsVideoControlsEn {
|
||||
|
||||
/// en: 'No chapters available'
|
||||
String get noChaptersAvailable => 'No chapters available';
|
||||
|
||||
/// en: 'Queue'
|
||||
String get queue => 'Queue';
|
||||
|
||||
/// en: 'No items in queue'
|
||||
String get noQueueItems => 'No items in queue';
|
||||
}
|
||||
|
||||
// Path: userStatus
|
||||
@@ -2765,6 +2777,7 @@ extension on Translations {
|
||||
'common.exitConfirmMessage' => 'Are you sure you want to exit?',
|
||||
'common.dontAskAgain' => 'Don\'t ask again',
|
||||
'common.exit' => 'Exit',
|
||||
'common.viewAll' => 'View All',
|
||||
'screens.licenses' => 'Licenses',
|
||||
'screens.switchProfile' => 'Switch Profile',
|
||||
'screens.subtitleStyling' => 'Subtitle Styling',
|
||||
@@ -2962,6 +2975,7 @@ extension on Translations {
|
||||
'mediaMenu.deleteMultipleWarning' => 'Multiple items may be deleted.',
|
||||
'mediaMenu.mediaDeletedSuccessfully' => 'Media item deleted successfully',
|
||||
'mediaMenu.mediaFailedToDelete' => 'Failed to delete media item',
|
||||
'mediaMenu.rate' => 'Rate',
|
||||
'accessibility.mediaCardMovie' => ({required Object title}) => '${title}, movie',
|
||||
'accessibility.mediaCardShow' => ({required Object title}) => '${title}, TV show',
|
||||
'accessibility.mediaCardEpisode' => ({required Object title, required Object episodeInfo}) => '${title}, ${episodeInfo}',
|
||||
@@ -3027,6 +3041,8 @@ extension on Translations {
|
||||
'videoControls.pipErrors.unknown' => ({required Object error}) => 'An error occurred: ${error}',
|
||||
'videoControls.chapters' => 'Chapters',
|
||||
'videoControls.noChaptersAvailable' => 'No chapters available',
|
||||
'videoControls.queue' => 'Queue',
|
||||
'videoControls.noQueueItems' => 'No items in queue',
|
||||
'userStatus.admin' => 'Admin',
|
||||
'userStatus.restricted' => 'Restricted',
|
||||
'userStatus.protected' => 'Protected',
|
||||
@@ -3225,12 +3241,12 @@ extension on Translations {
|
||||
'liveTv.allChannels' => 'All Channels',
|
||||
'liveTv.now' => 'Now',
|
||||
'liveTv.today' => 'Today',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.midnight' => 'Midnight',
|
||||
'liveTv.overnight' => 'Overnight',
|
||||
'liveTv.morning' => 'Morning',
|
||||
'liveTv.daytime' => 'Daytime',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Evening',
|
||||
'liveTv.lateNight' => 'Late Night',
|
||||
'liveTv.whatsOn' => 'What\'s On',
|
||||
|
||||
@@ -149,6 +149,7 @@ class _TranslationsCommonEs implements TranslationsCommonEn {
|
||||
@override String get exitConfirmMessage => '¿Estás seguro de que quieres salir?';
|
||||
@override String get dontAskAgain => 'No volver a preguntar';
|
||||
@override String get exit => 'Salir';
|
||||
@override String get viewAll => 'Ver todo';
|
||||
}
|
||||
|
||||
// Path: screens
|
||||
@@ -400,6 +401,7 @@ class _TranslationsMediaMenuEs implements TranslationsMediaMenuEn {
|
||||
@override String get deleteMultipleWarning => 'Es posible que se eliminen varios elementos.';
|
||||
@override String get mediaDeletedSuccessfully => 'Elemento multimedia eliminado con éxito';
|
||||
@override String get mediaFailedToDelete => 'Error al eliminar el elemento multimedia';
|
||||
@override String get rate => 'Calificar';
|
||||
}
|
||||
|
||||
// Path: accessibility
|
||||
@@ -488,6 +490,8 @@ class _TranslationsVideoControlsEs implements TranslationsVideoControlsEn {
|
||||
@override late final _TranslationsVideoControlsPipErrorsEs pipErrors = _TranslationsVideoControlsPipErrorsEs._(_root);
|
||||
@override String get chapters => 'Capítulos';
|
||||
@override String get noChaptersAvailable => 'No hay capítulos disponibles';
|
||||
@override String get queue => 'Queue';
|
||||
@override String get noQueueItems => 'No items in queue';
|
||||
}
|
||||
|
||||
// Path: userStatus
|
||||
@@ -1276,6 +1280,7 @@ extension on TranslationsEs {
|
||||
'common.exitConfirmMessage' => '¿Estás seguro de que quieres salir?',
|
||||
'common.dontAskAgain' => 'No volver a preguntar',
|
||||
'common.exit' => 'Salir',
|
||||
'common.viewAll' => 'Ver todo',
|
||||
'screens.licenses' => 'Licencias',
|
||||
'screens.switchProfile' => 'Cambiar Perfil',
|
||||
'screens.subtitleStyling' => 'Estilo de Subtítulos',
|
||||
@@ -1473,6 +1478,7 @@ extension on TranslationsEs {
|
||||
'mediaMenu.deleteMultipleWarning' => 'Es posible que se eliminen varios elementos.',
|
||||
'mediaMenu.mediaDeletedSuccessfully' => 'Elemento multimedia eliminado con éxito',
|
||||
'mediaMenu.mediaFailedToDelete' => 'Error al eliminar el elemento multimedia',
|
||||
'mediaMenu.rate' => 'Calificar',
|
||||
'accessibility.mediaCardMovie' => ({required Object title}) => '${title}, película',
|
||||
'accessibility.mediaCardShow' => ({required Object title}) => '${title}, serie de TV',
|
||||
'accessibility.mediaCardEpisode' => ({required Object title, required Object episodeInfo}) => '${title}, ${episodeInfo}',
|
||||
@@ -1538,6 +1544,8 @@ extension on TranslationsEs {
|
||||
'videoControls.pipErrors.unknown' => ({required Object error}) => 'Ocurrió un error: ${error}',
|
||||
'videoControls.chapters' => 'Capítulos',
|
||||
'videoControls.noChaptersAvailable' => 'No hay capítulos disponibles',
|
||||
'videoControls.queue' => 'Queue',
|
||||
'videoControls.noQueueItems' => 'No items in queue',
|
||||
'userStatus.admin' => 'Administrador',
|
||||
'userStatus.restricted' => 'Restringido',
|
||||
'userStatus.protected' => 'Protegido',
|
||||
@@ -1736,12 +1744,12 @@ extension on TranslationsEs {
|
||||
'liveTv.allChannels' => 'Todos los canales',
|
||||
'liveTv.now' => 'Ahora',
|
||||
'liveTv.today' => 'Hoy',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.midnight' => 'Medianoche',
|
||||
'liveTv.overnight' => 'Madrugada',
|
||||
'liveTv.morning' => 'Mañana',
|
||||
'liveTv.daytime' => 'Día',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Noche',
|
||||
'liveTv.lateNight' => 'Trasnoche',
|
||||
'liveTv.whatsOn' => 'En emisión',
|
||||
|
||||
@@ -149,6 +149,7 @@ class _TranslationsCommonFr implements TranslationsCommonEn {
|
||||
@override String get exitConfirmMessage => 'Êtes-vous sûr de vouloir quitter ?';
|
||||
@override String get dontAskAgain => 'Ne plus demander';
|
||||
@override String get exit => 'Quitter';
|
||||
@override String get viewAll => 'Tout afficher';
|
||||
}
|
||||
|
||||
// Path: screens
|
||||
@@ -400,6 +401,7 @@ class _TranslationsMediaMenuFr implements TranslationsMediaMenuEn {
|
||||
@override String get deleteMultipleWarning => 'Plusieurs éléments peuvent être supprimés.';
|
||||
@override String get mediaDeletedSuccessfully => 'Élément média supprimé avec succès';
|
||||
@override String get mediaFailedToDelete => 'Échec de la suppression de l\'élément média';
|
||||
@override String get rate => 'Noter';
|
||||
}
|
||||
|
||||
// Path: accessibility
|
||||
@@ -488,6 +490,8 @@ class _TranslationsVideoControlsFr implements TranslationsVideoControlsEn {
|
||||
@override late final _TranslationsVideoControlsPipErrorsFr pipErrors = _TranslationsVideoControlsPipErrorsFr._(_root);
|
||||
@override String get chapters => 'Chapitres';
|
||||
@override String get noChaptersAvailable => 'Aucun chapitre disponible';
|
||||
@override String get queue => 'Queue';
|
||||
@override String get noQueueItems => 'No items in queue';
|
||||
}
|
||||
|
||||
// Path: userStatus
|
||||
@@ -1276,6 +1280,7 @@ extension on TranslationsFr {
|
||||
'common.exitConfirmMessage' => 'Êtes-vous sûr de vouloir quitter ?',
|
||||
'common.dontAskAgain' => 'Ne plus demander',
|
||||
'common.exit' => 'Quitter',
|
||||
'common.viewAll' => 'Tout afficher',
|
||||
'screens.licenses' => 'Licenses',
|
||||
'screens.switchProfile' => 'Changer de profil',
|
||||
'screens.subtitleStyling' => 'Configuration des sous-titres',
|
||||
@@ -1473,6 +1478,7 @@ extension on TranslationsFr {
|
||||
'mediaMenu.deleteMultipleWarning' => 'Plusieurs éléments peuvent être supprimés.',
|
||||
'mediaMenu.mediaDeletedSuccessfully' => 'Élément média supprimé avec succès',
|
||||
'mediaMenu.mediaFailedToDelete' => 'Échec de la suppression de l\'élément média',
|
||||
'mediaMenu.rate' => 'Noter',
|
||||
'accessibility.mediaCardMovie' => ({required Object title}) => '${title}, film',
|
||||
'accessibility.mediaCardShow' => ({required Object title}) => '${title}, show TV',
|
||||
'accessibility.mediaCardEpisode' => ({required Object title, required Object episodeInfo}) => '${title}, ${episodeInfo}',
|
||||
@@ -1538,6 +1544,8 @@ extension on TranslationsFr {
|
||||
'videoControls.pipErrors.unknown' => ({required Object error}) => 'Une erreur s\'est produite : ${error}',
|
||||
'videoControls.chapters' => 'Chapitres',
|
||||
'videoControls.noChaptersAvailable' => 'Aucun chapitre disponible',
|
||||
'videoControls.queue' => 'Queue',
|
||||
'videoControls.noQueueItems' => 'No items in queue',
|
||||
'userStatus.admin' => 'Admin',
|
||||
'userStatus.restricted' => 'Restreint',
|
||||
'userStatus.protected' => 'Protégé',
|
||||
@@ -1736,12 +1744,12 @@ extension on TranslationsFr {
|
||||
'liveTv.allChannels' => 'Toutes les chaînes',
|
||||
'liveTv.now' => 'Maintenant',
|
||||
'liveTv.today' => 'Aujourd\'hui',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.midnight' => 'Minuit',
|
||||
'liveTv.overnight' => 'Nuit',
|
||||
'liveTv.morning' => 'Matin',
|
||||
'liveTv.daytime' => 'Journée',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Soirée',
|
||||
'liveTv.lateNight' => 'Nuit tardive',
|
||||
'liveTv.whatsOn' => 'En ce moment',
|
||||
|
||||
@@ -149,6 +149,7 @@ class _TranslationsCommonIt implements TranslationsCommonEn {
|
||||
@override String get exitConfirmMessage => 'Sei sicuro di voler uscire?';
|
||||
@override String get dontAskAgain => 'Non chiedere più';
|
||||
@override String get exit => 'Esci';
|
||||
@override String get viewAll => 'Mostra tutto';
|
||||
}
|
||||
|
||||
// Path: screens
|
||||
@@ -400,6 +401,7 @@ class _TranslationsMediaMenuIt implements TranslationsMediaMenuEn {
|
||||
@override String get deleteMultipleWarning => 'Potrebbero essere eliminati più elementi.';
|
||||
@override String get mediaDeletedSuccessfully => 'Elemento multimediale eliminato con successo';
|
||||
@override String get mediaFailedToDelete => 'Impossibile eliminare l\'elemento multimediale';
|
||||
@override String get rate => 'Valuta';
|
||||
}
|
||||
|
||||
// Path: accessibility
|
||||
@@ -488,6 +490,8 @@ class _TranslationsVideoControlsIt implements TranslationsVideoControlsEn {
|
||||
@override late final _TranslationsVideoControlsPipErrorsIt pipErrors = _TranslationsVideoControlsPipErrorsIt._(_root);
|
||||
@override String get chapters => 'Capitoli';
|
||||
@override String get noChaptersAvailable => 'Nessun capitolo disponibile';
|
||||
@override String get queue => 'Queue';
|
||||
@override String get noQueueItems => 'No items in queue';
|
||||
}
|
||||
|
||||
// Path: userStatus
|
||||
@@ -1276,6 +1280,7 @@ extension on TranslationsIt {
|
||||
'common.exitConfirmMessage' => 'Sei sicuro di voler uscire?',
|
||||
'common.dontAskAgain' => 'Non chiedere più',
|
||||
'common.exit' => 'Esci',
|
||||
'common.viewAll' => 'Mostra tutto',
|
||||
'screens.licenses' => 'Licenze',
|
||||
'screens.switchProfile' => 'Cambia profilo',
|
||||
'screens.subtitleStyling' => 'Stile sottotitoli',
|
||||
@@ -1473,6 +1478,7 @@ extension on TranslationsIt {
|
||||
'mediaMenu.deleteMultipleWarning' => 'Potrebbero essere eliminati più elementi.',
|
||||
'mediaMenu.mediaDeletedSuccessfully' => 'Elemento multimediale eliminato con successo',
|
||||
'mediaMenu.mediaFailedToDelete' => 'Impossibile eliminare l\'elemento multimediale',
|
||||
'mediaMenu.rate' => 'Valuta',
|
||||
'accessibility.mediaCardMovie' => ({required Object title}) => '${title}, film',
|
||||
'accessibility.mediaCardShow' => ({required Object title}) => '${title}, serie TV',
|
||||
'accessibility.mediaCardEpisode' => ({required Object title, required Object episodeInfo}) => '${title}, ${episodeInfo}',
|
||||
@@ -1538,6 +1544,8 @@ extension on TranslationsIt {
|
||||
'videoControls.pipErrors.unknown' => ({required Object error}) => 'Si è verificato un errore: ${error}',
|
||||
'videoControls.chapters' => 'Capitoli',
|
||||
'videoControls.noChaptersAvailable' => 'Nessun capitolo disponibile',
|
||||
'videoControls.queue' => 'Queue',
|
||||
'videoControls.noQueueItems' => 'No items in queue',
|
||||
'userStatus.admin' => 'Admin',
|
||||
'userStatus.restricted' => 'Limitato',
|
||||
'userStatus.protected' => 'Protetto',
|
||||
@@ -1736,12 +1744,12 @@ extension on TranslationsIt {
|
||||
'liveTv.allChannels' => 'Tutti i canali',
|
||||
'liveTv.now' => 'Ora',
|
||||
'liveTv.today' => 'Oggi',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.midnight' => 'Mezzanotte',
|
||||
'liveTv.overnight' => 'Notte',
|
||||
'liveTv.morning' => 'Mattina',
|
||||
'liveTv.daytime' => 'Giorno',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Sera',
|
||||
'liveTv.lateNight' => 'Notte tarda',
|
||||
'liveTv.whatsOn' => 'In onda ora',
|
||||
|
||||
@@ -149,6 +149,7 @@ class _TranslationsCommonKo implements TranslationsCommonEn {
|
||||
@override String get exitConfirmMessage => '정말 종료하시겠습니까?';
|
||||
@override String get dontAskAgain => '다시 묻지 않기';
|
||||
@override String get exit => '종료';
|
||||
@override String get viewAll => '모두 보기';
|
||||
}
|
||||
|
||||
// Path: screens
|
||||
@@ -400,6 +401,7 @@ class _TranslationsMediaMenuKo implements TranslationsMediaMenuEn {
|
||||
@override String get deleteMultipleWarning => '여러 항목이 삭제될 수 있습니다.';
|
||||
@override String get mediaDeletedSuccessfully => '미디어 항목이 성공적으로 삭제되었습니다';
|
||||
@override String get mediaFailedToDelete => '미디어 항목 삭제 실패';
|
||||
@override String get rate => '평가';
|
||||
}
|
||||
|
||||
// Path: accessibility
|
||||
@@ -488,6 +490,8 @@ class _TranslationsVideoControlsKo implements TranslationsVideoControlsEn {
|
||||
@override late final _TranslationsVideoControlsPipErrorsKo pipErrors = _TranslationsVideoControlsPipErrorsKo._(_root);
|
||||
@override String get chapters => '챕터';
|
||||
@override String get noChaptersAvailable => '사용 가능한 챕터가 없습니다';
|
||||
@override String get queue => 'Queue';
|
||||
@override String get noQueueItems => 'No items in queue';
|
||||
}
|
||||
|
||||
// Path: userStatus
|
||||
@@ -1276,6 +1280,7 @@ extension on TranslationsKo {
|
||||
'common.exitConfirmMessage' => '정말 종료하시겠습니까?',
|
||||
'common.dontAskAgain' => '다시 묻지 않기',
|
||||
'common.exit' => '종료',
|
||||
'common.viewAll' => '모두 보기',
|
||||
'screens.licenses' => '라이선스',
|
||||
'screens.switchProfile' => '프로필 전환',
|
||||
'screens.subtitleStyling' => '자막 스타일 설정',
|
||||
@@ -1473,6 +1478,7 @@ extension on TranslationsKo {
|
||||
'mediaMenu.deleteMultipleWarning' => '여러 항목이 삭제될 수 있습니다.',
|
||||
'mediaMenu.mediaDeletedSuccessfully' => '미디어 항목이 성공적으로 삭제되었습니다',
|
||||
'mediaMenu.mediaFailedToDelete' => '미디어 항목 삭제 실패',
|
||||
'mediaMenu.rate' => '평가',
|
||||
'accessibility.mediaCardMovie' => ({required Object title}) => '${title}, 영화',
|
||||
'accessibility.mediaCardShow' => ({required Object title}) => '${title}, TV 프로그램',
|
||||
'accessibility.mediaCardEpisode' => ({required Object title, required Object episodeInfo}) => '${title}, ${episodeInfo}',
|
||||
@@ -1538,6 +1544,8 @@ extension on TranslationsKo {
|
||||
'videoControls.pipErrors.unknown' => ({required Object error}) => '오류가 발생했습니다: ${error}',
|
||||
'videoControls.chapters' => '챕터',
|
||||
'videoControls.noChaptersAvailable' => '사용 가능한 챕터가 없습니다',
|
||||
'videoControls.queue' => 'Queue',
|
||||
'videoControls.noQueueItems' => 'No items in queue',
|
||||
'userStatus.admin' => '관리자',
|
||||
'userStatus.restricted' => '제한됨',
|
||||
'userStatus.protected' => '보호됨',
|
||||
@@ -1736,12 +1744,12 @@ extension on TranslationsKo {
|
||||
'liveTv.allChannels' => '전체 채널',
|
||||
'liveTv.now' => '지금',
|
||||
'liveTv.today' => '오늘',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.midnight' => '자정',
|
||||
'liveTv.overnight' => '심야',
|
||||
'liveTv.morning' => '아침',
|
||||
'liveTv.daytime' => '낮',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => '저녁',
|
||||
'liveTv.lateNight' => '심야 방송',
|
||||
'liveTv.whatsOn' => '지금 방송 중',
|
||||
|
||||
@@ -149,6 +149,7 @@ class _TranslationsCommonNl implements TranslationsCommonEn {
|
||||
@override String get exitConfirmMessage => 'Weet je zeker dat je wilt afsluiten?';
|
||||
@override String get dontAskAgain => 'Niet meer vragen';
|
||||
@override String get exit => 'Afsluiten';
|
||||
@override String get viewAll => 'Alles weergeven';
|
||||
}
|
||||
|
||||
// Path: screens
|
||||
@@ -400,6 +401,7 @@ class _TranslationsMediaMenuNl implements TranslationsMediaMenuEn {
|
||||
@override String get deleteMultipleWarning => 'Meerdere items kunnen worden verwijderd.';
|
||||
@override String get mediaDeletedSuccessfully => 'Media-item succesvol verwijderd';
|
||||
@override String get mediaFailedToDelete => 'Verwijderen van media-item mislukt';
|
||||
@override String get rate => 'Beoordelen';
|
||||
}
|
||||
|
||||
// Path: accessibility
|
||||
@@ -488,6 +490,8 @@ class _TranslationsVideoControlsNl implements TranslationsVideoControlsEn {
|
||||
@override late final _TranslationsVideoControlsPipErrorsNl pipErrors = _TranslationsVideoControlsPipErrorsNl._(_root);
|
||||
@override String get chapters => 'Hoofdstukken';
|
||||
@override String get noChaptersAvailable => 'Geen hoofdstukken beschikbaar';
|
||||
@override String get queue => 'Queue';
|
||||
@override String get noQueueItems => 'No items in queue';
|
||||
}
|
||||
|
||||
// Path: userStatus
|
||||
@@ -1276,6 +1280,7 @@ extension on TranslationsNl {
|
||||
'common.exitConfirmMessage' => 'Weet je zeker dat je wilt afsluiten?',
|
||||
'common.dontAskAgain' => 'Niet meer vragen',
|
||||
'common.exit' => 'Afsluiten',
|
||||
'common.viewAll' => 'Alles weergeven',
|
||||
'screens.licenses' => 'Licenties',
|
||||
'screens.switchProfile' => 'Wissel van profiel',
|
||||
'screens.subtitleStyling' => 'Ondertitel opmaak',
|
||||
@@ -1473,6 +1478,7 @@ extension on TranslationsNl {
|
||||
'mediaMenu.deleteMultipleWarning' => 'Meerdere items kunnen worden verwijderd.',
|
||||
'mediaMenu.mediaDeletedSuccessfully' => 'Media-item succesvol verwijderd',
|
||||
'mediaMenu.mediaFailedToDelete' => 'Verwijderen van media-item mislukt',
|
||||
'mediaMenu.rate' => 'Beoordelen',
|
||||
'accessibility.mediaCardMovie' => ({required Object title}) => '${title}, film',
|
||||
'accessibility.mediaCardShow' => ({required Object title}) => '${title}, TV-serie',
|
||||
'accessibility.mediaCardEpisode' => ({required Object title, required Object episodeInfo}) => '${title}, ${episodeInfo}',
|
||||
@@ -1538,6 +1544,8 @@ extension on TranslationsNl {
|
||||
'videoControls.pipErrors.unknown' => ({required Object error}) => 'Er is een fout opgetreden: ${error}',
|
||||
'videoControls.chapters' => 'Hoofdstukken',
|
||||
'videoControls.noChaptersAvailable' => 'Geen hoofdstukken beschikbaar',
|
||||
'videoControls.queue' => 'Queue',
|
||||
'videoControls.noQueueItems' => 'No items in queue',
|
||||
'userStatus.admin' => 'Beheerder',
|
||||
'userStatus.restricted' => 'Beperkt',
|
||||
'userStatus.protected' => 'Beschermd',
|
||||
@@ -1736,12 +1744,12 @@ extension on TranslationsNl {
|
||||
'liveTv.allChannels' => 'Alle zenders',
|
||||
'liveTv.now' => 'Nu',
|
||||
'liveTv.today' => 'Vandaag',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.midnight' => 'Middernacht',
|
||||
'liveTv.overnight' => 'Nacht',
|
||||
'liveTv.morning' => 'Ochtend',
|
||||
'liveTv.daytime' => 'Overdag',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Avond',
|
||||
'liveTv.lateNight' => 'Late avond',
|
||||
'liveTv.whatsOn' => 'Nu op TV',
|
||||
|
||||
@@ -149,6 +149,7 @@ class _TranslationsCommonSv implements TranslationsCommonEn {
|
||||
@override String get exitConfirmMessage => 'Är du säker på att du vill avsluta?';
|
||||
@override String get dontAskAgain => 'Fråga inte igen';
|
||||
@override String get exit => 'Avsluta';
|
||||
@override String get viewAll => 'Visa alla';
|
||||
}
|
||||
|
||||
// Path: screens
|
||||
@@ -400,6 +401,7 @@ class _TranslationsMediaMenuSv implements TranslationsMediaMenuEn {
|
||||
@override String get deleteMultipleWarning => 'Flera objekt kan komma att tas bort.';
|
||||
@override String get mediaDeletedSuccessfully => 'Mediaobjekt borttaget';
|
||||
@override String get mediaFailedToDelete => 'Kunde inte ta bort mediaobjekt';
|
||||
@override String get rate => 'Betygsätt';
|
||||
}
|
||||
|
||||
// Path: accessibility
|
||||
@@ -488,6 +490,8 @@ class _TranslationsVideoControlsSv implements TranslationsVideoControlsEn {
|
||||
@override late final _TranslationsVideoControlsPipErrorsSv pipErrors = _TranslationsVideoControlsPipErrorsSv._(_root);
|
||||
@override String get chapters => 'Kapitel';
|
||||
@override String get noChaptersAvailable => 'Inga kapitel tillgängliga';
|
||||
@override String get queue => 'Queue';
|
||||
@override String get noQueueItems => 'No items in queue';
|
||||
}
|
||||
|
||||
// Path: userStatus
|
||||
@@ -1276,6 +1280,7 @@ extension on TranslationsSv {
|
||||
'common.exitConfirmMessage' => 'Är du säker på att du vill avsluta?',
|
||||
'common.dontAskAgain' => 'Fråga inte igen',
|
||||
'common.exit' => 'Avsluta',
|
||||
'common.viewAll' => 'Visa alla',
|
||||
'screens.licenses' => 'Licenser',
|
||||
'screens.switchProfile' => 'Byt profil',
|
||||
'screens.subtitleStyling' => 'Undertext-styling',
|
||||
@@ -1473,6 +1478,7 @@ extension on TranslationsSv {
|
||||
'mediaMenu.deleteMultipleWarning' => 'Flera objekt kan komma att tas bort.',
|
||||
'mediaMenu.mediaDeletedSuccessfully' => 'Mediaobjekt borttaget',
|
||||
'mediaMenu.mediaFailedToDelete' => 'Kunde inte ta bort mediaobjekt',
|
||||
'mediaMenu.rate' => 'Betygsätt',
|
||||
'accessibility.mediaCardMovie' => ({required Object title}) => '${title}, film',
|
||||
'accessibility.mediaCardShow' => ({required Object title}) => '${title}, TV-serie',
|
||||
'accessibility.mediaCardEpisode' => ({required Object title, required Object episodeInfo}) => '${title}, ${episodeInfo}',
|
||||
@@ -1538,6 +1544,8 @@ extension on TranslationsSv {
|
||||
'videoControls.pipErrors.unknown' => ({required Object error}) => 'Ett fel uppstod: ${error}',
|
||||
'videoControls.chapters' => 'Kapitel',
|
||||
'videoControls.noChaptersAvailable' => 'Inga kapitel tillgängliga',
|
||||
'videoControls.queue' => 'Queue',
|
||||
'videoControls.noQueueItems' => 'No items in queue',
|
||||
'userStatus.admin' => 'Admin',
|
||||
'userStatus.restricted' => 'Begränsad',
|
||||
'userStatus.protected' => 'Skyddad',
|
||||
@@ -1736,12 +1744,12 @@ extension on TranslationsSv {
|
||||
'liveTv.allChannels' => 'Alla kanaler',
|
||||
'liveTv.now' => 'Nu',
|
||||
'liveTv.today' => 'Idag',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.midnight' => 'Midnatt',
|
||||
'liveTv.overnight' => 'Natt',
|
||||
'liveTv.morning' => 'Morgon',
|
||||
'liveTv.daytime' => 'Dagtid',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => 'Kväll',
|
||||
'liveTv.lateNight' => 'Sen kväll',
|
||||
'liveTv.whatsOn' => 'På TV nu',
|
||||
|
||||
@@ -149,6 +149,7 @@ class _TranslationsCommonZh implements TranslationsCommonEn {
|
||||
@override String get exitConfirmMessage => '确定要退出吗?';
|
||||
@override String get dontAskAgain => '不再询问';
|
||||
@override String get exit => '退出';
|
||||
@override String get viewAll => '查看全部';
|
||||
}
|
||||
|
||||
// Path: screens
|
||||
@@ -400,6 +401,7 @@ class _TranslationsMediaMenuZh implements TranslationsMediaMenuEn {
|
||||
@override String get deleteMultipleWarning => '可能会删除多个项目。';
|
||||
@override String get mediaDeletedSuccessfully => '媒体项已成功删除';
|
||||
@override String get mediaFailedToDelete => '删除媒体项失败';
|
||||
@override String get rate => '评分';
|
||||
}
|
||||
|
||||
// Path: accessibility
|
||||
@@ -488,6 +490,8 @@ class _TranslationsVideoControlsZh implements TranslationsVideoControlsEn {
|
||||
@override late final _TranslationsVideoControlsPipErrorsZh pipErrors = _TranslationsVideoControlsPipErrorsZh._(_root);
|
||||
@override String get chapters => '章节';
|
||||
@override String get noChaptersAvailable => '没有可用的章节';
|
||||
@override String get queue => 'Queue';
|
||||
@override String get noQueueItems => 'No items in queue';
|
||||
}
|
||||
|
||||
// Path: userStatus
|
||||
@@ -1276,6 +1280,7 @@ extension on TranslationsZh {
|
||||
'common.exitConfirmMessage' => '确定要退出吗?',
|
||||
'common.dontAskAgain' => '不再询问',
|
||||
'common.exit' => '退出',
|
||||
'common.viewAll' => '查看全部',
|
||||
'screens.licenses' => '许可证',
|
||||
'screens.switchProfile' => '切换用户',
|
||||
'screens.subtitleStyling' => '字幕样式',
|
||||
@@ -1473,6 +1478,7 @@ extension on TranslationsZh {
|
||||
'mediaMenu.deleteMultipleWarning' => '可能会删除多个项目。',
|
||||
'mediaMenu.mediaDeletedSuccessfully' => '媒体项已成功删除',
|
||||
'mediaMenu.mediaFailedToDelete' => '删除媒体项失败',
|
||||
'mediaMenu.rate' => '评分',
|
||||
'accessibility.mediaCardMovie' => ({required Object title}) => '${title}, 电影',
|
||||
'accessibility.mediaCardShow' => ({required Object title}) => '${title}, 电视剧',
|
||||
'accessibility.mediaCardEpisode' => ({required Object title, required Object episodeInfo}) => '${title}, ${episodeInfo}',
|
||||
@@ -1538,6 +1544,8 @@ extension on TranslationsZh {
|
||||
'videoControls.pipErrors.unknown' => ({required Object error}) => '发生错误:${error}',
|
||||
'videoControls.chapters' => '章节',
|
||||
'videoControls.noChaptersAvailable' => '没有可用的章节',
|
||||
'videoControls.queue' => 'Queue',
|
||||
'videoControls.noQueueItems' => 'No items in queue',
|
||||
'userStatus.admin' => '管理员',
|
||||
'userStatus.restricted' => '受限',
|
||||
'userStatus.protected' => '受保护',
|
||||
@@ -1736,12 +1744,12 @@ extension on TranslationsZh {
|
||||
'liveTv.allChannels' => '所有频道',
|
||||
'liveTv.now' => '现在',
|
||||
'liveTv.today' => '今天',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.midnight' => '午夜',
|
||||
'liveTv.overnight' => '凌晨',
|
||||
'liveTv.morning' => '上午',
|
||||
'liveTv.daytime' => '白天',
|
||||
_ => null,
|
||||
} ?? switch (path) {
|
||||
'liveTv.evening' => '晚上',
|
||||
'liveTv.lateNight' => '深夜',
|
||||
'liveTv.whatsOn' => '正在播出',
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
"exitConfirmTitle": "Avsluta appen?",
|
||||
"exitConfirmMessage": "Är du säker på att du vill avsluta?",
|
||||
"dontAskAgain": "Fråga inte igen",
|
||||
"exit": "Avsluta"
|
||||
"exit": "Avsluta",
|
||||
"viewAll": "Visa alla"
|
||||
},
|
||||
"screens": {
|
||||
"licenses": "Licenser",
|
||||
@@ -266,7 +267,8 @@
|
||||
"confirmDelete": "Är du säker på att du vill ta bort detta objekt från ditt filsystem?",
|
||||
"deleteMultipleWarning": "Flera objekt kan komma att tas bort.",
|
||||
"mediaDeletedSuccessfully": "Mediaobjekt borttaget",
|
||||
"mediaFailedToDelete": "Kunde inte ta bort mediaobjekt"
|
||||
"mediaFailedToDelete": "Kunde inte ta bort mediaobjekt",
|
||||
"rate": "Betygsätt"
|
||||
},
|
||||
"accessibility": {
|
||||
"mediaCardMovie": "${title}, film",
|
||||
@@ -339,7 +341,9 @@
|
||||
"unknown": "Ett fel uppstod: ${error}"
|
||||
},
|
||||
"chapters": "Kapitel",
|
||||
"noChaptersAvailable": "Inga kapitel tillgängliga"
|
||||
"noChaptersAvailable": "Inga kapitel tillgängliga",
|
||||
"queue": "Queue",
|
||||
"noQueueItems": "No items in queue"
|
||||
},
|
||||
"userStatus": {
|
||||
"admin": "Admin",
|
||||
|
||||
@@ -51,7 +51,8 @@
|
||||
"exitConfirmTitle": "退出应用?",
|
||||
"exitConfirmMessage": "确定要退出吗?",
|
||||
"dontAskAgain": "不再询问",
|
||||
"exit": "退出"
|
||||
"exit": "退出",
|
||||
"viewAll": "查看全部"
|
||||
},
|
||||
"screens": {
|
||||
"licenses": "许可证",
|
||||
@@ -266,7 +267,8 @@
|
||||
"confirmDelete": "确定要从文件系统中删除此项吗?",
|
||||
"deleteMultipleWarning": "可能会删除多个项目。",
|
||||
"mediaDeletedSuccessfully": "媒体项已成功删除",
|
||||
"mediaFailedToDelete": "删除媒体项失败"
|
||||
"mediaFailedToDelete": "删除媒体项失败",
|
||||
"rate": "评分"
|
||||
},
|
||||
"accessibility": {
|
||||
"mediaCardMovie": "${title}, 电影",
|
||||
@@ -339,7 +341,9 @@
|
||||
"unknown": "发生错误:${error}"
|
||||
},
|
||||
"chapters": "章节",
|
||||
"noChaptersAvailable": "没有可用的章节"
|
||||
"noChaptersAvailable": "没有可用的章节",
|
||||
"queue": "Queue",
|
||||
"noQueueItems": "No items in queue"
|
||||
},
|
||||
"userStatus": {
|
||||
"admin": "管理员",
|
||||
|
||||
@@ -183,4 +183,51 @@ class PlaybackExtras {
|
||||
final List<PlexMarker> markers;
|
||||
|
||||
PlaybackExtras({required this.chapters, required this.markers});
|
||||
|
||||
static final _introPattern = RegExp(
|
||||
r'(?:^|\b)(?:intro(?:duction)?|opening)(?:\b|$)|^op(?:\s?\d+)?$',
|
||||
caseSensitive: false,
|
||||
);
|
||||
static final _creditsPattern = RegExp(
|
||||
r'(?:^|\b)(?:outro|closing|credits?|ending)(?:\b|$)|^ed(?:\s?\d+)?$',
|
||||
caseSensitive: false,
|
||||
);
|
||||
|
||||
static String? _classifyChapterTitle(String title) {
|
||||
if (_introPattern.hasMatch(title)) return 'intro';
|
||||
if (_creditsPattern.hasMatch(title)) return 'credits';
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Returns [PlaybackExtras] using real markers when available, otherwise
|
||||
/// synthesises markers from chapter titles matching intro/credits patterns.
|
||||
factory PlaybackExtras.withChapterFallback({
|
||||
required List<PlexChapter> chapters,
|
||||
required List<PlexMarker> markers,
|
||||
}) {
|
||||
if (markers.isNotEmpty) {
|
||||
return PlaybackExtras(chapters: chapters, markers: markers);
|
||||
}
|
||||
|
||||
final synthetic = <PlexMarker>[];
|
||||
for (var i = 0; i < chapters.length; i++) {
|
||||
final ch = chapters[i];
|
||||
final title = ch.title;
|
||||
if (title == null || title.isEmpty) continue;
|
||||
|
||||
final type = _classifyChapterTitle(title);
|
||||
if (type == null) continue;
|
||||
|
||||
final start = ch.startTimeOffset;
|
||||
if (start == null) continue;
|
||||
|
||||
final end = ch.endTimeOffset ??
|
||||
(i + 1 < chapters.length ? chapters[i + 1].startTimeOffset : null);
|
||||
if (end == null) continue;
|
||||
|
||||
synthetic.add(PlexMarker(id: ch.id, type: type, startTimeOffset: start, endTimeOffset: end));
|
||||
}
|
||||
|
||||
return PlaybackExtras(chapters: chapters, markers: synthetic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ class PlexMetadata with MultiServerFields {
|
||||
final String? summary;
|
||||
final double? rating;
|
||||
final double? audienceRating;
|
||||
final double? userRating;
|
||||
final int? year;
|
||||
final String? originallyAvailableAt; // Full release date (YYYY-MM-DD)
|
||||
final String? thumb;
|
||||
@@ -128,6 +129,7 @@ class PlexMetadata with MultiServerFields {
|
||||
this.summary,
|
||||
this.rating,
|
||||
this.audienceRating,
|
||||
this.userRating,
|
||||
this.year,
|
||||
this.originallyAvailableAt,
|
||||
this.thumb,
|
||||
@@ -180,6 +182,7 @@ class PlexMetadata with MultiServerFields {
|
||||
String? summary,
|
||||
double? rating,
|
||||
double? audienceRating,
|
||||
double? userRating,
|
||||
int? year,
|
||||
String? originallyAvailableAt,
|
||||
String? thumb,
|
||||
@@ -230,6 +233,7 @@ class PlexMetadata with MultiServerFields {
|
||||
summary: summary ?? this.summary,
|
||||
rating: rating ?? this.rating,
|
||||
audienceRating: audienceRating ?? this.audienceRating,
|
||||
userRating: userRating ?? this.userRating,
|
||||
year: year ?? this.year,
|
||||
originallyAvailableAt: originallyAvailableAt ?? this.originallyAvailableAt,
|
||||
thumb: thumb ?? this.thumb,
|
||||
|
||||
@@ -18,6 +18,7 @@ PlexMetadata _$PlexMetadataFromJson(Map<String, dynamic> json) => PlexMetadata(
|
||||
summary: json['summary'] as String?,
|
||||
rating: (json['rating'] as num?)?.toDouble(),
|
||||
audienceRating: (json['audienceRating'] as num?)?.toDouble(),
|
||||
userRating: (json['userRating'] as num?)?.toDouble(),
|
||||
year: (json['year'] as num?)?.toInt(),
|
||||
originallyAvailableAt: json['originallyAvailableAt'] as String?,
|
||||
thumb: json['thumb'] as String?,
|
||||
@@ -67,6 +68,7 @@ Map<String, dynamic> _$PlexMetadataToJson(PlexMetadata instance) => <String, dyn
|
||||
'summary': instance.summary,
|
||||
'rating': instance.rating,
|
||||
'audienceRating': instance.audienceRating,
|
||||
'userRating': instance.userRating,
|
||||
'year': instance.year,
|
||||
'originallyAvailableAt': instance.originallyAvailableAt,
|
||||
'thumb': instance.thumb,
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/// Represents a contiguous buffered range in the demuxer cache.
|
||||
class BufferRange {
|
||||
final Duration start;
|
||||
final Duration end;
|
||||
const BufferRange({required this.start, required this.end});
|
||||
}
|
||||
|
||||
/// Log level for player messages.
|
||||
enum PlayerLogLevel {
|
||||
/// No logging.
|
||||
|
||||
@@ -176,9 +176,18 @@ abstract class PlayerBase with PlayerStreamControllersMixin implements Player {
|
||||
final buffer = Duration(milliseconds: (value * 1000).toInt());
|
||||
_state = _state.copyWith(buffer: buffer);
|
||||
bufferController.add(buffer);
|
||||
// Synthesize a single range for players without demuxer-cache-state (ExoPlayer).
|
||||
// ExoPlayer only buffers ahead of the current position, so use position as start.
|
||||
final ranges = [BufferRange(start: _state.position, end: buffer)];
|
||||
_state = _state.copyWith(bufferRanges: ranges);
|
||||
bufferRangesController.add(ranges);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'demuxer-cache-state':
|
||||
_handleDemuxerCacheState(value);
|
||||
break;
|
||||
|
||||
case 'volume':
|
||||
if (value is num) {
|
||||
final volume = value.toDouble();
|
||||
@@ -259,6 +268,48 @@ abstract class PlayerBase with PlayerStreamControllersMixin implements Player {
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse demuxer-cache-state property to extract seekable ranges and buffer end.
|
||||
void _handleDemuxerCacheState(dynamic value) {
|
||||
Map? cacheState;
|
||||
if (value is Map) {
|
||||
cacheState = value;
|
||||
} else if (value is String && value.isNotEmpty) {
|
||||
try {
|
||||
final parsed = jsonDecode(value);
|
||||
if (parsed is Map) cacheState = parsed;
|
||||
} catch (_) {}
|
||||
}
|
||||
if (cacheState == null) return;
|
||||
|
||||
// Extract cache-end for the single buffer duration (replaces demuxer-cache-time)
|
||||
final cacheEnd = cacheState['cache-end'] as num?;
|
||||
if (cacheEnd != null) {
|
||||
final buffer = Duration(milliseconds: (cacheEnd * 1000).toInt());
|
||||
_state = _state.copyWith(buffer: buffer);
|
||||
bufferController.add(buffer);
|
||||
}
|
||||
|
||||
// Extract seekable-ranges array
|
||||
final seekableRanges = cacheState['seekable-ranges'];
|
||||
if (seekableRanges is List) {
|
||||
final ranges = <BufferRange>[];
|
||||
for (final range in seekableRanges) {
|
||||
if (range is Map) {
|
||||
final start = range['start'] as num?;
|
||||
final end = range['end'] as num?;
|
||||
if (start != null && end != null) {
|
||||
ranges.add(BufferRange(
|
||||
start: Duration(milliseconds: (start * 1000).toInt()),
|
||||
end: Duration(milliseconds: (end * 1000).toInt()),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
_state = _state.copyWith(bufferRanges: ranges);
|
||||
bufferRangesController.add(ranges);
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle a player event from the platform.
|
||||
/// Subclasses can override this to handle platform-specific events.
|
||||
void handlePlayerEvent(String name, Map? data) {
|
||||
@@ -280,6 +331,10 @@ abstract class PlayerBase with PlayerStreamControllersMixin implements Player {
|
||||
break;
|
||||
|
||||
case 'playback-restart':
|
||||
// Clear stale buffer ranges from before the seek; fresh ones will
|
||||
// arrive shortly via the next demuxer-cache-state update.
|
||||
_state = _state.copyWith(bufferRanges: const []);
|
||||
bufferRangesController.add(const []);
|
||||
playbackRestartController.add(null);
|
||||
break;
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@ class PlayerNative extends PlayerBase {
|
||||
@override
|
||||
String get playerType => 'mpv';
|
||||
|
||||
/// Node properties are returned as structured maps on macOS/iOS/Linux,
|
||||
/// but as JSON strings on Android/Windows.
|
||||
static final String _nodeFormat = (Platform.isAndroid || Platform.isWindows) ? 'string' : 'node';
|
||||
|
||||
// ============================================
|
||||
// Initialization
|
||||
// ============================================
|
||||
@@ -58,13 +62,14 @@ class PlayerNative extends PlayerBase {
|
||||
await observeProperty('duration', 'double');
|
||||
await observeProperty('pause', 'flag');
|
||||
await observeProperty('paused-for-cache', 'flag');
|
||||
await observeProperty('track-list', (Platform.isAndroid || Platform.isWindows) ? 'string' : 'node');
|
||||
await observeProperty('track-list', _nodeFormat);
|
||||
await observeProperty('eof-reached', 'flag');
|
||||
await observeProperty('volume', 'double');
|
||||
await observeProperty('speed', 'double');
|
||||
await observeProperty('aid', 'string');
|
||||
await observeProperty('sid', 'string');
|
||||
await observeProperty('audio-device-list', (Platform.isAndroid || Platform.isWindows) ? 'string' : 'node');
|
||||
await observeProperty('demuxer-cache-state', _nodeFormat);
|
||||
await observeProperty('audio-device-list', _nodeFormat);
|
||||
await observeProperty('audio-device', 'string');
|
||||
} catch (e) {
|
||||
errorController.add('Initialization failed: $e');
|
||||
|
||||
@@ -50,6 +50,9 @@ class PlayerState {
|
||||
/// Available audio output devices.
|
||||
final List<AudioDevice> audioDevices;
|
||||
|
||||
/// Seekable buffered ranges from the demuxer cache.
|
||||
final List<BufferRange> bufferRanges;
|
||||
|
||||
const PlayerState({
|
||||
this.playing = false,
|
||||
this.completed = false,
|
||||
@@ -66,6 +69,7 @@ class PlayerState {
|
||||
this.audioPassthrough = false,
|
||||
this.audioDevice = AudioDevice.auto,
|
||||
this.audioDevices = const [],
|
||||
this.bufferRanges = const [],
|
||||
});
|
||||
|
||||
/// Creates a copy with the given fields replaced.
|
||||
@@ -85,6 +89,7 @@ class PlayerState {
|
||||
bool? audioPassthrough,
|
||||
AudioDevice? audioDevice,
|
||||
List<AudioDevice>? audioDevices,
|
||||
List<BufferRange>? bufferRanges,
|
||||
}) {
|
||||
return PlayerState(
|
||||
playing: playing ?? this.playing,
|
||||
@@ -102,6 +107,7 @@ class PlayerState {
|
||||
audioPassthrough: audioPassthrough ?? this.audioPassthrough,
|
||||
audioDevice: audioDevice ?? this.audioDevice,
|
||||
audioDevices: audioDevices ?? this.audioDevices,
|
||||
bufferRanges: bufferRanges ?? this.bufferRanges,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ mixin PlayerStreamControllersMixin {
|
||||
final errorController = StreamController<String>.broadcast();
|
||||
final audioDeviceController = StreamController<AudioDevice>.broadcast();
|
||||
final audioDevicesController = StreamController<List<AudioDevice>>.broadcast();
|
||||
final bufferRangesController = StreamController<List<BufferRange>>.broadcast();
|
||||
final playbackRestartController = StreamController<void>.broadcast();
|
||||
final backendSwitchedController = StreamController<void>.broadcast();
|
||||
|
||||
@@ -43,6 +44,7 @@ mixin PlayerStreamControllersMixin {
|
||||
error: errorController.stream,
|
||||
audioDevice: audioDeviceController.stream,
|
||||
audioDevices: audioDevicesController.stream,
|
||||
bufferRanges: bufferRangesController.stream,
|
||||
playbackRestart: playbackRestartController.stream,
|
||||
backendSwitched: backendSwitchedController.stream,
|
||||
);
|
||||
@@ -64,6 +66,7 @@ mixin PlayerStreamControllersMixin {
|
||||
await errorController.close();
|
||||
await audioDeviceController.close();
|
||||
await audioDevicesController.close();
|
||||
await bufferRangesController.close();
|
||||
await playbackRestartController.close();
|
||||
await backendSwitchedController.close();
|
||||
}
|
||||
|
||||
@@ -50,6 +50,9 @@ class PlayerStreams {
|
||||
/// Stream that emits when playback restarts (first frame ready after load/seek).
|
||||
final Stream<void> playbackRestart;
|
||||
|
||||
/// Stream of seekable buffer ranges from the demuxer cache.
|
||||
final Stream<List<BufferRange>> bufferRanges;
|
||||
|
||||
/// Stream that emits when the native player backend switches (e.g., ExoPlayer to MPV).
|
||||
/// Only emitted on Android when ExoPlayer encounters an unsupported format.
|
||||
final Stream<void> backendSwitched;
|
||||
@@ -69,6 +72,7 @@ class PlayerStreams {
|
||||
required this.error,
|
||||
required this.audioDevice,
|
||||
required this.audioDevices,
|
||||
required this.bufferRanges,
|
||||
required this.playbackRestart,
|
||||
required this.backendSwitched,
|
||||
});
|
||||
|
||||
@@ -57,6 +57,12 @@ class PlaybackStateProvider with ChangeNotifier {
|
||||
/// Current play queue ID
|
||||
int? get playQueueId => _playQueueId;
|
||||
|
||||
/// The currently loaded queue items (windowed subset of full queue)
|
||||
List<PlexMetadata> get loadedItems => List.unmodifiable(_loadedItems);
|
||||
|
||||
/// The current play queue item ID
|
||||
int? get currentPlayQueueItemID => _currentPlayQueueItemID;
|
||||
|
||||
/// Total number of items in the play queue
|
||||
int get queueLength => _playQueueTotalCount;
|
||||
|
||||
|
||||
@@ -223,14 +223,13 @@ class UserProfileProvider extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> switchToUser(PlexHomeUser user, BuildContext? context) async {
|
||||
Future<bool> switchToUser(PlexHomeUser user, BuildContext? context, {bool verifyPin = false}) async {
|
||||
if (_authService == null || _storageService == null) {
|
||||
_setError('Services not initialized');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (user.uuid == _currentUser?.uuid) {
|
||||
// Already on this user
|
||||
if (user.uuid == _currentUser?.uuid && !(verifyPin && user.requiresPassword)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,8 +143,9 @@ class _PairingScreenState extends State<PairingScreen> {
|
||||
if (data == _lastScannedCode) return;
|
||||
_lastScannedCode = data;
|
||||
|
||||
// New format: ip|port|sessionId|pin (4 parts separated by pipe)
|
||||
final parts = data.split('|');
|
||||
// Strip URL wrapper if present (e.g. "https://plezy.app/scan#ip|port|sid|pin")
|
||||
final payload = data.contains('#') ? data.split('#').last : data;
|
||||
final parts = payload.split('|');
|
||||
if (parts.length == 4) {
|
||||
final ip = parts.first;
|
||||
final port = parts[1];
|
||||
|
||||
@@ -10,9 +10,17 @@ import '../providers/settings_provider.dart';
|
||||
import '../services/settings_service.dart';
|
||||
import '../utils/provider_extensions.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import '../widgets/media_grid_sliver.dart';
|
||||
import '../widgets/focused_scroll_scaffold.dart';
|
||||
import '../utils/grid_size_calculator.dart';
|
||||
import '../widgets/focusable_media_card.dart';
|
||||
import '../widgets/media_grid_delegate.dart';
|
||||
import '../widgets/desktop_app_bar.dart';
|
||||
import '../widgets/overlay_sheet.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import '../focus/dpad_navigator.dart';
|
||||
import '../focus/focus_theme.dart';
|
||||
import '../focus/input_mode_tracker.dart';
|
||||
import '../focus/key_event_utils.dart';
|
||||
import '../mixins/grid_focus_node_mixin.dart';
|
||||
import 'libraries/sort_bottom_sheet.dart';
|
||||
import 'libraries/state_messages.dart';
|
||||
import '../mixins/refreshable.dart';
|
||||
@@ -28,7 +36,7 @@ class HubDetailScreen extends StatefulWidget {
|
||||
State<HubDetailScreen> createState() => _HubDetailScreenState();
|
||||
}
|
||||
|
||||
class _HubDetailScreenState extends State<HubDetailScreen> with Refreshable {
|
||||
class _HubDetailScreenState extends State<HubDetailScreen> with Refreshable, GridFocusNodeMixin {
|
||||
PlexClient get client => _getClientForHub();
|
||||
|
||||
List<PlexMetadata> _items = [];
|
||||
@@ -39,6 +47,14 @@ class _HubDetailScreenState extends State<HubDetailScreen> with Refreshable {
|
||||
bool _isLoading = false;
|
||||
String? _errorMessage;
|
||||
|
||||
late final FocusNode _firstItemFocusNode = FocusNode(debugLabel: 'hub_detail_first_item');
|
||||
late final FocusNode _sortButtonFocusNode = FocusNode(debugLabel: 'hub_detail_sort');
|
||||
bool _isAppBarFocused = false;
|
||||
bool _backHandledByKeyEvent = false;
|
||||
|
||||
/// Key for getting a context below OverlaySheetHost
|
||||
final GlobalKey _overlayChildKey = GlobalKey();
|
||||
|
||||
/// Get the correct PlexClient for this hub's server
|
||||
PlexClient _getClientForHub() {
|
||||
return context.getClientForServer(widget.hub.serverId!);
|
||||
@@ -47,6 +63,7 @@ class _HubDetailScreenState extends State<HubDetailScreen> with Refreshable {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_sortButtonFocusNode.addListener(_onSortButtonFocusChange);
|
||||
// Start with items already loaded in the hub
|
||||
_items = widget.hub.items;
|
||||
_filteredItems = widget.hub.items;
|
||||
@@ -56,6 +73,72 @@ class _HubDetailScreenState extends State<HubDetailScreen> with Refreshable {
|
||||
}
|
||||
// Load sorts based on the library type
|
||||
_loadSorts();
|
||||
// Auto-focus first grid item in keyboard mode after first frame
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
if (InputModeTracker.isKeyboardMode(context) && _filteredItems.isNotEmpty) {
|
||||
_firstItemFocusNode.requestFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_sortButtonFocusNode.removeListener(_onSortButtonFocusChange);
|
||||
_firstItemFocusNode.dispose();
|
||||
_sortButtonFocusNode.dispose();
|
||||
disposeGridFocusNodes();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _onSortButtonFocusChange() {
|
||||
if (!mounted) return;
|
||||
final hasFocus = _sortButtonFocusNode.hasFocus;
|
||||
if (hasFocus && !_isAppBarFocused) {
|
||||
setState(() => _isAppBarFocused = true);
|
||||
} else if (!hasFocus && _isAppBarFocused) {
|
||||
setState(() => _isAppBarFocused = false);
|
||||
}
|
||||
}
|
||||
|
||||
void _focusGrid() {
|
||||
if (_filteredItems.isEmpty) return;
|
||||
final targetIndex =
|
||||
shouldRestoreGridFocus && lastFocusedGridIndex! < _filteredItems.length ? lastFocusedGridIndex! : 0;
|
||||
if (targetIndex == 0) {
|
||||
_firstItemFocusNode.requestFocus();
|
||||
} else {
|
||||
getGridItemFocusNode(targetIndex, prefix: 'hub_detail_item').requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void _navigateToAppBar() {
|
||||
setState(() => _isAppBarFocused = true);
|
||||
_sortButtonFocusNode.requestFocus();
|
||||
}
|
||||
|
||||
void _handleBackFromContent() {
|
||||
_backHandledByKeyEvent = true;
|
||||
_navigateToAppBar();
|
||||
}
|
||||
|
||||
KeyEventResult _handleSortButtonKeyEvent(FocusNode _, KeyEvent event) {
|
||||
final key = event.logicalKey;
|
||||
|
||||
final backResult = handleBackKeyAction(event, () => Navigator.pop(context));
|
||||
if (backResult != KeyEventResult.ignored) return backResult;
|
||||
|
||||
if (event is! KeyDownEvent) return KeyEventResult.ignored;
|
||||
|
||||
if (key.isDownKey) {
|
||||
_focusGrid();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (key.isSelectKey) {
|
||||
_showSortBottomSheet();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
||||
Future<void> _loadSorts() async {
|
||||
@@ -153,7 +236,8 @@ class _HubDetailScreenState extends State<HubDetailScreen> with Refreshable {
|
||||
}
|
||||
|
||||
void _showSortBottomSheet() {
|
||||
OverlaySheetController.of(context).show(
|
||||
final overlayContext = _overlayChildKey.currentContext ?? context;
|
||||
OverlaySheetController.of(overlayContext).show(
|
||||
builder: (context) => SortBottomSheet(
|
||||
sortOptions: _sortOptions,
|
||||
selectedSort: _selectedSort,
|
||||
@@ -230,58 +314,126 @@ class _HubDetailScreenState extends State<HubDetailScreen> with Refreshable {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return OverlaySheetHost(
|
||||
child: FocusedScrollScaffold(
|
||||
title: Text(widget.hub.title),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: AppIcon(Symbols.swap_vert_rounded, fill: 1, semanticLabel: t.libraries.sort),
|
||||
onPressed: _showSortBottomSheet,
|
||||
),
|
||||
],
|
||||
slivers: [
|
||||
if (_errorMessage != null)
|
||||
SliverFillRemaining(
|
||||
child: ErrorStateWidget(
|
||||
message: _errorMessage!,
|
||||
icon: Symbols.error_outline_rounded,
|
||||
onRetry: _loadMoreItems,
|
||||
final isKeyboardMode = InputModeTracker.isKeyboardMode(context);
|
||||
final sortButtonFocused = isKeyboardMode && _isAppBarFocused;
|
||||
|
||||
return PopScope(
|
||||
canPop: !isKeyboardMode || _isAppBarFocused,
|
||||
onPopInvokedWithResult: (didPop, _) {
|
||||
if (didPop || _backHandledByKeyEvent) {
|
||||
_backHandledByKeyEvent = false;
|
||||
return;
|
||||
}
|
||||
_navigateToAppBar();
|
||||
},
|
||||
child: OverlaySheetHost(
|
||||
child: Scaffold(
|
||||
key: _overlayChildKey,
|
||||
body: CustomScrollView(
|
||||
clipBehavior: Clip.none,
|
||||
slivers: [
|
||||
CustomAppBar(
|
||||
title: Text(widget.hub.title),
|
||||
pinned: true,
|
||||
actions: [
|
||||
Focus(
|
||||
focusNode: _sortButtonFocusNode,
|
||||
onKeyEvent: _handleSortButtonKeyEvent,
|
||||
child: Container(
|
||||
decoration: FocusTheme.focusBackgroundDecoration(isFocused: sortButtonFocused, borderRadius: 20),
|
||||
child: IconButton(
|
||||
icon: AppIcon(Symbols.swap_vert_rounded, fill: 1, semanticLabel: t.libraries.sort),
|
||||
onPressed: _showSortBottomSheet,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
else if (_filteredItems.isEmpty && _isLoading)
|
||||
const SliverFillRemaining(child: Center(child: CircularProgressIndicator()))
|
||||
else if (_filteredItems.isEmpty)
|
||||
SliverFillRemaining(child: Center(child: Text(t.hubDetail.noItemsFound)))
|
||||
else
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final episodePosterMode = context.watch<SettingsProvider>().episodePosterMode;
|
||||
if (_errorMessage != null)
|
||||
SliverFillRemaining(
|
||||
child: ErrorStateWidget(
|
||||
message: _errorMessage!,
|
||||
icon: Symbols.error_outline_rounded,
|
||||
onRetry: _loadMoreItems,
|
||||
),
|
||||
)
|
||||
else if (_filteredItems.isEmpty && _isLoading)
|
||||
const SliverFillRemaining(child: Center(child: CircularProgressIndicator()))
|
||||
else if (_filteredItems.isEmpty)
|
||||
SliverFillRemaining(child: Center(child: Text(t.hubDetail.noItemsFound)))
|
||||
else
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final settings = context.watch<SettingsProvider>();
|
||||
final episodePosterMode = settings.episodePosterMode;
|
||||
|
||||
// Determine hub content type for layout decisions
|
||||
final hasEpisodes = _filteredItems.any((item) => item.usesWideAspectRatio(episodePosterMode));
|
||||
final hasNonEpisodes = _filteredItems.any((item) => !item.usesWideAspectRatio(episodePosterMode));
|
||||
// Determine hub content type for layout decisions
|
||||
final hasEpisodes = _filteredItems.any((item) => item.usesWideAspectRatio(episodePosterMode));
|
||||
final hasNonEpisodes = _filteredItems.any((item) => !item.usesWideAspectRatio(episodePosterMode));
|
||||
|
||||
// Mixed hub = has both episodes AND non-episodes
|
||||
final isMixedHub = hasEpisodes && hasNonEpisodes;
|
||||
// Mixed hub = has both episodes AND non-episodes
|
||||
final isMixedHub = hasEpisodes && hasNonEpisodes;
|
||||
|
||||
// Episode-only = all items are episodes with thumbnails
|
||||
final isEpisodeOnlyHub = hasEpisodes && !hasNonEpisodes;
|
||||
// Episode-only = all items are episodes with thumbnails
|
||||
final isEpisodeOnlyHub = hasEpisodes && !hasNonEpisodes;
|
||||
|
||||
// Use 16:9 for episode-only hubs OR mixed hubs (with episode thumbnail mode)
|
||||
final useWideLayout =
|
||||
episodePosterMode == EpisodePosterMode.episodeThumbnail && (isEpisodeOnlyHub || isMixedHub);
|
||||
// Use 16:9 for episode-only hubs OR mixed hubs (with episode thumbnail mode)
|
||||
final useWideLayout =
|
||||
episodePosterMode == EpisodePosterMode.episodeThumbnail && (isEpisodeOnlyHub || isMixedHub);
|
||||
|
||||
return MediaGridSliver(
|
||||
items: _filteredItems,
|
||||
onRefresh: _handleItemRefresh,
|
||||
usePaddingAwareExtent: true,
|
||||
horizontalPadding: 16,
|
||||
useWideAspectRatio: useWideLayout,
|
||||
mixedHubContext: isMixedHub,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
return SliverPadding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 8, 8, 8),
|
||||
sliver: SliverLayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final maxExtent = GridSizeCalculator.getMaxCrossAxisExtentWithPadding(
|
||||
context,
|
||||
settings.libraryDensity,
|
||||
16,
|
||||
);
|
||||
final columnCount = GridSizeCalculator.getColumnCount(
|
||||
constraints.crossAxisExtent,
|
||||
useWideLayout ? maxExtent * 1.8 : maxExtent,
|
||||
);
|
||||
|
||||
return SliverGrid(
|
||||
gridDelegate: MediaGridDelegate.createDelegate(
|
||||
context: context,
|
||||
density: settings.libraryDensity,
|
||||
usePaddingAware: true,
|
||||
horizontalPadding: 16,
|
||||
useWideAspectRatio: useWideLayout,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
final item = _filteredItems[index];
|
||||
final focusNode = index == 0
|
||||
? _firstItemFocusNode
|
||||
: getGridItemFocusNode(index, prefix: 'hub_detail_item');
|
||||
final isFirstRow = GridSizeCalculator.isFirstRow(index, columnCount);
|
||||
final isFirstColumn = GridSizeCalculator.isFirstColumn(index, columnCount);
|
||||
|
||||
return FocusableMediaCard(
|
||||
focusNode: focusNode,
|
||||
item: item,
|
||||
onRefresh: _handleItemRefresh,
|
||||
onNavigateUp: isFirstRow ? _navigateToAppBar : null,
|
||||
onNavigateLeft: isFirstColumn ? () {} : null,
|
||||
onBack: _handleBackFromContent,
|
||||
onFocusChange: (hasFocus) => trackGridItemFocus(index, hasFocus),
|
||||
mixedHubContext: isMixedHub,
|
||||
);
|
||||
},
|
||||
childCount: _filteredItems.length,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -649,6 +649,13 @@ class _LibraryBrowseTabState extends BaseLibraryTabState<PlexMetadata, LibraryBr
|
||||
/// Whether the device is a phone (not tablet/desktop/TV).
|
||||
bool _isPhone(BuildContext context) => PlatformDetector.isPhone(context);
|
||||
|
||||
/// The letter currently visible at the top of the grid, determined by
|
||||
/// how many items we've scrolled past relative to the API's cumulative
|
||||
/// firstCharacter counts.
|
||||
String get _currentAlphaLetter {
|
||||
return _alphaHelper.currentLetter(_currentFirstVisibleIndex);
|
||||
}
|
||||
|
||||
/// Whether the alpha jump bar should be shown.
|
||||
/// Only shown when sorting by title (titleSort) and not in folders mode.
|
||||
bool get _shouldShowAlphaJumpBar {
|
||||
@@ -736,51 +743,23 @@ class _LibraryBrowseTabState extends BaseLibraryTabState<PlexMetadata, LibraryBr
|
||||
}
|
||||
|
||||
/// Scroll to the item at [targetIndex], loading more pages if necessary.
|
||||
/// Pins the index so scroll events during the animation don't override
|
||||
/// the highlighted letter. The pin is cleared on the next user scroll.
|
||||
///
|
||||
/// The [targetIndex] comes from [AlphaJumpHelper] which derives cumulative
|
||||
/// indices from the `firstCharacters` API. That API may count by display
|
||||
/// title (e.g. "The Simpsons" → T), while the grid sorts by `titleSort`
|
||||
/// (e.g. "Simpsons" → S). We correct for this by searching the loaded
|
||||
/// items' `titleSort` for the true start of the target letter.
|
||||
/// The target index is a cumulative offset from the API's firstCharacter
|
||||
/// counts — the same model used by [_currentAlphaLetter] so highlight
|
||||
/// and jump always agree.
|
||||
void _jumpToIndex(int targetIndex) {
|
||||
_jumpScrollGeneration++;
|
||||
_isJumpScrolling = true;
|
||||
|
||||
// Determine the intended letter from the helper's model
|
||||
final targetLetter = _alphaHelper.currentLetter(targetIndex);
|
||||
|
||||
// Correct the index using actual items' titleSort when available
|
||||
final correctedIndex = _findFirstItemForLetter(targetLetter) ?? targetIndex;
|
||||
|
||||
_hasJumpPin = true;
|
||||
setState(() => _currentFirstVisibleIndex = correctedIndex);
|
||||
setState(() => _currentFirstVisibleIndex = targetIndex);
|
||||
|
||||
if (correctedIndex < items.length) {
|
||||
_scrollToItemIndex(correctedIndex);
|
||||
if (targetIndex < items.length) {
|
||||
_scrollToItemIndex(targetIndex);
|
||||
} else {
|
||||
_loadUntilIndex(correctedIndex);
|
||||
_loadUntilIndex(targetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the first character (A-Z or #) of an item's sort title.
|
||||
static String _sortTitleFirstChar(String title) {
|
||||
if (title.isEmpty) return '#';
|
||||
final ch = title[0].toUpperCase();
|
||||
return ch.codeUnitAt(0) >= 65 && ch.codeUnitAt(0) <= 90 ? ch : '#';
|
||||
}
|
||||
|
||||
/// Find the index of the first loaded item whose `titleSort` starts with
|
||||
/// [letter]. Returns null if no match is found (e.g. items not yet loaded).
|
||||
int? _findFirstItemForLetter(String letter) {
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
final sortTitle = items[i].titleSort ?? items[i].title;
|
||||
if (_sortTitleFirstChar(sortTitle) == letter) return i;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Scroll the grid so that [index] is visible just below the chips bar
|
||||
void _scrollToItemIndex(int index) {
|
||||
if (_currentColumnCount < 1 || _lastCrossAxisExtent <= 0 || !_scrollController.hasClients) {
|
||||
@@ -867,13 +846,13 @@ class _LibraryBrowseTabState extends BaseLibraryTabState<PlexMetadata, LibraryBr
|
||||
? AlphaScrollHandle(
|
||||
firstCharacters: _firstCharacters,
|
||||
onJump: _jumpToIndex,
|
||||
currentFirstVisibleIndex: _currentFirstVisibleIndex,
|
||||
currentLetter: _currentAlphaLetter,
|
||||
isScrolling: _isScrollActive,
|
||||
)
|
||||
: AlphaJumpBar(
|
||||
firstCharacters: _firstCharacters,
|
||||
onJump: _jumpToIndex,
|
||||
currentFirstVisibleIndex: _currentFirstVisibleIndex,
|
||||
currentLetter: _currentAlphaLetter,
|
||||
focusNode: _alphaJumpBarFocusNode,
|
||||
onNavigateLeft: _navigateToGridNearScroll,
|
||||
onBack: _navigateToGridNearScroll,
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:plezy/widgets/app_icon.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../widgets/collapsible_text.dart';
|
||||
import '../widgets/rating_bottom_sheet.dart';
|
||||
|
||||
import '../focus/dpad_navigator.dart';
|
||||
import '../focus/focusable_wrapper.dart';
|
||||
@@ -75,6 +76,7 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
int _focusedSeasonIndex = 0;
|
||||
late final FocusNode _seasonsFocusNode;
|
||||
late final FocusNode _playButtonFocusNode;
|
||||
late final FocusNode _ratingChipFocusNode;
|
||||
Timer? _selectKeyTimer;
|
||||
bool _isSelectKeyDown = false;
|
||||
bool _longPressTriggered = false;
|
||||
@@ -256,6 +258,7 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
_seasonsFocusNode = FocusNode(debugLabel: 'seasons_row');
|
||||
_extrasFocusNode = FocusNode(debugLabel: 'extras_row');
|
||||
_playButtonFocusNode = FocusNode(debugLabel: 'play_button');
|
||||
_ratingChipFocusNode = FocusNode(debugLabel: 'rating_chip');
|
||||
_overviewFocusNode = FocusNode(debugLabel: 'overview');
|
||||
_castFocusNode = FocusNode(debugLabel: 'cast_row');
|
||||
_loadFullMetadata();
|
||||
@@ -275,6 +278,7 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
_seasonsFocusNode.dispose();
|
||||
_extrasFocusNode.dispose();
|
||||
_playButtonFocusNode.dispose();
|
||||
_ratingChipFocusNode.dispose();
|
||||
_overviewFocusNode.dispose();
|
||||
_castFocusNode.dispose();
|
||||
_castScrollController.dispose();
|
||||
@@ -772,9 +776,97 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
chips.add(_buildRatingChip(metadata.audienceRatingImage, metadata.audienceRating!, Symbols.people_rounded));
|
||||
}
|
||||
}
|
||||
|
||||
// User rating chip (tappable)
|
||||
if (!widget.isOffline) {
|
||||
chips.add(_buildUserRatingChip(metadata));
|
||||
}
|
||||
|
||||
return chips;
|
||||
}
|
||||
|
||||
Widget _buildUserRatingChip(PlexMetadata metadata) {
|
||||
final hasRating = metadata.userRating != null && metadata.userRating! > 0;
|
||||
final starValue = hasRating ? metadata.userRating! / 2.0 : 0.0;
|
||||
|
||||
return FocusableWrapper(
|
||||
focusNode: _ratingChipFocusNode,
|
||||
onSelect: () => _showRatingDialog(metadata, starValue),
|
||||
borderRadius: 100,
|
||||
useBackgroundFocus: true,
|
||||
onKeyEvent: (_, event) {
|
||||
if (!event.isActionable) return KeyEventResult.ignored;
|
||||
final key = event.logicalKey;
|
||||
if (key.isDownKey) {
|
||||
_playButtonFocusNode.requestFocus();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (key.isUpKey) {
|
||||
return KeyEventResult.handled; // consume — nothing above
|
||||
}
|
||||
return KeyEventResult.ignored;
|
||||
},
|
||||
child: GestureDetector(
|
||||
onTap: () => _showRatingDialog(metadata, starValue),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.secondaryContainer.withValues(alpha: 0.8),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(100)),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
AppIcon(
|
||||
Symbols.star_rounded,
|
||||
fill: hasRating ? 1 : 0,
|
||||
color: hasRating
|
||||
? Colors.amber
|
||||
: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
hasRating
|
||||
? (starValue == starValue.truncateToDouble()
|
||||
? '${starValue.toInt()}'
|
||||
: starValue.toStringAsFixed(1))
|
||||
: t.mediaMenu.rate,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showRatingDialog(PlexMetadata metadata, double currentStarValue) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) => RatingBottomSheet(
|
||||
currentRating: currentStarValue,
|
||||
onRate: (stars) async {
|
||||
final client = _getClientForMetadata(this.context);
|
||||
if (client == null) return;
|
||||
final plexRating = stars * 2.0; // Convert 0-5 stars to 0-10 scale
|
||||
final success = await client.rateItem(metadata.ratingKey, plexRating);
|
||||
if (success) _updateWatchState();
|
||||
},
|
||||
onClear: () async {
|
||||
final client = _getClientForMetadata(this.context);
|
||||
if (client == null) return;
|
||||
final success = await client.rateItem(metadata.ratingKey, -1);
|
||||
if (success) _updateWatchState();
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Build a combined RT chip showing critic + audience side by side.
|
||||
Widget _buildCombinedRtChip(RatingInfo critic, RatingInfo audience) {
|
||||
final textStyle = TextStyle(
|
||||
@@ -1036,6 +1128,16 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
|
||||
KeyEventResult _handlePlayButtonKeyEvent(FocusNode _, KeyEvent event) {
|
||||
final key = event.logicalKey;
|
||||
if (!event.isActionable) return KeyEventResult.ignored;
|
||||
|
||||
// UP: focus the rating chip if available
|
||||
if (key.isUpKey) {
|
||||
if (!widget.isOffline) {
|
||||
_ratingChipFocusNode.requestFocus();
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
if (!key.isDownKey) return KeyEventResult.ignored;
|
||||
|
||||
final metadata = _fullMetadata ?? widget.metadata;
|
||||
@@ -2386,6 +2488,22 @@ class _SeasonCardState extends State<_SeasonCard> {
|
||||
t.discover.episodeCount(count: widget.season.leafCount.toString()),
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.grey),
|
||||
),
|
||||
if (widget.season.userRating != null && widget.season.userRating! > 0) ...[
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Padding(padding: EdgeInsets.only(top: 2), child: Icon(Symbols.star_rounded, size: 14, fill: 1, color: Colors.amber)),
|
||||
const SizedBox(width: 3),
|
||||
Text(
|
||||
(widget.season.userRating! / 2) == (widget.season.userRating! / 2).truncateToDouble()
|
||||
? '${(widget.season.userRating! / 2).toInt()}'
|
||||
: (widget.season.userRating! / 2).toStringAsFixed(1),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
// Hide watch progress when offline (not tracked)
|
||||
if (!widget.isOffline) ...[
|
||||
const SizedBox(height: 8),
|
||||
@@ -2473,3 +2591,4 @@ class _SeasonCardState extends State<_SeasonCard> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ class ProfileListTile extends StatelessWidget {
|
||||
final VoidCallback onTap;
|
||||
final bool isCurrentUser;
|
||||
final bool showTrailingIcon;
|
||||
final bool allowCurrentUserTap;
|
||||
|
||||
const ProfileListTile({
|
||||
super.key,
|
||||
@@ -20,6 +21,7 @@ class ProfileListTile extends StatelessWidget {
|
||||
required this.onTap,
|
||||
this.isCurrentUser = false,
|
||||
this.showTrailingIcon = true,
|
||||
this.allowCurrentUserTap = false,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -53,7 +55,7 @@ class ProfileListTile extends StatelessWidget {
|
||||
title: Text(user.displayName),
|
||||
subtitle: _hasUserAttributes() ? Row(children: _buildUserAttributes(theme)) : null,
|
||||
trailing: trailing,
|
||||
onTap: isCurrentUser ? null : onTap,
|
||||
onTap: isCurrentUser && !allowCurrentUserTap ? null : onTap,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,11 +98,12 @@ class _ProfileSwitchScreenState extends State<ProfileSwitchScreen> {
|
||||
autofocus: isFirstSelectable,
|
||||
focusNode: isFirstSelectable ? _firstSelectableFocusNode : null,
|
||||
disableScale: true,
|
||||
onSelect: isCurrentUser ? null : () => _switchToUser(context, user),
|
||||
onSelect: isCurrentUser && !widget.requireSelection ? null : () => _switchToUser(context, user),
|
||||
child: Card(
|
||||
child: ProfileListTile(
|
||||
user: user,
|
||||
isCurrentUser: isCurrentUser,
|
||||
allowCurrentUserTap: widget.requireSelection,
|
||||
onTap: () => _switchToUser(context, user),
|
||||
),
|
||||
),
|
||||
@@ -120,7 +121,7 @@ class _ProfileSwitchScreenState extends State<ProfileSwitchScreen> {
|
||||
void _switchToUser(BuildContext context, PlexHomeUser user) async {
|
||||
final userProvider = context.userProfile;
|
||||
final navigator = Navigator.of(context);
|
||||
final success = await userProvider.switchToUser(user, context);
|
||||
final success = await userProvider.switchToUser(user, context, verifyPin: widget.requireSelection);
|
||||
|
||||
if (success) {
|
||||
if (widget.requireSelection) {
|
||||
|
||||
@@ -348,24 +348,27 @@ class _EpisodeCardState extends State<_EpisodeCard> {
|
||||
}
|
||||
|
||||
Widget _buildEpisodeMetaRow(BuildContext context) {
|
||||
final mutedStyle = Theme.of(context).textTheme.bodySmall?.copyWith(color: tokens(context).textMuted, fontSize: 12);
|
||||
final dot = Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
child: Text('•', style: mutedStyle),
|
||||
);
|
||||
return Row(
|
||||
children: [
|
||||
if (widget.episode.duration != null)
|
||||
Text(
|
||||
formatDurationTimestamp(Duration(milliseconds: widget.episode.duration!)),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: tokens(context).textMuted, fontSize: 12),
|
||||
),
|
||||
if (widget.episode.duration != null) Text(formatDurationTimestamp(Duration(milliseconds: widget.episode.duration!)), style: mutedStyle),
|
||||
if (widget.episode.originallyAvailableAt != null) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
child: Text(
|
||||
'•',
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: tokens(context).textMuted, fontSize: 12),
|
||||
),
|
||||
),
|
||||
dot,
|
||||
Text(formatFullDate(widget.episode.originallyAvailableAt!), style: mutedStyle),
|
||||
],
|
||||
if (widget.episode.userRating != null && widget.episode.userRating! > 0) ...[
|
||||
dot,
|
||||
Padding(padding: const EdgeInsets.only(top: 2), child: Icon(Symbols.star_rounded, size: 12, fill: 1, color: Colors.amber)),
|
||||
const SizedBox(width: 2),
|
||||
Text(
|
||||
formatFullDate(widget.episode.originallyAvailableAt!),
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: tokens(context).textMuted, fontSize: 12),
|
||||
(widget.episode.userRating! / 2) == (widget.episode.userRating! / 2).truncateToDouble()
|
||||
? '${(widget.episode.userRating! / 2).toInt()}'
|
||||
: (widget.episode.userRating! / 2).toStringAsFixed(1),
|
||||
style: mutedStyle,
|
||||
),
|
||||
],
|
||||
],
|
||||
|
||||
@@ -40,6 +40,7 @@ import '../services/ambient_lighting_service.dart';
|
||||
import '../services/video_filter_manager.dart';
|
||||
import '../services/video_pip_manager.dart';
|
||||
import '../services/pip_service.dart';
|
||||
import '../models/shader_preset.dart';
|
||||
import '../services/shader_service.dart';
|
||||
import '../providers/shader_provider.dart';
|
||||
import '../providers/user_profile_provider.dart';
|
||||
@@ -1032,6 +1033,7 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
_videoFilterManager?.ambientLightingService = _ambientLightingService;
|
||||
|
||||
await _applySavedShaderPreset();
|
||||
await _restoreAmbientLighting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1147,6 +1149,39 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
}
|
||||
}
|
||||
|
||||
/// Restore ambient lighting from persisted setting
|
||||
Future<void> _restoreAmbientLighting() async {
|
||||
final settings = await SettingsService.getInstance();
|
||||
if (!settings.getAmbientLighting()) return;
|
||||
|
||||
final ambientLighting = _ambientLightingService;
|
||||
if (ambientLighting == null || !ambientLighting.isSupported) return;
|
||||
|
||||
// Same enable logic as _toggleAmbientLighting
|
||||
final dwidth = await player?.getProperty('dwidth');
|
||||
final dheight = await player?.getProperty('dheight');
|
||||
if (dwidth == null || dheight == null) return;
|
||||
final w = double.tryParse(dwidth);
|
||||
final h = double.tryParse(dheight);
|
||||
if (w == null || h == null || h == 0) return;
|
||||
final videoAspect = w / h;
|
||||
|
||||
final playerSize = _videoFilterManager?.playerSize;
|
||||
if (playerSize == null || playerSize.height == 0) return;
|
||||
final outputAspect = playerSize.width / playerSize.height;
|
||||
|
||||
// Clear shaders — ambient lighting and shaders are mutually exclusive
|
||||
final shaderProvider = context.read<ShaderProvider>();
|
||||
if (shaderProvider.isShaderEnabled) {
|
||||
await _shaderService!.applyPreset(ShaderPreset.none);
|
||||
shaderProvider.setCurrentPreset(ShaderPreset.none);
|
||||
}
|
||||
|
||||
_videoFilterManager?.resetToContain();
|
||||
await ambientLighting.enable(videoAspect, outputAspect);
|
||||
if (mounted) setState(() {});
|
||||
}
|
||||
|
||||
/// Cycle through BoxFit modes: contain → cover → fill → contain (for button)
|
||||
void _cycleBoxFitMode() {
|
||||
// Disable ambient lighting when switching boxfit modes
|
||||
@@ -1190,12 +1225,23 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
if (playerSize == null || playerSize.height == 0) return;
|
||||
final outputAspect = playerSize.width / playerSize.height;
|
||||
|
||||
// Clear shaders — ambient lighting and shaders are mutually exclusive
|
||||
final shaderProvider = context.read<ShaderProvider>();
|
||||
if (shaderProvider.isShaderEnabled) {
|
||||
await _shaderService!.applyPreset(ShaderPreset.none);
|
||||
shaderProvider.setCurrentPreset(ShaderPreset.none);
|
||||
}
|
||||
|
||||
// Force contain mode when enabling ambient lighting
|
||||
_videoFilterManager?.resetToContain();
|
||||
|
||||
await ambientLighting.enable(videoAspect, outputAspect);
|
||||
}
|
||||
|
||||
// Persist ambient lighting state
|
||||
final settings = await SettingsService.getInstance();
|
||||
settings.setAmbientLighting(ambientLighting.isEnabled);
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@@ -1712,6 +1758,12 @@ class VideoPlayerScreenState extends State<VideoPlayerScreen> with WidgetsBindin
|
||||
await _navigateToEpisode(_previousEpisode!);
|
||||
}
|
||||
|
||||
/// Navigate to a specific queue item (called from QueueSheet)
|
||||
Future<void> navigateToQueueItem(PlexMetadata metadata) async {
|
||||
_notifyWatchTogetherMediaChange(metadata: metadata);
|
||||
await _navigateToEpisode(metadata);
|
||||
}
|
||||
|
||||
bool _isSwitchingChannel = false;
|
||||
|
||||
/// Switch to an adjacent live TV channel (delta: +1 for next, -1 for previous)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:isolate';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
@@ -40,7 +41,7 @@ class PlexApiCache {
|
||||
final result = await (_db.select(_db.apiCache)..where((t) => t.cacheKey.equals(key))).getSingleOrNull();
|
||||
|
||||
if (result != null) {
|
||||
return jsonDecode(result.data) as Map<String, dynamic>;
|
||||
return await Isolate.run(() => jsonDecode(result.data) as Map<String, dynamic>);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -48,11 +49,10 @@ class PlexApiCache {
|
||||
/// Cache a response for an endpoint
|
||||
Future<void> put(String serverId, String endpoint, Map<String, dynamic> data) async {
|
||||
final key = _buildKey(serverId, endpoint);
|
||||
final encoded = await Isolate.run(() => jsonEncode(data));
|
||||
await _db
|
||||
.into(_db.apiCache)
|
||||
.insertOnConflictUpdate(
|
||||
ApiCacheCompanion(cacheKey: Value(key), data: Value(jsonEncode(data)), cachedAt: Value(DateTime.now())),
|
||||
);
|
||||
.insertOnConflictUpdate(ApiCacheCompanion(cacheKey: Value(key), data: Value(encoded), cachedAt: Value(DateTime.now())));
|
||||
}
|
||||
|
||||
/// Delete all cached data for a server
|
||||
@@ -130,27 +130,35 @@ class PlexApiCache {
|
||||
Future<Map<String, PlexMetadata>> getAllPinnedMetadata() async {
|
||||
final rows = await (_db.select(_db.apiCache)..where((t) => t.pinned.equals(true))).get();
|
||||
|
||||
final result = <String, PlexMetadata>{};
|
||||
// Extract (cacheKey, data) pairs and parse serverId/ratingKey on main thread (cheap string ops),
|
||||
// then send raw JSON strings to isolate for the expensive decode+parse.
|
||||
final entries = <(String serverId, String ratingKey, String data)>[];
|
||||
for (final row in rows) {
|
||||
// Extract serverId and ratingKey from cache key like "serverId:/library/metadata/12345"
|
||||
final colonIdx = row.cacheKey.indexOf(':');
|
||||
if (colonIdx < 0) continue;
|
||||
final serverId = row.cacheKey.substring(0, colonIdx);
|
||||
final match = RegExp(r'/library/metadata/([^/]+)$').firstMatch(row.cacheKey);
|
||||
if (match == null) continue;
|
||||
final ratingKey = match.group(1)!;
|
||||
|
||||
try {
|
||||
final data = jsonDecode(row.data) as Map<String, dynamic>;
|
||||
final json = PlexCacheParser.extractFirstMetadata(data);
|
||||
if (json == null) continue;
|
||||
final metadata = PlexMetadata.fromJsonWithImages(json).copyWith(serverId: serverId);
|
||||
result['$serverId:$ratingKey'] = metadata;
|
||||
} catch (_) {
|
||||
// Skip malformed entries
|
||||
}
|
||||
entries.add((serverId, match.group(1)!, row.data));
|
||||
}
|
||||
return result;
|
||||
|
||||
if (entries.isEmpty) return {};
|
||||
|
||||
return await Isolate.run(() {
|
||||
final result = <String, PlexMetadata>{};
|
||||
for (final (serverId, ratingKey, rawData) in entries) {
|
||||
try {
|
||||
final data = jsonDecode(rawData) as Map<String, dynamic>;
|
||||
final json = PlexCacheParser.extractFirstMetadata(data);
|
||||
if (json == null) continue;
|
||||
final metadata = PlexMetadata.fromJsonWithImages(json).copyWith(serverId: serverId);
|
||||
result['$serverId:$ratingKey'] = metadata;
|
||||
} catch (_) {
|
||||
// Skip malformed entries
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
/// Clear all cached data (useful for debugging/testing)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:isolate';
|
||||
import 'dart:math';
|
||||
import 'dart:ui' show VoidCallback;
|
||||
|
||||
@@ -33,6 +34,61 @@ import '../utils/plex_url_helper.dart';
|
||||
import '../utils/watch_state_notifier.dart';
|
||||
import 'plex_api_cache.dart';
|
||||
|
||||
/// Process hub JSON response in an isolate.
|
||||
/// Top-level function so it can be passed to [Isolate.run].
|
||||
List<PlexHub> _processHubResponse(String jsonStr, String serverId, String? serverName) {
|
||||
final decoded = jsonDecode(jsonStr) as Map<String, dynamic>;
|
||||
final container = decoded['MediaContainer'] as Map<String, dynamic>?;
|
||||
if (container == null || container['Hub'] == null) return [];
|
||||
|
||||
final hubs = <PlexHub>[];
|
||||
for (final hubJson in container['Hub'] as List) {
|
||||
try {
|
||||
final hub = PlexHub.fromJson(hubJson as Map<String, dynamic>);
|
||||
if (hub.items.isEmpty) continue;
|
||||
|
||||
final videoItems = hub.items
|
||||
.where((item) => item.isVideoContent)
|
||||
.map((item) => item.copyWith(serverId: serverId, serverName: serverName))
|
||||
.toList();
|
||||
|
||||
if (videoItems.isNotEmpty) {
|
||||
hubs.add(
|
||||
PlexHub(
|
||||
hubKey: hub.hubKey,
|
||||
title: hub.title,
|
||||
type: hub.type,
|
||||
hubIdentifier: hub.hubIdentifier,
|
||||
size: hub.size,
|
||||
more: hub.more,
|
||||
items: videoItems,
|
||||
serverId: serverId,
|
||||
serverName: serverName,
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (_) {
|
||||
// Skip hubs that fail to parse
|
||||
}
|
||||
}
|
||||
return hubs;
|
||||
}
|
||||
|
||||
/// Process on-deck JSON response in an isolate.
|
||||
/// Top-level function so it can be passed to [Isolate.run].
|
||||
List<PlexMetadata> _processOnDeckResponse(String jsonStr, String serverId, String? serverName) {
|
||||
final decoded = jsonDecode(jsonStr) as Map<String, dynamic>;
|
||||
final container = decoded['MediaContainer'] as Map<String, dynamic>?;
|
||||
if (container == null || container['Metadata'] == null) return [];
|
||||
|
||||
final allItems = (container['Metadata'] as List)
|
||||
.map((json) => PlexMetadata.fromJsonWithImages(json as Map<String, dynamic>)
|
||||
.copyWith(serverId: serverId, serverName: serverName))
|
||||
.toList();
|
||||
|
||||
return allItems.where((item) => !item.isMusicContent).toList();
|
||||
}
|
||||
|
||||
/// Constants for Plex stream types
|
||||
class PlexStreamType {
|
||||
static const int video = 1;
|
||||
@@ -702,17 +758,13 @@ class PlexClient {
|
||||
|
||||
/// Get on deck items (continue watching, filtered to video content only)
|
||||
Future<List<PlexMetadata>> getOnDeck() async {
|
||||
final response = await _dio.get('/library/onDeck');
|
||||
final container = _getMediaContainer(response);
|
||||
if (container != null && container['Metadata'] != null) {
|
||||
final allItems = (container['Metadata'] as List)
|
||||
.map((json) => _tagMetadata(PlexMetadata.fromJsonWithImages(json)))
|
||||
.toList();
|
||||
|
||||
// Filter out music content (artists, albums, tracks)
|
||||
return allItems.where((item) => !item.isMusicContent).toList();
|
||||
}
|
||||
return [];
|
||||
final response = await _dio.get(
|
||||
'/library/onDeck',
|
||||
options: Options(responseType: ResponseType.plain),
|
||||
);
|
||||
final sid = serverId;
|
||||
final sname = serverName;
|
||||
return Isolate.run(() => _processOnDeckResponse(response.data as String, sid, sname));
|
||||
}
|
||||
|
||||
/// Get on deck items filtered by a specific library section
|
||||
@@ -945,7 +997,7 @@ class PlexClient {
|
||||
}
|
||||
}
|
||||
|
||||
return PlaybackExtras(chapters: chapters, markers: markers);
|
||||
return PlaybackExtras.withChapterFallback(chapters: chapters, markers: markers);
|
||||
}
|
||||
|
||||
/// Get consolidated video playback data (URL, media info, versions, and markers) in a single API call.
|
||||
@@ -1177,6 +1229,19 @@ class PlexClient {
|
||||
await _dio.put('/actions/removeFromContinueWatching', queryParameters: {'ratingKey': ratingKey});
|
||||
}
|
||||
|
||||
/// Rate a media item (0.0-10.0 scale, where each integer = half a star)
|
||||
/// Pass -1 to clear an existing rating
|
||||
Future<bool> rateItem(String ratingKey, double rating) {
|
||||
return _wrapBoolApiCall(
|
||||
() => _dio.put('/:/rate', queryParameters: {
|
||||
'key': ratingKey,
|
||||
'identifier': 'com.plexapp.plugins.library',
|
||||
'rating': rating,
|
||||
}),
|
||||
'Failed to rate item',
|
||||
);
|
||||
}
|
||||
|
||||
/// Delete a media item from the library
|
||||
/// This permanently removes the item and its associated files from the server
|
||||
/// Returns true if deletion was successful, false otherwise
|
||||
@@ -1292,44 +1357,11 @@ class PlexClient {
|
||||
final response = await _dio.get(
|
||||
'/hubs/sections/$sectionId',
|
||||
queryParameters: {'count': limit, 'includeGuids': 1},
|
||||
options: Options(responseType: ResponseType.plain),
|
||||
);
|
||||
|
||||
final container = _getMediaContainer(response);
|
||||
if (container != null && container['Hub'] != null) {
|
||||
final hubs = <PlexHub>[];
|
||||
for (final hubJson in container['Hub'] as List) {
|
||||
try {
|
||||
final hub = PlexHub.fromJson(hubJson);
|
||||
// Only include hubs that have items and are movie/show content
|
||||
if (hub.items.isNotEmpty) {
|
||||
// Filter to only video content (movies, shows, seasons, episodes) and tag with server info
|
||||
final videoItems = hub.items
|
||||
.where((item) => item.isVideoContent)
|
||||
.map((item) => item.copyWith(serverId: serverId, serverName: serverName))
|
||||
.toList();
|
||||
|
||||
if (videoItems.isNotEmpty) {
|
||||
hubs.add(
|
||||
PlexHub(
|
||||
hubKey: hub.hubKey,
|
||||
title: hub.title,
|
||||
type: hub.type,
|
||||
hubIdentifier: hub.hubIdentifier,
|
||||
size: hub.size,
|
||||
more: hub.more,
|
||||
items: videoItems,
|
||||
serverId: serverId,
|
||||
serverName: serverName,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
appLogger.w('Failed to parse hub', error: e);
|
||||
}
|
||||
}
|
||||
return hubs;
|
||||
}
|
||||
final sid = serverId;
|
||||
final sname = serverName;
|
||||
return Isolate.run(() => _processHubResponse(response.data as String, sid, sname));
|
||||
} catch (e) {
|
||||
appLogger.e('Failed to get library hubs: $e');
|
||||
}
|
||||
@@ -1341,43 +1373,14 @@ class PlexClient {
|
||||
/// This matches the official Plex client's home page layout.
|
||||
Future<List<PlexHub>> getGlobalHubs({int limit = 10}) async {
|
||||
try {
|
||||
final response = await _dio.get('/hubs', queryParameters: {'count': limit, 'includeGuids': 1});
|
||||
|
||||
final container = _getMediaContainer(response);
|
||||
if (container != null && container['Hub'] != null) {
|
||||
final hubs = <PlexHub>[];
|
||||
for (final hubJson in container['Hub'] as List) {
|
||||
try {
|
||||
final hub = PlexHub.fromJson(hubJson);
|
||||
if (hub.items.isEmpty) continue;
|
||||
|
||||
// Filter to only video content (movies, shows, seasons, episodes) and tag with server info
|
||||
final videoItems = hub.items
|
||||
.where((item) => item.isVideoContent)
|
||||
.map((item) => item.copyWith(serverId: serverId, serverName: serverName))
|
||||
.toList();
|
||||
|
||||
if (videoItems.isNotEmpty) {
|
||||
hubs.add(
|
||||
PlexHub(
|
||||
hubKey: hub.hubKey,
|
||||
title: hub.title,
|
||||
type: hub.type,
|
||||
hubIdentifier: hub.hubIdentifier,
|
||||
size: hub.size,
|
||||
more: hub.more,
|
||||
items: videoItems,
|
||||
serverId: serverId,
|
||||
serverName: serverName,
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
appLogger.w('Failed to parse global hub', error: e);
|
||||
}
|
||||
}
|
||||
return hubs;
|
||||
}
|
||||
final response = await _dio.get(
|
||||
'/hubs',
|
||||
queryParameters: {'count': limit, 'includeGuids': 1},
|
||||
options: Options(responseType: ResponseType.plain),
|
||||
);
|
||||
final sid = serverId;
|
||||
final sname = serverName;
|
||||
return Isolate.run(() => _processHubResponse(response.data as String, sid, sname));
|
||||
} catch (e) {
|
||||
appLogger.e('Failed to get global hubs: $e');
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
static const String _keySelectedExternalPlayer = 'selected_external_player';
|
||||
static const String _keyCustomExternalPlayers = 'custom_external_players';
|
||||
static const String _keyConfirmExitOnBack = 'confirm_exit_on_back';
|
||||
static const String _keyAmbientLighting = 'ambient_lighting';
|
||||
|
||||
SettingsService._();
|
||||
|
||||
@@ -1117,6 +1118,15 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
return prefs.getBool(_keyConfirmExitOnBack) ?? true; // Default: enabled
|
||||
}
|
||||
|
||||
// Ambient Lighting
|
||||
Future<void> setAmbientLighting(bool enabled) async {
|
||||
await prefs.setBool(_keyAmbientLighting, enabled);
|
||||
}
|
||||
|
||||
bool getAmbientLighting() {
|
||||
return prefs.getBool(_keyAmbientLighting) ?? false;
|
||||
}
|
||||
|
||||
// Reset all settings to defaults
|
||||
Future<void> resetAllSettings() async {
|
||||
await Future.wait([
|
||||
@@ -1171,6 +1181,7 @@ class SettingsService extends BaseSharedPreferencesService {
|
||||
prefs.remove(_keySelectedExternalPlayer),
|
||||
prefs.remove(_keyCustomExternalPlayers),
|
||||
prefs.remove(_keyConfirmExitOnBack),
|
||||
prefs.remove(_keyAmbientLighting),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,15 +6,20 @@ import 'package:flutter/services.dart';
|
||||
import '../models/plex_first_character.dart';
|
||||
import 'alpha_jump_helper.dart';
|
||||
|
||||
/// Vertical strip of letters (#, A–Z) for jumping through sorted library items.
|
||||
/// Vertical strip of letters for jumping through sorted library items.
|
||||
///
|
||||
/// Pre-computes a cumulative index map from [firstCharacters] data so that
|
||||
/// tapping a letter triggers [onJump] with the item index where that letter
|
||||
/// begins. Supports both touch (tap/drag) and D-pad (up/down/select) input.
|
||||
/// begins. When more letters exist than fit vertically, the bar keeps the
|
||||
/// highest-count letters (by item size) and drops the rest.
|
||||
/// Supports both touch (tap/drag) and D-pad (up/down/select) input.
|
||||
class AlphaJumpBar extends StatefulWidget {
|
||||
final List<PlexFirstCharacter> firstCharacters;
|
||||
final void Function(int targetIndex) onJump;
|
||||
final int currentFirstVisibleIndex;
|
||||
|
||||
/// The letter currently visible at the top of the grid, derived from the
|
||||
/// actual item's sort title by the parent widget.
|
||||
final String currentLetter;
|
||||
final FocusNode? focusNode;
|
||||
final VoidCallback? onNavigateLeft;
|
||||
final VoidCallback? onBack;
|
||||
@@ -23,7 +28,7 @@ class AlphaJumpBar extends StatefulWidget {
|
||||
super.key,
|
||||
required this.firstCharacters,
|
||||
required this.onJump,
|
||||
required this.currentFirstVisibleIndex,
|
||||
required this.currentLetter,
|
||||
this.focusNode,
|
||||
this.onNavigateLeft,
|
||||
this.onBack,
|
||||
@@ -36,6 +41,12 @@ class AlphaJumpBar extends StatefulWidget {
|
||||
class _AlphaJumpBarState extends State<AlphaJumpBar> {
|
||||
late AlphaJumpHelper _helper;
|
||||
|
||||
/// Subset of letters actually rendered, filtered by available height.
|
||||
List<String> _displayed = const [];
|
||||
|
||||
/// Cached max-letter count from the last layout pass.
|
||||
int _lastMaxLetters = -1;
|
||||
|
||||
/// Currently highlighted letter index (for D-pad navigation).
|
||||
int _highlightedIndex = 0;
|
||||
|
||||
@@ -45,10 +56,14 @@ class _AlphaJumpBarState extends State<AlphaJumpBar> {
|
||||
/// Debounce timer for keyboard-driven jumps.
|
||||
Timer? _debounce;
|
||||
|
||||
/// Minimum vertical space per letter slot.
|
||||
static const double _minLetterHeight = 20.0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_helper = AlphaJumpHelper(widget.firstCharacters);
|
||||
_displayed = _helper.letters;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -56,6 +71,9 @@ class _AlphaJumpBarState extends State<AlphaJumpBar> {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.firstCharacters != widget.firstCharacters) {
|
||||
_helper = AlphaJumpHelper(widget.firstCharacters);
|
||||
_lastMaxLetters = -1; // force recompute in next layout
|
||||
_displayed = _helper.letters;
|
||||
_clampHighlight();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +83,36 @@ class _AlphaJumpBarState extends State<AlphaJumpBar> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _clampHighlight() {
|
||||
if (_displayed.isNotEmpty) {
|
||||
_highlightedIndex = _highlightedIndex.clamp(0, _displayed.length - 1);
|
||||
} else {
|
||||
_highlightedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// Recompute [_displayed] if the available letter count changed.
|
||||
void _updateDisplayed(double availableHeight) {
|
||||
final maxLetters = (availableHeight / _minLetterHeight).floor();
|
||||
if (maxLetters == _lastMaxLetters) return;
|
||||
_lastMaxLetters = maxLetters;
|
||||
_displayed = _helper.displayLetters(maxLetters);
|
||||
_clampHighlight();
|
||||
}
|
||||
|
||||
/// Find the nearest displayed letter at or before [letter] in the full list.
|
||||
String _nearestDisplayed(String letter) {
|
||||
if (_displayed.contains(letter)) return letter;
|
||||
final pos = _helper.letters.indexOf(letter);
|
||||
if (pos < 0 && _displayed.isNotEmpty) return _displayed.first;
|
||||
String result = _displayed.first;
|
||||
for (final dl in _displayed) {
|
||||
final dlPos = _helper.letters.indexOf(dl);
|
||||
if (dlPos <= pos) result = dl;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void _jumpToLetter(String letter) {
|
||||
final index = _helper.indexForLetter(letter);
|
||||
if (index != null) {
|
||||
@@ -73,19 +121,19 @@ class _AlphaJumpBarState extends State<AlphaJumpBar> {
|
||||
}
|
||||
|
||||
/// Schedule a debounced jump to the currently highlighted letter.
|
||||
/// The highlight updates immediately for visual feedback, but the
|
||||
/// actual scroll only fires after keyboard input settles.
|
||||
void _debouncedJump() {
|
||||
_debounce?.cancel();
|
||||
_debounce = Timer(const Duration(milliseconds: 150), () {
|
||||
_jumpToLetter(AlphaJumpHelper.allLetters[_highlightedIndex]);
|
||||
if (_highlightedIndex < _displayed.length) {
|
||||
_jumpToLetter(_displayed[_highlightedIndex]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Resolves a vertical drag position to a letter index.
|
||||
/// Resolves a vertical drag position to a displayed-letter index.
|
||||
int _letterIndexFromDy(double dy, double totalHeight) {
|
||||
final index = (dy / totalHeight * AlphaJumpHelper.allLetters.length).floor();
|
||||
return index.clamp(0, AlphaJumpHelper.allLetters.length - 1);
|
||||
final index = (dy / totalHeight * _displayed.length).floor();
|
||||
return index.clamp(0, _displayed.length - 1);
|
||||
}
|
||||
|
||||
KeyEventResult _handleKeyEvent(FocusNode _, KeyEvent event) {
|
||||
@@ -101,7 +149,7 @@ class _AlphaJumpBarState extends State<AlphaJumpBar> {
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
|
||||
if (_highlightedIndex < AlphaJumpHelper.allLetters.length - 1) {
|
||||
if (_highlightedIndex < _displayed.length - 1) {
|
||||
setState(() => _highlightedIndex++);
|
||||
_debouncedJump();
|
||||
}
|
||||
@@ -123,7 +171,6 @@ class _AlphaJumpBarState extends State<AlphaJumpBar> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final currentLetter = _helper.currentLetter(widget.currentFirstVisibleIndex);
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
|
||||
return Focus(
|
||||
@@ -133,26 +180,30 @@ class _AlphaJumpBarState extends State<AlphaJumpBar> {
|
||||
setState(() {
|
||||
_hasFocus = hasFocus;
|
||||
if (hasFocus) {
|
||||
// Start highlight at the current letter when gaining focus
|
||||
final idx = AlphaJumpHelper.allLetters.indexOf(currentLetter);
|
||||
final displayed = _nearestDisplayed(widget.currentLetter);
|
||||
final idx = _displayed.indexOf(displayed);
|
||||
if (idx >= 0) _highlightedIndex = idx;
|
||||
}
|
||||
});
|
||||
},
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
_updateDisplayed(constraints.maxHeight);
|
||||
|
||||
final currentLetter = _nearestDisplayed(widget.currentLetter);
|
||||
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTapDown: (details) {
|
||||
final idx = _letterIndexFromDy(details.localPosition.dy, constraints.maxHeight);
|
||||
setState(() => _highlightedIndex = idx);
|
||||
_jumpToLetter(AlphaJumpHelper.allLetters[idx]);
|
||||
_jumpToLetter(_displayed[idx]);
|
||||
},
|
||||
onVerticalDragUpdate: (details) {
|
||||
final idx = _letterIndexFromDy(details.localPosition.dy, constraints.maxHeight);
|
||||
if (idx != _highlightedIndex) {
|
||||
setState(() => _highlightedIndex = idx);
|
||||
_jumpToLetter(AlphaJumpHelper.allLetters[idx]);
|
||||
_jumpToLetter(_displayed[idx]);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
@@ -163,9 +214,8 @@ class _AlphaJumpBarState extends State<AlphaJumpBar> {
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: List.generate(AlphaJumpHelper.allLetters.length, (i) {
|
||||
final letter = AlphaJumpHelper.allLetters[i];
|
||||
final isActive = _helper.activeLetters.contains(letter);
|
||||
children: List.generate(_displayed.length, (i) {
|
||||
final letter = _displayed[i];
|
||||
final isCurrent = letter == currentLetter && !_hasFocus;
|
||||
final isHighlighted = _hasFocus && i == _highlightedIndex;
|
||||
|
||||
@@ -184,14 +234,12 @@ class _AlphaJumpBarState extends State<AlphaJumpBar> {
|
||||
letterColor = colorScheme.onPrimary;
|
||||
} else if (isCurrent) {
|
||||
letterColor = colorScheme.primary;
|
||||
} else if (isActive) {
|
||||
letterColor = colorScheme.onSurface;
|
||||
} else {
|
||||
letterColor = colorScheme.onSurface.withValues(alpha: 0.25);
|
||||
letterColor = colorScheme.onSurface;
|
||||
}
|
||||
|
||||
return SizedBox(
|
||||
height: constraints.maxHeight / AlphaJumpHelper.allLetters.length,
|
||||
height: constraints.maxHeight / _displayed.length,
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 22,
|
||||
|
||||
@@ -1,83 +1,79 @@
|
||||
import '../data/ducet_order.dart';
|
||||
import '../models/plex_first_character.dart';
|
||||
|
||||
/// Shared letter-index mapping logic used by both [AlphaJumpBar] (desktop/tablet/TV)
|
||||
/// and [AlphaScrollHandle] (phone).
|
||||
///
|
||||
/// Builds a cumulative index map from [PlexFirstCharacter] data and provides
|
||||
/// fraction-based mapping for proportional scroll handle positioning.
|
||||
/// Builds a dynamic letter list and cumulative index map from [PlexFirstCharacter]
|
||||
/// data returned by the Plex API. Only letters that have items are included,
|
||||
/// supporting non-Latin scripts (Korean, Japanese, Cyrillic, etc.).
|
||||
///
|
||||
/// The API's firstCharacter endpoint returns characters in Unicode codepoint
|
||||
/// order, which doesn't match the content endpoint's ICU locale-aware sort.
|
||||
/// We re-sort using ICU collation so cumulative indices are correct.
|
||||
class AlphaJumpHelper {
|
||||
static const List<String> allLetters = [
|
||||
'#',
|
||||
'A',
|
||||
'B',
|
||||
'C',
|
||||
'D',
|
||||
'E',
|
||||
'F',
|
||||
'G',
|
||||
'H',
|
||||
'I',
|
||||
'J',
|
||||
'K',
|
||||
'L',
|
||||
'M',
|
||||
'N',
|
||||
'O',
|
||||
'P',
|
||||
'Q',
|
||||
'R',
|
||||
'S',
|
||||
'T',
|
||||
'U',
|
||||
'V',
|
||||
'W',
|
||||
'X',
|
||||
'Y',
|
||||
'Z',
|
||||
];
|
||||
/// Dynamic letter list derived from the API's firstCharacter data,
|
||||
/// re-sorted to match ICU collation order.
|
||||
final List<String> letters;
|
||||
|
||||
/// Maps each letter to its cumulative start index in the full item list.
|
||||
final Map<String, int> letterToIndex;
|
||||
|
||||
/// Letters that have at least one item in the data.
|
||||
final Set<String> activeLetters;
|
||||
/// Maps each letter to its item count.
|
||||
final Map<String, int> letterSizes;
|
||||
|
||||
/// Total number of items across all letters.
|
||||
final int totalItemCount;
|
||||
|
||||
AlphaJumpHelper._(this.letterToIndex, this.activeLetters, this.totalItemCount);
|
||||
AlphaJumpHelper._(this.letters, this.letterToIndex, this.letterSizes, this.totalItemCount);
|
||||
|
||||
factory AlphaJumpHelper(List<PlexFirstCharacter> firstCharacters) {
|
||||
// Build a lookup from the API data. Note: the firstCharacters API may
|
||||
// count by display title (e.g. "The Simpsons" → T) rather than titleSort
|
||||
// ("Simpsons" → S), so cumulative indices are approximate. The browse tab
|
||||
// corrects for this when jumping by searching loaded items' titleSort.
|
||||
final sizeByLetter = <String, int>{};
|
||||
// Collect characters with their sizes.
|
||||
final entries = <({String letter, int size})>[];
|
||||
final letterSizes = <String, int>{};
|
||||
|
||||
for (final fc in firstCharacters) {
|
||||
sizeByLetter[fc.title.toUpperCase()] = fc.size;
|
||||
}
|
||||
|
||||
// Compute cumulative indices in allLetters order (#, A, B, …, Z).
|
||||
final letterToIndex = <String, int>{};
|
||||
final activeLetters = <String>{};
|
||||
int cumulative = 0;
|
||||
|
||||
for (final letter in allLetters) {
|
||||
final size = sizeByLetter[letter];
|
||||
if (size != null && size > 0) {
|
||||
activeLetters.add(letter);
|
||||
letterToIndex[letter] = cumulative;
|
||||
cumulative += size;
|
||||
final letter = fc.title.toUpperCase();
|
||||
if (fc.size > 0) {
|
||||
entries.add((letter: letter, size: fc.size));
|
||||
letterSizes[letter] = fc.size;
|
||||
}
|
||||
}
|
||||
|
||||
return AlphaJumpHelper._(letterToIndex, activeLetters, cumulative);
|
||||
// Re-sort by DUCET collation to match the content endpoint's ICU sort order.
|
||||
entries.sort((a, b) => ducetCompare(a.letter, b.letter));
|
||||
|
||||
// Build cumulative index map in the corrected order.
|
||||
final letters = <String>[];
|
||||
final letterToIndex = <String, int>{};
|
||||
int cumulative = 0;
|
||||
|
||||
for (final e in entries) {
|
||||
letters.add(e.letter);
|
||||
letterToIndex[e.letter] = cumulative;
|
||||
cumulative += e.size;
|
||||
}
|
||||
|
||||
return AlphaJumpHelper._(letters, letterToIndex, letterSizes, cumulative);
|
||||
}
|
||||
|
||||
/// Returns at most [maxCount] letters, prioritizing those with the most
|
||||
/// items. The returned letters maintain their original order.
|
||||
List<String> displayLetters(int maxCount) {
|
||||
if (maxCount >= letters.length) return letters;
|
||||
if (maxCount <= 0) return const [];
|
||||
|
||||
final indices = List.generate(letters.length, (i) => i);
|
||||
indices.sort((a, b) => (letterSizes[letters[b]] ?? 0).compareTo(letterSizes[letters[a]] ?? 0));
|
||||
final kept = indices.take(maxCount).toList()..sort();
|
||||
return [for (final i in kept) letters[i]];
|
||||
}
|
||||
|
||||
/// Returns the letter that the given item index falls within.
|
||||
String currentLetter(int itemIndex) {
|
||||
String current = allLetters.first;
|
||||
for (final letter in allLetters) {
|
||||
if (letters.isEmpty) return '#';
|
||||
String current = letters.first;
|
||||
for (final letter in letters) {
|
||||
final startIndex = letterToIndex[letter];
|
||||
if (startIndex != null && startIndex <= itemIndex) {
|
||||
current = letter;
|
||||
@@ -101,7 +97,8 @@ class AlphaJumpHelper {
|
||||
/// Returns the letter at a given fractional position (0.0–1.0), proportional
|
||||
/// to item count.
|
||||
String letterAtFraction(double fraction) {
|
||||
if (totalItemCount == 0) return allLetters.first;
|
||||
if (letters.isEmpty) return '#';
|
||||
if (totalItemCount == 0) return letters.first;
|
||||
final targetIndex = (fraction * totalItemCount).round().clamp(0, totalItemCount - 1);
|
||||
return currentLetter(targetIndex);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@ import 'alpha_jump_helper.dart';
|
||||
class AlphaScrollHandle extends StatefulWidget {
|
||||
final List<PlexFirstCharacter> firstCharacters;
|
||||
final void Function(int targetIndex) onJump;
|
||||
final int currentFirstVisibleIndex;
|
||||
|
||||
/// The letter currently visible at the top of the grid, derived from the
|
||||
/// actual item's sort title by the parent widget.
|
||||
final String currentLetter;
|
||||
|
||||
/// Whether the parent scroll view is currently scrolling.
|
||||
final bool isScrolling;
|
||||
@@ -22,7 +25,7 @@ class AlphaScrollHandle extends StatefulWidget {
|
||||
super.key,
|
||||
required this.firstCharacters,
|
||||
required this.onJump,
|
||||
required this.currentFirstVisibleIndex,
|
||||
required this.currentLetter,
|
||||
required this.isScrolling,
|
||||
});
|
||||
|
||||
@@ -104,11 +107,10 @@ class _AlphaScrollHandleState extends State<AlphaScrollHandle> with SingleTicker
|
||||
}
|
||||
|
||||
void _onDragStart(DragStartDetails _) {
|
||||
final currentLetter = _helper.currentLetter(widget.currentFirstVisibleIndex);
|
||||
setState(() {
|
||||
_isDragging = true;
|
||||
_dragFraction = _helper.fractionForLetter(currentLetter);
|
||||
_dragLetter = currentLetter;
|
||||
_dragFraction = _helper.fractionForLetter(widget.currentLetter);
|
||||
_dragLetter = widget.currentLetter;
|
||||
});
|
||||
_hideTimer?.cancel();
|
||||
_show();
|
||||
@@ -152,10 +154,9 @@ class _AlphaScrollHandleState extends State<AlphaScrollHandle> with SingleTicker
|
||||
final trackHeight = constraints.maxHeight;
|
||||
_trackHeight = trackHeight;
|
||||
|
||||
final currentLetter = _helper.currentLetter(widget.currentFirstVisibleIndex);
|
||||
final fraction = _isDragging && _dragFraction != null
|
||||
? _dragFraction!
|
||||
: _helper.fractionForLetter(currentLetter);
|
||||
: _helper.fractionForLetter(widget.currentLetter);
|
||||
final usableHeight = trackHeight - _handleHeight;
|
||||
final handleTop = usableHeight > 0 ? (fraction * usableHeight) : 0.0;
|
||||
|
||||
|
||||
@@ -123,8 +123,8 @@ class _RemoteSessionDialogState extends State<RemoteSessionDialog> {
|
||||
final ip = addressParts.first;
|
||||
final port = addressParts[1];
|
||||
|
||||
// New QR format: ip|port|sessionId|pin (using pipe separator)
|
||||
final qrData = '$ip|$port|${session.sessionId}|${session.pin}';
|
||||
// URL-wrapped QR format so external scanners open a real webpage
|
||||
final qrData = 'https://plezy.app/scan#$ip|$port|${session.sessionId}|${session.pin}';
|
||||
|
||||
return Dialog(
|
||||
child: ConstrainedBox(
|
||||
|
||||
@@ -24,6 +24,9 @@ class FocusableMediaCard extends StatefulWidget {
|
||||
/// True for downloaded content without server access
|
||||
final bool isOffline;
|
||||
|
||||
/// True when in a hub with mixed content (movies + episodes)
|
||||
final bool mixedHubContext;
|
||||
|
||||
/// Optional external focus node for programmatic focus control.
|
||||
/// If not provided, an internal focus node is created.
|
||||
final FocusNode? focusNode;
|
||||
@@ -60,6 +63,7 @@ class FocusableMediaCard extends StatefulWidget {
|
||||
this.isInContinueWatching = false,
|
||||
this.collectionId,
|
||||
this.isOffline = false,
|
||||
this.mixedHubContext = false,
|
||||
this.focusNode,
|
||||
this.onNavigateUp,
|
||||
this.onNavigateLeft,
|
||||
@@ -102,6 +106,7 @@ class _FocusableMediaCardState extends State<FocusableMediaCard> {
|
||||
isInContinueWatching: widget.isInContinueWatching,
|
||||
collectionId: widget.collectionId,
|
||||
isOffline: widget.isOffline,
|
||||
mixedHubContext: widget.mixedHubContext,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:plezy/widgets/app_icon.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../focus/dpad_navigator.dart';
|
||||
import '../focus/input_mode_tracker.dart';
|
||||
import '../focus/key_event_utils.dart';
|
||||
import '../providers/settings_provider.dart';
|
||||
import '../services/settings_service.dart' show EpisodePosterMode, LibraryDensity;
|
||||
@@ -94,12 +95,15 @@ class HubSectionState extends State<HubSection> {
|
||||
_hubFocusNode.addListener(_onFocusChange);
|
||||
}
|
||||
|
||||
/// Total item count including the optional "View All" card
|
||||
int get _totalItemCount => widget.hub.items.length + (widget.hub.more ? 1 : 0);
|
||||
|
||||
@override
|
||||
void didUpdateWidget(HubSection oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
// Clamp focus index if item count changed
|
||||
if (widget.hub.items.length != oldWidget.hub.items.length) {
|
||||
final maxIndex = widget.hub.items.isEmpty ? 0 : widget.hub.items.length - 1;
|
||||
final maxIndex = _totalItemCount == 0 ? 0 : _totalItemCount - 1;
|
||||
if (_focusedIndex > maxIndex) {
|
||||
_focusedIndex = maxIndex;
|
||||
}
|
||||
@@ -128,9 +132,9 @@ class HubSectionState extends State<HubSection> {
|
||||
|
||||
/// Request focus on this hub at a specific item index
|
||||
void requestFocusAt(int index) {
|
||||
if (widget.hub.items.isEmpty) return;
|
||||
if (_totalItemCount == 0) return;
|
||||
|
||||
final clamped = index.clamp(0, widget.hub.items.length - 1);
|
||||
final clamped = index.clamp(0, _totalItemCount - 1);
|
||||
_focusedIndex = clamped;
|
||||
// Remember this position for this specific hub
|
||||
HubFocusMemory.setForHub(widget.hub.hubKey, clamped);
|
||||
@@ -145,7 +149,7 @@ class HubSectionState extends State<HubSection> {
|
||||
|
||||
/// Request focus using the stored memory for this hub
|
||||
void requestFocusFromMemory() {
|
||||
final index = HubFocusMemory.getForHub(widget.hub.hubKey, widget.hub.items.length);
|
||||
final index = HubFocusMemory.getForHub(widget.hub.hubKey, _totalItemCount);
|
||||
requestFocusAt(index);
|
||||
}
|
||||
|
||||
@@ -166,7 +170,7 @@ class HubSectionState extends State<HubSection> {
|
||||
bool get hasFocusedItem => _hubFocusNode.hasFocus;
|
||||
|
||||
/// Get the number of items in this hub
|
||||
int get itemCount => widget.hub.items.length;
|
||||
int get itemCount => _totalItemCount;
|
||||
|
||||
/// Scroll to center the item at the given index
|
||||
void _scrollToIndex(int index, {bool animate = true}) {
|
||||
@@ -225,8 +229,8 @@ class HubSectionState extends State<HubSection> {
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
||||
final itemCount = widget.hub.items.length;
|
||||
if (itemCount == 0) return KeyEventResult.ignored;
|
||||
final totalCount = _totalItemCount;
|
||||
if (totalCount == 0) return KeyEventResult.ignored;
|
||||
|
||||
// Left: move to previous item, or navigate to sidebar at left edge
|
||||
if (key.isLeftKey) {
|
||||
@@ -246,7 +250,7 @@ class HubSectionState extends State<HubSection> {
|
||||
|
||||
// Right: move to next item, ALWAYS consume to prevent escape
|
||||
if (key.isRightKey) {
|
||||
if (_focusedIndex < itemCount - 1) {
|
||||
if (_focusedIndex < totalCount - 1) {
|
||||
setState(() {
|
||||
_focusedIndex++;
|
||||
});
|
||||
@@ -287,12 +291,18 @@ class HubSectionState extends State<HubSection> {
|
||||
}
|
||||
|
||||
void _activateCurrentItem() {
|
||||
if (_focusedIndex == widget.hub.items.length && widget.hub.more) {
|
||||
_navigateToHubDetail(context);
|
||||
return;
|
||||
}
|
||||
if (_focusedIndex >= widget.hub.items.length) return;
|
||||
final item = widget.hub.items[_focusedIndex];
|
||||
_navigateToItem(item);
|
||||
}
|
||||
|
||||
void _showContextMenuForCurrentItem() {
|
||||
// No context menu for the "View All" card
|
||||
if (_focusedIndex >= widget.hub.items.length) return;
|
||||
_mediaCardKeys[_focusedIndex]?.currentState?.showContextMenu();
|
||||
}
|
||||
|
||||
@@ -307,6 +317,7 @@ class HubSectionState extends State<HubSection> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final hasFocus = _hubFocusNode.hasFocus;
|
||||
final isKeyboardMode = InputModeTracker.isKeyboardMode(context);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -350,7 +361,7 @@ class HubSectionState extends State<HubSection> {
|
||||
),
|
||||
),
|
||||
],
|
||||
if (widget.hub.more) ...[
|
||||
if (widget.hub.more && !isKeyboardMode) ...[
|
||||
const SizedBox(width: 4),
|
||||
const AppIcon(Symbols.chevron_right_rounded, fill: 1, size: 20),
|
||||
],
|
||||
@@ -425,11 +436,49 @@ class HubSectionState extends State<HubSection> {
|
||||
controller: scrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 5),
|
||||
itemCount: widget.hub.items.length,
|
||||
itemCount: isKeyboardMode ? _totalItemCount : widget.hub.items.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = widget.hub.items[index];
|
||||
final isItemFocused = hasFocus && index == _focusedIndex;
|
||||
|
||||
// "View All" card at end
|
||||
if (index == widget.hub.items.length) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2),
|
||||
child: _LockedHubItemWrapper(
|
||||
isFocused: isItemFocused,
|
||||
onTap: () {
|
||||
_onItemTapped(index);
|
||||
_navigateToHubDetail(context);
|
||||
},
|
||||
child: SizedBox(
|
||||
width: 80,
|
||||
height: containerHeight - 10,
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Symbols.arrow_forward_rounded,
|
||||
size: 32,
|
||||
color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
t.common.viewAll,
|
||||
style: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final item = widget.hub.items[index];
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 2),
|
||||
child: _LockedHubItemWrapper(
|
||||
|
||||
@@ -26,6 +26,7 @@ import '../theme/mono_tokens.dart';
|
||||
import '../widgets/file_info_bottom_sheet.dart';
|
||||
import '../widgets/focusable_list_tile.dart';
|
||||
import '../widgets/overlay_sheet.dart';
|
||||
import '../widgets/rating_bottom_sheet.dart';
|
||||
import '../i18n/strings.g.dart';
|
||||
|
||||
/// Helper class to store menu action data
|
||||
@@ -187,6 +188,16 @@ class MediaContextMenuState extends State<MediaContextMenu> {
|
||||
);
|
||||
}
|
||||
|
||||
// Rate (for movies, shows, seasons, and episodes)
|
||||
if (mediaType == PlexMediaType.movie ||
|
||||
mediaType == PlexMediaType.show ||
|
||||
mediaType == PlexMediaType.season ||
|
||||
mediaType == PlexMediaType.episode) {
|
||||
menuActions.add(
|
||||
_MenuAction(value: 'rate', icon: Symbols.star_rounded, label: t.mediaMenu.rate),
|
||||
);
|
||||
}
|
||||
|
||||
// Remove from Collection (only when viewing items within a collection)
|
||||
if (widget.collectionId != null) {
|
||||
menuActions.add(
|
||||
@@ -397,6 +408,12 @@ class MediaContextMenuState extends State<MediaContextMenu> {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'rate':
|
||||
if (context.mounted) {
|
||||
await _showRatingSheet(context, metadata!, client);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'remove_from_collection':
|
||||
await _handleRemoveFromCollection(context, metadata!);
|
||||
break;
|
||||
@@ -928,6 +945,25 @@ class MediaContextMenuState extends State<MediaContextMenu> {
|
||||
}
|
||||
|
||||
/// Handle remove from collection action
|
||||
Future<void> _showRatingSheet(BuildContext context, PlexMetadata metadata, PlexClient client) async {
|
||||
final currentStarValue = (metadata.userRating != null && metadata.userRating! > 0) ? metadata.userRating! / 2.0 : 0.0;
|
||||
await showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (context) => RatingBottomSheet(
|
||||
currentRating: currentStarValue,
|
||||
onRate: (stars) async {
|
||||
final plexRating = stars * 2.0;
|
||||
final success = await client.rateItem(metadata.ratingKey, plexRating);
|
||||
if (success) widget.onRefresh?.call(metadata.ratingKey);
|
||||
},
|
||||
onClear: () async {
|
||||
final success = await client.rateItem(metadata.ratingKey, -1);
|
||||
if (success) widget.onRefresh?.call(metadata.ratingKey);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _handleRemoveFromCollection(BuildContext context, PlexMetadata metadata) async {
|
||||
final client = _getClientForItem();
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../models/plex_metadata.dart';
|
||||
import '../providers/settings_provider.dart';
|
||||
import 'media_card.dart';
|
||||
import 'media_grid_delegate.dart';
|
||||
|
||||
/// Shared sliver grid builder for displaying media items
|
||||
/// Used across hub detail, collection detail, playlist detail, and library browse screens
|
||||
/// to maintain consistent spacing and focus behavior
|
||||
class MediaGridSliver extends StatelessWidget {
|
||||
/// The list of media items to display
|
||||
final List<PlexMetadata> items;
|
||||
|
||||
/// Callback when an item needs to be refreshed
|
||||
final void Function(String ratingKey)? onRefresh;
|
||||
|
||||
/// Optional collection ID for collection-specific functionality
|
||||
final String? collectionId;
|
||||
|
||||
/// Optional callback to refresh the entire parent list
|
||||
final VoidCallback? onListRefresh;
|
||||
|
||||
/// Padding around the grid
|
||||
/// Defaults to EdgeInsets.fromLTRB(8, 0, 8, 8)
|
||||
final EdgeInsets padding;
|
||||
|
||||
/// Whether to use the padding-aware cross axis extent calculation
|
||||
/// Defaults to false (uses standard GridSizeCalculator)
|
||||
final bool usePaddingAwareExtent;
|
||||
|
||||
/// Horizontal padding to account for when usePaddingAwareExtent is true
|
||||
/// Only used if usePaddingAwareExtent is true
|
||||
final double horizontalPadding;
|
||||
|
||||
/// Whether to use 16:9 aspect ratio for episode thumbnails
|
||||
final bool useWideAspectRatio;
|
||||
|
||||
/// Whether this grid is displaying items from a mixed hub context
|
||||
/// (containing both episodes and non-episodes)
|
||||
final bool mixedHubContext;
|
||||
|
||||
const MediaGridSliver({
|
||||
super.key,
|
||||
required this.items,
|
||||
this.onRefresh,
|
||||
this.collectionId,
|
||||
this.onListRefresh,
|
||||
this.padding = const EdgeInsets.only(left: 8, right: 8, bottom: 8),
|
||||
this.usePaddingAwareExtent = false,
|
||||
this.horizontalPadding = 16,
|
||||
this.useWideAspectRatio = false,
|
||||
this.mixedHubContext = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverPadding(
|
||||
padding: padding,
|
||||
sliver: Consumer<SettingsProvider>(
|
||||
builder: (context, settingsProvider, child) {
|
||||
return SliverGrid(
|
||||
gridDelegate: MediaGridDelegate.createDelegate(
|
||||
context: context,
|
||||
density: settingsProvider.libraryDensity,
|
||||
usePaddingAware: usePaddingAwareExtent,
|
||||
horizontalPadding: horizontalPadding,
|
||||
useWideAspectRatio: useWideAspectRatio,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate((context, index) {
|
||||
final item = items[index];
|
||||
return MediaCard(
|
||||
key: Key(item.ratingKey),
|
||||
item: item,
|
||||
onRefresh: onRefresh,
|
||||
collectionId: collectionId,
|
||||
onListRefresh: onListRefresh,
|
||||
mixedHubContext: mixedHubContext,
|
||||
);
|
||||
}, childCount: items.length),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import '../widgets/app_icon.dart';
|
||||
import '../focus/dpad_navigator.dart';
|
||||
import '../i18n/strings.g.dart';
|
||||
|
||||
class RatingBottomSheet extends StatefulWidget {
|
||||
final double currentRating;
|
||||
final Future<void> Function(double stars) onRate;
|
||||
final Future<void> Function() onClear;
|
||||
|
||||
const RatingBottomSheet({
|
||||
super.key,
|
||||
required this.currentRating,
|
||||
required this.onRate,
|
||||
required this.onClear,
|
||||
});
|
||||
|
||||
@override
|
||||
State<RatingBottomSheet> createState() => _RatingBottomSheetState();
|
||||
}
|
||||
|
||||
class _RatingBottomSheetState extends State<RatingBottomSheet> {
|
||||
late double _selectedRating;
|
||||
late final FocusNode _starsFocusNode;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_selectedRating = widget.currentRating;
|
||||
_starsFocusNode = FocusNode(debugLabel: 'rating_stars');
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_starsFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(24, 16, 24, 24),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 32,
|
||||
height: 4,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
_selectedRating > 0
|
||||
? '${_selectedRating == _selectedRating.truncateToDouble() ? _selectedRating.toInt().toString() : _selectedRating.toStringAsFixed(1)} / 5'
|
||||
: t.mediaMenu.rate,
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Focus(
|
||||
focusNode: _starsFocusNode,
|
||||
autofocus: true,
|
||||
onKeyEvent: _handleStarsKeyEvent,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final starSize = (constraints.maxWidth / 5).clamp(0.0, 48.0);
|
||||
return GestureDetector(
|
||||
onTapDown: (details) => _handleStarTap(details.localPosition.dx, starSize),
|
||||
onPanUpdate: (details) => _handleStarTap(details.localPosition.dx, starSize),
|
||||
child: AnimatedBuilder(
|
||||
animation: _starsFocusNode,
|
||||
builder: (context, child) {
|
||||
final hasFocus = _starsFocusNode.hasFocus;
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: hasFocus
|
||||
? theme.colorScheme.primary.withValues(alpha: 0.12)
|
||||
: null,
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: List.generate(5, (i) {
|
||||
final starIndex = i + 1;
|
||||
final IconData icon;
|
||||
if (_selectedRating >= starIndex) {
|
||||
icon = Symbols.star_rounded;
|
||||
} else if (_selectedRating >= starIndex - 0.5) {
|
||||
icon = Symbols.star_half_rounded;
|
||||
} else {
|
||||
icon = Symbols.star_rounded;
|
||||
}
|
||||
return SizedBox(
|
||||
width: starSize,
|
||||
height: starSize,
|
||||
child: Center(
|
||||
child: AppIcon(
|
||||
icon,
|
||||
fill: _selectedRating >= starIndex - 0.5 ? 1 : 0,
|
||||
color: _selectedRating >= starIndex - 0.5
|
||||
? Colors.amber
|
||||
: theme.colorScheme.onSurfaceVariant.withValues(alpha: 0.3),
|
||||
size: starSize * 0.8,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Row(
|
||||
children: [
|
||||
if (widget.currentRating > 0)
|
||||
Expanded(
|
||||
child: OutlinedButton(
|
||||
onPressed: () {
|
||||
widget.onClear();
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Text(t.common.clear),
|
||||
),
|
||||
),
|
||||
if (widget.currentRating > 0) const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: _selectedRating > 0
|
||||
? () {
|
||||
widget.onRate(_selectedRating);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
: null,
|
||||
child: Text(t.mediaMenu.rate),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
KeyEventResult _handleStarsKeyEvent(FocusNode _, KeyEvent event) {
|
||||
if (!event.isActionable) return KeyEventResult.ignored;
|
||||
final key = event.logicalKey;
|
||||
|
||||
if (key.isRightKey) {
|
||||
setState(() {
|
||||
_selectedRating = (_selectedRating + 0.5).clamp(0.5, 5.0);
|
||||
});
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (key.isLeftKey) {
|
||||
setState(() {
|
||||
_selectedRating = (_selectedRating - 0.5).clamp(0.5, 5.0);
|
||||
});
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (key == LogicalKeyboardKey.select || key == LogicalKeyboardKey.enter) {
|
||||
if (_selectedRating > 0) {
|
||||
widget.onRate(_selectedRating);
|
||||
Navigator.pop(context);
|
||||
}
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
|
||||
return KeyEventResult.ignored;
|
||||
}
|
||||
|
||||
void _handleStarTap(double dx, double starSize) {
|
||||
final totalWidth = starSize * 5;
|
||||
final clampedX = dx.clamp(0.0, totalWidth);
|
||||
final halfStars = (clampedX / (starSize / 2)).ceil().clamp(1, 10);
|
||||
setState(() {
|
||||
_selectedRating = halfStars / 2.0;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -95,6 +95,12 @@ class DesktopVideoControls extends StatefulWidget {
|
||||
/// Called to toggle ambient lighting (passed to settings sheet)
|
||||
final VoidCallback? onToggleAmbientLighting;
|
||||
|
||||
/// Whether to show the queue button
|
||||
final bool showQueueButton;
|
||||
|
||||
/// Callback when a queue item is selected
|
||||
final Function(PlexMetadata)? onQueueItemSelected;
|
||||
|
||||
const DesktopVideoControls({
|
||||
super.key,
|
||||
required this.player,
|
||||
@@ -143,6 +149,8 @@ class DesktopVideoControls extends StatefulWidget {
|
||||
this.liveChannelName,
|
||||
this.isAmbientLightingEnabled = false,
|
||||
this.onToggleAmbientLighting,
|
||||
this.showQueueButton = false,
|
||||
this.onQueueItemSelected,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -686,6 +694,8 @@ class DesktopVideoControlsState extends State<DesktopVideoControls> {
|
||||
onNavigateLeft: navigateFromTrackToVolume,
|
||||
canControl: widget.canControl,
|
||||
isLive: widget.isLive,
|
||||
showQueueButton: widget.showQueueButton,
|
||||
onQueueItemSelected: widget.onQueueItemSelected,
|
||||
shaderService: widget.shaderService,
|
||||
onShaderChanged: widget.onShaderChanged,
|
||||
isAmbientLightingEnabled: widget.isAmbientLightingEnabled,
|
||||
|
||||
@@ -34,6 +34,8 @@ class MobileVideoControls extends StatelessWidget {
|
||||
final VoidCallback? onBack;
|
||||
final VoidCallback? onNext;
|
||||
final VoidCallback? onPrevious;
|
||||
final VoidCallback? onSeekToPreviousChapter;
|
||||
final VoidCallback? onSeekToNextChapter;
|
||||
|
||||
/// Whether the user can control playback (false in host-only mode for non-host).
|
||||
final bool canControl;
|
||||
@@ -67,6 +69,8 @@ class MobileVideoControls extends StatelessWidget {
|
||||
this.onBack,
|
||||
this.onNext,
|
||||
this.onPrevious,
|
||||
this.onSeekToPreviousChapter,
|
||||
this.onSeekToNextChapter,
|
||||
this.canControl = true,
|
||||
this.hasFirstFrame,
|
||||
this.thumbnailUrlBuilder,
|
||||
@@ -118,6 +122,8 @@ class MobileVideoControls extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildPlaybackControlsContent(BuildContext _) {
|
||||
final hasChapters = !isLive && chaptersLoaded && chapters.isNotEmpty;
|
||||
|
||||
return PlayPauseStreamBuilder(
|
||||
player: player,
|
||||
builder: (context, isPlaying) {
|
||||
@@ -125,6 +131,15 @@ class MobileVideoControls extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (!isLive) ...[
|
||||
if (hasChapters) ...[
|
||||
CircularControlButton(
|
||||
semanticLabel: t.videoControls.previousChapterButton,
|
||||
icon: Symbols.fast_rewind_rounded,
|
||||
iconSize: 32,
|
||||
onPressed: onSeekToPreviousChapter,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
// Previous episode button (greyed out when unavailable)
|
||||
CircularControlButton(
|
||||
semanticLabel: t.videoControls.previousButton,
|
||||
@@ -157,6 +172,15 @@ class MobileVideoControls extends StatelessWidget {
|
||||
iconSize: 48,
|
||||
onPressed: onNext,
|
||||
),
|
||||
if (hasChapters) ...[
|
||||
const SizedBox(width: 16),
|
||||
CircularControlButton(
|
||||
semanticLabel: t.videoControls.nextChapterButton,
|
||||
icon: Symbols.fast_forward_rounded,
|
||||
iconSize: 32,
|
||||
onPressed: onSeekToNextChapter,
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../mpv/models.dart';
|
||||
|
||||
/// Custom painter that draws a background track and buffered range bars
|
||||
/// on the video timeline slider.
|
||||
class BufferRangePainter extends CustomPainter {
|
||||
final List<BufferRange> ranges;
|
||||
final Duration duration;
|
||||
|
||||
BufferRangePainter({required this.ranges, required this.duration});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final trackHeight = 4.0;
|
||||
final y = (size.height - trackHeight) / 2;
|
||||
|
||||
// Background track (full width)
|
||||
final bgPaint = Paint()
|
||||
..color = Colors.white.withValues(alpha: 0.3)
|
||||
..style = PaintingStyle.fill;
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(Rect.fromLTWH(0, y, size.width, trackHeight), const Radius.circular(2)),
|
||||
bgPaint,
|
||||
);
|
||||
|
||||
if (duration.inMilliseconds <= 0) return;
|
||||
|
||||
// Buffer range bars
|
||||
final bufPaint = Paint()
|
||||
..color = Colors.white.withValues(alpha: 0.5)
|
||||
..style = PaintingStyle.fill;
|
||||
|
||||
final durationMs = duration.inMilliseconds.toDouble();
|
||||
for (final range in ranges) {
|
||||
final startFraction = (range.start.inMilliseconds / durationMs).clamp(0.0, 1.0);
|
||||
final endFraction = (range.end.inMilliseconds / durationMs).clamp(0.0, 1.0);
|
||||
if (endFraction <= startFraction) continue;
|
||||
|
||||
final left = startFraction * size.width;
|
||||
final right = endFraction * size.width;
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(Rect.fromLTWH(left, y, right - left, trackHeight), const Radius.circular(2)),
|
||||
bufPaint,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(BufferRangePainter oldDelegate) {
|
||||
return oldDelegate.duration != duration || oldDelegate.ranges != ranges;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:plezy/widgets/app_icon.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../../i18n/strings.g.dart';
|
||||
import '../../../models/plex_metadata.dart';
|
||||
import '../../../providers/playback_state_provider.dart';
|
||||
import '../../../utils/provider_extensions.dart';
|
||||
import '../../../widgets/focusable_list_tile.dart';
|
||||
import '../../../widgets/overlay_sheet.dart';
|
||||
import 'base_video_control_sheet.dart';
|
||||
import '../../plex_optimized_image.dart';
|
||||
|
||||
/// Bottom sheet for viewing and navigating the play queue
|
||||
class QueueSheet extends StatelessWidget {
|
||||
final Function(PlexMetadata) onItemSelected;
|
||||
|
||||
const QueueSheet({super.key, required this.onItemSelected});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<PlaybackStateProvider>(
|
||||
builder: (context, playbackState, _) {
|
||||
final items = playbackState.loadedItems;
|
||||
final currentItemID = playbackState.currentPlayQueueItemID;
|
||||
|
||||
Widget content;
|
||||
if (items.isEmpty) {
|
||||
content = Center(
|
||||
child: Text(t.videoControls.noQueueItems, style: const TextStyle(color: Colors.white70)),
|
||||
);
|
||||
} else {
|
||||
// Find current index for initial scroll
|
||||
final currentIndex = items.indexWhere((item) => item.playQueueItemID == currentItemID);
|
||||
|
||||
content = ListView.builder(
|
||||
controller: currentIndex > 0 ? ScrollController(initialScrollOffset: currentIndex * 56.0) : null,
|
||||
itemCount: items.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = items[index];
|
||||
final isCurrent = item.playQueueItemID == currentItemID;
|
||||
|
||||
return FocusableListTile(
|
||||
leading: _buildThumbnail(context, item, isCurrent),
|
||||
title: Text(
|
||||
item.title,
|
||||
style: TextStyle(
|
||||
color: isCurrent ? Colors.blue : Colors.white,
|
||||
fontWeight: isCurrent ? FontWeight.bold : FontWeight.normal,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle: Text(
|
||||
_buildSubtitle(item),
|
||||
style: TextStyle(
|
||||
color: isCurrent ? Colors.blue.withValues(alpha: 0.7) : Colors.white70,
|
||||
fontSize: 12,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
trailing: isCurrent
|
||||
? const AppIcon(Symbols.play_circle_rounded, fill: 1, color: Colors.blue)
|
||||
: null,
|
||||
onTap: () {
|
||||
onItemSelected(item);
|
||||
OverlaySheetController.of(context).close();
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return BaseVideoControlSheet(
|
||||
title: t.videoControls.queue,
|
||||
icon: Symbols.queue_music_rounded,
|
||||
child: content,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget? _buildThumbnail(BuildContext context, PlexMetadata item, bool isCurrent) {
|
||||
if (item.thumb == null) return null;
|
||||
|
||||
// Try to get client for thumbnails, may fail in offline mode
|
||||
final client = _tryGetClient(context, item);
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||
child: PlexOptimizedImage.thumb(
|
||||
client: client,
|
||||
imagePath: item.thumb,
|
||||
width: 60,
|
||||
height: 34,
|
||||
fit: BoxFit.cover,
|
||||
errorWidget: (context, url, error) =>
|
||||
const AppIcon(Symbols.image_rounded, fill: 1, color: Colors.white54, size: 34),
|
||||
),
|
||||
),
|
||||
if (isCurrent)
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||
border: const Border.fromBorderSide(BorderSide(color: Colors.blue, width: 2)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String _buildSubtitle(PlexMetadata item) {
|
||||
if (item.grandparentTitle != null && item.parentIndex != null && item.index != null) {
|
||||
return '${item.grandparentTitle} \u00b7 S${item.parentIndex}E${item.index}';
|
||||
}
|
||||
if (item.grandparentTitle != null) {
|
||||
return item.grandparentTitle!;
|
||||
}
|
||||
if (item.year != null) {
|
||||
return '${item.year}';
|
||||
}
|
||||
return item.type;
|
||||
}
|
||||
|
||||
static dynamic _tryGetClient(BuildContext context, PlexMetadata item) {
|
||||
if (item.serverId == null) return null;
|
||||
try {
|
||||
return context.getClientForServer(item.serverId!);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -576,6 +576,10 @@ class _VideoSettingsSheetState extends State<VideoSettingsSheet> {
|
||||
: null,
|
||||
trailing: isSelected ? const AppIcon(Symbols.check_rounded, fill: 1, color: Colors.amber) : null,
|
||||
onTap: () async {
|
||||
// Disable ambient lighting when selecting a shader
|
||||
if (preset.type != ShaderPresetType.none && widget.isAmbientLightingEnabled) {
|
||||
widget.onToggleAmbientLighting?.call();
|
||||
}
|
||||
await widget.shaderService!.applyPreset(preset);
|
||||
await shaderProvider.setPreset(preset);
|
||||
widget.onShaderChanged?.call();
|
||||
|
||||
@@ -51,6 +51,7 @@ import 'desktop_video_controls.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../models/shader_preset.dart';
|
||||
import '../../providers/playback_state_provider.dart';
|
||||
import '../../providers/shader_provider.dart';
|
||||
import '../../services/shader_service.dart';
|
||||
|
||||
@@ -884,10 +885,12 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
}
|
||||
}
|
||||
|
||||
return PlaybackExtras(chapters: chapters, markers: markers);
|
||||
return PlaybackExtras.withChapterFallback(chapters: chapters, markers: markers);
|
||||
}
|
||||
|
||||
Widget _buildTrackChapterControlsWidget() {
|
||||
final playbackState = context.watch<PlaybackStateProvider>();
|
||||
|
||||
return TrackChapterControls(
|
||||
player: widget.player,
|
||||
chapters: _chapters,
|
||||
@@ -916,6 +919,8 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
serverId: widget.metadata.serverId ?? '',
|
||||
canControl: widget.canControl,
|
||||
isLive: widget.isLive,
|
||||
showQueueButton: playbackState.isQueueActive,
|
||||
onQueueItemSelected: playbackState.isQueueActive ? _onQueueItemSelected : null,
|
||||
shaderService: widget.shaderService,
|
||||
onShaderChanged: widget.onShaderChanged,
|
||||
isAmbientLightingEnabled: widget.isAmbientLightingEnabled,
|
||||
@@ -1798,6 +1803,8 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
onBack: widget.onBack,
|
||||
onNext: widget.onNext,
|
||||
onPrevious: widget.onPrevious,
|
||||
onSeekToPreviousChapter: _seekToPreviousChapter,
|
||||
onSeekToNextChapter: _seekToNextChapter,
|
||||
canControl: widget.canControl,
|
||||
hasFirstFrame: widget.hasFirstFrame,
|
||||
thumbnailUrlBuilder: widget.thumbnailUrlBuilder,
|
||||
@@ -1862,6 +1869,7 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
Widget _buildDesktopControlsListener() {
|
||||
final pipMode = (_isPipSupported && Platform.isAndroid) ? widget.onTogglePIPMode : null;
|
||||
final boxFitMode = widget.player.playerType != 'exoplayer' ? widget.onCycleBoxFitMode : null;
|
||||
final playbackState = context.watch<PlaybackStateProvider>();
|
||||
|
||||
return Listener(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
@@ -1910,6 +1918,8 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
onBack: widget.onBack,
|
||||
canControl: widget.canControl,
|
||||
hasFirstFrame: widget.hasFirstFrame,
|
||||
showQueueButton: playbackState.isQueueActive,
|
||||
onQueueItemSelected: playbackState.isQueueActive ? _onQueueItemSelected : null,
|
||||
shaderService: widget.shaderService,
|
||||
onShaderChanged: widget.onShaderChanged,
|
||||
thumbnailUrlBuilder: widget.thumbnailUrlBuilder,
|
||||
@@ -2032,6 +2042,11 @@ class _PlexVideoControlsState extends State<PlexVideoControls> with WindowListen
|
||||
}
|
||||
|
||||
/// Switch to a different media version
|
||||
void _onQueueItemSelected(PlexMetadata item) {
|
||||
final videoPlayerState = context.findAncestorStateOfType<VideoPlayerScreenState>();
|
||||
videoPlayerState?.navigateToQueueItem(item);
|
||||
}
|
||||
|
||||
Future<void> _switchMediaVersion(int newMediaIndex) async {
|
||||
if (newMediaIndex == widget.selectedMediaIndex) {
|
||||
return; // Already using this version
|
||||
|
||||
@@ -3,9 +3,11 @@ import 'dart:async';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../models/plex_media_info.dart';
|
||||
import '../../../mpv/models.dart';
|
||||
import '../../../i18n/strings.g.dart';
|
||||
import '../../../focus/focusable_wrapper.dart';
|
||||
import '../../../utils/formatters.dart';
|
||||
import '../painters/buffer_range_painter.dart';
|
||||
import '../painters/chapter_marker_painter.dart';
|
||||
import '../../plex_optimized_image.dart' show blurArtwork;
|
||||
|
||||
@@ -16,6 +18,7 @@ import '../../plex_optimized_image.dart' show blurArtwork;
|
||||
class TimelineSlider extends StatefulWidget {
|
||||
final Duration position;
|
||||
final Duration duration;
|
||||
final List<BufferRange> bufferRanges;
|
||||
final List<PlexChapter> chapters;
|
||||
final bool chaptersLoaded;
|
||||
final ValueChanged<Duration> onSeek;
|
||||
@@ -40,6 +43,7 @@ class TimelineSlider extends StatefulWidget {
|
||||
super.key,
|
||||
required this.position,
|
||||
required this.duration,
|
||||
this.bufferRanges = const [],
|
||||
required this.chapters,
|
||||
required this.chaptersLoaded,
|
||||
required this.onSeek,
|
||||
@@ -61,7 +65,8 @@ class _TimelineSliderState extends State<TimelineSlider> {
|
||||
bool _showKeySeekThumbnail = false;
|
||||
Timer? _keySeekTimer;
|
||||
|
||||
static const _sliderPadding = 24.0;
|
||||
// Must match the slider track inset: max(overlayRadius, thumbRadius)
|
||||
static const _sliderPadding = 12.0;
|
||||
|
||||
static const _thumbWidth = 160.0;
|
||||
static const _thumbHeight = 90.0;
|
||||
@@ -201,7 +206,7 @@ class _TimelineSliderState extends State<TimelineSlider> {
|
||||
if (widget.chaptersLoaded && widget.chapters.isNotEmpty && widget.duration.inMilliseconds > 0)
|
||||
Positioned.fill(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
padding: const EdgeInsets.symmetric(horizontal: _sliderPadding),
|
||||
child: Row(
|
||||
children:
|
||||
widget.chapters.map((chapter) {
|
||||
@@ -223,10 +228,26 @@ class _TimelineSliderState extends State<TimelineSlider> {
|
||||
),
|
||||
),
|
||||
),
|
||||
// Buffer range + background track painter
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: _sliderPadding),
|
||||
child: CustomPaint(
|
||||
painter: BufferRangePainter(ranges: widget.bufferRanges, duration: widget.duration),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Slider - use IgnorePointer to block interaction while preserving visual style
|
||||
IgnorePointer(
|
||||
ignoring: !widget.enabled,
|
||||
child: Semantics(
|
||||
child: SliderTheme(
|
||||
data: SliderThemeData(
|
||||
thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 6),
|
||||
overlayShape: const RoundSliderOverlayShape(overlayRadius: 12),
|
||||
),
|
||||
child: Semantics(
|
||||
label: t.videoControls.timelineSlider,
|
||||
slider: true,
|
||||
child: Slider(
|
||||
@@ -242,16 +263,17 @@ class _TimelineSliderState extends State<TimelineSlider> {
|
||||
widget.onSeekEnd(Duration(milliseconds: value.toInt()));
|
||||
},
|
||||
activeColor: Colors.white,
|
||||
inactiveColor: Colors.white.withValues(alpha: 0.3),
|
||||
inactiveColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Chapter marker indicators
|
||||
if (widget.chaptersLoaded && widget.chapters.isNotEmpty && widget.duration.inMilliseconds > 0)
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
padding: const EdgeInsets.symmetric(horizontal: _sliderPadding),
|
||||
child: CustomPaint(
|
||||
painter: ChapterMarkerPainter(chapters: widget.chapters, duration: widget.duration),
|
||||
),
|
||||
|
||||
@@ -12,8 +12,10 @@ import '../../../services/sleep_timer_service.dart';
|
||||
import '../../../utils/platform_detector.dart';
|
||||
import '../../../i18n/strings.g.dart';
|
||||
import '../../../widgets/overlay_sheet.dart';
|
||||
import '../../../models/plex_metadata.dart';
|
||||
import '../sheets/audio_track_sheet.dart';
|
||||
import '../sheets/chapter_sheet.dart';
|
||||
import '../sheets/queue_sheet.dart';
|
||||
import '../sheets/subtitle_track_sheet.dart';
|
||||
import '../sheets/version_sheet.dart';
|
||||
import '../sheets/video_settings_sheet.dart';
|
||||
@@ -70,6 +72,12 @@ class TrackChapterControls extends StatelessWidget {
|
||||
/// Whether this is a live TV stream (hides speed settings).
|
||||
final bool isLive;
|
||||
|
||||
/// Whether to show the queue button
|
||||
final bool showQueueButton;
|
||||
|
||||
/// Callback when a queue item is selected
|
||||
final Function(PlexMetadata)? onQueueItemSelected;
|
||||
|
||||
const TrackChapterControls({
|
||||
super.key,
|
||||
required this.player,
|
||||
@@ -100,6 +108,8 @@ class TrackChapterControls extends StatelessWidget {
|
||||
this.onNavigateLeft,
|
||||
this.canControl = true,
|
||||
this.isLive = false,
|
||||
this.showQueueButton = false,
|
||||
this.onQueueItemSelected,
|
||||
this.shaderService,
|
||||
this.onShaderChanged,
|
||||
this.isAmbientLightingEnabled = false,
|
||||
@@ -303,6 +313,29 @@ class TrackChapterControls extends StatelessWidget {
|
||||
buttonIndex++;
|
||||
}
|
||||
|
||||
// Queue button
|
||||
if (showQueueButton && onQueueItemSelected != null) {
|
||||
final currentIndex = buttonIndex;
|
||||
buttons.add(
|
||||
_buildTrackButton(
|
||||
buttonIndex: currentIndex,
|
||||
icon: Symbols.queue_music_rounded,
|
||||
tooltip: t.videoControls.queue,
|
||||
semanticLabel: t.videoControls.queue,
|
||||
tracks: tracks,
|
||||
isMobile: isMobile,
|
||||
isDesktop: isDesktop,
|
||||
onPressed: () {
|
||||
onCancelAutoHide?.call();
|
||||
OverlaySheetController.of(context).show(
|
||||
builder: (_) => QueueSheet(onItemSelected: onQueueItemSelected!),
|
||||
).whenComplete(() => onStartAutoHide?.call());
|
||||
},
|
||||
),
|
||||
);
|
||||
buttonIndex++;
|
||||
}
|
||||
|
||||
// Versions button
|
||||
if (availableVersions.length > 1 && onSwitchVersion != null) {
|
||||
final currentIndex = buttonIndex;
|
||||
@@ -433,6 +466,7 @@ class TrackChapterControls extends StatelessWidget {
|
||||
if (_hasMultipleAudioTracks(tracks)) count++;
|
||||
if (_hasSubtitles(tracks)) count++;
|
||||
if (chapters.isNotEmpty) count++;
|
||||
if (showQueueButton && onQueueItemSelected != null) count++;
|
||||
if (availableVersions.length > 1 && onSwitchVersion != null) count++;
|
||||
if (onTogglePIPMode != null) count++;
|
||||
if (onCycleBoxFitMode != null) count++;
|
||||
|
||||
@@ -65,35 +65,42 @@ class VideoTimelineBar extends StatelessWidget {
|
||||
stream: player.streams.duration,
|
||||
initialData: player.state.duration,
|
||||
builder: (context, durationSnapshot) {
|
||||
final position = positionSnapshot.data ?? Duration.zero;
|
||||
final duration = durationSnapshot.data ?? Duration.zero;
|
||||
final remaining = position - duration; // We want this to be negative
|
||||
return StreamBuilder<List<BufferRange>>(
|
||||
stream: player.streams.bufferRanges,
|
||||
initialData: player.state.bufferRanges,
|
||||
builder: (context, bufferRangesSnapshot) {
|
||||
final position = positionSnapshot.data ?? Duration.zero;
|
||||
final duration = durationSnapshot.data ?? Duration.zero;
|
||||
final bufferRanges = bufferRangesSnapshot.data ?? const [];
|
||||
final remaining = position - duration; // We want this to be negative
|
||||
|
||||
return horizontalLayout
|
||||
? _buildHorizontalLayout(position, duration, remaining)
|
||||
: _buildVerticalLayout(position, duration, remaining);
|
||||
return horizontalLayout
|
||||
? _buildHorizontalLayout(position, duration, remaining, bufferRanges)
|
||||
: _buildVerticalLayout(position, duration, remaining, bufferRanges);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHorizontalLayout(Duration position, Duration duration, Duration remaining) {
|
||||
Widget _buildHorizontalLayout(Duration position, Duration duration, Duration remaining, List<BufferRange> bufferRanges) {
|
||||
return Row(
|
||||
children: [
|
||||
_buildTimestamp(position),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(child: _buildSlider(position, duration)),
|
||||
Expanded(child: _buildSlider(position, duration, bufferRanges)),
|
||||
const SizedBox(width: 12),
|
||||
_buildTimestamp(remaining),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildVerticalLayout(Duration position, Duration duration, Duration remaining) {
|
||||
Widget _buildVerticalLayout(Duration position, Duration duration, Duration remaining, List<BufferRange> bufferRanges) {
|
||||
return Column(
|
||||
children: [
|
||||
_buildSlider(position, duration),
|
||||
_buildSlider(position, duration, bufferRanges),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Row(
|
||||
@@ -124,10 +131,11 @@ class VideoTimelineBar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSlider(Duration position, Duration duration) {
|
||||
Widget _buildSlider(Duration position, Duration duration, List<BufferRange> bufferRanges) {
|
||||
return TimelineSlider(
|
||||
position: position,
|
||||
duration: duration,
|
||||
bufferRanges: bufferRanges,
|
||||
chapters: chapters,
|
||||
chaptersLoaded: chaptersLoaded,
|
||||
onSeek: onSeek,
|
||||
|
||||
@@ -130,13 +130,27 @@ bool MpvPlayer::InitRenderContext() {
|
||||
}
|
||||
|
||||
void MpvPlayer::Dispose() {
|
||||
std::lock_guard<std::mutex> lock(callback_mutex_);
|
||||
|
||||
// 1. Set disposed flag atomically FIRST — all callback paths check this
|
||||
if (disposed_.exchange(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cancel pending async commands
|
||||
// 2. Clear mpv's native callbacks to prevent new ones from firing
|
||||
if (mpv_gl_) {
|
||||
mpv_render_context_set_update_callback(mpv_gl_, nullptr, nullptr);
|
||||
}
|
||||
if (mpv_) {
|
||||
mpv_set_wakeup_callback(mpv_, nullptr, nullptr);
|
||||
}
|
||||
|
||||
// 3. Briefly hold mutex to null our callbacks
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(callback_mutex_);
|
||||
redraw_callback_ = nullptr;
|
||||
event_callback_ = nullptr;
|
||||
}
|
||||
|
||||
// 4. Cancel pending async commands
|
||||
{
|
||||
std::lock_guard<std::mutex> cmd_lock(pending_commands_mutex_);
|
||||
for (auto& pair : pending_commands_) {
|
||||
@@ -145,32 +159,31 @@ void MpvPlayer::Dispose() {
|
||||
pending_commands_.clear();
|
||||
}
|
||||
|
||||
// Clear mpv callbacks BEFORE freeing
|
||||
if (mpv_gl_) {
|
||||
mpv_render_context_set_update_callback(mpv_gl_, nullptr, nullptr);
|
||||
}
|
||||
if (mpv_) {
|
||||
mpv_set_wakeup_callback(mpv_, nullptr, nullptr);
|
||||
}
|
||||
|
||||
// Remove pending idle callbacks
|
||||
// 5. Remove pending idle callbacks
|
||||
if (event_source_id_ != 0) {
|
||||
g_source_remove(event_source_id_);
|
||||
event_source_id_ = 0;
|
||||
}
|
||||
|
||||
if (mpv_gl_) {
|
||||
mpv_render_context_free(mpv_gl_);
|
||||
mpv_gl_ = nullptr;
|
||||
}
|
||||
// 6. Free render context and mpv handle in a background thread.
|
||||
// mpv_render_context_free() can block waiting for mpv's render/VO thread,
|
||||
// and mpv_terminate_destroy() can block on demuxer/network I/O.
|
||||
// Running these off the main thread prevents stalling the GLib main loop.
|
||||
auto* gl = mpv_gl_;
|
||||
auto* handle = mpv_;
|
||||
mpv_gl_ = nullptr;
|
||||
mpv_ = nullptr;
|
||||
|
||||
if (mpv_) {
|
||||
mpv_terminate_destroy(mpv_);
|
||||
mpv_ = nullptr;
|
||||
}
|
||||
std::thread([gl, handle]() {
|
||||
if (gl) {
|
||||
mpv_render_context_free(gl);
|
||||
}
|
||||
if (handle) {
|
||||
mpv_terminate_destroy(handle);
|
||||
}
|
||||
}).detach();
|
||||
|
||||
observed_properties_.clear();
|
||||
redraw_callback_ = nullptr;
|
||||
}
|
||||
|
||||
void MpvPlayer::Command(const std::vector<std::string>& args) {
|
||||
@@ -336,11 +349,23 @@ void MpvPlayer::OnMpvRenderUpdate(void* ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Call the redraw callback to notify MpvTexture via the registrar
|
||||
std::lock_guard<std::mutex> lock(player->callback_mutex_);
|
||||
if (player->redraw_callback_) {
|
||||
player->redraw_callback_();
|
||||
}
|
||||
// Schedule redraw on main thread. Calling Flutter's
|
||||
// fl_texture_registrar_mark_texture_frame_available directly from mpv's
|
||||
// render/VO thread can deadlock during disposal on Wayland: the main thread
|
||||
// blocks in mpv_render_context_free() waiting for the VO thread, while the
|
||||
// VO thread blocks in the Flutter registrar waiting for the main thread.
|
||||
g_idle_add(
|
||||
[](gpointer data) -> gboolean {
|
||||
auto* player = static_cast<MpvPlayer*>(data);
|
||||
if (player->disposed_) return G_SOURCE_REMOVE;
|
||||
|
||||
std::lock_guard<std::mutex> lock(player->callback_mutex_);
|
||||
if (player->redraw_callback_) {
|
||||
player->redraw_callback_();
|
||||
}
|
||||
return G_SOURCE_REMOVE;
|
||||
},
|
||||
player);
|
||||
}
|
||||
|
||||
bool MpvPlayer::ProcessEvents() {
|
||||
|
||||
@@ -55,6 +55,9 @@ class MpvPlayer {
|
||||
/// Returns true if mpv is initialized (has both mpv handle and render context).
|
||||
bool IsInitialized() const { return mpv_ != nullptr && mpv_gl_ != nullptr; }
|
||||
|
||||
/// Returns true if this player has been disposed.
|
||||
bool IsDisposed() const { return disposed_.load(); }
|
||||
|
||||
/// Returns true if mpv handle exists (even without render context).
|
||||
bool HasMpvHandle() const { return mpv_ != nullptr; }
|
||||
|
||||
|
||||
@@ -123,8 +123,8 @@ static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(
|
||||
fl_value_new_int(mpv_texture_get_id(self->texture))));
|
||||
} else {
|
||||
// Create player if it was disposed
|
||||
if (!self->player) {
|
||||
// Create player if it was disposed or doesn't exist
|
||||
if (!self->player || self->player->IsDisposed()) {
|
||||
self->player = std::make_unique<mpv::MpvPlayer>();
|
||||
}
|
||||
|
||||
@@ -159,10 +159,9 @@ static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
|
||||
}
|
||||
}
|
||||
} else if (strcmp(method, "dispose") == 0) {
|
||||
if (self->player) {
|
||||
self->player->Dispose();
|
||||
self->player.reset();
|
||||
}
|
||||
// Disconnect and unregister texture FIRST — this stops Flutter from
|
||||
// calling populate(), preventing concurrent mpv_render_context_render()
|
||||
// during player disposal.
|
||||
if (self->texture) {
|
||||
mpv_texture_dispose(self->texture);
|
||||
fl_texture_registrar_unregister_texture(self->texture_registrar,
|
||||
@@ -170,6 +169,11 @@ static void mpv_plugin_handle_method_call(FlMethodChannel* channel,
|
||||
g_object_unref(self->texture);
|
||||
self->texture = nullptr;
|
||||
}
|
||||
if (self->player) {
|
||||
self->player->Dispose();
|
||||
// Don't reset player here — stray g_idle callbacks still reference it.
|
||||
// It will be replaced on next initialize() call.
|
||||
}
|
||||
self->initialized = FALSE;
|
||||
self->visible = FALSE;
|
||||
response = FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
|
||||
|
||||
@@ -43,6 +43,7 @@ class MpvPlayerCore: NSObject {
|
||||
private var mpv: OpaquePointer?
|
||||
private weak var window: NSWindow?
|
||||
private lazy var queue = DispatchQueue(label: "mpv", qos: .userInitiated)
|
||||
private var playbackActivity: NSObjectProtocol?
|
||||
|
||||
weak var delegate: MpvPlayerDelegate?
|
||||
|
||||
@@ -79,6 +80,7 @@ class MpvPlayerCore: NSObject {
|
||||
layer.contentsScale = screen.backingScaleFactor
|
||||
}
|
||||
layer.framebufferOnly = true
|
||||
layer.isOpaque = true
|
||||
layer.backgroundColor = NSColor.black.cgColor
|
||||
layer.autoresizingMask = [.layerWidthSizable, .layerHeightSizable]
|
||||
|
||||
@@ -166,6 +168,7 @@ class MpvPlayerCore: NSObject {
|
||||
checkError(mpv_set_option_string(mpv, "gpu-context", "moltenvk"))
|
||||
checkError(mpv_set_option_string(mpv, "hwdec", "videotoolbox"))
|
||||
checkError(mpv_set_option_string(mpv, "target-colorspace-hint", "yes"))
|
||||
checkError(mpv_set_option_string(mpv, "vulkan-swap-mode", "mailbox"))
|
||||
|
||||
// Initialize MPV
|
||||
let initResult = mpv_initialize(mpv)
|
||||
@@ -307,6 +310,9 @@ class MpvPlayerCore: NSObject {
|
||||
if let superlayer = window?.contentView?.layer {
|
||||
superlayer.insertSublayer(layer, at: 0)
|
||||
}
|
||||
beginPlaybackActivity()
|
||||
} else {
|
||||
endPlaybackActivity()
|
||||
}
|
||||
|
||||
layer.isHidden = !visible
|
||||
@@ -547,9 +553,28 @@ class MpvPlayerCore: NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Power Management
|
||||
|
||||
private func beginPlaybackActivity() {
|
||||
guard playbackActivity == nil else { return }
|
||||
playbackActivity = ProcessInfo.processInfo.beginActivity(
|
||||
options: [.userInitiated, .latencyCritical],
|
||||
reason: "Video playback"
|
||||
)
|
||||
print("[MpvPlayerCore] Began playback activity assertion")
|
||||
}
|
||||
|
||||
private func endPlaybackActivity() {
|
||||
guard let activity = playbackActivity else { return }
|
||||
ProcessInfo.processInfo.endActivity(activity)
|
||||
playbackActivity = nil
|
||||
print("[MpvPlayerCore] Ended playback activity assertion")
|
||||
}
|
||||
|
||||
// MARK: - Cleanup
|
||||
|
||||
func dispose() {
|
||||
endPlaybackActivity()
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
|
||||
// Cancel any pending async commands
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
name: plezy
|
||||
description: "A beautiful Plex client for Flutter"
|
||||
publish_to: "none"
|
||||
version: 1.18.2+42
|
||||
version: 1.19.0+43
|
||||
|
||||
environment:
|
||||
sdk: ^3.8.1
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
/// Generates lib/data/ducet_order.dart from Unicode allkeys.txt and CLDR FractionalUCA.txt.
|
||||
///
|
||||
/// Usage:
|
||||
/// dart run scripts/generate_ducet_ranks.dart [allkeys.txt] [FractionalUCA.txt]
|
||||
///
|
||||
/// Downloads the files automatically if not provided.
|
||||
import 'dart:io';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Weight tuple for multi-level UCA comparison
|
||||
// ---------------------------------------------------------------------------
|
||||
class _Weight implements Comparable<_Weight> {
|
||||
final List<(int, int, int)> levels;
|
||||
final int codepoint; // tiebreaker
|
||||
|
||||
const _Weight(this.levels, this.codepoint);
|
||||
|
||||
@override
|
||||
int compareTo(_Weight other) {
|
||||
final len = levels.length < other.levels.length ? levels.length : other.levels.length;
|
||||
|
||||
// Primary pass
|
||||
for (var i = 0; i < len; i++) {
|
||||
final cmp = levels[i].$1.compareTo(other.levels[i].$1);
|
||||
if (cmp != 0) return cmp;
|
||||
}
|
||||
if (levels.length != other.levels.length) {
|
||||
return levels.length.compareTo(other.levels.length);
|
||||
}
|
||||
|
||||
// Secondary pass
|
||||
for (var i = 0; i < len; i++) {
|
||||
final cmp = levels[i].$2.compareTo(other.levels[i].$2);
|
||||
if (cmp != 0) return cmp;
|
||||
}
|
||||
|
||||
// Tertiary pass
|
||||
for (var i = 0; i < len; i++) {
|
||||
final cmp = levels[i].$3.compareTo(other.levels[i].$3);
|
||||
if (cmp != 0) return cmp;
|
||||
}
|
||||
|
||||
// Codepoint tiebreaker
|
||||
return codepoint.compareTo(other.codepoint);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Katakana codepoint ranges (for CLDR kana tertiary reversal)
|
||||
// ---------------------------------------------------------------------------
|
||||
bool _isKatakana(int cp) =>
|
||||
(cp >= 0x30A0 && cp <= 0x30FF) || // Katakana
|
||||
(cp >= 0x31F0 && cp <= 0x31FF) || // Katakana Phonetic Extensions
|
||||
(cp >= 0xFF65 && cp <= 0xFF9F); // Halfwidth Katakana
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Parse allkeys.txt → Map<codepoint, weight-tuples>
|
||||
//
|
||||
// CLDR kana fix: ICU/CLDR root collation sorts katakana before hiragana
|
||||
// (opposite of raw DUCET). We adjust by subtracting 6 from katakana tertiary
|
||||
// weights, placing them below hiragana tertiaries (0x000D+).
|
||||
// ---------------------------------------------------------------------------
|
||||
Map<int, _Weight> parseAllKeys(String text) {
|
||||
final result = <int, _Weight>{};
|
||||
final weightRe = RegExp(r'\[([.*])([0-9A-Fa-f]{4})\.([0-9A-Fa-f]{4})\.([0-9A-Fa-f]{4})\]');
|
||||
|
||||
for (final line in text.split('\n')) {
|
||||
final trimmed = line.trim();
|
||||
if (trimmed.isEmpty || trimmed.startsWith('#') || trimmed.startsWith('@')) continue;
|
||||
|
||||
final semiIdx = trimmed.indexOf(';');
|
||||
if (semiIdx < 0) continue;
|
||||
|
||||
final cpPart = trimmed.substring(0, semiIdx).trim();
|
||||
if (cpPart.contains(' ')) continue; // skip multi-codepoint
|
||||
|
||||
final cp = int.tryParse(cpPart, radix: 16);
|
||||
if (cp == null || cp > 0xFFFF) continue; // BMP only
|
||||
|
||||
final weightPart = trimmed.substring(semiIdx + 1);
|
||||
final matches = weightRe.allMatches(weightPart);
|
||||
if (matches.isEmpty) continue;
|
||||
|
||||
final isKat = _isKatakana(cp);
|
||||
final levels = <(int, int, int)>[];
|
||||
for (final m in matches) {
|
||||
final p = int.parse(m.group(2)!, radix: 16);
|
||||
final s = int.parse(m.group(3)!, radix: 16);
|
||||
var t = int.parse(m.group(4)!, radix: 16);
|
||||
// CLDR kana fix: lower katakana tertiary below hiragana range
|
||||
if (isKat && t >= 0x000F) t -= 6;
|
||||
levels.add((p, s, t));
|
||||
}
|
||||
|
||||
if (levels.every((l) => l.$1 == 0 && l.$2 == 0 && l.$3 == 0)) continue;
|
||||
|
||||
result[cp] = _Weight(levels, cp);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Parse FractionalUCA.txt radical lines → CJK codepoints in radical-stroke
|
||||
// order, plus Kangxi radical → CJK decomposition map.
|
||||
// ---------------------------------------------------------------------------
|
||||
(List<int>, Map<int, int>) parseRadicals(String text) {
|
||||
final order = <int>[];
|
||||
final kangxiDecomp = <int, int>{}; // kangxi radical CP → CJK CP
|
||||
final radicalRe = RegExp(r'^\[radical \d+');
|
||||
|
||||
for (final line in text.split('\n')) {
|
||||
if (!radicalRe.hasMatch(line)) continue;
|
||||
|
||||
// Parse header: [radical N=<kangxi><cjk>:<char-list>]
|
||||
final eqIdx = line.indexOf('=');
|
||||
final colonIdx = line.indexOf(':');
|
||||
if (eqIdx < 0 || colonIdx < 0 || colonIdx <= eqIdx) continue;
|
||||
final closeBracket = line.lastIndexOf(']');
|
||||
if (closeBracket < 0) continue;
|
||||
|
||||
// Extract Kangxi radical → CJK mapping from header
|
||||
final headerChars = line.substring(eqIdx + 1, colonIdx).runes.toList();
|
||||
if (headerChars.length >= 2) {
|
||||
final kangxi = headerChars[0];
|
||||
final cjk = headerChars[1];
|
||||
// Kangxi Radicals: U+2F00-U+2FD5
|
||||
if (kangxi >= 0x2F00 && kangxi <= 0x2FD5 && cjk <= 0xFFFF) {
|
||||
kangxiDecomp[kangxi] = cjk;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse character list after colon
|
||||
final charList = line.substring(colonIdx + 1, closeBracket);
|
||||
final runes = charList.runes.toList();
|
||||
var i = 0;
|
||||
while (i < runes.length) {
|
||||
final cp = runes[i];
|
||||
|
||||
if (cp == 0x20) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check for range: <char>-<char>
|
||||
if (i + 2 < runes.length && runes[i + 1] == 0x2D) {
|
||||
final endCp = runes[i + 2];
|
||||
for (var c = cp; c <= endCp; c++) {
|
||||
if (c <= 0xFFFF) order.add(c);
|
||||
}
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cp <= 0xFFFF) order.add(cp);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
// Deduplicate preserving order
|
||||
final seen = <int>{};
|
||||
final deduped = order.where((cp) => seen.add(cp)).toList();
|
||||
return (deduped, kangxiDecomp);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Build final ordered list
|
||||
// ---------------------------------------------------------------------------
|
||||
List<int> buildOrder(Map<int, _Weight> allKeys, List<int> cjkRadicalOrder) {
|
||||
final entries = allKeys.entries.toList();
|
||||
entries.sort((a, b) => a.value.compareTo(b.value));
|
||||
|
||||
final ordered = <int>[];
|
||||
final cjkSet = cjkRadicalOrder.toSet();
|
||||
bool cjkInserted = false;
|
||||
|
||||
for (final e in entries) {
|
||||
if (cjkSet.contains(e.key)) continue;
|
||||
|
||||
if (!cjkInserted && e.value.levels.isNotEmpty && e.value.levels.first.$1 >= 0xFB00) {
|
||||
for (final cp in cjkRadicalOrder) {
|
||||
if (cp <= 0xFFFF) ordered.add(cp);
|
||||
}
|
||||
cjkInserted = true;
|
||||
}
|
||||
|
||||
ordered.add(e.key);
|
||||
}
|
||||
|
||||
if (!cjkInserted) {
|
||||
for (final cp in cjkRadicalOrder) {
|
||||
if (cp <= 0xFFFF) ordered.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
return ordered;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Main
|
||||
// ---------------------------------------------------------------------------
|
||||
Future<void> main(List<String> args) async {
|
||||
final allKeysPath = args.length > 0 ? args[0] : '/tmp/allkeys.txt';
|
||||
final fracUcaPath = args.length > 1 ? args[1] : '/tmp/FractionalUCA.txt';
|
||||
|
||||
// Download if missing
|
||||
if (!File(allKeysPath).existsSync()) {
|
||||
stderr.writeln('Downloading allkeys.txt...');
|
||||
final result = await Process.run('curl', [
|
||||
'-sL',
|
||||
'https://www.unicode.org/Public/UCA/13.0.0/allkeys.txt',
|
||||
'-o',
|
||||
allKeysPath,
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
stderr.writeln('Failed to download allkeys.txt');
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!File(fracUcaPath).existsSync()) {
|
||||
stderr.writeln('Downloading FractionalUCA.txt...');
|
||||
final result = await Process.run('curl', [
|
||||
'-sL',
|
||||
'https://raw.githubusercontent.com/unicode-org/cldr/release-39/common/uca/FractionalUCA.txt',
|
||||
'-o',
|
||||
fracUcaPath,
|
||||
]);
|
||||
if (result.exitCode != 0) {
|
||||
stderr.writeln('Failed to download FractionalUCA.txt');
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
stderr.writeln('Parsing allkeys.txt (with CLDR kana fix)...');
|
||||
final allKeysText = File(allKeysPath).readAsStringSync();
|
||||
final allKeys = parseAllKeys(allKeysText);
|
||||
stderr.writeln(' ${allKeys.length} BMP entries');
|
||||
|
||||
stderr.writeln('Parsing FractionalUCA.txt...');
|
||||
final fracText = File(fracUcaPath).readAsStringSync();
|
||||
final (cjkOrder, kangxiDecomp) = parseRadicals(fracText);
|
||||
stderr.writeln(' ${cjkOrder.length} CJK codepoints in radical-stroke order');
|
||||
stderr.writeln(' ${kangxiDecomp.length} Kangxi radical decompositions');
|
||||
final bmpCjk = cjkOrder.where((cp) => cp <= 0xFFFF).length;
|
||||
stderr.writeln(' $bmpCjk BMP CJK codepoints');
|
||||
|
||||
stderr.writeln('Building total order...');
|
||||
final ordered = buildOrder(allKeys, cjkOrder);
|
||||
stderr.writeln(' ${ordered.length} total BMP codepoints in order');
|
||||
|
||||
stderr.writeln(' ${ordered.length * 2} raw bytes');
|
||||
|
||||
// Generate Dart file — store codepoints as a raw UTF-16 string constant.
|
||||
// Each char IS the codepoint. Dart strings are UTF-16 natively, so the
|
||||
// compiled snapshot stores the data as raw 2-byte values with zero decoding.
|
||||
final outPath = '${Directory.current.path}/lib/data/ducet_order.dart';
|
||||
final buf = StringBuffer();
|
||||
buf.writeln('/// Sorted BMP codepoints per DUCET (Unicode 13.0) + CLDR 39 CJK radical-stroke.');
|
||||
buf.writeln('/// Katakana sorts before hiragana (CLDR root tailoring).');
|
||||
buf.writeln('/// Generated by scripts/generate_ducet_ranks.dart — do not edit.');
|
||||
buf.writeln();
|
||||
|
||||
// Raw UTF-16 string — each code unit is a codepoint in DUCET order.
|
||||
// Use \uXXXX escapes so the source stays ASCII-safe.
|
||||
buf.write("const String _ducetOrder = '");
|
||||
for (var i = 0; i < ordered.length; i++) {
|
||||
final cp = ordered[i];
|
||||
if (cp == 0x27) {
|
||||
buf.write(r"\'"); // escape single quote
|
||||
} else if (cp == 0x5C) {
|
||||
buf.write(r'\\'); // escape backslash
|
||||
} else if (cp == 0x24) {
|
||||
buf.write(r'\$'); // escape dollar
|
||||
} else {
|
||||
buf.write('\\u${cp.toRadixString(16).padLeft(4, '0')}');
|
||||
}
|
||||
}
|
||||
buf.writeln("';");
|
||||
|
||||
// Kangxi radical decomposition map
|
||||
buf.writeln();
|
||||
buf.writeln('/// Kangxi Radicals (U+2F00-U+2FD5) → CJK Unified equivalents.');
|
||||
buf.writeln('/// ICU decomposes these via NFD before collation.');
|
||||
buf.writeln('const Map<int, int> _kangxiDecomp = {');
|
||||
final sortedKangxi = kangxiDecomp.entries.toList()..sort((a, b) => a.key.compareTo(b.key));
|
||||
for (final e in sortedKangxi) {
|
||||
buf.writeln(' 0x${e.key.toRadixString(16).toUpperCase()}: 0x${e.value.toRadixString(16).toUpperCase()},');
|
||||
}
|
||||
buf.writeln('};');
|
||||
|
||||
buf.writeln();
|
||||
buf.writeln('late final Map<int, int> _ranks = _buildRanks();');
|
||||
buf.writeln();
|
||||
buf.writeln('Map<int, int> _buildRanks() {');
|
||||
buf.writeln(' return {');
|
||||
buf.writeln(' for (var i = 0; i < _ducetOrder.length; i++)');
|
||||
buf.writeln(' _ducetOrder.codeUnitAt(i): i,');
|
||||
buf.writeln(' };');
|
||||
buf.writeln('}');
|
||||
buf.writeln();
|
||||
buf.writeln('/// Compare two characters using DUCET + CLDR ordering.');
|
||||
buf.writeln('/// Decomposes Kangxi radicals to CJK equivalents before lookup.');
|
||||
buf.writeln('/// Falls back to codepoint order for characters not in the table.');
|
||||
buf.writeln('int ducetCompare(String a, String b) {');
|
||||
buf.writeln(' var cpA = a.runes.first;');
|
||||
buf.writeln(' var cpB = b.runes.first;');
|
||||
buf.writeln(' cpA = _kangxiDecomp[cpA] ?? cpA;');
|
||||
buf.writeln(' cpB = _kangxiDecomp[cpB] ?? cpB;');
|
||||
buf.writeln(' final rankA = _ranks[cpA] ?? (0x100000 + cpA);');
|
||||
buf.writeln(' final rankB = _ranks[cpB] ?? (0x100000 + cpB);');
|
||||
buf.writeln(' return rankA.compareTo(rankB);');
|
||||
buf.writeln('}');
|
||||
|
||||
File(outPath).writeAsStringSync(buf.toString());
|
||||
stderr.writeln('Written to $outPath');
|
||||
}
|
||||
Reference in New Issue
Block a user