92 lines
2.4 KiB
Dart
92 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ControlPage extends StatefulWidget {
|
|
@override
|
|
_ControlPageState createState() => _ControlPageState();
|
|
}
|
|
|
|
class _ControlPageState extends State<ControlPage> {
|
|
bool isLightOn = false; // Status lampu
|
|
bool isFanOn = false; // Status kipas
|
|
|
|
void toggleLight(bool value) {
|
|
setState(() {
|
|
isLightOn = value; // Perbarui status lampu
|
|
});
|
|
// Tambahkan logika untuk mengontrol lampu di sini
|
|
if (isLightOn) {
|
|
print("Lampu dinyalakan");
|
|
} else {
|
|
print("Lampu dimatikan");
|
|
}
|
|
}
|
|
|
|
void toggleFan(bool value) {
|
|
setState(() {
|
|
isFanOn = value; // Perbarui status kipas
|
|
});
|
|
// Tambahkan logika untuk mengontrol kipas di sini
|
|
if (isFanOn) {
|
|
print("Kipas dinyalakan");
|
|
} else {
|
|
print("Kipas dimatikan");
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Color(0xFFA82429), // Warna merah
|
|
leading: IconButton(
|
|
icon: Icon(Icons.arrow_back, color: Colors.white),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
title: Text(
|
|
'Kontrol Manual',
|
|
style: TextStyle(color: Colors.white),
|
|
),
|
|
),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
children: [
|
|
// Kontrol Lampu
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: Colors.black),
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: ListTile(
|
|
title: Text('Lampu'),
|
|
trailing: Switch(
|
|
value: isLightOn,
|
|
onChanged: toggleLight, // Panggil fungsi toggleLight
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 10),
|
|
|
|
// Kontrol Kipas
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
border: Border.all(color: Colors.black),
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: ListTile(
|
|
title: Text('Kipas'),
|
|
trailing: Switch(
|
|
value: isFanOn,
|
|
onChanged: toggleFan, // Panggil fungsi toggleFan
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|