mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-22 12:51:57 +00:00
categories screen clean up
This commit is contained in:
parent
40fdfc2592
commit
ee2d42fa4b
1 changed files with 16 additions and 27 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:isar_community/isar.dart';
|
import 'package:isar_community/isar.dart';
|
||||||
|
|
@ -115,10 +114,8 @@ class _CategoriesTabState extends ConsumerState<CategoriesTab>
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get _isDesktop {
|
final bool _isDesktop =
|
||||||
if (kIsWeb) return false;
|
Platform.isMacOS || Platform.isLinux || Platform.isWindows;
|
||||||
return Platform.isMacOS || Platform.isLinux || Platform.isWindows;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Moves a category from `index` to `newIndex` in the list,
|
/// Moves a category from `index` to `newIndex` in the list,
|
||||||
/// swaps their positions in memory, and persists the change in Isar.
|
/// swaps their positions in memory, and persists the change in Isar.
|
||||||
|
|
@ -133,6 +130,7 @@ class _CategoriesTabState extends ConsumerState<CategoriesTab>
|
||||||
});
|
});
|
||||||
|
|
||||||
await _swapAnimationController.forward(from: 0.0);
|
await _swapAnimationController.forward(from: 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
// Grab the two category objects involved in the swap
|
// Grab the two category objects involved in the swap
|
||||||
final a = _entries[index];
|
final a = _entries[index];
|
||||||
|
|
@ -147,20 +145,11 @@ class _CategoriesTabState extends ConsumerState<CategoriesTab>
|
||||||
// Persist both updated objects in a single Isar transaction
|
// Persist both updated objects in a single Isar transaction
|
||||||
await isar.writeTxn(() async => isar.categorys.putAll([a, b]));
|
await isar.writeTxn(() async => isar.categorys.putAll([a, b]));
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_animatingFromIndex = null;
|
_animatingFromIndex = null;
|
||||||
_animatingToIndex = null;
|
_animatingToIndex = null;
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
final a = _entries[index];
|
|
||||||
final b = _entries[newIndex];
|
|
||||||
_entries[newIndex] = a;
|
|
||||||
_entries[index] = b;
|
|
||||||
final temp = a.pos;
|
|
||||||
a.pos = b.pos;
|
|
||||||
b.pos = temp;
|
|
||||||
await isar.writeTxn(() async => isar.categorys.putAll([a, b]));
|
|
||||||
setState(() {});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue