import 'package:flutter/material.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart'; // Import tetap diperlukan class AnimatedIntroScreen extends StatefulWidget { const AnimatedIntroScreen({super.key}); @override _AnimatedIntroScreenState createState() => _AnimatedIntroScreenState(); } class _AnimatedIntroScreenState extends State { final PageController _pageController = PageController(); int _currentPage = 0; final List _pages = [ IntroPage( title: 'TaniSM4RT', description: 'Solusi pertanian modern untuk hasil panen yang optimal', icon: Icons.eco, backgroundColor: Color(0xFF0D3B2A), ), IntroPage( title: 'Deteksi Penyakit', description: 'Identifikasi penyakit tanaman dengan cepat untuk penanganan yang tepat waktu', icon: Icons.search, backgroundColor: Color(0xFF0D3B2A), ), IntroPage( title: 'Kalender Tanam', description: 'Optimalkan waktu tanam berdasarkan data cuaca dan kondisi tanah', icon: Icons.calendar_today, backgroundColor: Color(0xFF0D3B2A), ), IntroPage( title: 'Analisis Panen', description: 'Dapatkan wawasan data untuk meningkatkan produktivitas dan efisiensi', icon: Icons.analytics, backgroundColor: Color(0xFF0D3B2A), ), IntroPage( title: 'Komunitas', description: 'Berinteraksi dengan petani lainnya untuk berbagi pengalaman seputar pertanian', icon: Icons.support_agent, backgroundColor: Color(0xFF0D3B2A), ), ]; @override void initState() { super.initState(); } @override void dispose() { _pageController.dispose(); super.dispose(); } void _navigateToLogin() { Navigator.of(context).pushReplacementNamed('/login'); } @override Widget build(BuildContext context) { return Scaffold( body: Stack( children: [ Container( decoration: BoxDecoration( color: _pages[_currentPage].backgroundColor, ), ), PageView.builder( controller: _pageController, itemCount: _pages.length, onPageChanged: (index) { setState(() { _currentPage = index; }); }, itemBuilder: (context, index) { return _buildPage(_pages[index]); }, ), SafeArea( child: Column( children: [ Padding( padding: EdgeInsets.all(16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ // Logo or brand Text( 'TaniSM4RT', style: TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold, letterSpacing: 1.2, ), ), // Skip button TextButton( onPressed: _navigateToLogin, child: Text( 'Lewati', style: TextStyle( color: Colors.white70, fontSize: 16, ), ), ), ], ), ), Spacer(), // Bottom Navigation Container( padding: EdgeInsets.symmetric(horizontal: 24, vertical: 32), decoration: BoxDecoration( color: Colors.white.withOpacity(0.05), borderRadius: BorderRadius.only( topLeft: Radius.circular(30), topRight: Radius.circular(30), ), ), child: Column( children: [ SmoothPageIndicator( controller: _pageController, count: _pages.length, effect: ExpandingDotsEffect( dotColor: Colors.white.withOpacity(0.3), activeDotColor: Colors.white, dotHeight: 8, dotWidth: 8, expansionFactor: 3, spacing: 6, ), ), SizedBox(height: 24), ElevatedButton( onPressed: () { if (_currentPage == _pages.length - 1) { _navigateToLogin(); } else { _pageController.nextPage( duration: Duration(milliseconds: 300), curve: Curves.easeInOut, ); } }, style: ElevatedButton.styleFrom( foregroundColor: _pages[_currentPage].backgroundColor, backgroundColor: Colors.white, padding: EdgeInsets.symmetric(vertical: 16), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), ), elevation: 0, minimumSize: Size(double.infinity, 54), ), child: Text( _currentPage == _pages.length - 1 ? 'Mulai Sekarang' : 'Lanjutkan', style: TextStyle( fontSize: 16, fontWeight: FontWeight.w600, letterSpacing: 0.5, ), ), ), ], ), ), ], ), ), ], ), ); } Widget _buildPage(IntroPage page) { return Container( padding: EdgeInsets.symmetric(horizontal: 32), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Icon( page.icon, size: 80, color: Colors.white, ), SizedBox(height: 40), Text( page.title, textAlign: TextAlign.center, style: TextStyle( fontSize: 28, fontWeight: FontWeight.bold, color: Colors.white, letterSpacing: 0.5, ), ), SizedBox(height: 16), Text( page.description, textAlign: TextAlign.center, style: TextStyle( color: Colors.white.withOpacity(0.9), fontSize: 16, height: 1.6, letterSpacing: 0.2, ), ), ], ), ); } } class IntroPage { final String title; final String description; final IconData icon; final Color backgroundColor; IntroPage({ required this.title, required this.description, required this.icon, required this.backgroundColor, }); }