638 lines
22 KiB
Dart
638 lines
22 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:mobile_number/mobile_number.dart';
|
|
import '../theme.dart';
|
|
import '../route_transitions.dart';
|
|
import '../feedback_helper.dart';
|
|
import 'mobile_login_screen.dart';
|
|
|
|
class WelcomeScreen extends StatefulWidget {
|
|
const WelcomeScreen({super.key});
|
|
|
|
@override
|
|
State<WelcomeScreen> createState() => _WelcomeScreenState();
|
|
}
|
|
|
|
class _WelcomeScreenState extends State<WelcomeScreen> with SingleTickerProviderStateMixin {
|
|
late AnimationController _controller;
|
|
late Animation<double> _splashScaleAnimation;
|
|
late Animation<double> _splashLogoOpacityAnimation;
|
|
late Animation<double> _splashContainerOpacityAnimation;
|
|
late Animation<double> _contentFadeAnimation;
|
|
late Animation<Offset> _contentSlideAnimation;
|
|
|
|
String? _detectedMobileNumber;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_initMobileNumberDetection();
|
|
_controller = AnimationController(
|
|
vsync: this,
|
|
duration: const Duration(milliseconds: 1400),
|
|
);
|
|
|
|
// 1. Splash Logo Zoom/Scale-down (from 3.0 to 1.0)
|
|
_splashScaleAnimation = Tween<double>(begin: 3.0, end: 1.0).animate(
|
|
CurvedAnimation(
|
|
parent: _controller,
|
|
curve: const Interval(0.0, 0.45, curve: Curves.easeOutBack),
|
|
),
|
|
);
|
|
|
|
// 2. Splash Logo Fade-in as it scales down
|
|
_splashLogoOpacityAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
|
CurvedAnimation(
|
|
parent: _controller,
|
|
curve: const Interval(0.0, 0.35, curve: Curves.easeIn),
|
|
),
|
|
);
|
|
|
|
// 3. Splash Container Fade-out
|
|
_splashContainerOpacityAnimation = Tween<double>(begin: 1.0, end: 0.0).animate(
|
|
CurvedAnimation(
|
|
parent: _controller,
|
|
curve: const Interval(0.45, 0.6, curve: Curves.easeOut),
|
|
),
|
|
);
|
|
|
|
// 4. Welcome Content Fade-in
|
|
_contentFadeAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
|
CurvedAnimation(
|
|
parent: _controller,
|
|
curve: const Interval(0.55, 1.0, curve: Curves.easeIn),
|
|
),
|
|
);
|
|
|
|
// 5. Welcome Content Slide-up
|
|
_contentSlideAnimation = Tween<Offset>(
|
|
begin: const Offset(0.0, 0.05),
|
|
end: Offset.zero,
|
|
).animate(
|
|
CurvedAnimation(
|
|
parent: _controller,
|
|
curve: const Interval(0.55, 1.0, curve: Curves.easeOutCubic),
|
|
),
|
|
);
|
|
|
|
_controller.forward();
|
|
Future.delayed(const Duration(milliseconds: 300), () {
|
|
if (mounted) {
|
|
AppFeedback.success();
|
|
}
|
|
});
|
|
}
|
|
|
|
Future<void> _initMobileNumberDetection() async {
|
|
try {
|
|
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
|
|
if (await MobileNumber.hasPhonePermission) {
|
|
final String? mobileNumber = await MobileNumber.mobileNumber;
|
|
if (mobileNumber != null && mobileNumber.isNotEmpty) {
|
|
// Extract 10 digits if possible, else just use the number
|
|
final cleaned = mobileNumber.replaceAll(RegExp(r'\D'), '');
|
|
if (cleaned.length >= 10) {
|
|
_detectedMobileNumber = cleaned.substring(cleaned.length - 10);
|
|
} else {
|
|
_detectedMobileNumber = mobileNumber;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
} catch (e) {
|
|
debugPrint('Error getting mobile number: $e');
|
|
}
|
|
// Fallback to mock number
|
|
_detectedMobileNumber = '9988776655';
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final isMobile = context.isMobile;
|
|
|
|
return Scaffold(
|
|
body: AnimatedBuilder(
|
|
animation: _controller,
|
|
builder: (context, child) {
|
|
final showSplash = _controller.value < 0.6;
|
|
|
|
return Stack(
|
|
children: [
|
|
// Main Welcome Content
|
|
Opacity(
|
|
opacity: _contentFadeAnimation.value,
|
|
child: SlideTransition(
|
|
position: _contentSlideAnimation,
|
|
child: IgnorePointer(
|
|
ignoring: showSplash,
|
|
child: child,
|
|
),
|
|
),
|
|
),
|
|
|
|
// Splash Overlay (Centered Logo scaling down)
|
|
if (showSplash)
|
|
Opacity(
|
|
opacity: _splashContainerOpacityAnimation.value,
|
|
child: Container(
|
|
color: Colors.white,
|
|
alignment: Alignment.center,
|
|
child: ScaleTransition(
|
|
scale: _splashScaleAnimation,
|
|
child: Opacity(
|
|
opacity: _splashLogoOpacityAnimation.value,
|
|
child: Container(
|
|
width: 140,
|
|
height: 140,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(32),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.08),
|
|
blurRadius: 24,
|
|
offset: const Offset(0, 8),
|
|
)
|
|
],
|
|
),
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(32),
|
|
child: Image.asset(
|
|
'assets/logo/pozo_logo.jpg',
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
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 Container(
|
|
width: 80,
|
|
height: 80,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(20),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.12),
|
|
blurRadius: 20,
|
|
offset: const Offset(0, 6),
|
|
)
|
|
],
|
|
),
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(20),
|
|
child: Image.asset(
|
|
'assets/logo/pozo_logo.jpg',
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
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: [
|
|
InteractiveScale(
|
|
child: ElevatedButton(
|
|
onPressed: () {
|
|
AppFeedback.click();
|
|
Navigator.push(
|
|
context,
|
|
FadeSlidePageRoute(child: MobileLoginScreen(autoFilledMobileNumber: _detectedMobileNumber)),
|
|
);
|
|
},
|
|
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)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|