80 lines
3.1 KiB
Dart
80 lines
3.1 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
import '../widgets/rounded_input.dart';
|
||
|
|
import '../widgets/primary_button.dart';
|
||
|
|
import 'otp_screen.dart';
|
||
|
|
|
||
|
|
class SignupScreen extends StatefulWidget {
|
||
|
|
const SignupScreen({super.key});
|
||
|
|
@override
|
||
|
|
State<SignupScreen> createState() => _SignupScreenState();
|
||
|
|
}
|
||
|
|
|
||
|
|
class _SignupScreenState extends State<SignupScreen> {
|
||
|
|
final cName = TextEditingController();
|
||
|
|
final cCompany = TextEditingController();
|
||
|
|
final cDesignation = TextEditingController();
|
||
|
|
final cEmail = TextEditingController();
|
||
|
|
final cMobile = TextEditingController();
|
||
|
|
final cAddress = TextEditingController();
|
||
|
|
final cPincode = TextEditingController();
|
||
|
|
|
||
|
|
bool sending = false;
|
||
|
|
|
||
|
|
void _sendOtp() async {
|
||
|
|
// We don't call backend for OTP here per your flow - OTP is default 123456.
|
||
|
|
// Validate minimal
|
||
|
|
if (cName.text.trim().isEmpty || cCompany.text.trim().isEmpty || cEmail.text.trim().isEmpty || cMobile.text.trim().isEmpty) {
|
||
|
|
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Please fill the required fields')));
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
setState(() => sending = true);
|
||
|
|
await Future.delayed(const Duration(milliseconds: 600)); // UI feel
|
||
|
|
setState(() => sending = false);
|
||
|
|
// Navigate to OTP screen with collected data
|
||
|
|
final data = {
|
||
|
|
'customer_name': cName.text.trim(),
|
||
|
|
'company_name': cCompany.text.trim(),
|
||
|
|
'designation': cDesignation.text.trim(),
|
||
|
|
'email': cEmail.text.trim(),
|
||
|
|
'mobile_no': cMobile.text.trim(),
|
||
|
|
'address': cAddress.text.trim(),
|
||
|
|
'pincode': cPincode.text.trim(),
|
||
|
|
};
|
||
|
|
Navigator.of(context).push(MaterialPageRoute(builder: (_) => OtpScreen(signupPayload: data)));
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
final pad = MediaQuery.of(context).size.width * 0.06;
|
||
|
|
return Scaffold(
|
||
|
|
appBar: AppBar(title: const Text("Create Account")),
|
||
|
|
body: SafeArea(
|
||
|
|
child: Padding(
|
||
|
|
padding: EdgeInsets.symmetric(horizontal: pad),
|
||
|
|
child: SingleChildScrollView(
|
||
|
|
child: Column(children: [
|
||
|
|
const SizedBox(height: 16),
|
||
|
|
RoundedInput(controller: cName, hint: "Customer name"),
|
||
|
|
const SizedBox(height: 12),
|
||
|
|
RoundedInput(controller: cCompany, hint: "Company name"),
|
||
|
|
const SizedBox(height: 12),
|
||
|
|
RoundedInput(controller: cDesignation, hint: "Designation (optional)"),
|
||
|
|
const SizedBox(height: 12),
|
||
|
|
RoundedInput(controller: cEmail, hint: "Email", keyboardType: TextInputType.emailAddress),
|
||
|
|
const SizedBox(height: 12),
|
||
|
|
RoundedInput(controller: cMobile, hint: "Mobile", keyboardType: TextInputType.phone),
|
||
|
|
const SizedBox(height: 12),
|
||
|
|
RoundedInput(controller: cAddress, hint: "Address", maxLines: 3),
|
||
|
|
const SizedBox(height: 12),
|
||
|
|
RoundedInput(controller: cPincode, hint: "Pincode", keyboardType: TextInputType.number),
|
||
|
|
const SizedBox(height: 20),
|
||
|
|
PrimaryButton(label: "Send OTP", onTap: _sendOtp, busy: sending),
|
||
|
|
const SizedBox(height: 14),
|
||
|
|
]),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|