2019-07-05 09:15:57 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
|
|
|
typedef OnSubmittedBuilder = ValueChanged<String> Function(
|
|
|
|
BuildContext context,
|
|
|
|
);
|
|
|
|
|
|
|
|
class TextField extends StatelessWidget {
|
|
|
|
final OnSubmittedBuilder onSubmittedBuilder;
|
|
|
|
final TextEditingController controller;
|
2019-07-09 02:03:44 +00:00
|
|
|
final OverlayVisibilityMode clearButtonMode;
|
2019-07-07 04:14:09 +00:00
|
|
|
final Widget prefix;
|
|
|
|
final Widget suffix;
|
2019-07-05 09:15:57 +00:00
|
|
|
final bool obscure;
|
|
|
|
final bool autofocus;
|
|
|
|
final bool autocorrect;
|
|
|
|
final int minLines;
|
|
|
|
final int maxLines;
|
|
|
|
|
|
|
|
const TextField({
|
|
|
|
this.onSubmittedBuilder,
|
|
|
|
this.controller,
|
|
|
|
this.obscure = false,
|
|
|
|
this.autofocus = false,
|
|
|
|
this.minLines,
|
|
|
|
this.maxLines,
|
|
|
|
this.autocorrect = false,
|
2019-07-07 04:14:09 +00:00
|
|
|
this.prefix,
|
|
|
|
this.suffix,
|
2019-07-09 02:03:44 +00:00
|
|
|
this.clearButtonMode = OverlayVisibilityMode.editing,
|
2019-07-05 09:15:57 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
|
|
|
child: CupertinoTextField(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(color: CupertinoColors.black),
|
|
|
|
borderRadius: const BorderRadius.all(Radius.circular(5.0)),
|
|
|
|
),
|
2019-07-09 02:03:44 +00:00
|
|
|
clearButtonMode: clearButtonMode,
|
2019-07-05 09:15:57 +00:00
|
|
|
textAlign: TextAlign.start,
|
|
|
|
onSubmitted: this.onSubmittedBuilder != null
|
|
|
|
? onSubmittedBuilder(context)
|
|
|
|
: null,
|
|
|
|
controller: controller,
|
|
|
|
obscureText: obscure,
|
|
|
|
autofocus: autofocus,
|
|
|
|
autocorrect: autocorrect,
|
|
|
|
minLines: minLines,
|
|
|
|
maxLines: maxLines,
|
2019-07-07 04:14:09 +00:00
|
|
|
prefix: prefix,
|
|
|
|
suffix: suffix,
|
2019-07-05 09:15:57 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|