Skip to content

Commit

Permalink
update config page
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobaraujo7 committed Jan 16, 2024
1 parent b72df68 commit e5990d6
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 52 deletions.
55 changes: 36 additions & 19 deletions lib/app/(public)/config/config_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:yuno/injector.dart';
import '../../core/services/game_service.dart';
import '../../core/widgets/animated_title_app_bart.dart';
import 'widgets/about_widget.dart';
import 'widgets/feedback_widget.dart';
import 'widgets/platform_widget.dart';
import 'widgets/settings_widget.dart';

Expand All @@ -27,6 +28,7 @@ Route routeBuilder(BuildContext context, RouteSettings settings) {

class ConfigPage extends StatefulWidget {
final Animation<double> transitionAnimation;

const ConfigPage({super.key, required this.transitionAnimation});

@override
Expand Down Expand Up @@ -66,35 +68,50 @@ class _ConfigPageState extends State<ConfigPage> {
),
body: Row(
children: [
NavigationRail(
extended: true,
destinations: const [
NavigationRailDestination(
icon: Icon(Icons.gamepad),
label: Text('Gamepad'),
),
NavigationRailDestination(
icon: Icon(Icons.settings),
label: Text('Settings'),
Stack(
children: [
NavigationRail(
extended: true,
destinations: const [
NavigationRailDestination(
icon: Icon(Icons.gamepad),
label: Text('Platforms'),
),
NavigationRailDestination(
icon: Icon(Icons.settings),
label: Text('Preferences'),
),
NavigationRailDestination(
icon: Icon(Icons.chat_outlined),
label: Text('Feedback'),
),
NavigationRailDestination(
icon: Icon(Icons.info_outline),
label: Text('About'),
),
],
selectedIndex: selectedItemIndex,
onDestinationSelected: (index) {
setState(() {
selectedItemIndex = index;
});
},
),
NavigationRailDestination(
icon: Icon(Icons.info_outline),
label: Text('Settings'),
Positioned(
bottom: 10,
left: 18,
right: 0,
child: Text(buildNumberState.value),
),
],
selectedIndex: selectedItemIndex,
onDestinationSelected: (index) {
setState(() {
selectedItemIndex = index;
});
},
),
Expanded(
child: IndexedStack(
index: selectedItemIndex,
children: [
PlatformWidget(transitionAnimation: widget.transitionAnimation),
const SettingsWidget(),
const FeedbackWidget(),
const AboutWidget(),
],
),
Expand Down
10 changes: 10 additions & 0 deletions lib/app/(public)/config/widgets/feedback_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:flutter/widgets.dart';

class FeedbackWidget extends StatelessWidget {
const FeedbackWidget({super.key});

@override
Widget build(BuildContext context) {
return const Placeholder();
}
}
86 changes: 55 additions & 31 deletions lib/app/(public)/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:async';
import 'package:asp/asp.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:gap/gap.dart';
import 'package:routefly/routefly.dart';
import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:yuno/app/core/services/game_service.dart';
Expand Down Expand Up @@ -332,46 +333,69 @@ class _HomePageState extends State<HomePage> {
),
),
),
Expanded(
child: GridView.builder(
controller: scrollController,
addAutomaticKeepAlives: true,
padding: const EdgeInsets.only(bottom: 120),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
childAspectRatio: 3 / 5,
if (games.isEmpty)
Expanded(
child: Center(
child: Container(
height: 90,
width: 220,
alignment: Alignment.center,
color: colorScheme.surfaceVariant.withOpacity(0.5),
child: const Column(
mainAxisSize: MainAxisSize.min,
children: [
Text('No games found'),
Gap(3),
Icon(Icons.gamepad_outlined),
],
),
),
),
itemCount: games.length,
itemBuilder: (context, index) {
return AutoScrollTag(
index: index,
key: ValueKey(index),
controller: scrollController,
child: CardTile(
game: games[index],
colorSelect: colorScheme.primary,
transitionAnimation: widget.transitionAnimation,
selected: selectedItemIndex == index,
onTap: () {
if (index == selectedItemIndex) {
openGame();
} else {
handlerSelect(index);
}
},
),
if (games.isNotEmpty)
Expanded(
child: GridView.builder(
controller: scrollController,
addAutomaticKeepAlives: true,
padding: const EdgeInsets.only(bottom: 120),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
childAspectRatio: 3 / 5,
),
itemCount: games.length,
itemBuilder: (context, index) {
return AutoScrollTag(
index: index,
gamesLength: games.length,
),
);
},
key: ValueKey(index),
controller: scrollController,
child: CardTile(
game: games[index],
colorSelect: colorScheme.primary,
transitionAnimation: widget.transitionAnimation,
selected: selectedItemIndex == index,
onTap: () {
if (index == selectedItemIndex) {
openGame();
} else {
handlerSelect(index);
}
},
index: index,
gamesLength: games.length,
),
);
},
),
),
),
],
),
bottomNavigationBar: NavigationCommand(
colorScheme: colorScheme,
onApps: openApps,
onSettings: openSettings,
onFavorite: () {
debugPrint('onFavorite');
},
onPlay: openGame,
),
),
Expand Down
1 change: 0 additions & 1 deletion lib/app/data/mocks/mock_game_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class MockGameRepository implements GameRepository {
path: 'caminho_do_jogo',
category: {
defaultCategoryAllState,
defaultCategoryFavorite,
categorieState.firstWhere((e) => e.name == "Nintendo Switch"),
},
genre: 'Platform',
Expand Down
2 changes: 2 additions & 0 deletions lib/app/interactor/atoms/config_atom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ import 'package:asp/asp.dart';
import '../models/game_config.dart';

final gameConfigState = Atom<GameConfig>(GameConfig());

final buildNumberState = Atom<String>('');
5 changes: 5 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:wakelock_plus/wakelock_plus.dart';
import 'package:yuno/injector.dart';

import 'app/app_widget.dart';
import 'app/interactor/actions/config_action.dart';
import 'app/interactor/atoms/config_atom.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
Expand All @@ -21,5 +23,8 @@ void main() async {
await fetchConfig();
await GoogleFonts.pendingFonts();

final packageInfo = await PackageInfo.fromPlatform();
buildNumberState.value = 'build-${packageInfo.buildNumber}';

runApp(const AppWidget());
}
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ packages:
source: hosted
version: "0.1.7"
package_info_plus:
dependency: transitive
dependency: "direct main"
description:
name: package_info_plus
sha256: "88bc797f44a94814f2213db1c9bd5badebafdfb8290ca9f78d4b9ee2a3db4d79"
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ dependencies:
newton_particles: ^0.1.7
flutter_svg: ^2.0.9
collection: ^1.18.0
package_info_plus: ^5.0.1

dev_dependencies:
flutter_native_splash: ^2.3.9
Expand Down

0 comments on commit e5990d6

Please sign in to comment.