Compare commits

..

10 Commits

12 changed files with 424 additions and 153 deletions

View File

@ -29,9 +29,10 @@ protected static function boot()
*/
public static function syncKontrakanStatus($kontrakanId)
{
// Cek apakah ada booking checked_in
// Cek apakah ada booking checked_in (sewa)
$hasCheckedIn = static::where('kontrakan_id', $kontrakanId)
->where('status', self::STATUS_CHECKED_IN)
->where('jenis_pengajuan', 'sewa')
->exists();
if ($hasCheckedIn) {
@ -39,9 +40,10 @@ public static function syncKontrakanStatus($kontrakanId)
return;
}
// Cek apakah ada booking confirmed atau pending
// Cek apakah ada booking confirmed atau pending (sewa)
$hasActiveOrPending = static::where('kontrakan_id', $kontrakanId)
->whereIn('status', [self::STATUS_CONFIRMED, self::STATUS_PENDING])
->where('jenis_pengajuan', 'sewa')
->exists();
if ($hasActiveOrPending) {

View File

@ -178,7 +178,7 @@
</div>
@if($booking->jam_survei)
<small class="text-muted">
<i class="bi bi-clock me-1"></i>Pukul {{ $booking->jam_survei }} WIB
<i class="bi bi-clock me-1"></i>Pukul {{ date('H.i', strtotime($booking->jam_survei)) }} WIB
</small>
@endif
<br>

View File

@ -199,7 +199,7 @@ class="rounded me-3" style="width: 120px; height: 90px; object-fit: cover;">
</div>
@if($booking->jam_survei)
<div class="fw-semibold mt-1">
<i class="bi bi-clock me-1 text-success"></i>Pukul {{ $booking->jam_survei }} WIB
<i class="bi bi-clock me-1 text-success"></i>Pukul {{ date('H.i', strtotime($booking->jam_survei)) }} WIB
</div>
@endif
<span class="badge bg-success mt-1">Survei</span>

View File

@ -4,6 +4,8 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<application
android:label="Kontrak Kampus"

View File

@ -264,7 +264,6 @@ class _SplashScreenState extends State<SplashScreen>
late AnimationController _animController;
late Animation<double> _fadeAnim;
late Animation<double> _scaleAnim;
String _statusText = 'Memulai aplikasi...';
@override
void initState() {
@ -291,12 +290,9 @@ class _SplashScreenState extends State<SplashScreen>
}
Future<void> _checkAuth() async {
// 🔍 Auto-detect server IP dengan fallback ke konfigurasi default.
// Ini membantu APK tetap bisa konek saat IP LAN berubah.
// Auto-detect server IP (status callback ditelan, user hanya lihat "Sedang memuat...")
await ServerDiscoveryService.discover(
onStatus: (status) {
if (mounted) setState(() => _statusText = status);
},
onStatus: (_) {}, // Tidak tampilkan info teknis ke user
).timeout(
const Duration(seconds: 8),
onTimeout: () {
@ -305,7 +301,6 @@ class _SplashScreenState extends State<SplashScreen>
},
);
if (mounted) setState(() => _statusText = 'Memeriksa sesi...');
await _authService.loadToken();
await Future.delayed(const Duration(milliseconds: 400));
@ -319,13 +314,7 @@ class _SplashScreenState extends State<SplashScreen>
Navigator.pushReplacement(
context,
PageRouteBuilder(
pageBuilder: (_, __, ___) => destination,
transitionsBuilder: (_, animation, __, child) {
return FadeTransition(opacity: animation, child: child);
},
transitionDuration: const Duration(milliseconds: 500),
),
MaterialPageRoute(builder: (_) => destination),
);
}
@ -335,82 +324,122 @@ class _SplashScreenState extends State<SplashScreen>
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color(0xFF1565C0), Color(0xFF0D47A1), Color(0xFF1A237E)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFF1565C0), Color(0xFF1E88E5)],
),
),
child: Center(
child: FadeTransition(
opacity: _fadeAnim,
child: ScaleTransition(
scale: _scaleAnim,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(28),
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.15),
blurRadius: 30,
offset: const Offset(0, 10),
child: Stack(
children: [
// ==================== KONTEN UTAMA (TENGAH) ====================
Center(
child: FadeTransition(
opacity: _fadeAnim,
child: ScaleTransition(
scale: _scaleAnim,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Logo toga di dalam CircleAvatar putih
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.15),
blurRadius: 30,
offset: const Offset(0, 10),
),
],
),
child: const CircleAvatar(
radius: 50,
backgroundColor: Colors.white,
child: Icon(
Icons.school,
size: 56,
color: Color(0xFF1565C0),
),
),
],
),
child: const Icon(
Icons.school_rounded,
size: 64,
color: Color(0xFF1565C0),
),
),
const SizedBox(height: 32),
const Text(
'Kontrak Kampus',
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w800,
color: Colors.white,
letterSpacing: 0.5,
),
),
const SizedBox(height: 8),
Text(
'Rekomendasi Kontrakan & Laundry untuk Mahasiswa',
style: TextStyle(
fontSize: 14,
color: Colors.white.withOpacity(0.8),
letterSpacing: 0.3,
),
),
const SizedBox(height: 48),
SizedBox(
width: 32,
height: 32,
child: CircularProgressIndicator(
strokeWidth: 2.5,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.white.withOpacity(0.9),
),
),
const SizedBox(height: 32),
// Nama aplikasi — bold, non-italic, 28sp, putih
const Text(
'Kontrak Kampus',
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
fontStyle: FontStyle.normal,
color: Colors.white,
letterSpacing: 0.5,
),
),
const SizedBox(height: 8),
// Tagline — kecil, putih transparan
Text(
'Rekomendasi Kontrakan & Laundry untuk Mahasiswa',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
color: Colors.white.withValues(alpha: 0.8),
letterSpacing: 0.3,
),
),
const SizedBox(height: 48),
// Teks loading ramah user
Text(
'Sedang memuat...',
style: TextStyle(
fontSize: 13,
color: Colors.white.withValues(alpha: 0.7),
),
),
const SizedBox(height: 16),
// Loading indicator di bawah teks loading
SizedBox(
width: 32,
height: 32,
child: CircularProgressIndicator(
strokeWidth: 2.5,
valueColor: AlwaysStoppedAnimation<Color>(
Colors.white.withValues(alpha: 0.9),
),
),
),
],
),
const SizedBox(height: 16),
Text(
_statusText,
style: TextStyle(
fontSize: 13,
color: Colors.white.withOpacity(0.7),
),
),
],
),
),
),
),
// ==================== VERSI APP (BAWAH TENGAH) ====================
Positioned(
bottom: 32,
left: 0,
right: 0,
child: Center(
child: Text(
'v1.0.0',
style: TextStyle(
fontSize: 12,
color: Colors.white.withValues(alpha: 0.5),
fontWeight: FontWeight.w400,
),
),
),
),
],
),
),
);
}
}

