From be96f7f000f3545ada034d7c906a84ff300edc33 Mon Sep 17 00:00:00 2001 From: Simon Ding Date: Thu, 4 Jul 2024 15:43:47 +0800 Subject: [PATCH] ui improve --- ui/lib/main.dart | 4 ++-- ui/lib/search.dart | 54 ++++++++++++++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/ui/lib/main.dart b/ui/lib/main.dart index 9d147bd..0b8592e 100644 --- a/ui/lib/main.dart +++ b/ui/lib/main.dart @@ -88,13 +88,13 @@ class _MyHomePageState extends State { // the App.build method, and use it to set our appbar title. title: Text(widget.title), ), - body: Center( + body: const Center( // Center is a layout widget. It takes a single child and positions it // in the middle of the parent. child: Row( children: [ NavDrawer(), - const SearchPage(), + SearchPage(), ], )), floatingActionButton: FloatingActionButton( diff --git a/ui/lib/search.dart b/ui/lib/search.dart index 54e91c9..3345723 100644 --- a/ui/lib/search.dart +++ b/ui/lib/search.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:dio/dio.dart'; import 'package:ui/APIs.dart'; @@ -38,26 +37,43 @@ class _SearchPageState extends State { for (final item in list) { var m = item as Map; cards.add(Card( - margin: const EdgeInsets.all(10), - child: Row( - children: [ - Flexible( - child: SizedBox( - width: 150, - height: 200, - child: Image.network( - tmdbImgBaseUrl + m["poster_path"], - fit: BoxFit.contain, + margin: const EdgeInsets.all(4), + clipBehavior: Clip.hardEdge, + child: InkWell( + //splashColor: Colors.blue.withAlpha(30), + onTap: () { + //showDialog(context: context, builder: builder) + debugPrint('Card tapped.'); + }, + child: Row( + children: [ + Flexible( + child: SizedBox( + width: 150, + height: 200, + child: Image.network( + tmdbImgBaseUrl + m["poster_path"], + fit: BoxFit.contain, + ), + ), ), - ), + Flexible( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + m["name"], + style: const TextStyle( + fontSize: 14, fontWeight: FontWeight.bold), + ), + const Text(""), + Text(m["overview"]) + ], + ), + ) + ], ), - Flexible( - child: ListTile(title: Text(m["name"])), - ), - Flexible(child: Text(m["overview"])) - ], - ), - )); + ))); } return Expanded(