JJ_MKVMaker/lib/ui/jj_field.dart

88 lines
2.8 KiB
Dart

/// 약속 (W 공용 위젯, 설계 7-2 JjField - 글 칸): 칸 이름은 짧게 · 설명은 칸 아래 도움 글 (3줄까지, 넘으면 "…") · 오류 글은 칸 아래.
/// 입력: 글 칸 · 칸 이름 · 도움 글 · 오류 글 · 키보드 종류 · 바뀜 / 넣기 알림 · 칸 끝 단추 · 여러 줄 · 테두리 상자 · 가림.
/// 출력: Material 글 칸 하나 (모양은 앱 테마를 따른다). 오류 없음.
/// 쓰는 곳: 서버 설정 (WebDAV · FTP · SFTP · SMB) · AI 서비스 · 해시 비교 · 시드 · 패턴 · 일정 · 이름 틀 · [SecretField]. 화면은 부르기만 한다
library;
import 'package:flutter/material.dart';
class JjField extends StatelessWidget {
const JjField({
super.key,
required this.controller,
this.label,
this.helper,
this.helperLines = 3,
this.errorText,
this.keyboardType,
this.onChanged,
this.onSubmitted,
this.isDense = false,
this.enabled = true,
this.autofocus = false,
this.suffix,
this.minLines,
this.maxLines = 1,
this.style,
this.outlined = false,
this.obscureText = false,
this.plainText = false,
});
final TextEditingController controller;
/// 칸 이름 (짧게 - 설명은 [helper] 로)
final String? label;
/// 칸 아래 도움 글. [helperLines] 줄까지 (처음 3 - 412 폭 ja 에서 한 줄이면 잘렸다, F2)
final String? helper;
final int helperLines;
final String? errorText;
final TextInputType? keyboardType;
final ValueChanged<String>? onChanged;
final ValueChanged<String>? onSubmitted;
final bool isDense;
final bool enabled;
final bool autofocus;
/// 칸 끝 단추 (예: 눈 단추 · 반영 단추)
final Widget? suffix;
final int? minLines;
final int? maxLines;
final TextStyle? style;
/// 테두리 상자 (여러 줄 글 등)
final bool outlined;
/// 가린 글 (비밀번호 - [SecretField] 가 쓴다)
final bool obscureText;
/// 자동 고침 · 추천 끔 (비밀번호 · 키 등 - [SecretField] 는 늘 켠다)
final bool plainText;
@override
Widget build(BuildContext context) => TextField(
controller: controller,
keyboardType: keyboardType,
obscureText: obscureText,
autocorrect: !plainText,
enableSuggestions: !plainText,
enabled: enabled,
autofocus: autofocus,
minLines: minLines,
maxLines: obscureText ? 1 : maxLines,
style: style,
onChanged: onChanged,
onSubmitted: onSubmitted,
decoration: InputDecoration(
labelText: label,
helperText: helper,
helperMaxLines: helperLines,
errorText: errorText,
isDense: isDense,
border: outlined ? const OutlineInputBorder() : null,
suffixIcon: suffix,
),
);
}