界面功能优化

This commit is contained in:
DelLevin-Home
2026-08-12 13:14:35 +08:00
parent 05c3eaeed5
commit 432c14462f
4 changed files with 207 additions and 277 deletions

View File

@@ -146,6 +146,7 @@ class _PersonListPageState extends State<PersonListPage> {
Widget _buildIndexBar(ColorScheme colors) {
final present = _letterFirstIndex.keys.toSet();
final barKey = GlobalKey();
return Positioned(
right: 2,
top: 0,
@@ -155,42 +156,64 @@ class _PersonListPageState extends State<PersonListPage> {
final maxH = constraints.maxHeight;
const barPadding = 4.0;
final available = maxH - barPadding * 2;
final itemH = (available / _allLetters.length).clamp(8.0, 16.0);
final itemH = (available / _allLetters.length).clamp(12.0, 24.0);
String letterAtY(double y) {
final localY = (y - barPadding).clamp(0.0, available);
final i = (localY / itemH).floor().clamp(0, _allLetters.length - 1);
return _allLetters[i];
}
void handleAt(Offset globalPos) {
final robj = barKey.currentContext?.findRenderObject();
if (robj is! RenderBox) return;
final local = robj.globalToLocal(globalPos);
final letter = letterAtY(local.dy);
if (!present.contains(letter)) return;
if (_activeLetterNotifier.value != letter) {
_activeLetterNotifier.value = letter;
_jumpToLetter(letter);
}
}
return Padding(
key: barKey,
padding: const EdgeInsets.symmetric(vertical: barPadding),
child: ValueListenableBuilder<String>(
valueListenable: _activeLetterNotifier,
builder: (context, activeLetter, _) {
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
for (final letter in _allLetters)
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (!present.contains(letter)) return;
_activeLetterNotifier.value = letter;
_jumpToLetter(letter);
},
child: SizedBox(
height: itemH,
width: itemH + 8,
child: AnimatedDefaultTextStyle(
duration: const Duration(milliseconds: 150),
curve: Curves.easeOut,
style: TextStyle(
fontSize: activeLetter == letter ? itemH * 1.1 : itemH * 0.65,
fontWeight: activeLetter == letter ? FontWeight.w800 : FontWeight.w500,
color: present.contains(letter)
? (activeLetter == letter ? colors.primary : colors.onSurface.withValues(alpha: 0.7))
: colors.onSurface.withValues(alpha: 0.25),
return GestureDetector(
behavior: HitTestBehavior.opaque,
onVerticalDragDown: (d) => handleAt(d.globalPosition),
onVerticalDragUpdate: (d) => handleAt(d.globalPosition),
onTapDown: (d) => handleAt(d.globalPosition),
child: Container(
width: itemH + 12,
color: Colors.transparent,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
for (final letter in _allLetters)
SizedBox(
height: itemH,
width: itemH + 12,
child: AnimatedDefaultTextStyle(
duration: const Duration(milliseconds: 150),
curve: Curves.easeOut,
style: TextStyle(
fontSize: activeLetter == letter ? itemH * 0.95 : itemH * 0.7,
fontWeight: activeLetter == letter ? FontWeight.w800 : FontWeight.w500,
color: present.contains(letter)
? (activeLetter == letter ? colors.primary : colors.onSurface.withValues(alpha: 0.7))
: colors.onSurface.withValues(alpha: 0.25),
),
child: Text(letter, textAlign: TextAlign.center),
),
child: Text(letter, textAlign: TextAlign.center),
),
),
),
],
],
),
),
);
},
),

View File

@@ -1506,12 +1506,38 @@ class _ProfilePageState extends State<ProfilePage> with RouteAware {
provider.notes.where((n) => !n.isDeleted).toList());
}
if (!context.mounted) return;
ToastUtil.show(context, '已导出到 ${file.path}');
_showExportResult(context, true, '已导出到 ${file.path}');
} catch (e) {
if (!context.mounted) return;
ToastUtil.show(context, '导出失败:$e');
_showExportResult(context, false, '导出失败:$e');
}
}
void _showExportResult(BuildContext context, bool success, String message) {
final colors = Theme.of(context).colorScheme;
showDialog(
context: context,
builder: (ctx) => AlertDialog(
icon: Icon(
success ? Icons.check_circle_outline : Icons.error_outline,
color: success ? colors.primary : colors.error,
size: 32,
),
content: Text(
message,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: colors.onSurface),
),
actionsAlignment: MainAxisAlignment.center,
actions: [
FilledButton(
onPressed: () => Navigator.pop(ctx),
child: const Text('确定'),
),
],
),
);
}
}
class _WatchlistItem {

View File

@@ -964,7 +964,7 @@ class _SettingsPageState extends State<SettingsPage> {
final totalSize = imageInfo.$2 + epubInfo.$2 + tempInfo.$2 + emptyDirInfo.$2;
final totalCount = imageInfo.$1 + epubInfo.$1 + tempInfo.$1 + emptyDirInfo.$1;
if (totalCount == 0) {
ToastUtil.show(pageContext, '没有需要清理的缓存');
_showCacheResult(pageContext, true, '没有需要清理的缓存', false);
return;
}
@@ -1044,19 +1044,46 @@ class _SettingsPageState extends State<SettingsPage> {
builder: (_) => const Center(child: CircularProgressIndicator()));
final result = await CacheCleaner.instance.clean();
Navigator.pop(context);
if (context.mounted) {
if (result.total == 0) {
ToastUtil.show(context, '没有需要清理的缓存');
} else {
ToastUtil.show(context, result.description);
}
}
if (!context.mounted) return;
final success = result.total > 0;
_showCacheResult(
context, true, success ? result.description : '没有需要清理的缓存', success);
} catch (e) {
Navigator.pop(context);
if (context.mounted) ToastUtil.show(context, '清理失败: $e');
if (!context.mounted) return;
_showCacheResult(context, false, '清理失败: $e', false);
}
}
void _showCacheResult(
BuildContext context, bool success, String message, bool cleaned) {
final colors = Theme.of(context).colorScheme;
showDialog(
context: context,
builder: (ctx) => AlertDialog(
icon: Icon(
success
? (cleaned ? Icons.check_circle_outline : Icons.info_outline)
: Icons.error_outline,
color: success ? colors.primary : colors.error,
size: 32,
),
content: Text(
message,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 14, color: colors.onSurface),
),
actionsAlignment: MainAxisAlignment.center,
actions: [
FilledButton(
onPressed: () => Navigator.pop(ctx),
child: const Text('确定'),
),
],
),
);
}
/// 直接查 DB 收集所有图片路径(含软删除记录,与 CacheCleaner 保持一致)
Future<Set<String>> _getAllDbImagePaths() async {
final db = await DatabaseHelper.instance.database;