This repository has been archived by the owner on Jul 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add game view page & make small refactoring
- Loading branch information
1 parent
2c4b772
commit 0458e39
Showing
11 changed files
with
184 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,56 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:game_list/pages/game/game_view.dart'; | ||
import 'package:game_list/pages/home.dart'; | ||
import 'package:game_list/themes/dark_theme.dart'; | ||
import 'package:game_list/themes/light_theme.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
void main() { | ||
runApp(Home()); | ||
runApp(App()); | ||
} | ||
|
||
class App extends StatefulWidget { | ||
@override | ||
_AppState createState() => _AppState(); | ||
} | ||
|
||
class _AppState extends State<App> { | ||
bool _isDarkTheme; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return MaterialApp( | ||
title: 'Game List', | ||
theme: _isDarkTheme ? darkTheme : lightTheme, | ||
debugShowCheckedModeBanner: false, | ||
routes: { | ||
Home.routeName: (context) => | ||
Home(isDarkTheme: _isDarkTheme, updateTheme: _updateTheme), | ||
GameView.routeName: (context) => GameView(), | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
void initState() { | ||
_isDarkTheme = false; | ||
_applyTheme(); | ||
super.initState(); | ||
} | ||
|
||
_applyTheme() async { | ||
var prefs = await SharedPreferences.getInstance(); | ||
var isDarkTheme = prefs.getBool('isDarkTheme') ?? _isDarkTheme; | ||
setState(() { | ||
_isDarkTheme = isDarkTheme; | ||
}); | ||
} | ||
|
||
_updateTheme(bool value) async { | ||
setState(() { | ||
_isDarkTheme = value; | ||
}); | ||
var prefs = await SharedPreferences.getInstance(); | ||
prefs.setBool('isDarkTheme', _isDarkTheme); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:game_list/db/model/game.dart'; | ||
|
||
class GameView extends StatelessWidget { | ||
static const routeName = '/gameView'; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final Game game = ModalRoute.of(context).settings.arguments; | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text( | ||
game.name, | ||
overflow: TextOverflow.fade, | ||
), | ||
), | ||
body: Padding( | ||
padding: const EdgeInsets.all(8.0), | ||
child: Row( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
ClipRRect( | ||
borderRadius: BorderRadius.circular(4), | ||
child: Image.network( | ||
game.coverUrl, | ||
width: 128, | ||
), | ||
), | ||
Flexible( | ||
child: Padding( | ||
padding: const EdgeInsets.fromLTRB(8, 0, 0, 0), | ||
child: Column( | ||
children: [ | ||
Text( | ||
game.name, | ||
style: | ||
TextStyle(fontSize: 20, fontWeight: FontWeight.w700), | ||
), | ||
], | ||
), | ||
), | ||
) | ||
], | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
lib/tabs/settings_tab.dart → lib/pages/tabs/settings_tab.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export 'package:game_list/pages/tabs/games_tab.dart'; | ||
export 'package:game_list/pages/tabs/home_tab.dart'; | ||
export 'package:game_list/pages/tabs/search_tab.dart'; | ||
export 'package:game_list/pages/tabs/settings_tab.dart'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters