DB is looking a lot better now that she has all her data in order... time to try to dynamicly create view for diffrent lots
This commit is contained in:
parent
f5ded6fa18
commit
27e656c93b
@ -22,7 +22,7 @@ class MyHomePage extends StatefulWidget {
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
final db = Firestore.instance.collection('lots');
|
||||
static int lot = 26;
|
||||
static int lot = 25;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -31,11 +31,14 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
body:
|
||||
// _buildLot(context, db),
|
||||
_buildBody(
|
||||
context, db.document("Lot" + lot.toString()).collection('stalls')),
|
||||
context, db.document("Lot" + lot.toString()).collection('stalls'), 4),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: Text("Next Lot"),
|
||||
|
||||
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
lot++;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
);
|
||||
@ -64,41 +67,43 @@ Widget _buildListLotItem(BuildContext context, DocumentSnapshot data) {
|
||||
return Text(record.stall.toString());
|
||||
}
|
||||
|
||||
Widget _(BuildContext context, CollectionReference stallDB) {
|
||||
Widget _(BuildContext context, CollectionReference stallDB, int col) {
|
||||
return StreamBuilder<QuerySnapshot>(
|
||||
stream: stallDB.snapshots(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) return LinearProgressIndicator();
|
||||
|
||||
return _buildList(context, snapshot.data.documents);
|
||||
return _buildList(context, snapshot.data.documents, col);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(BuildContext context, CollectionReference stallDB) {
|
||||
Widget _buildBody(BuildContext context, CollectionReference stallDB, int col) {
|
||||
return StreamBuilder<QuerySnapshot>(
|
||||
stream: stallDB.snapshots(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) return LinearProgressIndicator();
|
||||
|
||||
return _buildList(context, snapshot.data.documents);
|
||||
return _buildList(context, snapshot.data.documents, col);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildList(BuildContext context, List<DocumentSnapshot> snapshot) {
|
||||
Widget _buildList(BuildContext context, List<DocumentSnapshot> snapshot,
|
||||
int col) {
|
||||
return GridView.count(
|
||||
primary: false,
|
||||
padding: const EdgeInsets.all(60),
|
||||
crossAxisSpacing: 1.0,
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 5.0,
|
||||
crossAxisCount: col,
|
||||
children: snapshot.map((data) => _buildListItem(context, data)).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildListItem(BuildContext context, DocumentSnapshot data) {
|
||||
final record = Record.fromSnapshot(data);
|
||||
return Card(
|
||||
return
|
||||
Card(
|
||||
key: ValueKey(record.stall),
|
||||
color: (record.open ? Colors.green[200] : Colors.red[100]),
|
||||
child: Center(
|
||||
|
Loading…
Reference in New Issue
Block a user