71 lines
2.4 KiB
Dart
71 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
import '../about/internal/application/TextType.dart';
|
|
import '../utils/Colors.dart';
|
|
import 'text/Text.dart';
|
|
|
|
/// A scrollable, copyable console sheet for one-shot command output — docker
|
|
/// logs, a kafka describe, a redis value. Raised from a screen rather than
|
|
/// pushed, because the output is a peek, not a destination.
|
|
void showOutputSheet(BuildContext context, String title, String output) {
|
|
final jp = context.jp;
|
|
showModalBottomSheet(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
backgroundColor: jp.surface,
|
|
shape: const RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
|
|
),
|
|
builder: (sheetContext) => SizedBox(
|
|
height: MediaQuery.of(sheetContext).size.height * 0.7,
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Expanded(child: text(title, 16, TextType.Bold, color: jp.text)),
|
|
IconButton(
|
|
tooltip: 'Copy',
|
|
onPressed: () {
|
|
Clipboard.setData(ClipboardData(text: output));
|
|
ScaffoldMessenger.of(
|
|
sheetContext,
|
|
).showSnackBar(const SnackBar(content: Text('Copied.')));
|
|
},
|
|
icon: const Icon(Icons.copy_all, size: 18),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 8),
|
|
Expanded(
|
|
child: Container(
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: jp.consoleBg,
|
|
borderRadius: BorderRadius.circular(12),
|
|
border: Border.all(color: ConsoleColors.frame),
|
|
),
|
|
child: SingleChildScrollView(
|
|
child: SelectableText(
|
|
output,
|
|
style: const TextStyle(
|
|
fontFamily: 'monospace',
|
|
fontSize: 12.5,
|
|
height: 1.4,
|
|
color: ConsoleColors.body,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|