73 lines
2.7 KiB
Dart
73 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:firebase_database/firebase_database.dart';
|
|
import 'package:firebase_database/ui/firebase_animated_list.dart';
|
|
import 'package:flutter/services.dart'; // Import Clipboard Flutter
|
|
|
|
final databaseReference = FirebaseDatabase.instance.reference();
|
|
|
|
class DaftarEspScreen extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.blue[900],
|
|
appBar: AppBar(
|
|
backgroundColor: Colors.black,
|
|
),
|
|
body: Container(
|
|
padding: EdgeInsets.all(16.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"Daftar Serial ESP",
|
|
style: TextStyle(fontSize: 24, color: Colors.white, fontWeight: FontWeight.bold),
|
|
),
|
|
SizedBox(height: 20),
|
|
Expanded(
|
|
child: FirebaseAnimatedList(
|
|
query: databaseReference,
|
|
itemBuilder: (context, snapshot, index, animation) {
|
|
// Mendapatkan serial ESP dari snapshot
|
|
String serialESP = snapshot.child("espSerial").value.toString();
|
|
String noRumah = snapshot.child("nomorRumah").value.toString();
|
|
|
|
return Container(
|
|
margin: EdgeInsets.symmetric(vertical: 8.0),
|
|
padding: EdgeInsets.all(16.0),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(10.0),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.grey.withOpacity(0.3),
|
|
spreadRadius: 2,
|
|
blurRadius: 4,
|
|
offset: Offset(0, 2),
|
|
),
|
|
],
|
|
),
|
|
child: ListTile(
|
|
title: Text(
|
|
"Serial ESP: $serialESP",
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
),
|
|
subtitle: Text(
|
|
"No Rumah: $noRumah",
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
),
|
|
onTap: () {
|
|
Clipboard.setData(ClipboardData(text: serialESP)); // Menyalin teks ke clipboard
|
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Serial ESP copied to clipboard')));
|
|
},
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|