75 lines
2.0 KiB
Dart
75 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
class SetGroupInfoPage extends StatelessWidget {
|
|
final String appBarTitle;
|
|
|
|
/// 标题
|
|
final String fieldLabel;
|
|
|
|
/// 字段名
|
|
final int maxLines;
|
|
final int maxLength;
|
|
final String? initialValue; // 初始值
|
|
final ValueChanged<String> onSubmit; // 提交回调
|
|
|
|
const SetGroupInfoPage({
|
|
super.key,
|
|
required this.appBarTitle,
|
|
required this.fieldLabel,
|
|
this.maxLines = 1,
|
|
this.maxLength = 100,
|
|
this.initialValue,
|
|
required this.onSubmit,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final controller = TextEditingController(text: initialValue);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(
|
|
appBarTitle,
|
|
style: TextStyle(fontSize: 18),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () {
|
|
if (controller.text.trim().isEmpty) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('请输入内容')),
|
|
);
|
|
return;
|
|
}
|
|
onSubmit(controller.text.trim());
|
|
Get.back();
|
|
},
|
|
child: const Text("保存", style: TextStyle(color: Colors.black)),
|
|
),
|
|
],
|
|
),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(fieldLabel, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
|
|
const SizedBox(height: 10),
|
|
TextField(
|
|
controller: controller,
|
|
maxLines: maxLines,
|
|
maxLength: maxLength,
|
|
decoration: InputDecoration(
|
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
|
hintText: "请输入 $fieldLabel",
|
|
// counterText: "", // 去掉默认的计数提示
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|