88 lines
3.4 KiB
Dart
88 lines
3.4 KiB
Dart
import 'package:firebase_database/firebase_database.dart';
|
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
final databaseReference = FirebaseDatabase.instance.reference();
|
|
|
|
class FamilyScreen extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.blue[900],
|
|
body: StreamBuilder(
|
|
stream: FirebaseFirestore.instance.collection('Penghuni').orderBy('norumah').snapshots(),
|
|
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return Center(
|
|
child: CircularProgressIndicator(),
|
|
);
|
|
}
|
|
if (snapshot.hasError) {
|
|
return Center(
|
|
child: Text('Error: ${snapshot.error}'),
|
|
);
|
|
}
|
|
return ListView(
|
|
padding: EdgeInsets.all(16.0),
|
|
children: (snapshot.data?.docs ?? []).map((DocumentSnapshot document) {
|
|
Map<String, dynamic> data = document.data() as Map<String, dynamic>;
|
|
return GestureDetector(
|
|
onTap: () {
|
|
Clipboard.setData(ClipboardData(text: data['idnomer']));
|
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('Nomor ID Berhasil Disalin')));
|
|
},
|
|
child: Container(
|
|
margin: EdgeInsets.only(bottom: 16.0),
|
|
padding: EdgeInsets.all(16.0),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(12.0),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.1),
|
|
spreadRadius: 1,
|
|
blurRadius: 5,
|
|
offset: Offset(0, 3),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'No Rumah: ${data['norumah']}',
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.black87),
|
|
),
|
|
SizedBox(height: 8.0),
|
|
Text(
|
|
'Nama Kepala Keluarga: ${data['namakepala']}',
|
|
style: TextStyle(fontSize: 16, color: Colors.black87),
|
|
),
|
|
SizedBox(height: 8.0),
|
|
Text(
|
|
'Nomor ID: ${data['idnomer']}',
|
|
style: TextStyle(fontSize: 16, color: Colors.black87),
|
|
),
|
|
SizedBox(height: 8.0),
|
|
Text(
|
|
'No Alat: ${data['noalat']}',
|
|
style: TextStyle(fontSize: 16, color: Colors.black87),
|
|
),
|
|
SizedBox(height: 8.0),
|
|
Text(
|
|
'No Telepon: ${data['nomortelepon']}',
|
|
style: TextStyle(fontSize: 16, color: Colors.black87),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|