feat(ui): add premium PluriWave redesign
This commit is contained in:
@@ -115,11 +115,28 @@ class ServicioFavoritos {
|
||||
/// Actualiza el orden de un favorito.
|
||||
Future<void> reordenar(String uuid, int nuevoOrden) async {
|
||||
final db = await _database;
|
||||
await db.update(
|
||||
'favoritos',
|
||||
{'orden': nuevoOrden},
|
||||
where: 'uuid = ?',
|
||||
whereArgs: [uuid],
|
||||
);
|
||||
await db.transaction((txn) async {
|
||||
final rows = await txn.query(
|
||||
'favoritos',
|
||||
columns: ['uuid'],
|
||||
orderBy: 'orden ASC, id ASC',
|
||||
);
|
||||
final uuids = rows.map((r) => r['uuid'] as String).toList();
|
||||
final oldIndex = uuids.indexOf(uuid);
|
||||
if (oldIndex == -1 || uuids.isEmpty) return;
|
||||
|
||||
final targetIndex = nuevoOrden.clamp(0, uuids.length - 1);
|
||||
final moved = uuids.removeAt(oldIndex);
|
||||
uuids.insert(targetIndex, moved);
|
||||
|
||||
for (var i = 0; i < uuids.length; i++) {
|
||||
await txn.update(
|
||||
'favoritos',
|
||||
{'orden': i},
|
||||
where: 'uuid = ?',
|
||||
whereArgs: [uuids[i]],
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user