Skip to content

Commit d6a6a68

Browse files
committed
feat(debug): launch view log action in main pages and use talker screen
1 parent 79f43f0 commit d6a6a68

File tree

6 files changed

+37
-57
lines changed

6 files changed

+37
-57
lines changed

lib/features/forum/view/forum_page.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ class _ForumPageState extends State<ForumPage>
183183
);
184184
case MenuActions.reverseOrder:
185185
;
186+
case MenuActions.debugViewLog:
187+
await context.pushNamed(ScreenPaths.debugLog);
186188
}
187189
},
188190
);

lib/features/root/view/root_page.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,11 @@ class _RootPageState extends State<RootPage> with LoggerMixin {
3030
@override
3131
void initState() {
3232
super.initState();
33-
debug('enter page ${widget.path}');
3433
rootLocationStream.add(RootLocationEventEnter(widget.path));
3534
}
3635

3736
@override
3837
void dispose() {
39-
debug('leave page ${widget.path}');
4038
rootLocationStream.add(RootLocationEventLeave(widget.path));
4139
super.dispose();
4240
}
Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flutter/material.dart';
2+
import 'package:talker_flutter/talker_flutter.dart';
23
import 'package:tsdm_client/i18n/strings.g.dart';
34
import 'package:tsdm_client/instance.dart';
4-
import 'package:tsdm_client/utils/clipboard.dart';
55

66
/// Debug page for show all caught log since this start.
77
class DebugLogPage extends StatefulWidget {
@@ -16,47 +16,12 @@ class _DebugLogPageState extends State<DebugLogPage> {
1616
@override
1717
Widget build(BuildContext context) {
1818
final tr = context.t.debugLogPage;
19-
// return Scaffold(
20-
// appBar: AppBar(
21-
// title: Text('aaa'),
22-
// ),
23-
// body: Text(talker.history.map((e) => e.generateTextMessage()).join('\n')),
24-
// );
25-
26-
return FutureBuilder(
27-
future: Future.value(
28-
talker.history.map((e) => e.generateTextMessage()).join('\n'),
19+
return TalkerScreen(
20+
talker: talker,
21+
appBarTitle: tr.title,
22+
theme: TalkerScreenTheme(
23+
backgroundColor: Theme.of(context).colorScheme.surface,
2924
),
30-
builder: (context, snapshot) {
31-
if (snapshot.hasError) {
32-
return Scaffold(
33-
appBar: AppBar(title: Text(tr.title)),
34-
body: Center(child: Text(snapshot.error!.toString())),
35-
);
36-
}
37-
38-
if (!snapshot.hasData) {
39-
return Scaffold(
40-
appBar: AppBar(title: Text(tr.title)),
41-
body: const Center(child: CircularProgressIndicator()),
42-
);
43-
}
44-
45-
final logData = snapshot.data!;
46-
47-
return Scaffold(
48-
appBar: AppBar(
49-
title: Text(tr.title),
50-
actions: [
51-
IconButton(
52-
icon: const Icon(Icons.copy_outlined),
53-
onPressed: () async => copyToClipboard(context, logData),
54-
),
55-
],
56-
),
57-
body: SingleChildScrollView(child: Text(logData)),
58-
);
59-
},
6025
);
6126
}
6227
}

lib/features/thread/view/thread_page.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ class _ThreadPageState extends State<ThreadPage>
369369
context
370370
.readOrNull<ThreadBloc>()
371371
?.add(const ThreadChangeViewOrderRequested());
372+
case MenuActions.debugViewLog:
373+
await context.pushNamed(ScreenPaths.debugLog);
372374
}
373375
},
374376
),

lib/widgets/card/notice_card_v2.dart

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,11 @@ class _NoticeCardV2State extends State<NoticeCardV2> {
153153
const PopupMenuDivider(),
154154
PopupMenuItem(
155155
value: _Actions.copyRawContent,
156-
child: Row(
157-
children: [
158-
Icon(
159-
Icons.bug_report_outlined,
160-
color: Theme.of(context).colorScheme.secondary,
161-
),
162-
sizedBoxPopupMenuItemIconSpacing,
163-
Text(
164-
tr.copyRawContent,
165-
style: TextStyle(
166-
color: Theme.of(context).colorScheme.secondary,
167-
),
168-
),
169-
],
156+
child: Text(
157+
tr.copyRawContent,
158+
style: TextStyle(
159+
color: Theme.of(context).colorScheme.secondary,
160+
),
170161
),
171162
),
172163
],

lib/widgets/list_app_bar.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:tsdm_client/constants/layout.dart';
66
import 'package:tsdm_client/extensions/build_context.dart';
77
import 'package:tsdm_client/features/jump_page/cubit/jump_page_cubit.dart';
88
import 'package:tsdm_client/features/jump_page/widgets/jump_page_dialog.dart';
9+
import 'package:tsdm_client/features/settings/bloc/settings_bloc.dart';
910
import 'package:tsdm_client/features/thread/bloc/thread_bloc.dart';
1011
import 'package:tsdm_client/i18n/strings.g.dart';
1112
import 'package:tsdm_client/widgets/notice_button.dart';
@@ -28,6 +29,11 @@ enum MenuActions {
2829
///
2930
/// Only available to thread pages.
3031
reverseOrder,
32+
33+
/// Debug option.
34+
///
35+
/// View log.
36+
debugViewLog,
3137
}
3238

3339
/// A app bar contains list and provides features including:
@@ -186,6 +192,22 @@ class ListAppBar extends StatelessWidget implements PreferredSizeWidget {
186192
],
187193
),
188194
),
195+
if (context
196+
.read<SettingsBloc>()
197+
.state
198+
.settingsMap
199+
.enableDebugOperations) ...<PopupMenuEntry<MenuActions>>[
200+
const PopupMenuDivider(),
201+
PopupMenuItem(
202+
value: MenuActions.debugViewLog,
203+
child: Text(
204+
context.t.settingsPage.debugSection.viewLog.title,
205+
style: TextStyle(
206+
color: Theme.of(context).colorScheme.secondary,
207+
),
208+
),
209+
),
210+
],
189211
],
190212
onSelected: onSelected,
191213
),

0 commit comments

Comments
 (0)