...
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
/// A Calculator.
|
||||
class Calculator {
|
||||
/// Returns [value] plus 1.
|
||||
int addOne(int value) => value + 1;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
enum CognitiveArea {
|
||||
memory, // 기억력
|
||||
calculation, // 계산/논리력
|
||||
attention, // 주의집중력
|
||||
perception, // 시지각/공간지각력
|
||||
}
|
||||
|
||||
// 게임별 훈련 영역 매핑
|
||||
enum BrainGameType {
|
||||
sequence(CognitiveArea.memory, '순서 기억'), // feature_game_sequence
|
||||
cardFlip(CognitiveArea.memory, '카드 뒤집기'), // feature_game_cardflip
|
||||
mathQuiz(CognitiveArea.calculation, '암산 퀴즈'), // feature_game_mathquiz
|
||||
sudoku(CognitiveArea.calculation, '스도쿠'), // feature_game_sudoku
|
||||
colorMatch(CognitiveArea.attention, '색상 매칭'), // feature_game_colormatch
|
||||
findDiff(CognitiveArea.perception, '다른 그림 찾기'), // feature_game_finddiff
|
||||
spider(CognitiveArea.perception, '스파이더 카드'); // feature_game_spider
|
||||
|
||||
final CognitiveArea area;
|
||||
final String label;
|
||||
const BrainGameType(this.area, this.label);
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:feature_common/feature_common.dart';
|
||||
import 'package:service_api/service_api.dart';
|
||||
|
||||
// 각 게임 패키지 import
|
||||
import 'package:feature_game_sudoku/feature_game_sudoku.dart';
|
||||
import 'package:feature_game_mathquiz/feature_game_mathquiz.dart';
|
||||
// ... (나머지 게임들)
|
||||
|
||||
class BrainTrainingHome extends StatelessWidget {
|
||||
const BrainTrainingHome({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('두뇌 건강 지킴이')),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// 1. 상태 체크 카드
|
||||
_buildCheckupCard(context),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 2. 오늘의 추천 코스 (자동 믹스 게임)
|
||||
const Text('오늘의 추천 훈련', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 10),
|
||||
_buildDailyTrainingButton(context),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 3. 게임 아케이드 (자유 선택)
|
||||
const Text('전체 게임', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
|
||||
const SizedBox(height: 10),
|
||||
_buildGameGrid(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCheckupCard(BuildContext context) {
|
||||
return Card(
|
||||
color: Colors.indigo.shade50,
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.health_and_safety, size: 40, color: Colors.indigo),
|
||||
title: const Text('나의 두뇌 건강 체크'),
|
||||
subtitle: const Text('간단한 질문으로 현재 상태를 확인하고\n맞춤형 훈련을 추천받으세요.'),
|
||||
trailing: const Icon(Icons.arrow_forward_ios),
|
||||
onTap: () {
|
||||
// TODO: 체크리스트 화면으로 이동
|
||||
// Navigator.push(context, MaterialPageRoute(builder: (_) => AssessmentScreen()));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDailyTrainingButton(BuildContext context) {
|
||||
return ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.all(20),
|
||||
backgroundColor: Colors.orange,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
icon: const Icon(Icons.play_circle_fill, size: 32),
|
||||
label: const Text('오늘의 코스 시작하기\n(맞춤형 3종 세트)', textAlign: TextAlign.center, style: TextStyle(fontSize: 18)),
|
||||
onPressed: () {
|
||||
// TODO: Assessment 결과에 따라 선정된 게임들을 순차적으로 실행하는 로직
|
||||
// 예: Sequence -> Math -> ColorMatch 순서로 실행되는 별도 Flow 화면으로 이동
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGameGrid(BuildContext context) {
|
||||
// 모든 게임 리스트
|
||||
final games = [
|
||||
{'name': '스도쿠', 'icon': Icons.grid_3x3, 'dest': const SudokuLobbyScreen()},
|
||||
{'name': '계산 퀴즈', 'icon': Icons.calculate, 'dest': const MathQuizLobbyScreen()},
|
||||
{'name': '순서 기억', 'icon': Icons.onetwothree, 'dest': const SequenceLobbyScreen()},
|
||||
// ... 나머지 게임 추가
|
||||
];
|
||||
|
||||
return GridView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
childAspectRatio: 1.5,
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
),
|
||||
itemCount: games.length,
|
||||
itemBuilder: (context, index) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(context, MaterialPageRoute(builder: (_) => games[index]['dest'] as Widget));
|
||||
},
|
||||
child: Card(
|
||||
elevation: 2,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(games[index]['icon'] as IconData, size: 36, color: Colors.blueGrey),
|
||||
const SizedBox(height: 8),
|
||||
Text(games[index]['name'] as String, style: const TextStyle(fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/cognitive_type.dart';
|
||||
|
||||
class AssessmentService {
|
||||
// 간단한 점수 산출 (Yes = 1점, 부족함 표시)
|
||||
Map<CognitiveArea, int> calculateWeaknesses(Map<String, bool> answers) {
|
||||
Map<CognitiveArea, int> scoreMap = {
|
||||
CognitiveArea.memory: 0,
|
||||
CognitiveArea.calculation: 0,
|
||||
CognitiveArea.attention: 0,
|
||||
CognitiveArea.perception: 0,
|
||||
};
|
||||
|
||||
// 실제로는 질문 ID와 영역을 매핑해서 처리
|
||||
// 예시 로직:
|
||||
if (answers['q_memory_1'] == true) scoreMap[CognitiveArea.memory] = (scoreMap[CognitiveArea.memory] ?? 0) + 1;
|
||||
// ...
|
||||
return scoreMap;
|
||||
}
|
||||
|
||||
// 점수에 기반하여 오늘의 추천 게임 리스트 생성
|
||||
List<BrainGameType> generateDailyCourse(Map<CognitiveArea, int> weaknesses) {
|
||||
List<BrainGameType> course = [];
|
||||
|
||||
// 1. 가장 취약한 영역의 게임 1개 (난이도 하)
|
||||
CognitiveArea weakest = weaknesses.entries.reduce((a, b) => a.value > b.value ? a : b).key;
|
||||
course.add(BrainGameType.values.firstWhere((g) => g.area == weakest));
|
||||
|
||||
// 2. 랜덤하게 다른 영역 게임 2개 섞기 (균형 잡힌 훈련)
|
||||
List<BrainGameType> others = BrainGameType.values.where((g) => g.area != weakest).toList()..shuffle();
|
||||
course.addAll(others.take(2));
|
||||
|
||||
return course;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user