Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class QRView extends StatefulWidget {
- const QRView({this.num, this.user, this.data});
- final int num;
- final DocumentSnapshot data;
- final FirebaseUser user;
- @override
- _QRViewState createState() => _QRViewState();
- }
- class _QRViewState extends State<QRView> {
- @override
- void initState() {
- // TODO: implement initState
- setState(() {});
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return Hero(
- tag: "card${widget.num}",
- child: SafeArea(
- child: Scaffold(
- resizeToAvoidBottomPadding: false,
- backgroundColor: Colors.teal,
- floatingActionButton: FloatingActionButton.extended(
- backgroundColor: Colors.white.withOpacity(0.8),
- foregroundColor: Colors.teal,
- onPressed: () {
- return showDialog(
- context: context,
- builder: (BuildContext context) {
- return CrearView(widget.data);
- });
- },
- icon: Icon(Icons.add),
- label: Text("Nuevo QR"),
- ),
- appBar: AppBar(
- backgroundColor: Colors.white.withOpacity(0.8),
- centerTitle: true,
- title: Text(
- "Entrada QR",
- style: TextStyle(color: Colors.teal, fontFamily: "Mono"),
- )),
- body: SafeArea(
- child: StreamBuilder(
- stream: Firestore.instance
- .collection("CondosDB")
- .document(widget.data.documentID)
- .collection("QR")
- .orderBy("fecha", descending: true)
- .snapshots(),
- builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
- if (snapshot.hasError) return new Text('${snapshot.error}');
- switch (snapshot.connectionState) {
- case ConnectionState.waiting:
- return Text("retorno waiting");
- default:
- var qrs = snapshot.data.documents;
- if (qrs.isEmpty) {
- return Container(
- child: Center(
- child: Text(
- "Para añadir tu primer código QR, presiona el botón +",
- style: TextStyle(
- color: Colors.white.withOpacity(0.8),
- fontSize: 30.0,
- ),
- textAlign: TextAlign.center,
- ),
- ),
- );
- } else {
- return ListView.builder(
- reverse: false,
- itemCount: qrs.length,
- shrinkWrap: true,
- scrollDirection: Axis.vertical,
- itemBuilder: (BuildContext context, int index) {
- var qr = qrs[index];
- return Container(
- color: Colors.white.withOpacity(0.3),
- child: ListTile(
- title: Text(qr["titulo"]),
- subtitle: Text(qr.documentID),
- ),
- );
- });
- }
- }
- },
- ),
- ),
- )));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement