import 'package:flutter/material.dart'; import '../theme.dart'; import '../route_transitions.dart'; import 'mobile_login_screen.dart'; class WelcomeScreen extends StatefulWidget { const WelcomeScreen({super.key}); @override State createState() => _WelcomeScreenState(); } class _WelcomeScreenState extends State with SingleTickerProviderStateMixin { late AnimationController _controller; late Animation _fadeAnimation; late Animation _logoScaleAnimation; late Animation _logoRotateAnimation; double _btnScale = 1.0; @override void initState() { super.initState(); _controller = AnimationController( vsync: this, duration: const Duration(milliseconds: 900), ); _fadeAnimation = CurvedAnimation( parent: _controller, curve: Curves.easeIn, ); _logoScaleAnimation = Tween(begin: 0.0, end: 1.0).animate( CurvedAnimation( parent: _controller, curve: const Interval(0.2, 0.8, curve: Curves.elasticOut), ), ); _logoRotateAnimation = Tween(begin: -0.1, end: 0.0).animate( CurvedAnimation( parent: _controller, curve: const Interval(0.2, 0.8, curve: Curves.easeOutBack), ), ); _controller.forward(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { final theme = Theme.of(context); final isMobile = context.isMobile; return Scaffold( body: FadeTransition( opacity: _fadeAnimation, child: SafeArea( child: Column( children: [ // Top Progress bar indicator - 1st segment active Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), child: Row( children: List.generate(5, (index) { return Expanded( child: AnimatedContainer( duration: const Duration(milliseconds: 350), height: 4, margin: const EdgeInsets.symmetric(horizontal: 2.0), decoration: BoxDecoration( color: index == 0 ? theme.colorScheme.primary : theme.colorScheme.surfaceContainerHighest, borderRadius: BorderRadius.circular(2), ), ), ); }), ), ), // Scrollable / Responsive Content Expanded( child: LayoutBuilder( builder: (context, constraints) { final maxWidth = constraints.maxWidth; if (maxWidth >= 768) { // Desktop / Tablet Double-Column Layout return SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Center( child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 1000), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ // Left column: content + button Expanded( flex: 5, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ _buildLogo(theme), const SizedBox(height: 16), Text( 'Manage your business billing in 3 clicks!', style: theme.textTheme.headlineLarge?.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 16), Text( 'The fastest, most reliable tool for Indian MSMEs to run their shop.', style: theme.textTheme.bodyMedium?.copyWith( color: theme.colorScheme.onSurfaceVariant, ), ), const SizedBox(height: 16), _buildSeal(theme), const SizedBox(height: 16), _buildCTAColumn(context, theme), ], ), ), const SizedBox(width: 32), // Right column: mock card Expanded( flex: 4, child: Center( child: _buildMockDashboard(theme), ), ), ], ), ), ), ), ); } else { // Mobile Single Column Layout return SingleChildScrollView( physics: const BouncingScrollPhysics(), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 16), _buildLogo(theme), const SizedBox(height: 16), Text( 'Manage your business billing in 3 clicks!', textAlign: TextAlign.left, style: theme.textTheme.headlineLarge?.copyWith( fontWeight: FontWeight.bold, ), ), const SizedBox(height: 16), Text( 'The fastest, most reliable tool for Indian MSMEs to run their shop.', textAlign: TextAlign.left, style: theme.textTheme.bodyMedium?.copyWith( color: theme.colorScheme.onSurfaceVariant, ), ), const SizedBox(height: 16), _buildSeal(theme), const SizedBox(height: 24), Center(child: _buildMockDashboard(theme)), const SizedBox(height: 24), ], ), ), ); } }, ), ), // Pinned Bottom Button on Mobile if (isMobile) Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), child: _buildCTAColumn(context, theme), ), ], ), ), ), ); } Widget _buildLogo(ThemeData theme) { return ScaleTransition( scale: _logoScaleAnimation, child: RotationTransition( turns: _logoRotateAnimation, child: Container( width: 80, height: 80, decoration: BoxDecoration( color: theme.colorScheme.primary, borderRadius: BorderRadius.circular(20), boxShadow: [ BoxShadow( color: theme.colorScheme.primary.withOpacity(0.15), blurRadius: 24, offset: const Offset(0, 8), ) ], ), alignment: Alignment.center, child: Stack( clipBehavior: Clip.none, children: [ Text( 'Pozo', style: theme.textTheme.headlineMedium?.copyWith( color: Colors.white, fontWeight: FontWeight.w800, letterSpacing: -1.0, ), ), Positioned( top: -16, right: -16, child: Container( padding: const EdgeInsets.all(4), decoration: BoxDecoration( color: Colors.amber[700], shape: BoxShape.circle, border: Border.all(color: Colors.white, width: 2), ), child: const Text( 'IN', style: TextStyle( color: Colors.white, fontSize: 8, fontWeight: FontWeight.bold, ), ), ), ) ], ), ), ), ); } Widget _buildSeal(ThemeData theme) { return Container( padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8), decoration: BoxDecoration( color: theme.colorScheme.surfaceContainerLow, borderRadius: BorderRadius.circular(20), border: Border.all(color: theme.colorScheme.outlineVariant), ), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon( Icons.verified, size: 16, color: theme.colorScheme.tertiary, ), const SizedBox(width: 6), Text( 'Trusted by 10,000+ merchants', style: theme.textTheme.bodySmall?.copyWith( fontWeight: FontWeight.w600, color: theme.colorScheme.onSurfaceVariant, ), ), ], ), ); } Widget _buildMockDashboard(ThemeData theme) { return Container( width: 280, height: 230, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(24), border: Border.all(color: theme.colorScheme.outlineVariant), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.04), blurRadius: 20, offset: const Offset(0, 8), ) ], ), child: Stack( clipBehavior: Clip.none, children: [ Column( children: [ Container( height: 44, padding: const EdgeInsets.symmetric(horizontal: 16), decoration: BoxDecoration( color: Colors.grey[50], borderRadius: const BorderRadius.vertical(top: Radius.circular(24)), border: Border(bottom: BorderSide(color: Colors.grey[200]!)), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Container( width: 8, height: 8, decoration: BoxDecoration( color: theme.colorScheme.primary, shape: BoxShape.circle, ), ), const SizedBox(width: 8), Container( width: 70, height: 8, decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.circular(4), ), ), ], ), Container( width: 14, height: 14, decoration: BoxDecoration( color: Colors.grey[300], shape: BoxShape.circle, ), ) ], ), ), Expanded( child: Padding( padding: const EdgeInsets.all(16.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ _buildMockRow(Icons.description, Colors.red[50]!, Colors.red), const SizedBox(height: 14), _buildMockRow(Icons.poll, Colors.green[50]!, Colors.green), ], ), ), ) ], ), Positioned( top: 60, right: -12, child: Container( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(14), border: Border.all(color: Colors.grey[200]!), boxShadow: [ BoxShadow( color: Colors.black.withOpacity(0.06), blurRadius: 10, offset: const Offset(0, 4), ) ], ), child: Row( children: [ Container( padding: const EdgeInsets.all(2), decoration: const BoxDecoration( color: Colors.green, shape: BoxShape.circle, ), child: const Icon( Icons.check, color: Colors.white, size: 10, ), ), const SizedBox(width: 6), const Text( 'Saved', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 11, color: Colors.black, ), ) ], ), ), ), Positioned( bottom: 30, left: -16, child: Container( padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8), decoration: BoxDecoration( color: theme.colorScheme.primary, borderRadius: BorderRadius.circular(16), boxShadow: [ BoxShadow( color: theme.colorScheme.primary.withOpacity(0.2), blurRadius: 12, offset: const Offset(0, 6), ) ], ), child: const Text( '₹ 4,500', style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12, ), ), ), ) ], ), ); } Widget _buildCTAColumn(BuildContext context, ThemeData theme) { return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: context.isMobile ? CrossAxisAlignment.center : CrossAxisAlignment.start, children: [ MouseRegion( onEnter: (_) => setState(() => _btnScale = 1.03), onExit: (_) => setState(() => _btnScale = 1.0), child: GestureDetector( onTapDown: (_) => setState(() => _btnScale = 0.95), onTapUp: (_) => setState(() => _btnScale = 1.03), onTapCancel: () => setState(() => _btnScale = 1.0), child: AnimatedScale( scale: _btnScale, duration: const Duration(milliseconds: 150), curve: Curves.easeOut, child: ElevatedButton( onPressed: () { Navigator.push( context, FadeSlidePageRoute(child: const MobileLoginScreen()), ); }, style: ElevatedButton.styleFrom( minimumSize: const Size(260, 54), ), child: Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: const [ Text('Get Started'), SizedBox(width: 8), Icon(Icons.arrow_forward, size: 18), ], ), ), ), ), ), const SizedBox(height: 16), Row( mainAxisAlignment: context.isMobile ? MainAxisAlignment.center : MainAxisAlignment.start, children: [ Container( width: 10, height: 10, decoration: BoxDecoration( color: theme.colorScheme.primary, shape: BoxShape.circle, ), ), const SizedBox(width: 6), Container( width: 8, height: 8, decoration: BoxDecoration( color: Colors.grey[300], shape: BoxShape.circle, ), ), const SizedBox(width: 6), Container( width: 8, height: 8, decoration: BoxDecoration( color: Colors.grey[300], shape: BoxShape.circle, ), ), ], ) ], ); } Widget _buildMockRow(IconData icon, Color bg, Color color) { return Container( height: 48, padding: const EdgeInsets.all(8), decoration: BoxDecoration( color: bg.withOpacity(0.4), borderRadius: BorderRadius.circular(12), border: Border.all(color: Colors.grey[100]!), ), child: Row( children: [ Container( padding: const EdgeInsets.all(6), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8), ), child: Icon(icon, color: color, size: 16), ), const SizedBox(width: 12), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 100, height: 6, decoration: BoxDecoration( color: Colors.grey[400], borderRadius: BorderRadius.circular(3), ), ), const SizedBox(height: 6), Container( width: 50, height: 4, decoration: BoxDecoration( color: Colors.grey[300], borderRadius: BorderRadius.circular(2), ), ), ], ), ), Icon(Icons.more_vert, color: Colors.grey[400], size: 16) ], ), ); } }