refactor: fix warnings
This commit is contained in:
@@ -61,16 +61,10 @@ class _HubDetailScreenState extends State<HubDetailScreen> with Refreshable {
|
||||
final hubKey = widget.hub.hubKey;
|
||||
appLogger.d('Hub key: $hubKey');
|
||||
|
||||
RegExpMatch? match;
|
||||
|
||||
// Try different patterns
|
||||
match = RegExp(r'/hubs/sections/(\d+)').firstMatch(hubKey);
|
||||
if (match == null) {
|
||||
match = RegExp(r'/library/sections/(\d+)').firstMatch(hubKey);
|
||||
}
|
||||
if (match == null) {
|
||||
match = RegExp(r'sections/(\d+)').firstMatch(hubKey);
|
||||
}
|
||||
RegExpMatch? match = RegExp(r'/hubs/sections/(\d+)').firstMatch(hubKey);
|
||||
match ??= RegExp(r'/library/sections/(\d+)').firstMatch(hubKey);
|
||||
match ??= RegExp(r'sections/(\d+)').firstMatch(hubKey);
|
||||
|
||||
if (match != null) {
|
||||
final sectionId = match.group(1)!;
|
||||
|
||||
@@ -201,16 +201,6 @@ class _LibrariesScreenState extends State<LibrariesScreen>
|
||||
await storage.saveLibraryOrder(libraryKeys);
|
||||
}
|
||||
|
||||
void _reorderLibraries(int oldIndex, int newIndex) {
|
||||
setState(() {
|
||||
if (newIndex > oldIndex) {
|
||||
newIndex -= 1;
|
||||
}
|
||||
final library = _allLibraries.removeAt(oldIndex);
|
||||
_allLibraries.insert(newIndex, library);
|
||||
});
|
||||
_saveLibraryOrder();
|
||||
}
|
||||
|
||||
Future<void> _loadLibraryContent(String libraryKey) async {
|
||||
// Compute visible libraries based on current provider state
|
||||
@@ -1436,45 +1426,58 @@ class _SortBottomSheetState extends State<_SortBottomSheet> {
|
||||
|
||||
// Sort options list
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
controller: scrollController,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: widget.sortOptions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final sort = widget.sortOptions[index];
|
||||
final isSelected = _tempSelectedSort?.key == sort.key;
|
||||
child: RadioGroup<String>(
|
||||
groupValue: _tempSelectedSort?.key,
|
||||
onChanged: (value) {
|
||||
final sort = widget.sortOptions.firstWhere((s) => s.key == value);
|
||||
setState(() {
|
||||
_tempSelectedSort = sort;
|
||||
// Use default direction for newly selected sort
|
||||
_tempDescending = sort.isDefaultDescending;
|
||||
});
|
||||
// Apply sort immediately with default direction
|
||||
widget.onSortChanged(sort, sort.isDefaultDescending);
|
||||
},
|
||||
child: ListView.builder(
|
||||
controller: scrollController,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: widget.sortOptions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final sort = widget.sortOptions[index];
|
||||
final isSelected = _tempSelectedSort?.key == sort.key;
|
||||
|
||||
return ListTile(
|
||||
title: Text(sort.title),
|
||||
trailing: isSelected
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Direction toggle buttons
|
||||
SegmentedButton<bool>(
|
||||
showSelectedIcon: false,
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: false,
|
||||
icon: Icon(Icons.arrow_upward, size: 16),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
icon: Icon(Icons.arrow_downward, size: 16),
|
||||
),
|
||||
],
|
||||
selected: {_tempDescending},
|
||||
onSelectionChanged: (Set<bool> selected) {
|
||||
widget.onSortChanged(sort, selected.first);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: null,
|
||||
leading: Radio<String>(
|
||||
value: sort.key,
|
||||
groupValue: _tempSelectedSort?.key,
|
||||
onChanged: (value) {
|
||||
return ListTile(
|
||||
title: Text(sort.title),
|
||||
trailing: isSelected
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Direction toggle buttons
|
||||
SegmentedButton<bool>(
|
||||
showSelectedIcon: false,
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: false,
|
||||
icon: Icon(Icons.arrow_upward, size: 16),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
icon: Icon(Icons.arrow_downward, size: 16),
|
||||
),
|
||||
],
|
||||
selected: {_tempDescending},
|
||||
onSelectionChanged: (Set<bool> selected) {
|
||||
widget.onSortChanged(sort, selected.first);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: null,
|
||||
leading: Radio<String>(
|
||||
value: sort.key,
|
||||
toggleable: false,
|
||||
),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_tempSelectedSort = sort;
|
||||
// Use default direction for newly selected sort
|
||||
@@ -1483,18 +1486,9 @@ class _SortBottomSheetState extends State<_SortBottomSheet> {
|
||||
// Apply sort immediately with default direction
|
||||
widget.onSortChanged(sort, sort.isDefaultDescending);
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_tempSelectedSort = sort;
|
||||
// Use default direction for newly selected sort
|
||||
_tempDescending = sort.isDefaultDescending;
|
||||
});
|
||||
// Apply sort immediately with default direction
|
||||
widget.onSortChanged(sort, sort.isDefaultDescending);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -1587,6 +1581,7 @@ class _LibraryManagementSheetState extends State<_LibraryManagementSheet> {
|
||||
);
|
||||
|
||||
if (selectedItem.requiresConfirmation) {
|
||||
if (!mounted || !context.mounted) return;
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
@@ -1703,7 +1698,7 @@ class _LibraryManagementSheetState extends State<_LibraryManagementSheet> {
|
||||
Icons.drag_indicator,
|
||||
color: Theme.of(
|
||||
context,
|
||||
).textTheme.bodyMedium?.color?.withOpacity(0.5),
|
||||
).textTheme.bodyMedium?.color?.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -32,6 +32,9 @@ Future<bool?> navigateToVideoPlayer(
|
||||
int? selectedMediaIndex,
|
||||
bool usePushReplacement = false,
|
||||
}) async {
|
||||
// Extract navigator before any async operations
|
||||
final navigator = Navigator.of(context);
|
||||
|
||||
// Load saved media version preference if not explicitly provided
|
||||
int mediaIndex = selectedMediaIndex ?? 0;
|
||||
if (selectedMediaIndex == null) {
|
||||
@@ -60,8 +63,8 @@ Future<bool?> navigateToVideoPlayer(
|
||||
);
|
||||
|
||||
if (usePushReplacement) {
|
||||
return Navigator.of(context).pushReplacement<bool, bool>(route);
|
||||
return navigator.pushReplacement<bool, bool>(route);
|
||||
} else {
|
||||
return Navigator.push<bool>(context, route);
|
||||
return navigator.push<bool>(route);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,6 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
late final FocusNode _focusNode;
|
||||
KeyboardShortcutsService? _keyboardService;
|
||||
int _seekTimeSmall = 10; // Default, loaded from settings
|
||||
int _seekTimeLarge = 30; // Default, loaded from settings
|
||||
// Double-tap feedback state
|
||||
bool _showDoubleTapFeedback = false;
|
||||
double _doubleTapFeedbackOpacity = 0.0;
|
||||
@@ -109,7 +108,6 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_seekTimeSmall = settingsService.getSeekTimeSmall();
|
||||
_seekTimeLarge = settingsService.getSeekTimeLarge();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1351,7 +1349,7 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
selectedSnapshot.data ??
|
||||
widget.player.state.track;
|
||||
final selectedTrack = currentTrack.audio;
|
||||
final selectedId = selectedTrack?.id;
|
||||
final selectedId = selectedTrack.id;
|
||||
|
||||
return ListView.builder(
|
||||
itemCount: audioTracks.length,
|
||||
@@ -1477,7 +1475,7 @@ class _PlexVideoControlsState extends State<PlexVideoControls>
|
||||
selectedSnapshot.data ??
|
||||
widget.player.state.track;
|
||||
final selectedTrack = currentTrack.subtitle;
|
||||
final selectedId = selectedTrack?.id;
|
||||
final selectedId = selectedTrack.id;
|
||||
final isOffSelected = selectedId == 'no';
|
||||
|
||||
return ListView.builder(
|
||||
|
||||
@@ -90,57 +90,60 @@ class _SortBottomSheetState extends State<SortBottomSheet> {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
controller: scrollController,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: widget.sortOptions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final sort = widget.sortOptions[index];
|
||||
final isSelected = _currentSort?.key == sort.key;
|
||||
|
||||
return ListTile(
|
||||
title: Text(sort.title),
|
||||
trailing: isSelected
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SegmentedButton<bool>(
|
||||
showSelectedIcon: false,
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: false,
|
||||
icon: Icon(Icons.arrow_upward, size: 16),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
icon: Icon(Icons.arrow_downward, size: 16),
|
||||
),
|
||||
],
|
||||
selected: {_currentDescending},
|
||||
onSelectionChanged: (Set<bool> newSelection) {
|
||||
_handleSortChange(sort, newSelection.first);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: null,
|
||||
leading: Radio<PlexSort>(
|
||||
value: sort,
|
||||
groupValue: _currentSort,
|
||||
onChanged: (PlexSort? value) {
|
||||
if (value != null) {
|
||||
_handleSortChange(
|
||||
value,
|
||||
value.defaultDirection == 'desc',
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
onTap: () {
|
||||
_handleSortChange(sort, sort.defaultDirection == 'desc');
|
||||
},
|
||||
);
|
||||
child: RadioGroup<PlexSort>(
|
||||
groupValue: _currentSort,
|
||||
onChanged: (PlexSort? value) {
|
||||
if (value != null) {
|
||||
_handleSortChange(
|
||||
value,
|
||||
value.defaultDirection == 'desc',
|
||||
);
|
||||
}
|
||||
},
|
||||
child: ListView.builder(
|
||||
controller: scrollController,
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: widget.sortOptions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final sort = widget.sortOptions[index];
|
||||
final isSelected = _currentSort?.key == sort.key;
|
||||
|
||||
return ListTile(
|
||||
title: Text(sort.title),
|
||||
trailing: isSelected
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SegmentedButton<bool>(
|
||||
showSelectedIcon: false,
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: false,
|
||||
icon: Icon(Icons.arrow_upward, size: 16),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: true,
|
||||
icon: Icon(Icons.arrow_downward, size: 16),
|
||||
),
|
||||
],
|
||||
selected: {_currentDescending},
|
||||
onSelectionChanged: (Set<bool> newSelection) {
|
||||
_handleSortChange(sort, newSelection.first);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: null,
|
||||
leading: Radio<PlexSort>(
|
||||
value: sort,
|
||||
toggleable: false,
|
||||
),
|
||||
onTap: () {
|
||||
_handleSortChange(sort, sort.defaultDirection == 'desc');
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user