TIFNGK_E41221954/lib/screens/kader/reports_page.dart

125 lines
3.8 KiB
Dart

import 'package:flutter/material.dart';
import 'add_report.dart';
import 'package:shared_preferences/shared_preferences.dart';
class ReportsPage extends StatelessWidget {
const ReportsPage({super.key});
Future<int> getUserId() async {
final prefs = await SharedPreferences.getInstance();
return prefs.getInt('id') ?? 0;
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Buat Laporan Baru',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
),
const SizedBox(height: 10),
Text(
'Laporkan temuan jentik nyamuk di rumah warga',
style: TextStyle(
fontSize: 14,
color: Colors.grey[600],
),
),
const SizedBox(height: 30),
// Card Panduan
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: const Color(0xFF206E97).withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: const Color(0xFF206E97).withOpacity(0.3),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const Icon(
Icons.info_outline,
color: Color(0xFF206E97),
),
const SizedBox(width: 10),
const Text(
'Panduan Singkat',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Color(0xFF206E97),
),
),
],
),
const SizedBox(height: 10),
const Text(
'1. Ambil foto wadah/tempat genangan air\n'
'2. Isi data alamat rumah\n'
'3. Catat temuan jentik/nyamuk\n'
'4. Kirim ke petugas untuk verifikasi',
style: TextStyle(
fontSize: 14,
color: Colors.black87,
),
),
],
),
),
const SizedBox(height: 30),
// Tombol Mulai
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton.icon(
onPressed: () async {
int userId = await getUserId();
print("USER ID: $userId"); // debug
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AddReportPage(
userId: userId, // ✅ FIX DI SINI
),
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF206E97),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
icon: const Icon(Icons.add, color: Colors.white),
label: const Text(
'Buat Laporan Baru',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Colors.white,
),
),
),
),
],
),
);
}
}