Skip to content
This repository has been archived by the owner on Jul 20, 2021. It is now read-only.

Commit

Permalink
start develop search & change game card in search
Browse files Browse the repository at this point in the history
  • Loading branch information
IceArrow256 committed Feb 9, 2021
1 parent e4d7a21 commit 2add9a9
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 3 additions & 1 deletion lib/pages/game/game_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ class _GameViewState extends State<GameView> {
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(
Expand Down
26 changes: 18 additions & 8 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class Home extends StatefulWidget {

class _HomeState extends State<Home> {
int _currentIndex;
bool _isSearching = false;
bool _isSearching;
String _search;

final tabsTitle = [
'Game List',
Expand All @@ -30,7 +31,7 @@ class _HomeState extends State<Home> {
Widget build(BuildContext context) {
final tabs = [
HomeTab(),
SearchTab(),
SearchTab(search: _search),
GamesTab(),
SettingsTab(
isDarkTheme: widget.isDarkTheme,
Expand All @@ -39,16 +40,23 @@ class _HomeState extends State<Home> {
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;
Expand Down Expand Up @@ -96,6 +104,8 @@ class _HomeState extends State<Home> {
@override
void initState() {
_currentIndex = 0;
_isSearching = false;
_search = '';
super.initState();
}
}
50 changes: 39 additions & 11 deletions lib/pages/tabs/search_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -17,6 +19,7 @@ class _SearchTabState extends State<SearchTab> {

@override
Widget build(BuildContext context) {
print(widget.search);
return FutureBuilder<List<Game>>(
future: _getAllGame(),
builder: (context, snapshot) {
Expand All @@ -28,21 +31,46 @@ class _SearchTabState extends State<SearchTab> {
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),
),
],
),
),
)
],
),
),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2add9a9

Please sign in to comment.