- estimate_screen.dart: /S1. 見積入力 - invoice_screen.dart: /S2. 請求書入力 - order_screen.dart: /S3. 受発注入力 - sales_return_screen.dart: /S5. 売上返品入力 - sales_screen.dart: /S4. 売上入力(レジ) - product_master_screen.dart: /M1. 商品マスタ - customer_master_screen.dart: /M2. 得意先マスタ - supplier_master_screen.dart: /M3. 仕入先マスタ - warehouse_master_screen.dart: /M4. 倉庫マスタ - employee_master_screen.dart: /M5. 担当者マスタ README.md にも画面 ID マッピングを明記
125 lines
No EOL
3.2 KiB
Dart
125 lines
No EOL
3.2 KiB
Dart
// Version: 1.0 - 汎用マスタ編集フィールド(Flutter 標準)
|
||
import 'package:flutter/material.dart';
|
||
|
||
/// マスタ編集用の統一 TextField
|
||
class MasterTextField extends StatelessWidget {
|
||
final String label;
|
||
final TextEditingController controller;
|
||
final String? hint;
|
||
final TextInputType keyboardType;
|
||
final bool obscureText;
|
||
final int maxLines;
|
||
final TextInputAction textInputAction;
|
||
final FormFieldValidator<String>? validator;
|
||
final void Function(String)? onChanged;
|
||
|
||
const MasterTextField({
|
||
super.key,
|
||
required this.label,
|
||
required this.controller,
|
||
this.hint,
|
||
this.keyboardType = TextInputType.text,
|
||
this.obscureText = false,
|
||
this.maxLines = 1,
|
||
this.textInputAction = TextInputAction.next,
|
||
this.validator,
|
||
this.onChanged,
|
||
});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return TextFormField(
|
||
controller: controller,
|
||
decoration: InputDecoration(
|
||
labelText: label,
|
||
hintText: hint,
|
||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||
),
|
||
keyboardType: keyboardType,
|
||
obscureText: obscureText,
|
||
maxLines: maxLines,
|
||
textInputAction: textInputAction,
|
||
validator: (value) => onChanged == null ? validator?.call(value) : 'Custom validation',
|
||
onChanged: onChanged,
|
||
);
|
||
}
|
||
}
|
||
|
||
/// マスタ編集用の数値入力 TextField
|
||
class MasterNumberField extends StatelessWidget {
|
||
final String label;
|
||
final TextEditingController controller;
|
||
final String? hint;
|
||
final FormFieldValidator<String>? validator;
|
||
final void Function(String)? onChanged;
|
||
|
||
const MasterNumberField({
|
||
super.key,
|
||
required this.label,
|
||
required this.controller,
|
||
this.hint,
|
||
this.validator,
|
||
this.onChanged,
|
||
});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return TextFormField(
|
||
controller: controller,
|
||
decoration: InputDecoration(
|
||
labelText: label,
|
||
hintText: hint,
|
||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||
),
|
||
keyboardType: TextInputType.number,
|
||
validator: (value) => onChanged == null ? validator?.call(value) : 'Custom validation',
|
||
onChanged: onChanged,
|
||
);
|
||
}
|
||
}
|
||
|
||
/// マスタ編集用の Checkbox
|
||
class MasterCheckboxField extends StatelessWidget {
|
||
final String label;
|
||
final bool value;
|
||
final ValueChanged<bool?>? onChangedCallback;
|
||
|
||
const MasterCheckboxField({
|
||
super.key,
|
||
required this.label,
|
||
required this.value,
|
||
this.onChangedCallback,
|
||
});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Checkbox(
|
||
value: value,
|
||
onChanged: onChangedCallback,
|
||
);
|
||
}
|
||
}
|
||
|
||
/// マスタ編集用の Switch
|
||
class MasterSwitchField extends StatelessWidget {
|
||
final String label;
|
||
final bool value;
|
||
final ValueChanged<bool>? onChangedCallback;
|
||
|
||
const MasterSwitchField({
|
||
super.key,
|
||
required this.label,
|
||
required this.value,
|
||
this.onChangedCallback,
|
||
});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Switch(
|
||
value: value,
|
||
onChanged: onChangedCallback,
|
||
);
|
||
}
|
||
} |