Fixed web loading screen and setup related issues

This commit is contained in:
2026-09-01 07:38:45 +05:30
parent a0e7a898fa
commit bfe0c1efbd
14 changed files with 268 additions and 131 deletions

View File

@@ -12,8 +12,7 @@ class SetupWizardScreen extends StatefulWidget {
State<SetupWizardScreen> createState() => _SetupWizardScreenState();
}
class _SetupWizardScreenState extends State<SetupWizardScreen>
with SingleTickerProviderStateMixin {
class _SetupWizardScreenState extends State<SetupWizardScreen> {
bool _isLoading = false;
int _currentStep = 0;
String _accountType = 'INDIVIDUAL';
@@ -40,6 +39,19 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
int get _totalSteps => _accountType == 'BUSINESS' ? 4 : 3;
@override
void dispose() {
_nameController.dispose();
_usernameController.dispose();
_businessNameController.dispose();
_addressController.dispose();
_emailController.dispose();
_gstController.dispose();
_panController.dispose();
_msmeController.dispose();
super.dispose();
}
Future<void> _checkUsername(String username) async {
if (username.length < 3) return;
setState(() => _checkingUsername = true);
@@ -111,6 +123,7 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
}
void _nextStep() {
FocusScope.of(context).unfocus();
if (_currentStep == 1) {
if (_nameController.text.trim().isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
@@ -150,6 +163,7 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
}
void _prevStep() {
FocusScope.of(context).unfocus();
if (_currentStep > 0) {
setState(() => _currentStep--);
}
@@ -209,7 +223,6 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
Widget _buildStep0AccountType() {
return Column(
key: const ValueKey(0),
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
@@ -324,7 +337,6 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
Widget _buildStep1Personal() {
return Column(
key: const ValueKey(1),
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
@@ -354,6 +366,7 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
duration: const Duration(milliseconds: 200),
child: _checkingUsername
? const SizedBox(
key: ValueKey('user_check_spinner'),
width: 20,
height: 20,
child: CircularProgressIndicator(strokeWidth: 2),
@@ -362,7 +375,7 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
_isUsernameAvailable
? LucideIcons.checkCircle2
: LucideIcons.xCircle,
key: ValueKey(_isUsernameAvailable),
key: ValueKey('user_avail_${_isUsernameAvailable}'),
color: _usernameController.text.isEmpty
? Colors.transparent
: (_isUsernameAvailable
@@ -388,7 +401,6 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
Widget _buildStep2Business() {
return Column(
key: const ValueKey(2),
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
@@ -410,6 +422,10 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
value: 'JEWELLERY',
child: Text('Jewellery', style: TextStyle(color: Colors.black87)),
),
DropdownMenuItem(
value: 'ECOMMERCE',
child: Text('E-Commerce Seller', style: TextStyle(color: Colors.black87)),
),
DropdownMenuItem(
value: 'PROJECT_MANAGEMENT',
child: Text(
@@ -474,7 +490,6 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
Widget _buildStep3Consent() {
return Column(
key: const ValueKey(3),
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
@@ -556,12 +571,11 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
);
}
Widget _buildCurrentStep() {
if (_currentStep == 0) return _buildStep0AccountType();
if (_currentStep == 1) return _buildStep1Personal();
if (_accountType == 'BUSINESS' && _currentStep == 2)
return _buildStep2Business();
return _buildStep3Consent(); // Step 2 (Individual) or Step 3 (Business)
int get _stackIndex {
if (_accountType == 'INDIVIDUAL' && _currentStep == 2) {
return 3;
}
return _currentStep;
}
@override
@@ -587,28 +601,38 @@ class _SetupWizardScreenState extends State<SetupWizardScreen>
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 600),
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 300),
switchInCurve: Curves.easeOutCubic,
switchOutCurve: Curves.easeInCubic,
transitionBuilder: (child, animation) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(0.05, 0),
end: Offset.zero,
).animate(animation),
child: FadeTransition(opacity: animation, child: child),
);
},
child: SingleChildScrollView(
key: ValueKey(_currentStep),
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.symmetric(
horizontal: 24.0,
vertical: 16.0,
child: IndexedStack(
index: _stackIndex,
children: [
SingleChildScrollView(
padding: const EdgeInsets.symmetric(
horizontal: 24.0,
vertical: 16.0,
),
child: _buildStep0AccountType(),
),
child: _buildCurrentStep(),
),
SingleChildScrollView(
padding: const EdgeInsets.symmetric(
horizontal: 24.0,
vertical: 16.0,
),
child: _buildStep1Personal(),
),
SingleChildScrollView(
padding: const EdgeInsets.symmetric(
horizontal: 24.0,
vertical: 16.0,
),
child: _buildStep2Business(),
),
SingleChildScrollView(
padding: const EdgeInsets.symmetric(
horizontal: 24.0,
vertical: 16.0,
),
child: _buildStep3Consent(),
),
],
),
),
),