home_screen.dart 3.6 KB

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