mirror of
https://github.com/R0m1k3/xtremobile.git
synced 2026-10-23 15:18:15 +02:00
debug
This commit is contained in:
1 parent
664e89f2b8
commit
51f73d102d
3 files changed
+90
-23
No files matched your search
@@ -14,7 +14,7 @@ class XtreamServiceMobile {
|
|||||||
|
|
||||||
PlaylistConfig? _currentPlaylist;
|
PlaylistConfig? _currentPlaylist;
|
||||||
|
|
||||||
XtreamServiceMobile() {
|
XtreamServiceMobile(String cachePath) {
|
||||||
_dio = Dio(BaseOptions(
|
_dio = Dio(BaseOptions(
|
||||||
connectTimeout: const Duration(seconds: 15),
|
connectTimeout: const Duration(seconds: 15),
|
||||||
receiveTimeout: const Duration(seconds: 15),
|
receiveTimeout: const Duration(seconds: 15),
|
||||||
@@ -22,7 +22,7 @@ class XtreamServiceMobile {
|
|||||||
|
|
||||||
// Setup caching for API responses
|
// Setup caching for API responses
|
||||||
_cacheOptions = CacheOptions(
|
_cacheOptions = CacheOptions(
|
||||||
store: HiveCacheStore('./cache'),
|
store: HiveCacheStore(cachePath),
|
||||||
policy: CachePolicy.forceCache,
|
policy: CachePolicy.forceCache,
|
||||||
maxStale: const Duration(hours: 1),
|
maxStale: const Duration(hours: 1),
|
||||||
priority: CachePriority.high,
|
priority: CachePriority.high,
|
||||||
|
|||||||
@@ -42,11 +42,12 @@ class _MobilePlaylistScreenState extends ConsumerState<MobilePlaylistScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _showAddPlaylistDialog() {
|
void _showPlaylistDialog({PlaylistConfig? playlist}) {
|
||||||
final nameController = TextEditingController();
|
final isEditing = playlist != null;
|
||||||
final dnsController = TextEditingController();
|
final nameController = TextEditingController(text: playlist?.name ?? '');
|
||||||
final usernameController = TextEditingController();
|
final dnsController = TextEditingController(text: playlist?.dns ?? '');
|
||||||
final passwordController = TextEditingController();
|
final usernameController = TextEditingController(text: playlist?.username ?? '');
|
||||||
|
final passwordController = TextEditingController(text: playlist?.password ?? '');
|
||||||
|
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -80,9 +81,9 @@ class _MobilePlaylistScreenState extends ConsumerState<MobilePlaylistScreen> {
|
|||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
const Text(
|
Text(
|
||||||
'Ajouter une playlist',
|
isEditing ? 'Modifier la playlist' : 'Ajouter une playlist',
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: AppColors.textPrimary,
|
color: AppColors.textPrimary,
|
||||||
@@ -140,26 +141,42 @@ class _MobilePlaylistScreenState extends ConsumerState<MobilePlaylistScreen> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _playlistService.addPlaylist(
|
// Auto-fix URL scheme
|
||||||
name: nameController.text,
|
String dns = dnsController.text.trim();
|
||||||
dns: dnsController.text,
|
if (!dns.startsWith('http://') && !dns.startsWith('https://')) {
|
||||||
username: usernameController.text,
|
dns = 'http://$dns';
|
||||||
password: passwordController.text,
|
}
|
||||||
);
|
|
||||||
|
if (isEditing) {
|
||||||
|
await _playlistService.updatePlaylist(
|
||||||
|
id: playlist!.id,
|
||||||
|
name: nameController.text.trim(),
|
||||||
|
dns: dns,
|
||||||
|
username: usernameController.text.trim(),
|
||||||
|
password: passwordController.text.trim(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await _playlistService.addPlaylist(
|
||||||
|
name: nameController.text.trim(),
|
||||||
|
dns: dns,
|
||||||
|
username: usernameController.text.trim(),
|
||||||
|
password: passwordController.text.trim(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
_refreshPlaylists();
|
_refreshPlaylists();
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
SnackBar(
|
||||||
content: Text('Playlist ajoutée avec succès'),
|
content: Text(isEditing ? 'Playlist modifiée' : 'Playlist ajoutée'),
|
||||||
backgroundColor: Colors.green,
|
backgroundColor: Colors.green,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.add),
|
icon: Icon(isEditing ? Icons.save : Icons.add),
|
||||||
label: const Text('Ajouter'),
|
label: Text(isEditing ? 'Enregistrer' : 'Ajouter'),
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
backgroundColor: AppColors.primary,
|
backgroundColor: AppColors.primary,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
@@ -207,6 +224,55 @@ class _MobilePlaylistScreenState extends ConsumerState<MobilePlaylistScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showOptionsSheet(PlaylistConfig playlist) {
|
||||||
|
showModalBottomSheet(
|
||||||
|
context: context,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
builder: (context) => Container(
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: AppColors.surface,
|
||||||
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
||||||
|
),
|
||||||
|
child: SafeArea(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Center(
|
||||||
|
child: Container(
|
||||||
|
width: 40,
|
||||||
|
height: 4,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColors.textTertiary,
|
||||||
|
borderRadius: BorderRadius.circular(2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.edit, color: AppColors.textPrimary),
|
||||||
|
title: const Text('Modifier', style: TextStyle(color: AppColors.textPrimary)),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
_showPlaylistDialog(playlist: playlist);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.delete, color: AppColors.error),
|
||||||
|
title: const Text('Supprimer', style: TextStyle(color: AppColors.error)),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
_showDeleteConfirmation(playlist);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void _showDeleteConfirmation(PlaylistConfig playlist) {
|
void _showDeleteConfirmation(PlaylistConfig playlist) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -312,7 +378,7 @@ class _MobilePlaylistScreenState extends ConsumerState<MobilePlaylistScreen> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
FilledButton.icon(
|
FilledButton.icon(
|
||||||
onPressed: _showAddPlaylistDialog,
|
onPressed: () => _showPlaylistDialog(),
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
label: const Text('Ajouter une playlist'),
|
label: const Text('Ajouter une playlist'),
|
||||||
style: FilledButton.styleFrom(
|
style: FilledButton.styleFrom(
|
||||||
@@ -337,14 +403,14 @@ class _MobilePlaylistScreenState extends ConsumerState<MobilePlaylistScreen> {
|
|||||||
return _PlaylistCard(
|
return _PlaylistCard(
|
||||||
playlist: playlist,
|
playlist: playlist,
|
||||||
onTap: () => _navigateToDashboard(playlist),
|
onTap: () => _navigateToDashboard(playlist),
|
||||||
onLongPress: () => _showDeleteConfirmation(playlist),
|
onLongPress: () => _showOptionsSheet(playlist),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: _showAddPlaylistDialog,
|
onPressed: () => _showPlaylistDialog(),
|
||||||
backgroundColor: AppColors.primary,
|
backgroundColor: AppColors.primary,
|
||||||
child: const Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ dependencies:
|
|||||||
intl: ^0.19.0
|
intl: ^0.19.0
|
||||||
equatable: ^2.0.5
|
equatable: ^2.0.5
|
||||||
shared_preferences: ^2.3.2
|
shared_preferences: ^2.3.2
|
||||||
|
path_provider: ^2.1.5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user