JJ_MKVMaker/lib/ui/home/log_panel.dart

87 lines
3.1 KiB
Dart

/// 약속: 작업 기록을 보여 준다 (넓은 화면은 아래 칸, 좁은 화면은 한 줄 - 누르면 전체).
library;
import 'package:flutter/material.dart';
import '../theme.dart';
import '../../l10n/tr.dart';
class LogPanel extends StatelessWidget {
final List<String> logs;
final VoidCallback onClose;
const LogPanel({super.key, required this.logs, required this.onClose});
/// 폰 세로에서 기록이 비었을 때의 높이 (안내 한 줄)
static const emptyHeight = 40.0;
@override
Widget build(BuildContext context) => Container(
color: JjColors.bg,
child: Stack(children: [
// 15 지적: 기록이 없으면 ✕ 하나만 있는 빈 칸으로 보였다 - 무엇이 들어오는 칸인지 적는다
if (logs.isEmpty)
Positioned.fill(
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 44, 0),
child: Text(tr('작업 기록이 아직 없습니다. MKV 만들기 · 자막 · 다운로드를 하면 여기에 차례로 남습니다.'),
maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 12, color: JjColors.textDim)),
),
),
Positioned.fill(
child: ListView.builder(
reverse: true,
padding: const EdgeInsets.fromLTRB(16, 8, 44, 8),
itemCount: logs.length,
itemBuilder: (_, i) => SelectableText(
logs[logs.length - 1 - i],
style: TextStyle(
fontSize: 12, fontFamily: 'Consolas', color: JjColors.textDim),
),
),
),
// 오른쪽 위 ✕: 작업 기록 숨기기
Positioned(
top: 2,
right: 4,
child: IconButton(
tooltip: tr('작업 기록 숨기기'),
iconSize: 16,
visualDensity: VisualDensity.compact,
icon: Icon(Icons.close, color: JjColors.textDim),
onPressed: onClose,
),
),
]),
);
}
/// 작업 기록을 숨겼을 때 맨 아래 얇은 줄: 마지막 기록 + 다시 보기
class LogStrip extends StatelessWidget {
final String last;
final VoidCallback onOpen;
const LogStrip({super.key, required this.last, required this.onOpen});
@override
Widget build(BuildContext context) => Material(
color: JjColors.bg,
child: InkWell(
onTap: onOpen,
child: SizedBox(
height: 26,
child: Row(children: [
const SizedBox(width: 16),
Expanded(
child: Text(last,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 11, fontFamily: 'Consolas', color: JjColors.textDim)),
),
Text(tr('작업 기록 보기'), style: TextStyle(fontSize: 11, color: JjColors.accent)),
Icon(Icons.expand_less, size: 16, color: JjColors.accent),
const SizedBox(width: 12),
]),
),
),
);
}