- Add copy button to each sync log tile; copies a markdown summary of the
entry plus the full About section (app version, platform, device info).
- Store stack trace and isPermanent flag on error entries (schema v33) so
bug reports contain enough context to diagnose device-specific failures
like MissingPluginException on Android.
- Add Android device info (manufacturer, model, OS version) to the About
screen via device_info_plus; shared with the sync log copy via a new
lib/ui/utils/about_markdown.dart utility.
- Show isPermanent in the subtitle ("Error (permanent)") and in the
copied markdown.
- Display stack trace in red monospace in the expanded tile view.
- Update migration tests to assert schema v33 columns exist.
- Update fake SyncLogRepository implementations in tests.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
192 lines
6.1 KiB
Dart
192 lines
6.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
import 'package:sharedinbox/core/models/account.dart';
|
|
import 'package:sharedinbox/di.dart';
|
|
import 'package:sharedinbox/ui/utils/about_markdown.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
class AboutScreen extends ConsumerStatefulWidget {
|
|
const AboutScreen({super.key});
|
|
|
|
@override
|
|
ConsumerState<AboutScreen> createState() => _AboutScreenState();
|
|
}
|
|
|
|
class _AboutScreenState extends ConsumerState<AboutScreen> {
|
|
final Future<PackageInfo> _packageInfoFuture = PackageInfo.fromPlatform();
|
|
late final Future<Map<String, String>> _deviceInfoFuture =
|
|
fetchAndroidDeviceInfo();
|
|
late final Stream<List<Account>> _accountsStream;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_accountsStream = ref.read(accountRepositoryProvider).observeAccounts();
|
|
}
|
|
|
|
Future<void> _copyToClipboard(
|
|
BuildContext context,
|
|
int imapCount,
|
|
int jmapCount,
|
|
) async {
|
|
PackageInfo? pkg;
|
|
try {
|
|
pkg = await _packageInfoFuture;
|
|
} catch (_) {}
|
|
final deviceInfo = await _deviceInfoFuture;
|
|
if (!context.mounted) return;
|
|
await Clipboard.setData(
|
|
ClipboardData(
|
|
text:
|
|
buildAboutMarkdown(context, pkg, imapCount, jmapCount, deviceInfo),
|
|
),
|
|
);
|
|
if (context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(
|
|
duration: Duration(seconds: 5),
|
|
content: Text('Copied to clipboard'),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
Future<void> _createIssue(
|
|
BuildContext context,
|
|
int imapCount,
|
|
int jmapCount,
|
|
) async {
|
|
PackageInfo? pkg;
|
|
try {
|
|
pkg = await _packageInfoFuture;
|
|
} catch (_) {}
|
|
final deviceInfo = await _deviceInfoFuture;
|
|
if (!context.mounted) return;
|
|
final body = Uri.encodeComponent(
|
|
buildAboutMarkdown(context, pkg, imapCount, jmapCount, deviceInfo),
|
|
);
|
|
final url = Uri.parse(
|
|
'https://codeberg.org/guettli/sharedinbox/issues/new?body=$body',
|
|
);
|
|
try {
|
|
final launched =
|
|
await launchUrl(url, mode: LaunchMode.externalApplication);
|
|
if (!launched && context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(
|
|
duration: Duration(seconds: 5),
|
|
content: Text('Could not open browser.'),
|
|
),
|
|
);
|
|
}
|
|
} catch (e) {
|
|
if (context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
duration: const Duration(seconds: 5),
|
|
content: Text('Error: $e'),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return StreamBuilder<List<Account>>(
|
|
stream: _accountsStream,
|
|
builder: (context, accountSnapshot) {
|
|
final accounts = accountSnapshot.data ?? [];
|
|
final imapCount =
|
|
accounts.where((a) => a.type == AccountType.imap).length;
|
|
final jmapCount =
|
|
accounts.where((a) => a.type == AccountType.jmap).length;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('About')),
|
|
body: Column(
|
|
children: [
|
|
Expanded(
|
|
child: FutureBuilder<(PackageInfo?, Map<String, String>)>(
|
|
future: Future.wait([
|
|
_packageInfoFuture.then<PackageInfo?>((p) => p).catchError(
|
|
(_) => null,
|
|
),
|
|
_deviceInfoFuture,
|
|
]).then(
|
|
(results) => (
|
|
results[0] as PackageInfo?,
|
|
results[1] as Map<String, String>,
|
|
),
|
|
),
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
}
|
|
final pkg = snapshot.data?.$1;
|
|
final deviceInfo = snapshot.data?.$2 ?? {};
|
|
return Markdown(
|
|
data: buildAboutMarkdown(
|
|
context,
|
|
pkg,
|
|
imapCount,
|
|
jmapCount,
|
|
deviceInfo,
|
|
),
|
|
selectable: true,
|
|
onTapLink: (text, href, title) {
|
|
if (href != null) {
|
|
unawaited(
|
|
launchUrl(
|
|
Uri.parse(href),
|
|
mode: LaunchMode.externalApplication,
|
|
),
|
|
);
|
|
}
|
|
},
|
|
);
|
|
},
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(
|
|
horizontal: 16,
|
|
vertical: 12,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: OutlinedButton.icon(
|
|
icon: const Icon(Icons.copy),
|
|
label: const Text('Copy to clipboard'),
|
|
onPressed: () => unawaited(
|
|
_copyToClipboard(context, imapCount, jmapCount),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
child: FilledButton.icon(
|
|
icon: const Icon(Icons.bug_report),
|
|
label: const Text('Create issue'),
|
|
onPressed: () => unawaited(
|
|
_createIssue(context, imapCount, jmapCount),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|