Skip to content

Commit fca3ed8

Browse files
committed
fix(docs): migrate from snackbar to StatusCenter (SPEC-48)
1 parent fb14296 commit fca3ed8

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

app/lib/ui/docs/doc_preview.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import 'package:phosphoricons_flutter/phosphoricons_flutter.dart';
2222
import 'package:url_launcher/url_launcher.dart';
2323

2424
import '../../app/theme.dart';
25+
import '../../status/status_providers.dart';
2526
import '../../store/docs.dart';
2627
import '../../store/connection.dart';
2728
import '../../store/store.dart';
@@ -629,17 +630,17 @@ class _DocPreviewSheetState extends ConsumerState<_DocPreviewSheet> {
629630
);
630631

631632
/// D8 rev 2: hand the file to the host's opener. Failure is stated — the
632-
/// server's reason surfaces in a snack bar rather than a silent no-op.
633+
/// server's reason surfaces in the Activity record rather than a silent no-op.
633634
Future<void> _openLocal() async {
634635
try {
635636
await ref
636637
.read(storeControllerProvider.notifier)
637638
.openDoc(_doc.worktreePath, _doc.relPath);
638639
} catch (e) {
639640
if (!mounted) return;
640-
ScaffoldMessenger.of(
641-
context,
642-
).showSnackBar(SnackBar(content: Text('Could not open: $e')));
641+
ref
642+
.read(statusCenterProvider)
643+
.failure('Could not open: $e', source: 'docs.open');
643644
}
644645
}
645646

app/lib/ui/docs/publish_sheet.dart

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import 'package:qr_flutter/qr_flutter.dart';
1717
import 'package:url_launcher/url_launcher.dart';
1818

1919
import '../../app/theme.dart';
20+
import '../../status/status_providers.dart';
2021
import '../../store/docs.dart';
2122
import '../../store/store.dart';
2223
import '../widgets/sheet_header.dart';
@@ -114,7 +115,7 @@ class _PublishSheetState extends ConsumerState<_PublishSheet> {
114115
Future<void> _open() async {
115116
final url = _grant?.url;
116117
if (url == null) return;
117-
final messenger = ScaffoldMessenger.maybeOf(context);
118+
final status = ref.status;
118119
final uri = Uri.tryParse(url);
119120
try {
120121
if (uri == null) throw const FormatException('bad url');
@@ -123,13 +124,17 @@ class _PublishSheetState extends ConsumerState<_PublishSheet> {
123124
mode: LaunchMode.externalApplication,
124125
);
125126
if (!launched) {
126-
messenger?.showSnackBar(
127-
const SnackBar(content: Text('Could not open the link')),
127+
status.failure(
128+
'Could not open the published link',
129+
source: 'docs',
130+
detail: url,
128131
);
129132
}
130-
} catch (_) {
131-
messenger?.showSnackBar(
132-
const SnackBar(content: Text('Could not open the link')),
133+
} catch (e) {
134+
status.failure(
135+
'Could not open the published link',
136+
source: 'docs',
137+
detail: '$url\n$e',
133138
);
134139
}
135140
}
@@ -246,9 +251,10 @@ class _GrantPanel extends StatelessWidget {
246251
final VoidCallback onOpen;
247252

248253
Future<void> _copy(BuildContext context) async {
249-
final messenger = ScaffoldMessenger.maybeOf(context);
254+
// A plain widget with no `ref`, hence `statusOf` (SPEC-48).
255+
final status = statusOf(context);
250256
await Clipboard.setData(ClipboardData(text: grant.url));
251-
messenger?.showSnackBar(const SnackBar(content: Text('Link copied')));
257+
status.success('Link copied', source: 'docs', detail: grant.url);
252258
}
253259

254260
@override

0 commit comments

Comments
 (0)