168 lines
5.2 KiB
Dart
168 lines
5.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'jadwal_user_screen.dart';
|
|
import 'laporan_kejadian_user_screen.dart';
|
|
import '../../../services/auth_service.dart';
|
|
|
|
class LaporanTabScreen extends StatefulWidget {
|
|
const LaporanTabScreen({super.key});
|
|
|
|
@override
|
|
State<LaporanTabScreen> createState() => _LaporanTabScreenState();
|
|
}
|
|
|
|
class _LaporanTabScreenState extends State<LaporanTabScreen> {
|
|
String _namaUser = '';
|
|
bool _isReady = false;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadNamaUser();
|
|
}
|
|
|
|
Future<void> _loadNamaUser() async {
|
|
final nama = await AuthService.getNamaUser();
|
|
if (mounted) {
|
|
setState(() {
|
|
_namaUser = nama ?? '';
|
|
_isReady = true;
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (!_isReady) {
|
|
return const Scaffold(
|
|
body: Center(child: CircularProgressIndicator()),
|
|
);
|
|
}
|
|
|
|
return DefaultTabController(
|
|
length: 2,
|
|
child: Scaffold(
|
|
appBar: AppBar(
|
|
automaticallyImplyLeading: false,
|
|
title: const Text(
|
|
'Laporan',
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
centerTitle: true,
|
|
backgroundColor: const Color(0xFF2F5BEA),
|
|
elevation: 0,
|
|
shape: const RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.vertical(bottom: Radius.circular(20)),
|
|
),
|
|
bottom: const TabBar(
|
|
indicatorColor: Colors.white,
|
|
indicatorWeight: 3,
|
|
labelColor: Colors.white,
|
|
unselectedLabelColor: Colors.white60,
|
|
labelStyle:
|
|
TextStyle(fontWeight: FontWeight.bold, fontSize: 13),
|
|
unselectedLabelStyle: TextStyle(fontSize: 13),
|
|
tabs: [
|
|
Tab(
|
|
icon: Icon(Icons.assignment_outlined, size: 20),
|
|
text: 'Patroli',
|
|
),
|
|
Tab(
|
|
icon: Icon(Icons.warning_amber_rounded, size: 20),
|
|
text: 'Kejadian',
|
|
),
|
|
],
|
|
),
|
|
),
|
|
body: TabBarView(
|
|
children: [
|
|
// ── Tab Patroli: arahkan ke jadwal ──
|
|
_LaporanPatroliTab(),
|
|
// ── Tab Kejadian: form input saja, tanpa AppBar/sub-tab ──
|
|
InputLaporanKejadianTab(namaUser: _namaUser),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
// ═══════════════════════════════════════════
|
|
// TAB PATROLI
|
|
// ═══════════════════════════════════════════
|
|
class _LaporanPatroliTab extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFFF5F7FB),
|
|
body: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(20),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF2F5BEA).withValues(alpha: 0.1),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: const Icon(
|
|
Icons.assignment_rounded,
|
|
size: 80,
|
|
color: Color(0xFF2F5BEA),
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
const Text(
|
|
'Butuh Laporan Patroli?',
|
|
style: TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold,
|
|
color: Color(0xFF2D3243),
|
|
),
|
|
),
|
|
const SizedBox(height: 10),
|
|
const Text(
|
|
'Untuk menginput laporan patroli,\nsilakan pilih jadwal aktif Anda terlebih dahulu.',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontSize: 14,
|
|
color: Colors.grey,
|
|
height: 1.5,
|
|
),
|
|
),
|
|
const SizedBox(height: 32),
|
|
ElevatedButton.icon(
|
|
onPressed: () => Navigator.push(
|
|
context,
|
|
MaterialPageRoute(
|
|
builder: (_) => const JadwalUserScreen()),
|
|
),
|
|
icon: const Icon(Icons.search_rounded, color: Colors.white),
|
|
label: const Text(
|
|
'Cari Jadwal',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: const Color(0xFF2F5BEA),
|
|
minimumSize: const Size(200, 50),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
elevation: 0,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |