...
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../model/game_info.dart'; // 위에서 만든 모델
|
||||
|
||||
class GameSelectionScreen extends StatelessWidget {
|
||||
final Function(String gameId) onGameSelected;
|
||||
|
||||
const GameSelectionScreen({super.key, required this.onGameSelected});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text("게임 선택")),
|
||||
body: GridView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2, // 한 줄에 2개
|
||||
childAspectRatio: 0.8,
|
||||
crossAxisSpacing: 16,
|
||||
mainAxisSpacing: 16,
|
||||
),
|
||||
itemCount: AppGames.games.length,
|
||||
itemBuilder: (context, index) {
|
||||
final game = AppGames.games[index];
|
||||
final bool isReady = !game.description.contains("[준비중]"); // 간단한 활성화 체크
|
||||
|
||||
return Opacity(
|
||||
opacity: isReady ? 1.0 : 0.5,
|
||||
child: GestureDetector(
|
||||
onTap: isReady ? () => onGameSelected(game.id) : null,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color: isReady ? Colors.blueAccent.withOpacity(0.3) : Colors.grey.withOpacity(0.3),
|
||||
width: 2
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(game.icon, size: 60, color: isReady ? Colors.blue : Colors.grey),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
game.name,
|
||||
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Text(
|
||||
game.description,
|
||||
style: const TextStyle(fontSize: 12, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user