This commit is contained in:
Felipe
2024-02-20 17:11:43 -05:00
parent 29d18e93e0
commit e00772f58a
21 changed files with 386 additions and 279 deletions
+2 -2
View File
@@ -22,11 +22,11 @@ class GeneralDrawerHeader extends StatelessWidget {
);
},
title: Text(
context.read<MyUserBloc>().state.user!.name,
context.read<MyUserBloc>().state.user!.name ?? '',
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: Text(
context.read<MyUserBloc>().state.user!.email,
context.read<MyUserBloc>().state.user!.email ?? '',
style: const TextStyle(fontSize: 12),
),
leading: context.read<MyUserBloc>().state.user!.picture == ""
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
class GeneralInputDecoration {
static InputDecoration getCustomDecoration({
required BuildContext context,
required String hintText,
String? labelText,
Widget? suffixIcon,
Widget? prefixIcon,
String? errorMsg,
}) {
Color? borderColor = errorMsg != null ? Colors.red : Colors.grey;
return InputDecoration(
labelText: labelText,
suffixIcon: suffixIcon,
prefixIcon: prefixIcon,
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(color: borderColor),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(color: Theme.of(context).colorScheme.primary),
),
errorBorder: OutlineInputBorder(
// Border when there's an error
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(color: Theme.of(context).colorScheme.error),
),
focusedErrorBorder: OutlineInputBorder(
// Border when focused with error
borderRadius: BorderRadius.circular(20),
borderSide: BorderSide(color: Theme.of(context).colorScheme.error),
),
fillColor: Colors.grey.shade200,
filled: true,
hintText: hintText,
hintStyle: TextStyle(color: Colors.grey[500]),
errorText: errorMsg,
);
}
}
+9 -16
View File
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:prosappco/components/general_input_decoration.dart';
class MyTextField extends StatelessWidget {
final TextEditingController controller;
final String? labelText;
final String hintText;
final bool obscureText;
final TextInputType keyboardType;
@@ -15,6 +17,7 @@ class MyTextField extends StatelessWidget {
const MyTextField(
{super.key,
this.labelText,
required this.controller,
required this.hintText,
required this.obscureText,
@@ -38,23 +41,13 @@ class MyTextField extends StatelessWidget {
onTap: onTap,
textInputAction: TextInputAction.next,
onChanged: onChanged,
decoration: InputDecoration(
suffixIcon: suffixIcon,
prefixIcon: prefixIcon,
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(color: Colors.transparent),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(20),
borderSide:
BorderSide(color: Theme.of(context).colorScheme.secondary),
),
fillColor: Colors.grey.shade200,
filled: true,
decoration: GeneralInputDecoration.getCustomDecoration(
labelText: labelText,
context: context,
hintText: hintText,
hintStyle: TextStyle(color: Colors.grey[500]),
errorText: errorMsg,
prefixIcon: prefixIcon,
errorMsg: errorMsg,
suffixIcon: suffixIcon,
),
);
}