Done Category, Product Catalogue, Customer, Vendor, Purchase Invoice Module
This commit is contained in:
@@ -16,9 +16,10 @@ class AuthScreen extends ConsumerStatefulWidget {
|
||||
ConsumerState<AuthScreen> createState() => _AuthScreenState();
|
||||
}
|
||||
|
||||
class _AuthScreenState extends ConsumerState<AuthScreen> with SingleTickerProviderStateMixin {
|
||||
class _AuthScreenState extends ConsumerState<AuthScreen>
|
||||
with SingleTickerProviderStateMixin {
|
||||
bool isLogin = true;
|
||||
final emailController = TextEditingController(text: 'maddy23285@gmail.com');
|
||||
final emailController = TextEditingController(text: 'nmadaswamy@gmail.com');
|
||||
final passwordController = TextEditingController(text: 'Algorithm@123');
|
||||
|
||||
void toggleMode(bool login) {
|
||||
@@ -35,25 +36,49 @@ class _AuthScreenState extends ConsumerState<AuthScreen> with SingleTickerProvid
|
||||
if (email.isEmpty || password.isEmpty) return;
|
||||
|
||||
if (isLogin) {
|
||||
final success = await ref.read(authControllerProvider.notifier).login(email, password);
|
||||
final success = await ref
|
||||
.read(authControllerProvider.notifier)
|
||||
.login(email, password);
|
||||
if (success && mounted) {
|
||||
try {
|
||||
await Future.delayed(const Duration(milliseconds: 500)); // Allow secure storage to settle
|
||||
final dio = DioClient().dio;
|
||||
final res = await dio.get('/account/setup/status');
|
||||
print('Setup status response: ${res.data}');
|
||||
final status = res.data['status'];
|
||||
print('Status is: $status');
|
||||
if (status == 'COMPLETED' && mounted) {
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => const DashboardScreen()));
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const DashboardScreen()),
|
||||
);
|
||||
} else if (mounted) {
|
||||
Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => const SetupWizardScreen()));
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const SetupWizardScreen()),
|
||||
);
|
||||
}
|
||||
} catch (e, st) {
|
||||
print('Error getting setup status: $e\n$st');
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Error fetching setup status: $e')));
|
||||
// Fallback to Dashboard if login was successful but status check failed (e.g. network glitch)
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const DashboardScreen()),
|
||||
);
|
||||
}
|
||||
} catch(e) {
|
||||
if (mounted) Navigator.pushReplacement(context, MaterialPageRoute(builder: (_) => const SetupWizardScreen()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final success = await ref.read(authControllerProvider.notifier).signup(email, password);
|
||||
final success = await ref
|
||||
.read(authControllerProvider.notifier)
|
||||
.signup(email, password);
|
||||
if (success && mounted) {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => OtpScreen(email: email)));
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => OtpScreen(email: email)),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,9 +110,9 @@ class _AuthScreenState extends ConsumerState<AuthScreen> with SingleTickerProvid
|
||||
Widget build(BuildContext context) {
|
||||
ref.listen<AsyncValue<void>>(authControllerProvider, (previous, next) {
|
||||
if (next.hasError) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('${next.error}')),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('${next.error}')));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -107,23 +132,36 @@ class _AuthScreenState extends ConsumerState<AuthScreen> with SingleTickerProvid
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Container(
|
||||
width: 80, height: 80,
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Center(child: Image.asset('assets/logo.png', width: 80, height: 80, fit: BoxFit.contain)),
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
'assets/logo.png',
|
||||
width: 80,
|
||||
height: 80,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
Text(
|
||||
'Welcome to Kifi',
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(fontWeight: FontWeight.bold, color: Colors.black87),
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Manage your inventory and expenses securely.',
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.grey.shade600),
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Colors.grey.shade600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
@@ -143,11 +181,31 @@ class _AuthScreenState extends ConsumerState<AuthScreen> with SingleTickerProvid
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: isLogin ? Colors.white : Colors.transparent,
|
||||
color: isLogin
|
||||
? Colors.white
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: isLogin ? [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 4, offset: const Offset(0, 2))] : [],
|
||||
boxShadow: isLogin
|
||||
? [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
]
|
||||
: [],
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Login',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: isLogin
|
||||
? Colors.black87
|
||||
: Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Center(child: Text('Login', style: TextStyle(fontWeight: FontWeight.w600, color: isLogin ? Colors.black87 : Colors.grey.shade600))),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -159,11 +217,31 @@ class _AuthScreenState extends ConsumerState<AuthScreen> with SingleTickerProvid
|
||||
duration: const Duration(milliseconds: 200),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: !isLogin ? Colors.white : Colors.transparent,
|
||||
color: !isLogin
|
||||
? Colors.white
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: !isLogin ? [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 4, offset: const Offset(0, 2))] : [],
|
||||
boxShadow: !isLogin
|
||||
? [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
]
|
||||
: [],
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Sign Up',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
color: !isLogin
|
||||
? Colors.black87
|
||||
: Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Center(child: Text('Sign Up', style: TextStyle(fontWeight: FontWeight.w600, color: !isLogin ? Colors.black87 : Colors.grey.shade600))),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -181,18 +259,30 @@ class _AuthScreenState extends ConsumerState<AuthScreen> with SingleTickerProvid
|
||||
TextField(
|
||||
controller: emailController,
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500, color: Colors.black87),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black87,
|
||||
),
|
||||
textInputAction: TextInputAction.next,
|
||||
decoration: _buildInputDecoration(isLogin ? 'Email or Username' : 'Email Address', LucideIcons.mail),
|
||||
decoration: _buildInputDecoration(
|
||||
isLogin ? 'Email or Username' : 'Email Address',
|
||||
LucideIcons.mail,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: passwordController,
|
||||
obscureText: true,
|
||||
style: const TextStyle(fontWeight: FontWeight.w500, color: Colors.black87),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black87,
|
||||
),
|
||||
textInputAction: TextInputAction.done,
|
||||
onSubmitted: (_) => submit(),
|
||||
decoration: _buildInputDecoration('Password', LucideIcons.lock),
|
||||
decoration: _buildInputDecoration(
|
||||
'Password',
|
||||
LucideIcons.lock,
|
||||
),
|
||||
),
|
||||
AnimatedSwitcher(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
@@ -202,14 +292,32 @@ class _AuthScreenState extends ConsumerState<AuthScreen> with SingleTickerProvid
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: TextButton(
|
||||
onPressed: () => Navigator.push(context, MaterialPageRoute(builder: (_) => const ForgotPasswordScreen())),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).primaryColor,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
minimumSize: Size.zero,
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) =>
|
||||
const ForgotPasswordScreen(),
|
||||
),
|
||||
),
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(
|
||||
context,
|
||||
).primaryColor,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 8,
|
||||
vertical: 4,
|
||||
),
|
||||
minimumSize: Size.zero,
|
||||
tapTargetSize:
|
||||
MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
child: const Text(
|
||||
'Forgot Password?',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 13,
|
||||
),
|
||||
),
|
||||
child: const Text('Forgot Password?', style: TextStyle(fontWeight: FontWeight.w600, fontSize: 13)),
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -227,12 +335,28 @@ class _AuthScreenState extends ConsumerState<AuthScreen> with SingleTickerProvid
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
elevation: 2,
|
||||
),
|
||||
child: isLoading
|
||||
? const SizedBox(height: 24, width: 24, child: CircularProgressIndicator(color: Colors.white, strokeWidth: 2))
|
||||
: Text(isLogin ? 'Log In' : 'Create Account', style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold, letterSpacing: 0.5)),
|
||||
? const SizedBox(
|
||||
height: 24,
|
||||
width: 24,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.white,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
isLogin ? 'Log In' : 'Create Account',
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 0.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user