|
|
@ -41,8 +41,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Widget _buildList(BuildContext context, List<DocumentSnapshot> snapshot) {
|
|
|
|
Widget _buildList(BuildContext context, List<DocumentSnapshot> snapshot) {
|
|
|
|
return ListView(
|
|
|
|
return GridView.count(
|
|
|
|
padding: const EdgeInsets.only(top: 20.0),
|
|
|
|
primary: false,
|
|
|
|
|
|
|
|
padding: const EdgeInsets.all(60),
|
|
|
|
|
|
|
|
crossAxisSpacing: 1.0,
|
|
|
|
|
|
|
|
crossAxisCount: 2,
|
|
|
|
children: snapshot.map((data) => _buildListItem(context, data)).toList(),
|
|
|
|
children: snapshot.map((data) => _buildListItem(context, data)).toList(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -50,27 +53,22 @@ class _MyHomePageState extends State<MyHomePage> {
|
|
|
|
Widget _buildListItem(BuildContext context, DocumentSnapshot data) {
|
|
|
|
Widget _buildListItem(BuildContext context, DocumentSnapshot data) {
|
|
|
|
final record = Record.fromSnapshot(data);
|
|
|
|
final record = Record.fromSnapshot(data);
|
|
|
|
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
return Card(
|
|
|
|
key: ValueKey(record.stall),
|
|
|
|
key: ValueKey(record.stall),
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
|
|
|
color: Colors.blue,
|
|
|
|
child: Container(
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
child: Center(
|
|
|
|
border: Border.all(color: Colors.blue),
|
|
|
|
child: Column(
|
|
|
|
borderRadius: BorderRadius.circular(5.0),
|
|
|
|
children: [
|
|
|
|
),
|
|
|
|
ListTile(
|
|
|
|
child: ListTile(
|
|
|
|
title: Text("Stall " + record.stall.toString(),
|
|
|
|
title: Text("Stall #" + record.stall.toString()),
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w500)),
|
|
|
|
trailing: Text("Open: " + record.open.toString()),
|
|
|
|
subtitle: Text(record.open.toString()),
|
|
|
|
|
|
|
|
|
|
|
|
// onTap: () => Firestore.instance.runTransaction((transaction) async {
|
|
|
|
|
|
|
|
// final freshSnapshot = await transaction.get(record.reference);
|
|
|
|
|
|
|
|
// final fresh = Record.fromSnapshot(freshSnapshot);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// await transaction
|
|
|
|
|
|
|
|
// .update(record.reference, {'votes': fresh.votes + 1});
|
|
|
|
|
|
|
|
// }),
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
],),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|