72 lines
1.9 KiB
Dart
72 lines
1.9 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'template_create_wording.dart';
|
|
|
|
/// Full wrapping native label, not a clipped placeholder/floating field label.
|
|
class TemplateCreateNameField extends StatelessWidget {
|
|
const TemplateCreateNameField({
|
|
super.key,
|
|
required this.cupertino,
|
|
required this.controller,
|
|
required this.enabled,
|
|
required this.onSubmit,
|
|
});
|
|
|
|
final bool cupertino;
|
|
final TextEditingController controller;
|
|
final bool enabled;
|
|
final VoidCallback onSubmit;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => MergeSemantics(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
const Text(templateCreateNameLabel),
|
|
const SizedBox(height: 8),
|
|
if (cupertino)
|
|
CupertinoTextField(
|
|
key: templateCreateNameKey,
|
|
controller: controller,
|
|
enabled: enabled,
|
|
autofocus: true,
|
|
textInputAction: TextInputAction.done,
|
|
onSubmitted: (_) => onSubmit(),
|
|
)
|
|
else
|
|
TextField(
|
|
key: templateCreateNameKey,
|
|
controller: controller,
|
|
enabled: enabled,
|
|
autofocus: true,
|
|
textInputAction: TextInputAction.done,
|
|
onSubmitted: (_) => onSubmit(),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget templateCreateDialogAction({
|
|
required Key key,
|
|
required bool cupertino,
|
|
required VoidCallback? onPressed,
|
|
required Widget child,
|
|
bool primary = false,
|
|
}) {
|
|
if (cupertino) {
|
|
return CupertinoDialogAction(
|
|
key: key,
|
|
isDefaultAction: primary,
|
|
onPressed: onPressed,
|
|
child: child,
|
|
);
|
|
}
|
|
if (primary) {
|
|
return FilledButton(key: key, onPressed: onPressed, child: child);
|
|
}
|
|
return TextButton(key: key, onPressed: onPressed, child: child);
|
|
}
|