Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
337 changes: 170 additions & 167 deletions lib/screens/auth/signup_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,171 @@ class _SignupScreenState extends State<SignupScreen>
}
}

Widget _buildJoinTeamForm() {
return Form(
key: _joinTeamFormKey,
child: Column(
children: [
const SizedBox(height: 12), // Spacing for floating label
CustomTextField(
controller: _teamIdController,
label: 'Team ID',
icon: Icons.people_outline,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter team ID';
}
if (value.length != 6) {
return 'Team ID must be 6 characters';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _nameController,
label: 'Full Name',
icon: Icons.person_outline,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your name';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _emailController,
label: 'Email',
icon: Icons.email_outlined,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your email';
}
if (!value.contains('@')) {
return 'Please enter a valid email';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _passwordController,
label: 'Password',
icon: Icons.lock_outline,
isPassword: true,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your password';
}
if (value.length < 6) {
return 'Password must be at least 6 characters';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _confirmPasswordController,
label: 'Confirm Password',
icon: Icons.lock_outline,
isPassword: true,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please confirm your password';
}
if (value != _passwordController.text) {
return 'Passwords do not match';
}
return null;
},
),
],
),
);
}

Widget _buildCreateTeamForm() {
return Form(
key: _createTeamFormKey,
child: Column(
children: [
const SizedBox(height: 12), // Spacing for floating label
CustomTextField(
controller: _teamNameController,
label: 'Team Name',
icon: Icons.group,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter team name';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _nameController,
label: 'Admin Name',
icon: Icons.person_outline,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter admin name';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _emailController,
label: 'Admin Email',
icon: Icons.email_outlined,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter admin email';
}
if (!value.contains('@')) {
return 'Please enter a valid email';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _passwordController,
label: 'Password',
icon: Icons.lock_outline,
isPassword: true,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your password';
}
if (value.length < 6) {
return 'Password must be at least 6 characters';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _confirmPasswordController,
label: 'Confirm Password',
icon: Icons.lock_outline,
isPassword: true,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please confirm your password';
}
if (value != _passwordController.text) {
return 'Passwords do not match';
}
return null;
},
),
],
),
);
}

@override
Widget build(BuildContext context) {
return AuthScreenWrapper(
Expand All @@ -220,175 +385,13 @@ class _SignupScreenState extends State<SignupScreen>
unselectedLabelColor: Colors.grey,
indicatorColor: Colors.green.shade400,
indicatorSize: TabBarIndicatorSize.tab,
onTap: (index) => setState(() {}),
),
const SizedBox(height: 24),
SizedBox(
height: 350, // Adjust height as needed
child: TabBarView(
controller: _tabController,
children: [
// Join Team Tab
Form(
key: _joinTeamFormKey,
child: Column(
children: [
CustomTextField(
controller: _teamIdController,
label: 'Team ID',
icon: Icons.people_outline,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter team ID';
}
if (value.length != 6) {
return 'Team ID must be 6 characters';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _nameController,
label: 'Full Name',
icon: Icons.person_outline,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your name';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _emailController,
label: 'Email',
icon: Icons.email_outlined,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your email';
}
if (!value.contains('@')) {
return 'Please enter a valid email';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _passwordController,
label: 'Password',
icon: Icons.lock_outline,
isPassword: true,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your password';
}
if (value.length < 6) {
return 'Password must be at least 6 characters';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _confirmPasswordController,
label: 'Confirm Password',
icon: Icons.lock_outline,
isPassword: true,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please confirm your password';
}
if (value != _passwordController.text) {
return 'Passwords do not match';
}
return null;
},
),
],
),
),
// Create Team Tab
Form(
key: _createTeamFormKey,
child: Column(
children: [
CustomTextField(
controller: _teamNameController,
label: 'Team Name',
icon: Icons.group,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter team name';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _nameController,
label: 'Admin Name',
icon: Icons.person_outline,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter admin name';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _emailController,
label: 'Admin Email',
icon: Icons.email_outlined,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter admin email';
}
if (!value.contains('@')) {
return 'Please enter a valid email';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _passwordController,
label: 'Password',
icon: Icons.lock_outline,
isPassword: true,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter your password';
}
if (value.length < 6) {
return 'Password must be at least 6 characters';
}
return null;
},
),
const SizedBox(height: 16),
CustomTextField(
controller: _confirmPasswordController,
label: 'Confirm Password',
icon: Icons.lock_outline,
isPassword: true,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please confirm your password';
}
if (value != _passwordController.text) {
return 'Passwords do not match';
}
return null;
},
),
],
),
),
],
),
),
// Renders the specific form based on selection without fixed height constraints
_tabController.index == 0
? _buildJoinTeamForm()
: _buildCreateTeamForm(),
const SizedBox(height: 24),
CustomButton(
text: _tabController.index == 0 ? 'Join Team' : 'Create Team',
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/custom_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CustomTextField extends StatelessWidget {

@override
Widget build(BuildContext context) {
final String effectiveHintText = label ?? hintText;
final String effectiveHintText = hintText;
final IconData? effectivePrefixIcon = icon ?? prefixIcon;
final bool effectiveObscureText = isPassword ?? obscureText;

Expand Down