home_screen.dart 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import 'package:flutter/material.dart';
  2. import 'analysis_screen.dart';
  3. import 'live_analysis_screen.dart';
  4. import 'static_capture_screen.dart';
  5. import 'history_screen.dart';
  6. class HomeScreen extends StatelessWidget {
  7. const HomeScreen({super.key});
  8. @override
  9. Widget build(BuildContext context) {
  10. return Scaffold(
  11. appBar: AppBar(
  12. title: const Text('Palm Oil Ripeness AI'),
  13. centerTitle: true,
  14. elevation: 2,
  15. ),
  16. body: Container(
  17. decoration: BoxDecoration(
  18. gradient: LinearGradient(
  19. begin: Alignment.topCenter,
  20. end: Alignment.bottomCenter,
  21. colors: [Colors.green.shade50, Colors.white],
  22. ),
  23. ),
  24. child: Center(
  25. child: Column(
  26. mainAxisAlignment: MainAxisAlignment.center,
  27. children: [
  28. _buildNavCard(
  29. context,
  30. title: 'Analyze Gallery',
  31. subtitle: 'Detect ripeness from photos',
  32. icon: Icons.photo_library,
  33. color: Colors.green,
  34. onTap: () => Navigator.push(
  35. context,
  36. MaterialPageRoute(builder: (context) => const AnalysisScreen()),
  37. ),
  38. ),
  39. const SizedBox(height: 24),
  40. _buildNavCard(
  41. context,
  42. title: 'Snap & Analyze',
  43. subtitle: 'Manual high-res capture',
  44. icon: Icons.camera_alt,
  45. color: Colors.teal,
  46. onTap: () => Navigator.push(
  47. context,
  48. MaterialPageRoute(builder: (context) => const StaticCaptureScreen()),
  49. ),
  50. ),
  51. const SizedBox(height: 24),
  52. _buildNavCard(
  53. context,
  54. title: 'Live Inference',
  55. subtitle: 'Real-time "Point-and-Scan"',
  56. icon: Icons.camera,
  57. color: Colors.orange,
  58. onTap: () => Navigator.push(
  59. context,
  60. MaterialPageRoute(builder: (context) => const LiveAnalysisScreen()),
  61. ),
  62. ),
  63. const SizedBox(height: 24),
  64. _buildNavCard(
  65. context,
  66. title: 'History Vault',
  67. subtitle: 'View previous detections',
  68. icon: Icons.history,
  69. color: Colors.blue,
  70. onTap: () => Navigator.push(
  71. context,
  72. MaterialPageRoute(builder: (context) => const HistoryScreen()),
  73. ),
  74. ),
  75. ],
  76. ),
  77. ),
  78. ),
  79. );
  80. }
  81. Widget _buildNavCard(
  82. BuildContext context, {
  83. required String title,
  84. required String subtitle,
  85. required IconData icon,
  86. required Color color,
  87. required VoidCallback onTap,
  88. }) {
  89. return GestureDetector(
  90. onTap: onTap,
  91. child: Container(
  92. width: MediaQuery.of(context).size.width * 0.85,
  93. padding: const EdgeInsets.all(20),
  94. decoration: BoxDecoration(
  95. color: Colors.white,
  96. borderRadius: BorderRadius.circular(20),
  97. boxShadow: [
  98. BoxShadow(
  99. color: color.withOpacity(0.1),
  100. blurRadius: 15,
  101. offset: const Offset(0, 8),
  102. ),
  103. ],
  104. border: Border.all(color: color.withOpacity(0.2), width: 1),
  105. ),
  106. child: Row(
  107. children: [
  108. Container(
  109. padding: const EdgeInsets.all(12),
  110. decoration: BoxDecoration(
  111. color: color.withOpacity(0.1),
  112. borderRadius: BorderRadius.circular(15),
  113. ),
  114. child: Icon(icon, color: color, size: 30),
  115. ),
  116. const SizedBox(width: 20),
  117. Expanded(
  118. child: Column(
  119. crossAxisAlignment: CrossAxisAlignment.start,
  120. children: [
  121. Text(
  122. title,
  123. style: TextStyle(
  124. fontSize: 18,
  125. fontWeight: FontWeight.bold,
  126. color: Colors.grey.shade800,
  127. ),
  128. ),
  129. const SizedBox(height: 4),
  130. Text(
  131. subtitle,
  132. style: TextStyle(
  133. fontSize: 14,
  134. color: Colors.grey.shade600,
  135. ),
  136. ),
  137. ],
  138. ),
  139. ),
  140. Icon(Icons.arrow_forward_ios, color: Colors.grey.shade400, size: 16),
  141. ],
  142. ),
  143. ),
  144. );
  145. }
  146. }