74 lines
2.0 KiB
Dart
74 lines
2.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class GlobalTextField extends StatelessWidget {
|
|
final TextEditingController controller;
|
|
final String? hintText;
|
|
final String? labelText;
|
|
final int limitTextLine;
|
|
final bool isPassword;
|
|
final bool obscureText;
|
|
final VoidCallback? onToggleVisibility;
|
|
|
|
const GlobalTextField({
|
|
super.key,
|
|
required this.controller,
|
|
this.hintText,
|
|
this.labelText,
|
|
this.limitTextLine = 1,
|
|
this.isPassword = false,
|
|
this.obscureText = false,
|
|
this.onToggleVisibility,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return TextField(
|
|
controller: controller,
|
|
obscureText: isPassword ? obscureText : false,
|
|
maxLines: limitTextLine, // <-- ini tambahan dari limitTextLine
|
|
decoration: InputDecoration(
|
|
labelText: labelText,
|
|
labelStyle: const TextStyle(
|
|
color: Color(0xFF6B778C),
|
|
fontSize: 14,
|
|
),
|
|
hintText: hintText,
|
|
hintStyle: const TextStyle(
|
|
color: Color(0xFF6B778C),
|
|
fontSize: 14,
|
|
),
|
|
filled: true,
|
|
fillColor: Color.fromARGB(255, 234, 234, 235),
|
|
contentPadding: const EdgeInsets.symmetric(
|
|
horizontal: 16,
|
|
vertical: 16,
|
|
),
|
|
border: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
borderSide: BorderSide.none,
|
|
),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
borderSide: BorderSide.none,
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
borderSide: const BorderSide(
|
|
color: Color(0xFF0052CC),
|
|
width: 2,
|
|
),
|
|
),
|
|
suffixIcon: isPassword
|
|
? IconButton(
|
|
icon: Icon(
|
|
obscureText ? Icons.visibility_off : Icons.visibility,
|
|
color: Color(0xFF6B778C),
|
|
),
|
|
onPressed: onToggleVisibility,
|
|
)
|
|
: null,
|
|
),
|
|
);
|
|
}
|
|
}
|