|
|
|
@ -1,3 +1,4 @@
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
@ -24,8 +25,9 @@ Future<String?> showTextInputDialog({
|
|
|
|
|
TextInputType? keyboardType,
|
|
|
|
|
int? maxLength,
|
|
|
|
|
bool autocorrect = true,
|
|
|
|
|
}) =>
|
|
|
|
|
showAdaptiveDialog<String>(
|
|
|
|
|
}) {
|
|
|
|
|
final theme = Theme.of(context);
|
|
|
|
|
return showAdaptiveDialog<String>(
|
|
|
|
|
context: context,
|
|
|
|
|
useRootNavigator: useRootNavigator,
|
|
|
|
|
builder: (context) {
|
|
|
|
@ -42,16 +44,19 @@ Future<String?> showTextInputDialog({
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
if (message != null)
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 16.0),
|
|
|
|
|
child: ConstrainedBox(
|
|
|
|
|
ConstrainedBox(
|
|
|
|
|
constraints: const BoxConstraints(maxWidth: 256),
|
|
|
|
|
child: Text(message),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
ValueListenableBuilder<String?>(
|
|
|
|
|
valueListenable: error,
|
|
|
|
|
builder: (context, error, _) {
|
|
|
|
|
switch (theme.platform) {
|
|
|
|
|
case TargetPlatform.android:
|
|
|
|
|
case TargetPlatform.fuchsia:
|
|
|
|
|
case TargetPlatform.linux:
|
|
|
|
|
case TargetPlatform.windows:
|
|
|
|
|
return TextField(
|
|
|
|
|
controller: controller,
|
|
|
|
|
obscureText: obscureText,
|
|
|
|
@ -68,6 +73,37 @@ Future<String?> showTextInputDialog({
|
|
|
|
|
suffixText: suffixText,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
case TargetPlatform.iOS:
|
|
|
|
|
case TargetPlatform.macOS:
|
|
|
|
|
return Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
CupertinoTextField(
|
|
|
|
|
controller: controller,
|
|
|
|
|
obscureText: obscureText,
|
|
|
|
|
minLines: minLines,
|
|
|
|
|
maxLines: maxLines,
|
|
|
|
|
maxLength: maxLength,
|
|
|
|
|
keyboardType: keyboardType,
|
|
|
|
|
autocorrect: autocorrect,
|
|
|
|
|
prefix:
|
|
|
|
|
prefixText != null ? Text(prefixText) : null,
|
|
|
|
|
suffix:
|
|
|
|
|
suffixText != null ? Text(suffixText) : null,
|
|
|
|
|
placeholder: labelText ?? hintText,
|
|
|
|
|
),
|
|
|
|
|
if (error != null)
|
|
|
|
|
Text(
|
|
|
|
|
error,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
color: theme.colorScheme.error,
|
|
|
|
|
),
|
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
@ -100,3 +136,4 @@ Future<String?> showTextInputDialog({
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|