update controlScreen

This commit is contained in:
Muhammad Iqbal 2025-05-17 00:00:24 +07:00
parent c36077c716
commit 946799b30b
1 changed files with 73 additions and 23 deletions

View File

@ -18,9 +18,31 @@ class _ControlScreenState extends State<ControlScreen> {
} }
void triggerRepeller() { void triggerRepeller() {
// fungsi sementara, nanti bisa dihubungkan ke backend/ESP32 showDialog(
ScaffoldMessenger.of(context).showSnackBar( context: context,
const SnackBar(content: Text('Pengusir diaktifkan secara manual!')), builder: (context) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
title: const Row(
children: [
Icon(Icons.check_circle_outline, color: Colors.green),
SizedBox(width: 8),
Text('Berhasil'),
],
),
content: const Text(
'Pengusir hama berhasil diaktifkan secara manual.',
style: TextStyle(fontSize: 16),
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text(
'Tutup',
style: TextStyle(fontWeight: FontWeight.w600),
),
),
],
),
); );
} }
@ -28,35 +50,58 @@ class _ControlScreenState extends State<ControlScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: const CustomHeader( appBar: const CustomHeader(
deviceName: 'HamaGuard', // ini wajib diisi deviceName: 'HamaGuard',
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(20),
child: Column( child: Column(
children: [ children: [
const SizedBox(height: 20), const SizedBox(height: 10),
const Text( const Text(
'Mode Operasi', 'Mode Operasi',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
), ),
const SizedBox(height: 20), const SizedBox(height: 16),
Card( Card(
elevation: 4, elevation: 3,
child: ListTile( shape: RoundedRectangleBorder(
leading: Icon( borderRadius: BorderRadius.circular(12)),
isAutoMode ? Icons.autorenew : Icons.handyman, child: Padding(
color: isAutoMode ? Colors.blue : Colors.orange, padding: const EdgeInsets.all(16),
), child: Row(
title: Text( children: [
isAutoMode ? 'Otomatis' : 'Manual', Icon(
style: const TextStyle(fontSize: 18), isAutoMode ? Icons.autorenew : Icons.handyman,
), color: isAutoMode ? Colors.blue : Colors.orange,
subtitle: const Text('Mode saat ini'), size: 36,
trailing: ElevatedButton( ),
onPressed: toggleMode, const SizedBox(width: 16),
child: Text( Expanded(
isAutoMode ? 'Ganti ke Manual' : 'Ganti ke Otomatis', child: Column(
), crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
isAutoMode ? 'Mode Otomatis' : 'Mode Manual',
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w600),
),
const SizedBox(height: 4),
Text(
isAutoMode
? 'Alat akan bekerja secara otomatis sesuai sensor'
: 'Kamu dapat mengaktifkan alat secara manual',
style: const TextStyle(
fontSize: 14, color: Colors.grey),
),
],
),
),
Switch(
value: isAutoMode,
onChanged: (_) => toggleMode(),
activeColor: Colors.green,
),
],
), ),
), ),
), ),
@ -68,6 +113,11 @@ class _ControlScreenState extends State<ControlScreen> {
label: const Text('Aktifkan Pengusir Sekarang'), label: const Text('Aktifkan Pengusir Sekarang'),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: Colors.red, backgroundColor: Colors.red,
foregroundColor: Colors.white,
padding:
const EdgeInsets.symmetric(vertical: 14, horizontal: 24),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12)),
minimumSize: const Size.fromHeight(50), minimumSize: const Size.fromHeight(50),
), ),
), ),