first week update
This commit is contained in:
parent
760bb2de66
commit
ff76abbbf6
@ -1,35 +1,36 @@
|
|||||||
package com.walkguide.controller;
|
package com.walkguide.controller;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.walkguide.dto.ApiResponse;
|
||||||
import com.walkguide.dto.AuthRequest;
|
import com.walkguide.dto.AuthRequest;
|
||||||
import com.walkguide.dto.AuthResponse;
|
|
||||||
import com.walkguide.service.AuthService;
|
import com.walkguide.service.AuthService;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/auth") // Ini URL awalnya
|
@RequestMapping("/api/auth")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AuthController {
|
public class AuthController {
|
||||||
|
|
||||||
private final AuthService authService;
|
private final AuthService authService;
|
||||||
|
|
||||||
// Ini URL lengkapnya jadi POST http://localhost:8080/api/auth/login
|
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public ResponseEntity<?> login(@RequestBody AuthRequest request) {
|
public ResponseEntity<ApiResponse<Map<String, String>>> login(@Valid @RequestBody AuthRequest request) {
|
||||||
try {
|
|
||||||
// Lempar kardus AuthRequest ke Service
|
// Panggil service buat cek password dan bikin token
|
||||||
AuthResponse response = authService.login(request);
|
Map<String, String> tokenData = authService.login(request);
|
||||||
// Kalau sukses, kirim status 200 OK + isinya
|
|
||||||
|
// Bungkus pakai ApiResponse biar sesuai standar Dosen lu!
|
||||||
|
ApiResponse<Map<String, String>> response = new ApiResponse<>(true, tokenData, "Login berhasil");
|
||||||
|
|
||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
} catch (RuntimeException e) {
|
|
||||||
// Kalau gagal (password salah/email gak ada), kirim status 401 Unauthorized
|
|
||||||
return ResponseEntity.status(401).body(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,36 +1,48 @@
|
|||||||
package com.walkguide.service;
|
package com.walkguide.service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.walkguide.dto.AuthRequest;
|
import com.walkguide.dto.AuthRequest;
|
||||||
import com.walkguide.dto.AuthResponse;
|
|
||||||
import com.walkguide.entity.User;
|
import com.walkguide.entity.User;
|
||||||
import com.walkguide.repository.UserRepository;
|
import com.walkguide.repository.UserRepository;
|
||||||
import com.walkguide.security.JwtUtil;
|
import com.walkguide.security.JwtUtil;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AuthService {
|
public class AuthService {
|
||||||
|
|
||||||
private final UserRepository userRepository;
|
private final UserRepository userRepository;
|
||||||
private final PasswordEncoder passwordEncoder;
|
|
||||||
private final JwtUtil jwtUtil;
|
private final JwtUtil jwtUtil;
|
||||||
|
|
||||||
public AuthResponse login(AuthRequest request) {
|
// Wajib panggil BCrypt biar bisa baca password enkripsi dari database
|
||||||
// 1. Cari user di database kampus lu berdasarkan email
|
private final PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||||
User user = userRepository.findByEmail(request.getEmail())
|
|
||||||
.orElseThrow(() -> new RuntimeException("Email tidak ditemukan!"));
|
|
||||||
|
|
||||||
// 2. Cocokin password yang diketik sama password yang di-hash di database
|
public Map<String, String> login(AuthRequest request) {
|
||||||
|
// 1. Cari user di database
|
||||||
|
User user = userRepository.findByEmail(request.getEmail())
|
||||||
|
.orElseThrow(() -> new RuntimeException("Email tidak terdaftar"));
|
||||||
|
|
||||||
|
// 2. Cocokin password (yang diketik VS yang dienkripsi di database)
|
||||||
if (!passwordEncoder.matches(request.getPassword(), user.getPassword())) {
|
if (!passwordEncoder.matches(request.getPassword(), user.getPassword())) {
|
||||||
throw new RuntimeException("Password salah!");
|
throw new RuntimeException("Password salah");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Kalau email dan password bener, suruh JwtUtil cetak Token
|
// 3. Kalau bener, bikin Token
|
||||||
|
// Asumsi JwtUtil lu nerima parameter (email, role). Sesuaikan kalau beda!
|
||||||
String token = jwtUtil.generateToken(user.getEmail(), user.getRole());
|
String token = jwtUtil.generateToken(user.getEmail(), user.getRole());
|
||||||
|
|
||||||
// 4. Bungkus token dan rolenya buat dikirim balik ke Flutter
|
// 4. Balikin ke Controller dalam bentuk Map
|
||||||
return new AuthResponse(token, user.getRole());
|
Map<String, String> data = new HashMap<>();
|
||||||
|
data.put("token", token);
|
||||||
|
data.put("role", user.getRole());
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,3 +43,6 @@
|
|||||||
</intent>
|
</intent>
|
||||||
</queries>
|
</queries>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
<uses-feature android:name="android.hardware.camera" />
|
||||||
@ -1,21 +1,40 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:animate_do/animate_do.dart';
|
||||||
|
import '../../../core/secure_storage.dart';
|
||||||
|
import '../../auth/presentation/login_screen.dart';
|
||||||
|
|
||||||
class GuardianDashboardScreen extends StatelessWidget {
|
class GuardianDashboardScreen extends StatelessWidget {
|
||||||
const GuardianDashboardScreen({super.key});
|
const GuardianDashboardScreen({super.key});
|
||||||
|
|
||||||
|
Future<void> _handleLogout(BuildContext context) async {
|
||||||
|
await SecureStorage().deleteToken();
|
||||||
|
if (context.mounted) {
|
||||||
|
Navigator.pushAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => const LoginScreen()),
|
||||||
|
(route) => false, // Bersihin tumpukan screen
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: const Color(0xFFF8FAFC), // Warna background abu-abu sangat muda (modern)
|
backgroundColor: const Color(0xFFF8FAFC),
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.transparent,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
title: Text('Guardian Command', style: GoogleFonts.outfit(color: const Color(0xFF0F172A), fontWeight: FontWeight.bold)),
|
title: FadeInDown(
|
||||||
|
child: Text('Guardian Command', style: GoogleFonts.outfit(color: const Color(0xFF0F172A), fontWeight: FontWeight.bold, fontSize: 24)),
|
||||||
|
),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
FadeInDown(
|
||||||
icon: const Icon(Icons.notifications_none_rounded, color: Color(0xFF0F172A)),
|
child: IconButton(
|
||||||
onPressed: () {},
|
icon: const Icon(Icons.logout_rounded, color: Color(0xFFDC2626)),
|
||||||
|
tooltip: 'Logout',
|
||||||
|
onPressed: () => _handleLogout(context),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -24,14 +43,16 @@ class GuardianDashboardScreen extends StatelessWidget {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
// 1. KARTU STATUS USER (Hero Card)
|
// 1. KARTU STATUS USER
|
||||||
Container(
|
FadeInUp(
|
||||||
|
duration: const Duration(milliseconds: 600),
|
||||||
|
child: Container(
|
||||||
padding: const EdgeInsets.all(24),
|
padding: const EdgeInsets.all(24),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: const LinearGradient(colors: [Color(0xFF2563EB), Color(0xFF1D4ED8)]),
|
gradient: const LinearGradient(colors: [Color(0xFF2563EB), Color(0xFF1D4ED8)]),
|
||||||
borderRadius: BorderRadius.circular(24),
|
borderRadius: BorderRadius.circular(24),
|
||||||
boxShadow: [
|
boxShadow: [
|
||||||
BoxShadow(color: const Color(0xFF2563EB).withOpacity(0.3), blurRadius: 20, offset: const Offset(0, 10))
|
BoxShadow(color: const Color(0xFF2563EB).withValues(alpha: 0.3), blurRadius: 20, offset: const Offset(0, 10))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
@ -51,13 +72,13 @@ class GuardianDashboardScreen extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text('User Pantauan', style: GoogleFonts.inter(color: Colors.blue[100], fontSize: 14)),
|
Text('User Pantauan', style: GoogleFonts.inter(color: Colors.blue[100], fontSize: 14)),
|
||||||
Text('Sedang Berjalan', style: GoogleFonts.outfit(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold)),
|
Text('Sistem Aktif', style: GoogleFonts.outfit(color: Colors.white, fontSize: 24, fontWeight: FontWeight.bold)),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.location_on, color: Colors.white70, size: 16),
|
const Icon(Icons.location_on, color: Colors.white70, size: 16),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text('Jl. Kenangan, SBY', style: GoogleFonts.inter(color: Colors.white70, fontSize: 12)),
|
Text('Melacak lokasi...', style: GoogleFonts.inter(color: Colors.white70, fontSize: 12)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -66,12 +87,18 @@ class GuardianDashboardScreen extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
|
|
||||||
// 2. QUICK ACTIONS
|
// 2. QUICK ACTIONS
|
||||||
Text('Aksi Cepat', style: GoogleFonts.outfit(fontSize: 18, fontWeight: FontWeight.bold, color: const Color(0xFF0F172A))),
|
FadeInUp(
|
||||||
|
delay: const Duration(milliseconds: 200),
|
||||||
|
child: Text('Aksi Cepat', style: GoogleFonts.outfit(fontSize: 18, fontWeight: FontWeight.bold, color: const Color(0xFF0F172A))),
|
||||||
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Row(
|
FadeInUp(
|
||||||
|
delay: const Duration(milliseconds: 300),
|
||||||
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
_buildQuickAction(Icons.videocam_outlined, 'Live View', const Color(0xFF10B981)),
|
_buildQuickAction(Icons.videocam_outlined, 'Live View', const Color(0xFF10B981)),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
@ -80,20 +107,29 @@ class GuardianDashboardScreen extends StatelessWidget {
|
|||||||
_buildQuickAction(Icons.settings_voice, 'Voice Conf', const Color(0xFF8B5CF6)),
|
_buildQuickAction(Icons.settings_voice, 'Voice Conf', const Color(0xFF8B5CF6)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
|
|
||||||
// 3. SETTINGAN DEVICE USER (Persiapan buat fitur shortcut lu)
|
// 3. SETTINGAN DEVICE USER
|
||||||
Text('Konfigurasi Perangkat', style: GoogleFonts.outfit(fontSize: 18, fontWeight: FontWeight.bold, color: const Color(0xFF0F172A))),
|
FadeInUp(
|
||||||
|
delay: const Duration(milliseconds: 400),
|
||||||
|
child: Text('Konfigurasi Perangkat', style: GoogleFonts.outfit(fontSize: 18, fontWeight: FontWeight.bold, color: const Color(0xFF0F172A))),
|
||||||
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
_buildSettingTile(Icons.gamepad_outlined, 'Hardware Shortcuts', 'Atur fungsi tombol volume hp user'),
|
FadeInUp(
|
||||||
_buildSettingTile(Icons.spatial_audio_outlined, 'Sensitivitas AI', 'Atur jarak deteksi rintangan'),
|
delay: const Duration(milliseconds: 500),
|
||||||
|
child: _buildSettingTile(Icons.gamepad_outlined, 'Hardware Shortcuts', 'Atur fungsi tombol volume hp user'),
|
||||||
|
),
|
||||||
|
FadeInUp(
|
||||||
|
delay: const Duration(milliseconds: 600),
|
||||||
|
child: _buildSettingTile(Icons.spatial_audio_outlined, 'Sensitivitas AI', 'Atur jarak deteksi rintangan'),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Widget bantuan buat Bikin Kotak Menu
|
|
||||||
Widget _buildQuickAction(IconData icon, String label, Color color) {
|
Widget _buildQuickAction(IconData icon, String label, Color color) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -101,8 +137,8 @@ class GuardianDashboardScreen extends StatelessWidget {
|
|||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
border: Border.all(color: Colors.grey.withOpacity(0.1)),
|
border: Border.all(color: Colors.grey.withValues(alpha: 0.1)),
|
||||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.02), blurRadius: 10)],
|
boxShadow: [BoxShadow(color: Colors.black.withValues(alpha: 0.02), blurRadius: 10, offset: const Offset(0, 4))],
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@ -115,14 +151,14 @@ class GuardianDashboardScreen extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Widget bantuan buat Bikin List Setting
|
|
||||||
Widget _buildSettingTile(IconData icon, String title, String subtitle) {
|
Widget _buildSettingTile(IconData icon, String title, String subtitle) {
|
||||||
return Container(
|
return Container(
|
||||||
margin: const EdgeInsets.only(bottom: 16),
|
margin: const EdgeInsets.only(bottom: 16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
border: Border.all(color: Colors.grey.withOpacity(0.1)),
|
border: Border.all(color: Colors.grey.withValues(alpha: 0.1)),
|
||||||
|
boxShadow: [BoxShadow(color: Colors.black.withValues(alpha: 0.02), blurRadius: 8, offset: const Offset(0, 2))],
|
||||||
),
|
),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
|
||||||
@ -134,7 +170,7 @@ class GuardianDashboardScreen extends StatelessWidget {
|
|||||||
title: Text(title, style: GoogleFonts.inter(fontWeight: FontWeight.w600, color: const Color(0xFF0F172A))),
|
title: Text(title, style: GoogleFonts.inter(fontWeight: FontWeight.w600, color: const Color(0xFF0F172A))),
|
||||||
subtitle: Text(subtitle, style: GoogleFonts.inter(fontSize: 13, color: const Color(0xFF64748B))),
|
subtitle: Text(subtitle, style: GoogleFonts.inter(fontSize: 13, color: const Color(0xFF64748B))),
|
||||||
trailing: const Icon(Icons.arrow_forward_ios, size: 16, color: Color(0xFFCBD5E1)),
|
trailing: const Icon(Icons.arrow_forward_ios, size: 16, color: Color(0xFFCBD5E1)),
|
||||||
onTap: () {}, // Nanti kita arahin ke halaman setting
|
onTap: () {},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,105 +1,169 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import 'package:camera/camera.dart';
|
||||||
|
import 'package:animate_do/animate_do.dart';
|
||||||
|
import '../../../core/secure_storage.dart';
|
||||||
|
import '../../auth/presentation/login_screen.dart';
|
||||||
|
import '../../../../main.dart'; // import global cameras
|
||||||
|
|
||||||
class UserDashboardScreen extends StatelessWidget {
|
class UserDashboardScreen extends StatefulWidget {
|
||||||
const UserDashboardScreen({super.key});
|
const UserDashboardScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<UserDashboardScreen> createState() => _UserDashboardScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UserDashboardScreenState extends State<UserDashboardScreen> with SingleTickerProviderStateMixin {
|
||||||
|
CameraController? _cameraController;
|
||||||
|
late AnimationController _pulseController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_initCamera();
|
||||||
|
|
||||||
|
// Setup animasi radar berdenyut
|
||||||
|
_pulseController = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: const Duration(seconds: 2),
|
||||||
|
)..repeat(reverse: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _initCamera() async {
|
||||||
|
if (cameras.isEmpty) return;
|
||||||
|
// Pakai kamera belakang (index 0)
|
||||||
|
_cameraController = CameraController(cameras[0], ResolutionPreset.high, enableAudio: false);
|
||||||
|
await _cameraController!.initialize();
|
||||||
|
if (mounted) setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleLogout() async {
|
||||||
|
await SecureStorage().deleteToken();
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.pushAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => const LoginScreen()),
|
||||||
|
(route) => false, // Hapus history back
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_cameraController?.dispose();
|
||||||
|
_pulseController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: Colors.black, // Background hitam buat area kamera
|
backgroundColor: Colors.black,
|
||||||
body: Stack(
|
body: Stack(
|
||||||
children: [
|
children: [
|
||||||
// 1. AREA KAMERA FULL SCREEN (Placeholder)
|
// 1. LIVE CAMERA FEED
|
||||||
|
SizedBox.expand(
|
||||||
|
child: _cameraController != null && _cameraController!.value.isInitialized
|
||||||
|
? CameraPreview(_cameraController!)
|
||||||
|
: const Center(child: CircularProgressIndicator(color: Colors.white)),
|
||||||
|
),
|
||||||
|
|
||||||
|
// 2. EFEK RADAR SCANNING (Animasi Pulse)
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
child: Container(
|
child: AnimatedBuilder(
|
||||||
color: Colors.grey[900],
|
animation: _pulseController,
|
||||||
child: const Center(
|
builder: (context, child) {
|
||||||
child: Column(
|
return Container(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
decoration: BoxDecoration(
|
||||||
children: [
|
gradient: RadialGradient(
|
||||||
Icon(Icons.camera_alt_outlined, color: Colors.white54, size: 64),
|
colors: [
|
||||||
SizedBox(height: 16),
|
Colors.transparent,
|
||||||
Text('Kamera Aktif\nMemindai Rintangan...',
|
const Color(0xFF10B981).withValues(alpha: 0.1 + (_pulseController.value * 0.15)),
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(color: Colors.white54, fontSize: 18),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
|
stops: const [0.5, 1.0],
|
||||||
|
radius: 1.5,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// 2. OVERLAY INFORMASI ATAS
|
// 3. OVERLAY STATUS & LOGOUT (Atas)
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 60,
|
top: 60,
|
||||||
left: 20,
|
left: 20,
|
||||||
right: 20,
|
right: 20,
|
||||||
child: Container(
|
child: FadeInDown(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.black.withOpacity(0.6),
|
|
||||||
borderRadius: BorderRadius.circular(16),
|
|
||||||
),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.black.withValues(alpha: 0.6),
|
||||||
|
borderRadius: BorderRadius.circular(30),
|
||||||
|
border: Border.all(color: const Color(0xFF10B981).withValues(alpha: 0.3)),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.spatial_audio_off, color: Colors.greenAccent, size: 24),
|
const Icon(Icons.spatial_audio_off, color: Color(0xFF10B981), size: 20),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text('Sistem Siap', style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.bold)),
|
Text('Memindai Area...', style: GoogleFonts.inter(color: Colors.white, fontWeight: FontWeight.bold)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const Icon(Icons.battery_4_bar, color: Colors.white),
|
),
|
||||||
|
|
||||||
|
// Tombol Logout
|
||||||
|
IconButton(
|
||||||
|
onPressed: _handleLogout,
|
||||||
|
icon: const Icon(Icons.power_settings_new, color: Colors.white, size: 28),
|
||||||
|
tooltip: 'Keluar',
|
||||||
|
style: IconButton.styleFrom(backgroundColor: Colors.redAccent.withValues(alpha: 0.8)),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// 3. OVERLAY TOMBOL BAWAH (Gede & Kontras)
|
// 4. OVERLAY TOMBOL BESAR (Bawah)
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 40,
|
bottom: 40,
|
||||||
left: 20,
|
left: 20,
|
||||||
right: 20,
|
right: 20,
|
||||||
|
child: FadeInUp(
|
||||||
|
delay: const Duration(milliseconds: 300),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
// Tombol Voice Command
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Semantics(
|
|
||||||
label: 'Tombol Perintah Suara',
|
|
||||||
hint: 'Tekan dua kali untuk memberikan perintah suara',
|
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: const Color(0xFF2563EB), // Biru terang
|
backgroundColor: const Color(0xFF2563EB).withValues(alpha: 0.9),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 24),
|
padding: const EdgeInsets.symmetric(vertical: 24),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
||||||
|
elevation: 10,
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.mic, size: 40, color: Colors.white),
|
child: const Icon(Icons.mic, size: 48, color: Colors.white),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
// Tombol Call Guardian
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Semantics(
|
|
||||||
label: 'Panggil Pendamping',
|
|
||||||
hint: 'Tekan dua kali untuk menelepon pendamping Anda',
|
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: const Color(0xFFDC2626), // Merah peringatan
|
backgroundColor: const Color(0xFFDC2626).withValues(alpha: 0.9),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 24),
|
padding: const EdgeInsets.symmetric(vertical: 24),
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
|
||||||
|
elevation: 10,
|
||||||
),
|
),
|
||||||
child: const Icon(Icons.phone_in_talk, size: 40, color: Colors.white),
|
child: const Icon(Icons.phone_in_talk, size: 48, color: Colors.white),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,8 +1,22 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'features/home/presentation/login_screen.dart';
|
import 'package:camera/camera.dart';
|
||||||
|
import 'features/auth/presentation/login_screen.dart';
|
||||||
|
|
||||||
|
// Variabel global buat nyimpen daftar kamera di HP
|
||||||
|
List<CameraDescription> cameras = [];
|
||||||
|
|
||||||
|
Future<void> main() async {
|
||||||
|
// Wajib dipanggil sebelum inisialisasi hardware
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
// Ambil daftar kamera yang ada di HP
|
||||||
|
try {
|
||||||
|
cameras = await availableCameras();
|
||||||
|
} catch (e) {
|
||||||
|
debugPrint('Error inisialisasi kamera: $e');
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
|
||||||
runApp(const WalkGuideApp());
|
runApp(const WalkGuideApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,14 @@
|
|||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
|
animate_do:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: animate_do
|
||||||
|
sha256: ddc9bde27df897088e02553f0aec44c614595de01fe357ffb257ecaf7d40c8fa
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "5.1.0"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -17,6 +25,46 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.2"
|
||||||
|
camera:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: camera
|
||||||
|
sha256: "034c38cb8014d29698dcae6d20276688a1bf74e6487dfeb274d70ea05d5f7777"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.12.0+1"
|
||||||
|
camera_android_camerax:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: camera_android_camerax
|
||||||
|
sha256: b5064cf25a2787d122d0bf12e77c7b1033a2b983d0730e3091f770ee376efde5
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.7.2"
|
||||||
|
camera_avfoundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: camera_avfoundation
|
||||||
|
sha256: "90e4cc3fde331581a3b2d35d83be41dbb7393af0ab857eb27b732174289cb96d"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.10.1"
|
||||||
|
camera_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: camera_platform_interface
|
||||||
|
sha256: "7ac852d77699acee79f0d438b793feee26721841e50973576419ff5c6d95e9b7"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.13.0"
|
||||||
|
camera_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: camera_web
|
||||||
|
sha256: "57f49a635c8bf249d07fb95eb693d7e4dda6796dedb3777f9127fb54847beba7"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.5+3"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -41,6 +89,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.19.1"
|
version: "1.19.1"
|
||||||
|
cross_file:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: cross_file
|
||||||
|
sha256: "28bb3ae56f117b5aec029d702a90f57d285cd975c3c5c281eaca38dbc47c5937"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.5+2"
|
||||||
crypto:
|
crypto:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -110,6 +166,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.0"
|
version: "5.0.0"
|
||||||
|
flutter_plugin_android_lifecycle:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_plugin_android_lifecycle
|
||||||
|
sha256: "38d1c268de9097ff59cf0e844ac38759fc78f76836d37edad06fa21e182055a0"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.34"
|
||||||
flutter_secure_storage:
|
flutter_secure_storage:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -357,6 +421,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.4"
|
version: "2.1.4"
|
||||||
|
stream_transform:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: stream_transform
|
||||||
|
sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.1"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -38,6 +38,8 @@ dependencies:
|
|||||||
flutter_secure_storage: ^10.0.0
|
flutter_secure_storage: ^10.0.0
|
||||||
google_fonts: ^8.0.2
|
google_fonts: ^8.0.2
|
||||||
dartz: ^0.10.1
|
dartz: ^0.10.1
|
||||||
|
camera: ^0.12.0+1
|
||||||
|
animate_do: ^5.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user