Skip to content

Commit

Permalink
fix: 优化日志页面的显示
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleafgo committed May 12, 2023
1 parent 7217ecc commit 0f5ab6b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
15 changes: 9 additions & 6 deletions lib/app/pages/logs/logs_page.dart
Expand Up @@ -24,6 +24,7 @@ class _LogsPageState extends State<LogsPage> {
@override
void initState() {
super.initState();
_logsListener();
_logs.addListener(_logsListener);
_controller.addListener(_scrollListener);
}
Expand All @@ -38,11 +39,13 @@ class _LogsPageState extends State<LogsPage> {
void _logsListener() {
// 等待组件渲染完成再滚动到底部
WidgetsBinding.instance.addPostFrameCallback((_) {
_controller.animateTo(
_controller.position.maxScrollExtent,
duration: const Duration(milliseconds: 300),
curve: Curves.easeOut,
);
if (_controller.hasClients) {
_controller.animateTo(
_controller.position.maxScrollExtent,
duration: const Duration(milliseconds: 300),
curve: Curves.easeOut,
);
}
});
}

Expand Down Expand Up @@ -110,7 +113,7 @@ class _LogsPageState extends State<LogsPage> {
margin: const EdgeInsets.all(6),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Theme.of(context).primaryColor.withAlpha(40),
color: Theme.of(context).primaryColor.withAlpha(20),
),
child: ListView.builder(
controller: _controller,
Expand Down
2 changes: 1 addition & 1 deletion lib/app/pages/profiles/profile_item.dart
Expand Up @@ -144,7 +144,7 @@ class SelectableCard extends StatelessWidget {
0,
IconButton(
tooltip: "更新",
icon: Icon(Icons.cached_outlined, color: Theme.of(ctx).textSelectionTheme.selectionColor),
icon: Icon(Icons.refresh_rounded, color: Theme.of(ctx).textSelectionTheme.selectionColor),
onPressed: () => onUpdate(),
));
}
Expand Down
5 changes: 4 additions & 1 deletion lib/app/source/logs_subscription.dart
Expand Up @@ -39,5 +39,8 @@ class LogsSubscription extends ChangeNotifier implements Disposable {
});
}

void clearLogs() => _logQueue.clear();
void clearLogs() {
_logQueue.clear();
notifyListeners();
}
}

0 comments on commit 0f5ab6b

Please sign in to comment.