Skip to content

Commit ef0b621

Browse files
authored
Merge pull request #1130 from SatoshiPortal/fix-session-logs-viewer-on-startup-failure
Fix session logs viewer on startup failure
2 parents bd1d589 + 6f4d840 commit ef0b621

1 file changed

Lines changed: 97 additions & 8 deletions

File tree

lib/core/widgets/share_logs_widget.dart

Lines changed: 97 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import 'dart:io';
22

33
import 'package:bb_mobile/core/screens/logs_viewer_screen.dart';
4+
import 'package:bb_mobile/core/themes/app_theme.dart';
45
import 'package:bb_mobile/core/utils/logger.dart';
56
import 'package:flutter/material.dart';
7+
import 'package:flutter/services.dart';
68
import 'package:gap/gap.dart';
79
import 'package:share_plus/share_plus.dart';
810

9-
class ShareLogsWidget extends StatelessWidget {
11+
class ShareLogsWidget extends StatefulWidget {
1012
final bool migrationLogs;
1113
final bool sessionLogs;
1214

@@ -16,11 +18,18 @@ class ShareLogsWidget extends StatelessWidget {
1618
this.sessionLogs = true,
1719
});
1820

21+
@override
22+
State<ShareLogsWidget> createState() => _ShareLogsWidgetState();
23+
}
24+
25+
class _ShareLogsWidgetState extends State<ShareLogsWidget> {
26+
bool _showLogsInline = false;
27+
1928
@override
2029
Widget build(BuildContext context) {
2130
return Column(
2231
children: [
23-
if (sessionLogs)
32+
if (widget.sessionLogs)
2433
ListTile(
2534
shape: RoundedRectangleBorder(
2635
borderRadius: BorderRadius.circular(2),
@@ -31,7 +40,7 @@ class ShareLogsWidget extends StatelessWidget {
3140
trailing: const Icon(Icons.share_sharp),
3241
),
3342
const Gap(16),
34-
if (migrationLogs)
43+
if (widget.migrationLogs)
3544
ListTile(
3645
shape: RoundedRectangleBorder(
3746
borderRadius: BorderRadius.circular(2),
@@ -46,15 +55,95 @@ class ShareLogsWidget extends StatelessWidget {
4655
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(2)),
4756
tileColor: Colors.transparent,
4857
title: const Text('View session logs'),
49-
onTap:
50-
() => Navigator.push(
51-
context,
58+
onTap: () {
59+
final navigator = Navigator.maybeOf(context);
60+
if (navigator != null) {
61+
navigator.push(
5262
MaterialPageRoute(
5363
builder: (context) => const LogsViewerScreen(),
5464
),
55-
),
56-
trailing: const Icon(Icons.list_alt),
65+
);
66+
} else {
67+
setState(() {
68+
_showLogsInline = !_showLogsInline;
69+
});
70+
}
71+
},
72+
trailing: Icon(_showLogsInline ? Icons.expand_less : Icons.list_alt),
5773
),
74+
if (_showLogsInline) ...[
75+
const Gap(16),
76+
Container(
77+
constraints: BoxConstraints(
78+
maxHeight: MediaQuery.of(context).size.height * 0.4,
79+
),
80+
decoration: BoxDecoration(
81+
border: Border.all(color: Colors.grey.withValues(alpha: 0.3)),
82+
borderRadius: BorderRadius.circular(8),
83+
),
84+
child: Column(
85+
crossAxisAlignment: CrossAxisAlignment.start,
86+
children: [
87+
Container(
88+
padding: const EdgeInsets.all(12),
89+
decoration: BoxDecoration(
90+
color: Colors.grey.withValues(alpha: 0.1),
91+
borderRadius: const BorderRadius.only(
92+
topLeft: Radius.circular(8),
93+
topRight: Radius.circular(8),
94+
),
95+
),
96+
child: Row(
97+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
98+
children: [
99+
Text('Session Logs', style: context.font.titleMedium),
100+
Text(
101+
'${log.session.length} entries',
102+
style: context.font.bodySmall,
103+
),
104+
],
105+
),
106+
),
107+
Expanded(
108+
child: SingleChildScrollView(
109+
scrollDirection: Axis.vertical,
110+
padding: const EdgeInsets.all(8),
111+
child: SingleChildScrollView(
112+
scrollDirection: Axis.horizontal,
113+
child: Column(
114+
crossAxisAlignment: CrossAxisAlignment.start,
115+
children: List.generate(log.session.length, (index) {
116+
final logLine = log.session[index];
117+
return Row(
118+
children: [
119+
IconButton(
120+
onPressed:
121+
() => Clipboard.setData(
122+
ClipboardData(text: logLine),
123+
),
124+
icon: const Icon(Icons.copy, size: 14),
125+
padding: const EdgeInsets.all(4),
126+
constraints: const BoxConstraints(),
127+
),
128+
SelectableText(
129+
logLine.replaceAll('\t', ' | '),
130+
style: context.font.bodySmall?.copyWith(
131+
fontFamily: 'monospace',
132+
fontSize: 10,
133+
color: context.colour.onSurface,
134+
),
135+
),
136+
],
137+
);
138+
}),
139+
),
140+
),
141+
),
142+
),
143+
],
144+
),
145+
),
146+
],
58147
],
59148
);
60149
}

0 commit comments

Comments
 (0)