40 lines
2.0 KiB
Dart
40 lines
2.0 KiB
Dart
/// 약속 (W 공용 위젯, 설계 7-2 JjTitleBar - 쪽 위 막대): 제목 · 앞 단추 · 뒤 단추들 → 위 막대 (Scaffold.appBar).
|
|
/// 입력: 제목 글 (한 줄 - 넘치면 끝을 "…", [path] 면 앞을 "…" 로 줄여 끝 (지금 폴더) 이 보임 - [TailText]) · 앞 단추 (없으면 Flutter 처음 값:
|
|
/// 돌아갈 곳이 있으면 화면 언어의 뒤로) · 뒤 단추들 · [twoLinesBelow] (화면 폭이 이보다 좁으면 뒤 단추들을 제목 아래 둘째 줄로 - 넓은 단추를 가진 쪽).
|
|
/// 출력: AppBar (모양은 앱 테마). 둘째 줄도 넘치면 그 줄만 줄여 모두 보이게 하며, 단추를 숨기지 않는다. 오류 없음.
|
|
/// 쓰는 곳: 휴지통 · 보관함 · 저장 공간 · 압축 · 글 보기 · 찾기 결과 · DLNA · AI 비교 등 쪽 위 막대. 화면은 부르기만 한다
|
|
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 [],
|
|
double twoLinesBelow = 0,
|
|
}) {
|
|
final twoLines = actions.isNotEmpty && MediaQuery.sizeOf(context).width < twoLinesBelow;
|
|
return AppBar(
|
|
leading: leading,
|
|
title: path ? TailText(title) : Text(title, maxLines: 1, overflow: TextOverflow.ellipsis),
|
|
actions: twoLines ? null : actions,
|
|
bottom: twoLines
|
|
? PreferredSize(
|
|
preferredSize: const Size.fromHeight(48),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
|
child: Align(
|
|
alignment: Alignment.centerRight,
|
|
// 둘째 줄에도 다 안 들어가면 (좁은 폭 · 큰 글자) 줄 전체를 그만큼만 줄인다 - 단추를 숨기거나 화면 밖으로 밀지 않음
|
|
child: FittedBox(fit: BoxFit.scaleDown, child: Row(mainAxisSize: MainAxisSize.min, children: actions)),
|
|
),
|
|
),
|
|
)
|
|
: null,
|
|
);
|
|
}
|