mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 18:04:18 +01:00
keys router ui
This commit is contained in:
106
lib/component/text_input/text_input_dialog_inner_component.dart
Normal file
106
lib/component/text_input/text_input_dialog_inner_component.dart
Normal file
@@ -0,0 +1,106 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../generated/l10n.dart';
|
||||
import '../../../util/router_util.dart';
|
||||
import '../../const/base.dart';
|
||||
|
||||
class TextInputDialogInnerComponent extends StatefulWidget {
|
||||
String title;
|
||||
|
||||
String? hintText;
|
||||
|
||||
String? value;
|
||||
|
||||
bool Function(BuildContext, String)? valueCheck;
|
||||
|
||||
TextInputDialogInnerComponent(
|
||||
this.title, {
|
||||
this.hintText,
|
||||
this.value,
|
||||
this.valueCheck,
|
||||
});
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _TextInputDialogInnerComponent();
|
||||
}
|
||||
}
|
||||
|
||||
class _TextInputDialogInnerComponent
|
||||
extends State<TextInputDialogInnerComponent> {
|
||||
late TextEditingController controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller = TextEditingController(text: widget.value);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var themeData = Theme.of(context);
|
||||
Color cardColor = themeData.cardColor;
|
||||
var mainColor = themeData.primaryColor;
|
||||
var titleFontSize = themeData.textTheme.bodyLarge!.fontSize;
|
||||
|
||||
List<Widget> list = [];
|
||||
|
||||
list.add(Container(
|
||||
margin: EdgeInsets.only(bottom: Base.BASE_PADDING),
|
||||
child: Text(
|
||||
widget.title,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: titleFontSize,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
list.add(Container(
|
||||
child: TextField(
|
||||
controller: controller,
|
||||
minLines: 4,
|
||||
maxLines: 4,
|
||||
autofocus: true,
|
||||
decoration: InputDecoration(
|
||||
hintText: widget.hintText,
|
||||
border: OutlineInputBorder(borderSide: BorderSide(width: 1)),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
list.add(Container(
|
||||
margin: EdgeInsets.only(top: Base.BASE_PADDING),
|
||||
width: double.infinity,
|
||||
child: FilledButton(
|
||||
onPressed: _onConfirm,
|
||||
child: Text("Confirm"),
|
||||
),
|
||||
));
|
||||
|
||||
var main = Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: list,
|
||||
),
|
||||
);
|
||||
|
||||
return main;
|
||||
}
|
||||
|
||||
void _onConfirm() {
|
||||
var value = controller.text;
|
||||
// if (StringUtil.isBlank(value)) {
|
||||
// BotToast.showText(text: "Input can't be null");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (widget.valueCheck != null) {
|
||||
if (!widget.valueCheck!(context, value)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return RouterUtil.back(context, value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user