View File

@ -291,7 +291,26 @@ class Laundry {
double get jarak => jarakKampus; // alias for jarak field
double get rating => avgRating ?? 0.0;
String get estimasiSelesai => '$waktuProses jam';
// Format jam secara umum menjadi format ramah pengguna (contoh: "3 hari", "10 jam")
static String formatJam(int jam) {
if (jam >= 24) {
final hari = jam ~/ 24;
final sisaJam = jam % 24;
if (sisaJam == 0) {
return '$hari hari';
} else {
return '$hari hari $sisaJam jam';
}
}
return '$jam jam';
}
// Format waktu proses sesuai jenis layanan
String formattedWaktuProsesFor(String? jenisLayanan) {
return formatJam(waktuProsesFor(jenisLayanan));
}
String get estimasiSelesai => formatJam(waktuProses);
// Check if currently open
bool get isOpen {

View File

@ -677,7 +677,7 @@ class _FavoritesScreenState extends State<FavoritesScreen>
children: [
_buildInfoChip(
Icons.schedule_rounded,
'${laundry.waktuProses}h proses',
'${laundry.estimasiSelesai} proses',
const Color(0xFF00897B),
),
const SizedBox(width: 8),

View File

@ -1378,7 +1378,7 @@ class _ImprovedHomeScreenState extends State<ImprovedHomeScreen> {
),
const SizedBox(width: 3),
Text(
'${laundry.waktuProses}h',
laundry.estimasiSelesai,
style: const TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,

View File

@ -295,7 +295,7 @@ class _LaundryDetailScreenState extends State<LaundryDetailScreen> {
),
_buildHeaderChip(
icon: Icons.schedule_rounded,
label: '${widget.laundry.waktuProsesFor(widget.selectedJenisLayanan)} jam',
label: widget.laundry.formattedWaktuProsesFor(widget.selectedJenisLayanan),
),
],
),
@ -347,7 +347,7 @@ class _LaundryDetailScreenState extends State<LaundryDetailScreen> {
_buildInfoRow(
Icons.schedule,
'Kecepatan Layanan',
'${widget.laundry.waktuProsesFor(widget.selectedJenisLayanan)} jam',
widget.laundry.formattedWaktuProsesFor(widget.selectedJenisLayanan),
),
],
),
@ -366,15 +366,17 @@ class _LaundryDetailScreenState extends State<LaundryDetailScreen> {
widget.laundry.formattedHargaFor("harian"),
Icons.scale,
const Color(0xFF00897B),
duration: widget.laundry.formattedWaktuProsesFor("harian"),
),
const SizedBox(height: 8),
],
if (widget.laundry.hargaJam > 0)
_buildPriceCard(
'Laundry Express (Jam/Satuan)',
'Laundry Express (Jam)',
widget.laundry.formattedHargaFor("jam"),
Icons.flash_on,
const Color(0xFFFF9800),
duration: widget.laundry.formattedWaktuProsesFor("jam"),
),
if (widget.laundry.hargaHarian == 0 && widget.laundry.hargaJam == 0)
_buildPriceCard(
@ -382,6 +384,7 @@ class _LaundryDetailScreenState extends State<LaundryDetailScreen> {
widget.laundry.formattedHargaKiloan,
Icons.scale,
const Color(0xFF00897B),
duration: widget.laundry.formattedWaktuProsesFor("harian"),
),
],
),
@ -811,8 +814,9 @@ class _LaundryDetailScreenState extends State<LaundryDetailScreen> {
String title,
String price,
IconData icon,
Color color,
) {
Color color, {
String? duration,
}) {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
@ -839,6 +843,17 @@ class _LaundryDetailScreenState extends State<LaundryDetailScreen> {
title,
style: TextStyle(fontSize: 14, color: Colors.grey[700]),
),
if (duration != null && duration.isNotEmpty) ...[
const SizedBox(height: 2),
Text(
'Estimasi selesai: $duration',
style: TextStyle(
fontSize: 12,
color: Colors.grey[600],
fontWeight: FontWeight.w500,
),
),
],
const SizedBox(height: 4),
Text(
price,

View File

@ -1,4 +1,6 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import '../services/auth_service.dart';
import '../services/favorite_service.dart';
import '../services/booking_service.dart';
@ -25,6 +27,7 @@ class _ProfileScreenState extends State<ProfileScreen>
bool _isLoading = true;
int _totalFavorites = 0;
int _totalBookings = 0;
File? _profileImage;
late AnimationController _animController;
late Animation<double> _fadeAnim;
@ -111,6 +114,115 @@ class _ProfileScreenState extends State<ProfileScreen>
return '${months[date.month]} ${date.year}';
}
Future<void> _pickProfileImage() async {
final source = await showModalBottomSheet<ImageSource>(
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(20)),
),
builder: (context) => SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 40,
height: 4,
decoration: BoxDecoration(
color: Colors.grey.shade300,
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(height: 16),
const Text(
'Pilih Sumber Foto',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
color: Color(0xFF1A1A2E),
),
),
const SizedBox(height: 16),
ListTile(
leading: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: const Color(0xFF1565C0).withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
),
child: const Icon(Icons.camera_alt_rounded,
color: Color(0xFF1565C0)),
),
title: const Text('Kamera',
style: TextStyle(fontWeight: FontWeight.w600)),
subtitle: const Text('Ambil foto baru'),
onTap: () => Navigator.pop(context, ImageSource.camera),
),
ListTile(
leading: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
color: const Color(0xFF00897B).withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
),
child: const Icon(Icons.photo_library_rounded,
color: Color(0xFF00897B)),
),
title: const Text('Galeri',
style: TextStyle(fontWeight: FontWeight.w600)),
subtitle: const Text('Pilih dari galeri'),
onTap: () => Navigator.pop(context, ImageSource.gallery),
),
],
),
),
),
);
if (source == null) return;
try {
final picker = ImagePicker();
final pickedFile = await picker.pickImage(
source: source,
maxWidth: 512,
maxHeight: 512,
imageQuality: 85,
);
if (pickedFile != null && mounted) {
setState(() {
_profileImage = File(pickedFile.path);
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text('Foto profil berhasil diperbarui'),
backgroundColor: const Color(0xFF00897B),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
margin: const EdgeInsets.all(16),
),
);
}
} catch (e) {
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Gagal memilih foto: $e'),
backgroundColor: Colors.red,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
margin: const EdgeInsets.all(16),
),
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
@ -181,6 +293,26 @@ class _ProfileScreenState extends State<ProfileScreen>
);
},
),
_buildMenuItem(
icon: Icons.notifications_outlined,
iconColor: const Color(0xFFFF8F00),
iconBg: const Color(0xFFFF8F00),
title: 'Pengaturan Notifikasi',
subtitle: 'Atur preferensi notifikasi',
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text('Fitur pengaturan notifikasi akan segera hadir'),
backgroundColor: const Color(0xFF1565C0),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
margin: const EdgeInsets.all(16),
),
);
},
),
]),
const SizedBox(height: 24),
@ -242,6 +374,46 @@ class _ProfileScreenState extends State<ProfileScreen>
subtitle: 'Informasi & versi aplikasi',
onTap: _showAboutDialog,
),
_buildMenuItem(
icon: Icons.help_outline_rounded,
iconColor: const Color(0xFF0288D1),
iconBg: const Color(0xFF0288D1),
title: 'Bantuan & FAQ',
subtitle: 'Pertanyaan umum & panduan',
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text('Fitur bantuan & FAQ akan segera hadir'),
backgroundColor: const Color(0xFF1565C0),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
margin: const EdgeInsets.all(16),
),
);
},
),
_buildMenuItem(
icon: Icons.privacy_tip_outlined,
iconColor: const Color(0xFF5E35B1),
iconBg: const Color(0xFF5E35B1),
title: 'Kebijakan Privasi',
subtitle: 'Syarat & ketentuan privasi',
onTap: () {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: const Text('Fitur kebijakan privasi akan segera hadir'),
backgroundColor: const Color(0xFF1565C0),
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
margin: const EdgeInsets.all(16),
),
);
},
),
]),
const SizedBox(height: 32),
@ -343,42 +515,78 @@ class _ProfileScreenState extends State<ProfileScreen>
// Avatar + Info
Row(
children: [
// Avatar with shadow and gradient ring
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.2),
blurRadius: 16,
offset: const Offset(0, 6),
// Avatar with shadow, gradient ring, and camera button
Stack(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.2),
blurRadius: 16,
offset: const Offset(0, 6),
),
],
),
],
),
child: Container(
padding: const EdgeInsets.all(3),
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Colors.white, Color(0xFFBBDEFB)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: CircleAvatar(
radius: 40,
backgroundColor: const Color(0xFF0D47A1),
child: Text(
_getInitials(_currentUser?.name ?? ''),
style: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.w800,
color: Colors.white,
letterSpacing: 1,
child: Container(
padding: const EdgeInsets.all(3),
decoration: const BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Colors.white, Color(0xFFBBDEFB)],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: CircleAvatar(
radius: 40,
backgroundColor: const Color(0xFF0D47A1),
backgroundImage: _profileImage != null
? FileImage(_profileImage!)
: null,
child: _profileImage == null
? Text(
_getInitials(_currentUser?.name ?? ''),
style: const TextStyle(
fontSize: 28,
fontWeight: FontWeight.w800,
color: Colors.white,
letterSpacing: 1,
),
)
: null,
),
),
),
),
Positioned(
bottom: 0,
right: 0,
child: GestureDetector(
onTap: _pickProfileImage,
child: Container(
padding: const EdgeInsets.all(6),
decoration: BoxDecoration(
color: const Color(0xFF1565C0),
shape: BoxShape.circle,
border: Border.all(color: Colors.white, width: 2),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.2),
blurRadius: 4,
offset: const Offset(0, 2),
),
],
),
child: const Icon(
Icons.camera_alt_rounded,
color: Colors.white,
size: 16,
),
),
),
),
],
),
const SizedBox(width: 18),
@ -697,33 +905,26 @@ class _ProfileScreenState extends State<ProfileScreen>
// ==================== LOGOUT ====================
Widget _buildLogoutButton() {
return Container(
return SizedBox(
width: double.infinity,
height: 54,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16),
border: Border.all(color: Colors.red.shade200, width: 1.5),
),
child: Material(
color: Colors.red.shade50.withValues(alpha: 0.5),
borderRadius: BorderRadius.circular(16),
child: InkWell(
onTap: _handleLogout,
borderRadius: BorderRadius.circular(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.logout_rounded, color: Colors.red.shade600, size: 20),
const SizedBox(width: 10),
Text(
'Keluar dari Akun',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
color: Colors.red.shade600,
),
),
],
child: ElevatedButton.icon(
onPressed: _handleLogout,
icon: const Icon(Icons.logout_rounded, size: 20),
label: const Text(
'Keluar dari Akun',
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.w700,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
foregroundColor: Colors.white,
elevation: 2,
shadowColor: Colors.red.withValues(alpha: 0.3),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
),
),

View File

@ -1060,7 +1060,7 @@ class _SearchScreenState extends State<SearchScreen> {
),
const SizedBox(width: 4),
Text(
'${laundry.waktuProses} jam',
laundry.estimasiSelesai,
style: TextStyle(
fontSize: 12,
color: Colors.grey[600],

View File

@ -31,7 +31,10 @@ class LaundryCard extends StatelessWidget {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LaundryDetailScreen(laundry: laundry),
builder: (context) => LaundryDetailScreen(
laundry: laundry,
selectedJenisLayanan: selectedJenisLayanan,
),
),
);
},
@ -236,7 +239,7 @@ class LaundryCard extends StatelessWidget {
),
const SizedBox(width: 4),
Text(
'${laundry.waktuProsesFor(selectedJenisLayanan)}h',
laundry.formattedWaktuProsesFor(selectedJenisLayanan),
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,