mhunt_launcher/lib/Widgets/Home/Library.dart
2024-10-28 17:34:48 +05:30

98 lines
2.7 KiB
Dart

import 'package:flutter/material.dart';
import '../../Backend/Backend.dart';
import '../CustomWidgets.dart';
String hoveringGameCard = "";
Widget Library({
required int selectedSidebarIndex,
required Function(int) onGameChanged,
required Function onUpdate,
}) {
return Center(
child: Wrap(
spacing: 20,
children: List.generate(Backend.Games.length, (index) {
GameData gameData = Backend.Games[index];
return LibGameCard(
gameData: gameData,
selectedSidebarIndex: selectedSidebarIndex,
onUpdate: onUpdate,
onGameChanged: onGameChanged
);
}),
),
);
}
Widget LibGameCard({
required GameData gameData,
required int selectedSidebarIndex,
required Function(int) onGameChanged,
required Function onUpdate,
}) {
return InkWell(
onTap: () {
selectedSidebarIndex = 1;
onGameChanged(gameData.id);
},
onHover: (val) {
if (val) {
hoveringGameCard = gameData.name;
} else if (hoveringGameCard == gameData.name) {
hoveringGameCard = "";
}
onUpdate();
},
child: AnimatedContainer(
duration: const Duration(milliseconds: 500),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.black,
image: DecorationImage(
image: AssetImage(gameData.imagePath), fit: BoxFit.fill)),
height: 200,
width: 300,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
hoveringGameCard != gameData.name
? Container()
: Expanded(
child: GlassContainer(
child: Center(
child: Text(
gameData.description,
textAlign: TextAlign.center,
),
),
opacity: 0.5,
color: Colors.black)),
GlassContainer(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: true? Container():Row(
children: [
Text(gameData.name),
gameData.isAvailable
? GlassButton(
onTap: () {},
child: Text("Install"),
width: 100,
color: Colors.blue,
opacity: 0.8)
: Text("Coming soon")
],
mainAxisAlignment: MainAxisAlignment.spaceBetween,
),
),
opacity: 0.9,
color: Colors.black),
],
),
),
);
}