update controlScreen
This commit is contained in:
parent
c36077c716
commit
946799b30b
|
@ -18,9 +18,31 @@ class _ControlScreenState extends State<ControlScreen> {
|
|||
}
|
||||
|
||||
void triggerRepeller() {
|
||||
// fungsi sementara, nanti bisa dihubungkan ke backend/ESP32
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Pengusir diaktifkan secara manual!')),
|
||||
showDialog(
|
||||
context: context,
|
||||
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) {
|
||||
return Scaffold(
|
||||
appBar: const CustomHeader(
|
||||
deviceName: 'HamaGuard', // ini wajib diisi
|
||||
deviceName: 'HamaGuard',
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
'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(
|
||||
elevation: 4,
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
isAutoMode ? Icons.autorenew : Icons.handyman,
|
||||
color: isAutoMode ? Colors.blue : Colors.orange,
|
||||
),
|
||||
title: Text(
|
||||
isAutoMode ? 'Otomatis' : 'Manual',
|
||||
style: const TextStyle(fontSize: 18),
|
||||
),
|
||||
subtitle: const Text('Mode saat ini'),
|
||||
trailing: ElevatedButton(
|
||||
onPressed: toggleMode,
|
||||
child: Text(
|
||||
isAutoMode ? 'Ganti ke Manual' : 'Ganti ke Otomatis',
|
||||
),
|
||||
elevation: 3,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
isAutoMode ? Icons.autorenew : Icons.handyman,
|
||||
color: isAutoMode ? Colors.blue : Colors.orange,
|
||||
size: 36,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
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'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
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),
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue