mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-25 15:29:40 +00:00
Add DuplicateSpaceTextField
widget for user input in duplicate space management.
This commit is contained in:
@ -0,0 +1,51 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
|
class DuplicateSpaceTextField extends StatelessWidget {
|
||||||
|
const DuplicateSpaceTextField({
|
||||||
|
required this.nameController,
|
||||||
|
required this.isNameValid,
|
||||||
|
required this.initialName,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
final TextEditingController nameController;
|
||||||
|
final bool isNameValid;
|
||||||
|
final String initialName;
|
||||||
|
|
||||||
|
String get _errorText => 'Name must be different from "$initialName"';
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return TextField(
|
||||||
|
controller: nameController,
|
||||||
|
style: context.textTheme.bodyMedium!.copyWith(
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
label: const Text('Space Name'),
|
||||||
|
border: _border(),
|
||||||
|
enabledBorder: _border(),
|
||||||
|
focusedBorder: _border(ColorsManager.primaryColor),
|
||||||
|
errorBorder: _border(context.theme.colorScheme.error),
|
||||||
|
focusedErrorBorder: _border(context.theme.colorScheme.error),
|
||||||
|
errorStyle: context.textTheme.bodyMedium!.copyWith(
|
||||||
|
color: context.theme.colorScheme.error,
|
||||||
|
fontSize: 8,
|
||||||
|
),
|
||||||
|
errorText: isNameValid ? null : _errorText,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
OutlineInputBorder _border([Color? color]) {
|
||||||
|
return OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(16),
|
||||||
|
borderSide: BorderSide(
|
||||||
|
color: color ?? ColorsManager.blackColor,
|
||||||
|
width: 0.5,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user