From 961d762f3557cab105d8b54e49020dff6cd18cd4 Mon Sep 17 00:00:00 2001 From: Simon Ding Date: Sun, 28 Jul 2024 16:43:59 +0800 Subject: [PATCH] feat: add text to empty screen --- db/db.go | 2 +- ui/lib/welcome_page.dart | 93 +++++++++++++++++++++------------------- 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/db/db.go b/db/db.go index 78ed934f..c5fa14b2 100644 --- a/db/db.go +++ b/db/db.go @@ -98,7 +98,7 @@ func (c *Client) generateDefaultLocalStorage() error { func (c *Client) GetSetting(key string) string { v, err := c.ent.Settings.Query().Where(settings.Key(key)).Only(context.TODO()) if err != nil { - log.Errorf("get setting by key: %s error: %v", key, err) + log.Warnf("get setting by key: %s error: %v", key, err) return "" } return v.Value diff --git a/ui/lib/welcome_page.dart b/ui/lib/welcome_page.dart index 9c2ca5cb..8fe99ec6 100644 --- a/ui/lib/welcome_page.dart +++ b/ui/lib/welcome_page.dart @@ -29,50 +29,57 @@ class WelcomePage extends ConsumerWidget { child: Wrap( spacing: 10, runSpacing: 20, - children: List.generate(value.length, (i) { - var item = value[i]; - return Card( - margin: const EdgeInsets.all(4), - clipBehavior: Clip.hardEdge, - child: InkWell( - //splashColor: Colors.blue.withAlpha(30), - onTap: () { - if (uri == routeMoivie) { - context.go(MovieDetailsPage.toRoute(item.id!)); - } else { - context.go(TvDetailsPage.toRoute(item.id!)); - } - }, - child: Column( - children: [ - SizedBox( - width: 140, - height: 210, - child: Image.network( - "${APIs.imagesUrl}/${item.id}/poster.jpg", - fit: BoxFit.fill, - headers: APIs.authHeaders, + children: value.isEmpty + ? [ + Container( + height: MediaQuery.of(context).size.height * 0.6, + alignment: Alignment.center, + child: const Text("啥都没有...", style: TextStyle(fontSize: 16),)) + ] + : List.generate(value.length, (i) { + var item = value[i]; + return Card( + margin: const EdgeInsets.all(4), + clipBehavior: Clip.hardEdge, + child: InkWell( + //splashColor: Colors.blue.withAlpha(30), + onTap: () { + if (uri == routeMoivie) { + context.go(MovieDetailsPage.toRoute(item.id!)); + } else { + context.go(TvDetailsPage.toRoute(item.id!)); + } + }, + child: Column( + children: [ + SizedBox( + width: 140, + height: 210, + child: Image.network( + "${APIs.imagesUrl}/${item.id}/poster.jpg", + fit: BoxFit.fill, + headers: APIs.authHeaders, + ), + ), + SizedBox( + width: 140, + child: LinearProgressIndicator( + value: 1, + color: item.status == "downloaded" + ? Colors.green + : Colors.blue, + )), + Text( + item.name!, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + height: 2.5), + ), + ], ), - ), - SizedBox( - width: 140, - child: LinearProgressIndicator( - value: 1, - color: item.status == "downloaded" - ? Colors.green - : Colors.blue, - )), - Text( - item.name!, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - height: 2.5), - ), - ], - ), - )); - }), + )); + }), ), ), _ => const MyProgressIndicator(),