85 lines
3.1 KiB
Dart
85 lines
3.1 KiB
Dart
//s1 Imports
|
|
//s2 Core Package Imports
|
|
import 'package:flutter/widgets.dart';
|
|
//s2 1st-party Package Imports
|
|
//s2 3rd-party Package Imports
|
|
//s2 Dependancies Imports
|
|
//s3 Routes
|
|
//s3 Services
|
|
//s3 Models
|
|
import 'src/text_field.dart';
|
|
import 'src/action_field.dart';
|
|
import 'src/models/models.exports.dart';
|
|
//s1 Exports
|
|
export 'src/models/models.exports.dart';
|
|
export 'src/enums/enums.exports.dart';
|
|
|
|
class AstromicFields {
|
|
/// Astromic TextField element.
|
|
static Widget text({
|
|
required TextEditingController controller,
|
|
Key? stateKey,
|
|
void Function(String v)? onChanged,
|
|
void Function(String v)? onSubmited,
|
|
AstromicFieldConfiguration? configuration,
|
|
AstromicFieldStyle Function(bool isEnabled, bool isFocused)? style,
|
|
String? hint,
|
|
Widget? Function(bool isEnabled, bool isFocused, VoidCallback stateSetter)? prefixWidget,
|
|
Widget? Function(bool isEnabled, bool isFocused, VoidCallback stateSetter)? suffixWidget,
|
|
Widget? Function(bool isEnabled, bool isFocused)? messageBuilder,
|
|
Iterable<ContextMenuButtonItem>? contextButtons,
|
|
}) =>
|
|
Column(
|
|
children: [
|
|
AstromicTextField(
|
|
textController: controller,
|
|
stateKey: stateKey,
|
|
onChanged: onChanged,
|
|
onSubmited: onSubmited,
|
|
configuration: configuration,
|
|
style: style,
|
|
hint: hint,
|
|
prefixWidget: prefixWidget,
|
|
suffixWidget: suffixWidget,
|
|
messageBuilder: messageBuilder,
|
|
contextButtons: contextButtons,
|
|
),
|
|
],
|
|
);
|
|
|
|
/// Astromic ActionField element.
|
|
static Widget action<T>(
|
|
{Key? stateKey,
|
|
(T item, String label)? initialValue,
|
|
required TextEditingController controller,
|
|
Future<(T item, String label)?> Function((T item, String label)? currentValue)? onTap,
|
|
Future<(T item, String label)?> Function((T item, String label)? currentValue)? onHold,
|
|
|
|
/// Map the old controller value and the new selected value to how it will look in the field. e.g Adding a new choosen value as a list in the field.
|
|
required String Function(String? oldValue, String newValue) onValueChangedMapper,
|
|
AstromicFieldConfiguration? configuration,
|
|
AstromicFieldStyle Function(bool isEnabled)? style,
|
|
String? hint,
|
|
Widget? Function(bool isEnabled, VoidCallback stateSetter)? prefixWidget,
|
|
Widget? Function(bool isEnabled, VoidCallback stateSetter)? suffixWidget,
|
|
Widget? Function(bool isEnabled)? messageBuilder}) =>
|
|
Column(
|
|
children: [
|
|
AstromicActionField(
|
|
stateKey: stateKey,
|
|
textController: controller,
|
|
initialValue: initialValue,
|
|
onTap: onTap,
|
|
onHold: onHold,
|
|
onValueChangedMapper: onValueChangedMapper,
|
|
configuration: configuration,
|
|
style: style,
|
|
hint: hint,
|
|
prefixWidget: prefixWidget,
|
|
suffixWidget: suffixWidget,
|
|
messageBuilder: messageBuilder,
|
|
),
|
|
],
|
|
);
|
|
}
|