]> git.cworth.org Git - lmno.games/commitdiff
Merge branch 'player-list'
authorKevin Worth <kworth082@gmail.com>
Tue, 12 May 2020 11:35:21 +0000 (07:35 -0400)
committerCarl Worth <cworth@cworth.org>
Sat, 23 May 2020 13:49:00 +0000 (06:49 -0700)
README.md
flutterempires/lib/main.dart
homepage-screenshot-1.png [new file with mode: 0644]
homepage-screenshot.png

index 178f7b327c3e7619d809974d2e0e84ad1fb5c173..5cdc24085cb6c4a9853df73246c11df7e750ce9a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1 +1,2 @@
-![alt text](/homepage-screenshot.png "Web App Screenshot")
\ No newline at end of file
+![alt text](/homepage-screenshot.png "Web App Screenshot")
+![alt text](/homepage-screenshot-1.png "Refreshed List Screenshot")
\ No newline at end of file
index 5a7981b19a1c0a76d6ea823c610ef894222658ef..64d8bf057591cad6e02f85b9c21844bef19e0eb3 100644 (file)
@@ -64,6 +64,7 @@ class _MyHomePageState extends State<MyHomePage> {
   void onPressPlusButton() {
     setState(() {
       // Probably use this to POST player name and character
+      allPlayers = Player.fetchAllPlayers();
     });
   }
 
@@ -109,31 +110,29 @@ class _MyHomePageState extends State<MyHomePage> {
                 ),
               ),
               Spacer(flex: 1),
-              FutureBuilder<Player>(
-                future: futurePlayer,
-                builder: (context, snapshot) {
-                  if (snapshot.hasData) {
-                    return Text(snapshot.data.name);
-                  } else if (snapshot.hasError) {
-                    return Text("${snapshot.error}");
-                  }
-                  return CircularProgressIndicator();
-                },
-              ),
-              Spacer(flex: 1),
-              FutureBuilder<List<Player>>(
-                future: allPlayers,
-                builder: (context, snapshot) {
-                  if (snapshot.hasData) {
-                    return Text(snapshot.data.length.toString());
-                  } else if (snapshot.hasError) {
-                    return Text("${snapshot.error}");
-                  }
-                  // By default, show a loading spinner.
-                  return CircularProgressIndicator();
-                },
-              ),
-              Spacer(flex: 10),
+              Expanded(
+                flex: 20,
+                child: FutureBuilder<List<Player>>(
+                    future: allPlayers,
+                    builder: (context, snapshot) {
+                      if (snapshot.hasData) {
+                        if (snapshot.data.length == 0) {
+                          return Text('No players yet');
+                        } else {
+                          return ListView.builder(
+                              itemCount: snapshot.data.length,
+                              itemBuilder: (context, index) {
+                                return ListTile(
+                                    title: Text(
+                                        snapshot.data[index].name.toString()));
+                              });
+                        }
+                      } else if (snapshot.hasError) {
+                        return Text("${snapshot.error}");
+                      }
+                      return CircularProgressIndicator();
+                    }),
+              )
             ],
           ),
         ),
diff --git a/homepage-screenshot-1.png b/homepage-screenshot-1.png
new file mode 100644 (file)
index 0000000..b5c2293
Binary files /dev/null and b/homepage-screenshot-1.png differ
index cf546fa8ef2ba934bd391335fea3969b251dc47f..7cf8f023d5f6308c5222f59c6d63386b8b86e99c 100644 (file)
Binary files a/homepage-screenshot.png and b/homepage-screenshot.png differ