2023-01-28 14:30:54 +01:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:opencanteen/pw/platformwidget.dart';
|
|
|
|
|
|
|
|
class PlatformField extends PlatformWidget<TextField, CupertinoTextField> {
|
|
|
|
final TextEditingController? controller;
|
2023-11-28 20:09:17 +01:00
|
|
|
final bool enabled;
|
2023-01-28 14:30:54 +01:00
|
|
|
final bool obscureText;
|
|
|
|
final String? labelText;
|
|
|
|
final bool autocorrect;
|
|
|
|
final TextInputType? keyboardType;
|
|
|
|
final List<TextInputFormatter> inputFormatters;
|
|
|
|
final void Function(String)? onChanged;
|
|
|
|
final List<String>? autofillHints;
|
|
|
|
const PlatformField({
|
|
|
|
super.key,
|
|
|
|
this.controller,
|
|
|
|
this.labelText,
|
|
|
|
this.obscureText = false,
|
|
|
|
this.autocorrect = false,
|
|
|
|
this.keyboardType,
|
|
|
|
this.inputFormatters = const [],
|
|
|
|
this.onChanged,
|
2023-11-28 20:09:17 +01:00
|
|
|
this.enabled = true,
|
2023-01-28 14:30:54 +01:00
|
|
|
this.autofillHints,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
TextField createAndroidWidget(BuildContext context) => TextField(
|
|
|
|
controller: controller,
|
|
|
|
enabled: enabled,
|
|
|
|
obscureText: obscureText,
|
|
|
|
decoration: InputDecoration(labelText: labelText),
|
|
|
|
autocorrect: autocorrect,
|
|
|
|
keyboardType: keyboardType,
|
|
|
|
inputFormatters: inputFormatters,
|
|
|
|
onChanged: onChanged,
|
|
|
|
autofillHints: autofillHints,
|
|
|
|
);
|
|
|
|
|
|
|
|
@override
|
|
|
|
CupertinoTextField createIosWidget(BuildContext context) =>
|
|
|
|
CupertinoTextField(
|
|
|
|
controller: controller,
|
|
|
|
enabled: enabled,
|
|
|
|
obscureText: obscureText,
|
|
|
|
prefix: (labelText == null) ? null : Text(labelText!),
|
|
|
|
autocorrect: autocorrect,
|
|
|
|
keyboardType: keyboardType,
|
|
|
|
inputFormatters: inputFormatters,
|
|
|
|
onChanged: onChanged,
|
|
|
|
);
|
|
|
|
}
|