JJ_MKVMaker/lib/ui/jj_title_bar.dart

40 lines
2.1 KiB
Dart

/// 약속 (W 공용 위젯, 설계 7-2 JjTitleBar - 쪽 위 막대): 제목 · 앞 단추 · 뒤 단추들 → 위 막대 (Scaffold.appBar).
/// 입력: 제목 글 (한 줄 - 넘치면 끝을 "…", [path] 면 앞을 "…" 로 줄여 끝 (지금 폴더) 이 보임 - [TailText]) · 앞 단추 (없으면 Flutter 처음 값:
/// 돌아갈 곳이 있으면 화면 언어의 뒤로) · 뒤 단추들 [actions] (늘 위 막대에) · 내려갈 단추들 [lowerActions] (넓으면 [actions] 앞에,
/// 화면 폭이 [twoLinesBelow] 보다 좁으면 제목 아래 둘째 줄 가운데로 - 넓은 고르기 · 글 단추).
/// 출력: AppBar (모양은 앱 테마). 둘째 줄도 넘치면 그 줄만 줄여 모두 보이게 하며, 단추를 숨기지 않는다. 오류 없음.
/// 쓰는 곳: 휴지통 · 보관함 · 저장 공간 · 압축 · 글 보기 · 찾기 결과 · DLNA · AI 비교 (G2) · 앱 안 폴더 고르기 등 쪽 위 막대. 화면은 부르기만 한다.
/// 창 · 판 안의 제목 줄은 [JjHeaderRow]
library;
import 'package:flutter/material.dart';
import 'tail_text.dart';
PreferredSizeWidget jjTitleBar(
BuildContext context, {
required String title,
bool path = false,
Widget? leading,
List<Widget> actions = const [],
List<Widget> lowerActions = const [],
double twoLinesBelow = 0,
}) {
final twoLines = lowerActions.isNotEmpty && MediaQuery.sizeOf(context).width < twoLinesBelow;
return AppBar(
leading: leading,
title: path ? TailText(title) : Text(title, maxLines: 1, overflow: TextOverflow.ellipsis),
actions: twoLines ? actions : [...lowerActions, ...actions],
bottom: twoLines
? PreferredSize(
preferredSize: const Size.fromHeight(52),
child: Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
// 둘째 줄에도 다 안 들어가면 (좁은 폭 · 큰 글자) 줄 전체를 그만큼만 줄인다 - 단추를 숨기거나 화면 밖으로 밀지 않음
child: Center(child: FittedBox(fit: BoxFit.scaleDown, child: Row(mainAxisSize: MainAxisSize.min, children: lowerActions))),
),
)
: null,
);
}