home_screen.dart 4.1 KB

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