Skip to content

Commit

Permalink
Added label no items found
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobaraujo7 committed Jan 22, 2024
1 parent 6db6104 commit 251504f
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 77 deletions.
132 changes: 71 additions & 61 deletions lib/app/(public)/config/widgets/platform_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:yuno/app/interactor/atoms/platform_atom.dart';

import '../../../../routes.dart';
import '../../../core/widgets/animated_sync_button.dart';
import '../../../core/widgets/no_items_widget.dart';
import '../../../interactor/actions/platform_action.dart';

class PlatformWidget extends StatefulWidget {
Expand Down Expand Up @@ -42,69 +43,78 @@ class _PlatformWidgetState extends State<PlatformWidget> {
final platforms = platformsState.value;

return Scaffold(
body: ListView.builder(
padding: const EdgeInsets.only(bottom: 100),
itemCount: platforms.length,
itemBuilder: (_, index) {
final platform = platforms[index];
var playerName = '';

if (platform.category.id == 'android') {
playerName = 'Android';
} else {
playerName = platform.player?.app.package ?? 'No player';
}
return ListTile(
leading: CircleAvatar(
child: SvgPicture(
getLoader(platform.category.image),
width: 24,
),
),
title: Text(platform.category.name),
subtitle: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.play_arrow_outlined,
size: 12,
),
Text(
playerName,
maxLines: 1,
),
],
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
AnimatedSyncButton(
isSyncing: platformSyncState.value.contains(platform.id),
onPressed: () async {
if (checkPlatformSyncing()) {
return;
}
await syncPlatform(platform);
},
),
IconButton(
icon: const Icon(Icons.edit),
onPressed: () async {
if (checkPlatformSyncing()) {
return;
}
Routefly.push(
routePaths.config.editPlatform,
arguments: platform,
);
},
body: platforms.isEmpty
? const Material(
child: Center(
child: NoItemWidget(
title: 'No platforms found',
),
],
),
)
: ListView.builder(
padding: const EdgeInsets.only(bottom: 100),
itemCount: platforms.length,
itemBuilder: (_, index) {
final platform = platforms[index];
var playerName = '';

if (platform.category.id == 'android') {
playerName = 'Android';
} else {
playerName = platform.player?.app.package ?? 'No player';
}
return ListTile(
leading: CircleAvatar(
child: SvgPicture(
getLoader(platform.category.image),
width: 24,
),
),
title: Text(platform.category.name),
subtitle: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.play_arrow_outlined,
size: 12,
),
Text(
playerName,
maxLines: 1,
),
],
),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
AnimatedSyncButton(
isSyncing:
platformSyncState.value.contains(platform.id),
onPressed: () async {
if (checkPlatformSyncing()) {
return;
}
await syncPlatform(platform);
},
),
IconButton(
icon: const Icon(Icons.edit),
onPressed: () async {
if (checkPlatformSyncing()) {
return;
}
Routefly.push(
routePaths.config.editPlatform,
arguments: platform,
);
},
),
],
),
onTap: () async {},
);
},
),
onTap: () async {},
);
},
),
floatingActionButton: AnimatedFloatingActionButton(
onPressed: () async {
if (checkPlatformSyncing()) {
Expand Down
22 changes: 6 additions & 16 deletions lib/app/(public)/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import '../core/widgets/animated_title_app_bart.dart';
import '../core/widgets/background/background.dart';
import '../core/widgets/card_tile/card_tile.dart';
import '../core/widgets/command_bar.dart';
import '../core/widgets/no_items_widget.dart';
import '../interactor/actions/game_action.dart';
import '../interactor/actions/platform_action.dart';
import '../interactor/atoms/gamepad_atom.dart';
Expand Down Expand Up @@ -100,7 +101,7 @@ class _HomePageState extends State<HomePage> {
: selectedItemIndex);
case GamepadButton.dpadLeft || GamepadButton.leftStickLeft:
handlerSelect(
selectedItemIndex > 0 ? selectedItemIndex - 1 : selectedItemIndex);
selectedItemIndex > 0 ? selectedItemIndex - 1 : selectedItemIndex);
case GamepadButton.dpadRight || GamepadButton.leftStickRight:
handlerSelect((selectedItemIndex + 1) % games.length);
case GamepadButton.LB:
Expand Down Expand Up @@ -148,7 +149,7 @@ class _HomePageState extends State<HomePage> {
}

void favorite() {
if(selectedItemIndex == -1){
if (selectedItemIndex == -1) {
return;
}

Expand Down Expand Up @@ -557,21 +558,10 @@ class _HomePageState extends State<HomePage> {
),
),
if (games.isEmpty)
Expanded(
const 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),
],
),
child: NoItemWidget(
title: 'No games found',
),
),
),
Expand Down
27 changes: 27 additions & 0 deletions lib/app/core/widgets/no_items_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';

class NoItemWidget extends StatelessWidget {
final String title;

const NoItemWidget({super.key, required this.title});

@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return Container(
height: 90,
width: 220,
alignment: Alignment.center,
color: colorScheme.surfaceVariant.withOpacity(0.5),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(title),
const Gap(3),
const Icon(Icons.gamepad_outlined),
],
),
);
}
}

0 comments on commit 251504f

Please sign in to comment.