49 lines
2.3 KiB
Dart
49 lines
2.3 KiB
Dart
/// 약속 (W 공용 위젯, 설계 7-2 FloatingAction - 떠 있는 단추 묶음): 단추들 · 내용 → 단추가 내용을 가리지 않는 자리.
|
|
/// 입력: [buttons] (첫 단추가 맨 아래 - 예전 [이동] 자리, 다음은 그 위로) · [content] (안에 넣을 단추 줄 · 아래에 비울 높이를 받아 그림) ·
|
|
/// [inline] (true 면 떠 있지 않고 내용 안 - 좁은 화면 · 낮은 화면 등, [floatingInline] 이 정해 준다).
|
|
/// 출력: inline 이면 내용 끝에 오른쪽으로 줄바꿈하는 단추 줄 (아래 여백 24), 아니면 오른쪽 아래에 떠 있고 내용 아래를 단추 높이만큼 비움
|
|
/// (끝까지 내리면 가리지 않게). 오류 없음. 쓰는 곳: MKV 자세히 [이동] 단추 (206 · F7). 화면은 부르기만 한다
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// 단추 하나의 높이 (FloatingActionButton.extended 56 + 사이 10)
|
|
const floatingActionRow = 66.0;
|
|
|
|
/// 떠 있으면 가리는 화면: 좁거나 ([compact]) 높이가 낮을 때 (글자 배율로 나눠 본다 - 글자가 크면 같은 높이에 들어가는 줄이 적다, F7)
|
|
bool floatingInline(BuildContext context, {required bool compact, double minHeight = 500}) =>
|
|
compact || MediaQuery.sizeOf(context).height < minHeight * MediaQuery.textScalerOf(context).scale(1);
|
|
|
|
class FloatingActions extends StatelessWidget {
|
|
const FloatingActions({super.key, required this.buttons, required this.content, required this.inline});
|
|
|
|
final List<Widget> buttons;
|
|
final Widget Function(Widget? inlineRow, double bottomGap) content;
|
|
final bool inline;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (inline) {
|
|
final row = Wrap(alignment: WrapAlignment.end, spacing: 10, runSpacing: 10, children: buttons);
|
|
return content(row, 24);
|
|
}
|
|
return Stack(children: [
|
|
content(null, 16 + buttons.length * floatingActionRow + 16),
|
|
Positioned(
|
|
right: 16,
|
|
bottom: 16,
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
for (var i = buttons.length - 1; i >= 0; i--) ...[
|
|
buttons[i],
|
|
if (i > 0) const SizedBox(height: 10),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
]);
|
|
}
|
|
}
|