i want you to make the upgrade of this Ui designed of page firstly analyzed the purpose of page and upgrade the Ui frontend designed, with professional and well designed structure and the coloring which should be latest material, designed in Ui and animation , here's the outline and info LAYOUT:
- Full-screen design with a subtle gradient background transitioning from deep teal to midnight blue
- Centered content with proper spacing and visual hierarchy
HEADER SECTION:
- Bold, modern typography displaying "Connecting Your Vehicle" with a pulsing electric bolt icon
- Subtle animation showing power flowing from charger to vehicle icon
- Small timer showing elapsed connection time (00:15)
MAIN CONTENT:
- Circular progress indicator (65% complete) in the center with glowing electric blue accent
- Inside the circle, display a stylized animated illustration of a charging cable connecting to an EV
CONNECTION STEPS SECTION:
- Clean, well-spaced list of connection stages with modern iconography
- Each completed step shows a checkmark in a circular pill with subtle completion animation
- Current step shows a subtle pulsing animation
- Pending steps appear slightly faded
The specific steps to display:
- ✓ Establishing connection (completed)
- ✓ Validating account (completed)
- ✓ Checking equipment (completed)
- ⟳ Initializing power delivery (in progress, animated)
- ⟳ Preparing vehicle charging (pending)
FOOTER:
- Minimalist support section with "Need help?" text and elegant "Contact Support" button
- Small informational note: "Your session will begin automatically once connection is established"
- Subtle branded element in bottom corner
VISUAL STYLE:
- Clean, minimalist design with
- High-contrast text for accessibility
- Smooth, subtle animations that provide feedback without distraction
- Professional color scheme using electric blues, teals, with energy yellow accents
- Soft shadow effects for depth
- Responsive layout that works on all device sizes
now here the code
import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:ecoplug/screens/charging_session_screen.dart';
/// Professional animated background for EV charging initialization
class AnimatedEVBackgroundPainter extends CustomPainter {
final Color color;
final double animationValue;
AnimatedEVBackgroundPainter(
{required this.color, required this.animationValue});
@override
void paint(Canvas canvas, Size size) {
// Modern gradient background
final gradient = LinearGradient(
colors: [
color.withOpacity(0.13 + 0.10 * animationValue),
color.withOpacity(0.19 + 0.13 * (1 - animationValue)),
Colors.lightBlueAccent.withOpacity(0.13),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
);
final rect = Offset.zero & size;
final paint = Paint()..shader = gradient.createShader(rect);
canvas.drawRect(rect, paint);
// Subtle EV station silhouette (abstract lines)
final evPaint = Paint()
..color = color.withOpacity(0.09 + 0.08 * animationValue)
..style = PaintingStyle.stroke
..strokeWidth = 2.2;
final path = Path();
path.moveTo(size.width * 0.2, size.height * 0.8);
path.cubicTo(
size.width * 0.3,
size.height * 0.5,
size.width * 0.7,
size.height * 0.5,
size.width * 0.8,
size.height * 0.8,
);
canvas.drawPath(path, evPaint);
// Abstract charging cable
final cablePaint = Paint()
..color = Colors.lightBlueAccent.withOpacity(0.07 + 0.05 * animationValue)
..style = PaintingStyle.stroke
..strokeWidth = 1.6;
final cablePath = Path();
cablePath.moveTo(size.width * 0.5, size.height * 0.2);
cablePath.quadraticBezierTo(
size.width * 0.55,
size.height * 0.4,
size.width * 0.6,
size.height * 0.8,
);
canvas.drawPath(cablePath, cablePaint);
}
@override
bool shouldRepaint(covariant AnimatedEVBackgroundPainter oldDelegate) {
return animationValue != oldDelegate.animationValue ||
color != oldDelegate.color;
}
}
/// Main charging initialization screen
class ChargingInitializationScreen extends StatefulWidget {
final String? stationUid;
final String? connectorId;
const ChargingInitializationScreen({
super.key,
this.stationUid,
this.connectorId,
});
@override
State createState() =>
_ChargingInitializationScreenState();
}
class _ChargingInitializationScreenState
extends State with TickerProviderStateMixin {
late final AnimationController _bgAnimationController;
late final AnimationController _fadeController;
late final AnimationController _pulseController;
late final AnimationController _shimmerController;
late final AnimationController _staggeredController;
late Animation _fadeAnimation;
late Animation _pulseAnimation;
// State variables
Timer? _simulationCompletionTimer;
String _headerText = "Initializing Charge";
double _progress = 0.0;
int _currentStep = 0;
// Connection steps
final List<Map<String, dynamic>> _steps = [
{
'title': 'Establishing connection',
'subtitle': 'Connecting to charging network',
'status': 'pending',
'icon': FontAwesomeIcons.circleNodes,
},
{
'title': 'Verifying account',
'subtitle': 'Validating payment method',
'status': 'pending',
'icon': FontAwesomeIcons.userShield,
},
{
'title': 'Inspecting equipment',
'subtitle': 'Checking charger readiness',
'status': 'pending',
'icon': FontAwesomeIcons.screwdriverWrench,
},
{
'title': 'Initializing power',
'subtitle': 'Preparing energy delivery',
'status': 'pending',
'icon': FontAwesomeIcons.bolt,
},
{
'title': 'Preparing vehicle',
'subtitle': 'Starting charging sequence',
'status': 'pending',
'icon': FontAwesomeIcons.carBattery,
},
];
@override
void initState() {
super.initState();
// Animated background controller
_bgAnimationController = AnimationController(
vsync: this,
duration: const Duration(seconds: 5),
)..repeat(reverse: true);
_fadeController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 950),
);
_pulseController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 1100),
lowerBound: 0.97,
upperBound: 1.05,
)..repeat(reverse: true);
_shimmerController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 1700),
)..repeat();
_staggeredController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 1600),
)..forward();
// No need for page controller in vertical list
_fadeAnimation = CurvedAnimation(
parent: _fadeController,
curve: Curves.easeInOut,
);
_pulseAnimation = CurvedAnimation(
parent: _pulseController,
curve: Curves.elasticInOut,
);
// Start the process
_startInitializationProcess();
}
void _startInitializationProcess() {
// Simulate step progress
if (_steps.isEmpty) return;
_currentStep = 0;
_progress = 0.1;
_fadeController.forward();
_autoAdvanceStep();
}
void _autoAdvanceStep() {
if (_currentStep >= _steps.length) return;
// 30 seconds divided by number of steps (for auto-advance)
final int intervalMs = (30000 / _steps.length).round();
Future.delayed(Duration(milliseconds: intervalMs), () {
if (!mounted) return;
if (_currentStep < _steps.length - 1) {
setState(() {
_steps[_currentStep] = {
..._steps[_currentStep],
'status': 'completed'
};
_steps[_currentStep + 1] = {
..._steps[_currentStep + 1],
'status': 'in-progress'
};
_currentStep++;
_progress = 0.1 + (0.9 * ((_currentStep + 1) / _steps.length));
});
// No need for page controller animation in vertical list
_autoAdvanceStep();
} else {
// Final step completed
setState(() {
_steps[_currentStep] = {
..._steps[_currentStep],
'status': 'completed'
};
_currentStep++;
_progress = 1.0;
});
Future.delayed(
const Duration(milliseconds: 1200), _completeChargingProcess);
}
});
}
void _completeChargingProcess() {
if (!mounted || widget.stationUid == null || widget.connectorId == null) {
_handleInvalidConfiguration();
return;
}
// Animate the transition
_fadeController.reset();
_fadeController.forward();
setState(() {
_headerText = 'Charging Ready';
_progress = 1.0;
// Mark all steps as completed
for (int i = 0; i < _steps.length; i++) {
_steps[i] = {..._steps[i], 'status': 'completed'};
}
_currentStep = -1;
});
// Navigate after a delay
Future.delayed(const Duration(seconds: 2), () {
if (!mounted) return;
try {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => ChargingSessionScreen(
stationUid: widget.stationUid ?? 'unknown',
connectorId: widget.connectorId ?? 'unknown',
initialCharge: 0.3,
),
),
);
} catch (e) {
debugPrint('Navigation error: $e');
// Handle navigation error
}
});
}
void _handleInvalidConfiguration() {
if (!mounted) return;
setState(() {
_headerText = 'Configuration Error';
});
// Show error animation
_pulseController.stop();
Future.delayed(const Duration(seconds: 2), () {
if (mounted) Navigator.of(context).pop();
});
}
@override
void dispose() {
_simulationCompletionTimer?.cancel();
_fadeController.dispose();
_pulseController.dispose();
_shimmerController.dispose();
_staggeredController.dispose();
_bgAnimationController.dispose();
// No need to dispose _stepPageController as it's no longer used
super.dispose();
}
@override
Widget build(BuildContext context) {
final ColorScheme scheme = Theme.of(context).colorScheme.copyWith(
primary: const Color(0xFF006E5C),
secondary: const Color(0xFF4FB477),
surface: const Color(0xFFFFFFFF),
onPrimary: const Color(0xFFFFFFFF),
onSecondary: const Color(0xFFFFFFFF),
onSurface: const Color(0xFF2D3B3A),
outline: const Color(0xFFB7C9C9),
surfaceContainerHighest: const Color(0xFFE9F3F2),
);
final isDark = Theme.of(context).brightness == Brightness.dark;
return Scaffold(
backgroundColor: scheme.background,
body: Stack(
children: [
// Animated background
AnimatedBuilder(
animation: _bgAnimationController,
builder: (context, _) => CustomPaint(
painter: AnimatedEVBackgroundPainter(
color: scheme.primary.withOpacity(isDark ? 0.22 : 0.15),
animationValue: _bgAnimationController.value,
),
size: Size.infinite,
),
),
// Main content
SafeArea(
child: FadeTransition(
opacity: _fadeAnimation,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Header section with progress
Container(
padding: const EdgeInsets.symmetric(
horizontal: 24, vertical: 16),
decoration: BoxDecoration(
color: scheme.surface.withOpacity(0.8),
boxShadow: [
BoxShadow(
color: scheme.shadow.withOpacity(0.1),
blurRadius: 10,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
_buildAnimatedHeader(scheme),
const SizedBox(height: 16),
_buildProgressIndicator(scheme),
],
),
),
// Vertical scrolling steps list
Expanded(
child: _buildAnimatedStepsPager(scheme),
),
],
),
),
),
],
),
);
}
Widget _buildAnimatedHeader(ColorScheme scheme) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 600),
transitionBuilder: (child, anim) => ScaleTransition(
scale: CurvedAnimation(parent: anim, curve: Curves.elasticOut),
child: child,
),
child: Text(
_headerText,
key: ValueKey(_headerText),
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: scheme.primary,
letterSpacing: 0.8,
shadows: [
Shadow(
color: scheme.primary.withOpacity(0.08),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
textAlign: TextAlign.center,
),
);
}
Widget _buildProgressIndicator(ColorScheme scheme) {
return Container(
height: 28,
margin: const EdgeInsets.symmetric(horizontal: 12),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
color: scheme.primaryContainer.withOpacity(0.15),
blurRadius: 12,
offset: const Offset(0, 4),
),
],
gradient: LinearGradient(
colors: [
scheme.primaryContainer.withOpacity(0.19),
scheme.secondaryContainer.withOpacity(0.13)
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
),
child: Stack(
alignment: Alignment.centerLeft,
children: [
LayoutBuilder(
builder: (context, constraints) {
final width = constraints.maxWidth * _progress;
return AnimatedContainer(
duration: const Duration(milliseconds: 550),
curve: Curves.easeOutCubic,
width: width,
height: 28,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
gradient: LinearGradient(
colors: [scheme.primary, scheme.secondary],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
boxShadow: [
BoxShadow(
color: scheme.primary.withOpacity(0.16),
blurRadius: 14,
offset: const Offset(0, 4),
),
],
),
);
},
),
// Shimmer
AnimatedBuilder(
animation: _shimmerController,
builder: (context, _) {
final shimmerPosition = Tween(begin: -1.0, end: 2.0)
.animate(CurvedAnimation(
parent: _shimmerController, curve: Curves.easeInOut));
return FractionallySizedBox(
widthFactor: _progress,
child: ShaderMask(
shaderCallback: (rect) {
return LinearGradient(
colors: [
const Color(0xFFFFFFFF).withOpacity(0.0),
const Color(0xFFFFFFFF).withOpacity(0.7),
const Color(0xFFFFFFFF).withOpacity(0.0),
],
stops: [0.1, 0.5, 0.9],
begin: Alignment(-1 + shimmerPosition.value * 2, 0),
end: Alignment(1 + shimmerPosition.value * 2, 0),
).createShader(rect);
},
child: Container(
height: 28,
decoration: BoxDecoration(
color: const Color(0xFFFFFFFF).withOpacity(0.18),
borderRadius: BorderRadius.circular(16),
),
),
blendMode: BlendMode.srcATop,
),
);
},
),
Center(
child: Text(
'${(_progress * 100).toInt()}%',
style: TextStyle(
color: scheme.onPrimary,
fontWeight: FontWeight.w600,
fontSize: 15,
letterSpacing: 0.5,
shadows: [
Shadow(
color: scheme.primary.withOpacity(0.22),
blurRadius: 8,
),
],
),
),
),
],
),
);
}
// Vertical scrolling list of steps with 3D depth effect
Widget _buildAnimatedStepsPager(ColorScheme scheme) {
return LayoutBuilder(
builder: (context, constraints) {
return NotificationListener(
onNotification: (notification) {
if (notification is ScrollEndNotification) {
// Handle scroll end if needed
}
return true;
},
child: ListView.builder(
padding: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.1, // Add top padding
bottom: 20,
left: 16,
right: 16,
),
physics: const BouncingScrollPhysics(),
itemCount: _steps.length,
itemBuilder: (context, index) {
final step = _steps[index];
final isActive = index == _currentStep;
final isCompleted = index < _currentStep;
// Removed unused variable isUpcoming
// Calculate scale and offset based on position
final distanceFromCenter =
(index - _currentStep).abs().toDouble();
final scale = 1.0 - (0.05 * distanceFromCenter);
final opacity = 1.0 - (0.25 * distanceFromCenter);
final verticalOffset = isActive
? 0.0
: isCompleted
? -20.0 * (1 / (index + 1))
: 20.0 * (1 / (index - _currentStep));
return AnimatedContainer(
duration: const Duration(milliseconds: 500),
curve: Curves.easeOutCubic,
margin: EdgeInsets.symmetric(
vertical: isActive ? 24 : 8,
horizontal: isActive ? 8 : 16,
),
transform: Matrix4.identity()
..setEntry(3, 2, 0.001) // 3D perspective
..scale(scale)
..translate(0.0, verticalOffset),
child: Opacity(
opacity: opacity.clamp(0.5, 1.0),
child: _buildStepItem(
step,
isActive,
isCompleted,
scheme.primary,
scheme.secondary,
scheme.onBackground,
scheme.onSurface.withOpacity(0.72),
scheme.surface,
scheme.surfaceVariant,
),
),
);
},
),
);
},
);
}
Widget _buildStepItem(
Map<String, dynamic> step,
bool isActive,
bool isCompleted,
Color primaryColor,
Color successColor,
Color textPrimaryColor,
Color textSecondaryColor,
Color cardColor,
Color surfaceVariantColor,
) {
// Add pulsing animation for active step
if (isActive) {
return TweenAnimationBuilder(
tween: Tween(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 1500),
builder: (context, value, child) {
return Transform.scale(
scale: 1.0 + (0.02 * math.sin(value * math.pi * 2)),
child: child,
);
},
child: _buildStepCard(
step,
isActive,
isCompleted,
primaryColor,
successColor,
textPrimaryColor,
textSecondaryColor,
cardColor,
surfaceVariantColor,
),
);
}
return _buildStepCard(
step,
isActive,
isCompleted,
primaryColor,
successColor,
textPrimaryColor,
textSecondaryColor,
cardColor,
surfaceVariantColor,
);
}
Widget _buildStepCard(
Map<String, dynamic> step,
bool isActive,
bool isCompleted,
Color primaryColor,
Color successColor,
Color textPrimaryColor,
Color textSecondaryColor,
Color cardColor,
Color surfaceVariantColor,
) {
return Card(
elevation: isActive ? 8 : 2,
shadowColor: isActive
? primaryColor.withOpacity(0.5)
: Colors.black.withOpacity(0.1),
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: isActive
? BorderSide(color: primaryColor.withOpacity(0.6), width: 2.0)
: BorderSide.none,
),
color: cardColor,
child: AnimatedContainer(
duration: const Duration(milliseconds: 400),
curve: Curves.easeOutQuad,
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
// Status indicator with animation
AnimatedSwitcher(
duration: const Duration(milliseconds: 400),
transitionBuilder: (child, animation) {
return ScaleTransition(
scale: animation,
child: child,
);
},
child: _buildStatusIndicator(
isCompleted, isActive, successColor, primaryColor),
),
const SizedBox(width: 16),
// Step content
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
step['title'],
style: TextStyle(
fontSize: isActive ? 18 : 16,
fontWeight: isActive ? FontWeight.w700 : FontWeight.w600,
color: isActive
? primaryColor
: isCompleted
? successColor
: textPrimaryColor,
letterSpacing: 0.2,
),
),
const SizedBox(height: 4),
Text(
step['subtitle'],
style: TextStyle(
fontSize: isActive ? 14 : 13,
color: isActive
? primaryColor.withOpacity(0.9)
: textSecondaryColor,
fontWeight:
isActive ? FontWeight.w500 : FontWeight.normal,
),
),
],
),
),
// Status icon
_buildStepIcon(
isActive,
isCompleted,
primaryColor,
successColor,
surfaceVariantColor,
textSecondaryColor,
step,
),
],
),
),
);
}
Widget _buildStatusIndicator(
bool isCompleted,
bool isActive,
Color successColor,
Color primaryColor,
) {
return AnimatedContainer(
duration: const Duration(milliseconds: 400),
curve: Curves.easeOutQuad,
width: 32,
height: 32,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: isCompleted
? successColor.withOpacity(0.85)
: isActive
? primaryColor.withOpacity(0.70)
: Colors.grey.withOpacity(0.14),
boxShadow: [
if (isActive)
BoxShadow(
color: primaryColor.withOpacity(0.19),
blurRadius: 14,
offset: const Offset(0, 2),
),
if (isCompleted)
BoxShadow(
color: successColor.withOpacity(0.17),
blurRadius: 14,
offset: const Offset(0, 2),
),
],
border: Border.all(
color: isCompleted
? successColor.withOpacity(0.7)
: isActive
? primaryColor.withOpacity(0.7)
: Colors.grey.withOpacity(0.18),
width: 2.2,
),
),
child: isCompleted
? Icon(Icons.check, color: const Color(0xFFFFFFFF), size: 20)
: isActive
? SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(
strokeWidth: 3.2,
valueColor: AlwaysStoppedAnimation(primaryColor),
backgroundColor: const Color(0xFFFFFFFF).withOpacity(0.11),
),
)
: Icon(Icons.circle_outlined,
color: Colors.grey.withOpacity(0.47), size: 18),
);
}
Widget _buildStepIcon(
bool isActive,
bool isCompleted,
Color primaryColor,
Color successColor,
Color surfaceVariantColor,
Color textSecondaryColor,
Map<String, dynamic> step,
) {
return AnimatedBuilder(
animation: _pulseController,
builder: (context, child) {
final double pulse = isActive ? _pulseAnimation.value : 1.0;
final double rotate =
isActive ? (_pulseController.value - 0.5) * 0.18 : 0.0;
final Color iconColor = isCompleted
? successColor
: isActive
? primaryColor
: textSecondaryColor.withOpacity(0.6);
return Transform(
alignment: Alignment.center,
transform: Matrix4.identity()
..scale(pulse, pulse)
..rotateZ(rotate),
child: Container(
width: 38,
height: 38,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: isCompleted
? successColor.withOpacity(0.14)
: isActive
? primaryColor.withOpacity(0.13)
: surfaceVariantColor.withOpacity(0.18),
boxShadow: [
if (isActive)
BoxShadow(
color: primaryColor.withOpacity(0.16),
blurRadius: 14,
offset: const Offset(0, 2),
),
if (isCompleted)
BoxShadow(
color: successColor.withOpacity(0.13),
blurRadius: 12,
offset: const Offset(0, 2),
),
],
),
child: Icon(
step['icon'],
color: iconColor,
size: 22,
),
),
);
},
);
}
}