From 2add9a9f9ea5d7194f19f73866ad4de5155ec582 Mon Sep 17 00:00:00 2001 From: IceArrow256 Date: Tue, 9 Feb 2021 19:21:34 +0200 Subject: [PATCH] start develop search & change game card in search --- CHANGELOG.md | 4 +++ lib/pages/game/game_view.dart | 4 ++- lib/pages/home.dart | 26 ++++++++++++------ lib/pages/tabs/search_tab.dart | 50 ++++++++++++++++++++++++++-------- pubspec.yaml | 2 +- 5 files changed, 65 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16d86fd..b3ca4c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,14 @@ ## [0.7.0] - 2020-02-09 ### Added - New dark and light theme. +- Start develop searching function. ### Fixed - Status icon color for light theme. +### Changed +- New card for games in search tab. + ## [0.6.0] - 2020-02-08 ### Added - Float action button for search tab and game view page. diff --git a/lib/pages/game/game_view.dart b/lib/pages/game/game_view.dart index 9ff2d6a..e7107c0 100644 --- a/lib/pages/game/game_view.dart +++ b/lib/pages/game/game_view.dart @@ -49,10 +49,12 @@ class _GameViewState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ ClipRRect( - borderRadius: BorderRadius.circular(4), + borderRadius: BorderRadius.circular(2.0), child: Image.network( game.coverUrl, width: 128, + height: 171, + fit: BoxFit.fill, ), ), Flexible( diff --git a/lib/pages/home.dart b/lib/pages/home.dart index daecfd5..07316f2 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -17,7 +17,8 @@ class Home extends StatefulWidget { class _HomeState extends State { int _currentIndex; - bool _isSearching = false; + bool _isSearching; + String _search; final tabsTitle = [ 'Game List', @@ -30,7 +31,7 @@ class _HomeState extends State { Widget build(BuildContext context) { final tabs = [ HomeTab(), - SearchTab(), + SearchTab(search: _search), GamesTab(), SettingsTab( isDarkTheme: widget.isDarkTheme, @@ -39,16 +40,23 @@ class _HomeState extends State { return Scaffold( appBar: AppBar( leading: Icon(Icons.gamepad), - title: !_isSearching - ? Text(tabsTitle[_currentIndex]) - : TextField( - decoration: InputDecoration(hintText: 'Search'), - ), + title: (_isSearching && _currentIndex == 1) + ? TextField( + autofocus: true, + onChanged: (value) { + setState(() { + _search = value; + }); + }, + decoration: InputDecoration( + hintText: 'Search', icon: Icon(Icons.search)), + ) + : Text(tabsTitle[_currentIndex]), actions: [ Visibility( visible: _currentIndex == 1, child: IconButton( - icon: Icon(Icons.search), + icon: Icon(!_isSearching ? Icons.search : Icons.clear), onPressed: () { setState(() { _isSearching = !_isSearching; @@ -96,6 +104,8 @@ class _HomeState extends State { @override void initState() { _currentIndex = 0; + _isSearching = false; + _search = ''; super.initState(); } } diff --git a/lib/pages/tabs/search_tab.dart b/lib/pages/tabs/search_tab.dart index c6adb3f..0a92607 100644 --- a/lib/pages/tabs/search_tab.dart +++ b/lib/pages/tabs/search_tab.dart @@ -4,8 +4,10 @@ import 'package:game_list/db/model/game.dart'; import 'package:game_list/pages/game/game_view.dart'; class SearchTab extends StatefulWidget { + final String search; + @override - const SearchTab({Key key}) : super(key: key); + const SearchTab({Key key, this.search}) : super(key: key); _SearchTabState createState() => _SearchTabState(); } @@ -17,6 +19,7 @@ class _SearchTabState extends State { @override Widget build(BuildContext context) { + print(widget.search); return FutureBuilder>( future: _getAllGame(), builder: (context, snapshot) { @@ -28,21 +31,46 @@ class _SearchTabState extends State { return SizedBox(height: 4); } else { return Card( - margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4), - child: ListTile( - title: Text(snapshot.data[index - 1].name), - subtitle: Text('Release: 2020\nAvg Rating: 9.99'), - leading: CircleAvatar( - backgroundImage: Image.network( - snapshot.data[index - 1].coverUrl, - ).image, - ), + margin: EdgeInsets.symmetric(horizontal: 8, vertical: 6), + child: InkWell( + borderRadius: BorderRadius.circular(6.0), onTap: () async { await Navigator.pushNamed(context, GameView.routeName, arguments: snapshot.data[index - 1]); setState(() {}); }, - isThreeLine: true, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(2.0), + child: Image.network( + snapshot.data[index - 1].coverUrl, + width: 100, + height: 133, + fit: BoxFit.fill, + ), + ), + Flexible( + child: Padding( + padding: const EdgeInsets.fromLTRB(8, 0, 0, 0), + child: Column( + children: [ + Text( + snapshot.data[index - 1].name, + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w600), + ), + ], + ), + ), + ) + ], + ), + ), ), ); } diff --git a/pubspec.yaml b/pubspec.yaml index 4452521..684971b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.6.0 +version: 0.7.0 environment: sdk: ">=2.7.0 <3.0.0"