main_menu.dart 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import 'package:flutter/material.dart';
  2. import '../utils/colors.dart';
  3. import 'game_screen.dart';
  4. class MainMenu extends StatelessWidget {
  5. const MainMenu({super.key});
  6. @override
  7. Widget build(BuildContext context) {
  8. return Scaffold(
  9. backgroundColor: ZenColors.appBackground,
  10. body: SafeArea(
  11. child: Padding(
  12. padding: const EdgeInsets.all(20.0),
  13. child: Column(
  14. mainAxisAlignment: MainAxisAlignment.center,
  15. children: [
  16. // Game Title
  17. const Text(
  18. 'ZenTap',
  19. style: TextStyle(
  20. color: ZenColors.primaryText,
  21. fontSize: 48,
  22. fontWeight: FontWeight.bold,
  23. letterSpacing: 2.0,
  24. ),
  25. ),
  26. const SizedBox(height: 10),
  27. // Subtitle
  28. Text(
  29. 'A stress relief tapping game',
  30. style: TextStyle(
  31. color: ZenColors.secondaryText,
  32. fontSize: 18,
  33. fontStyle: FontStyle.italic,
  34. ),
  35. ),
  36. const SizedBox(height: 60),
  37. // Play Button
  38. _buildMenuButton(
  39. context,
  40. 'Play',
  41. 'Tap to earn Relaxation Points',
  42. Icons.play_arrow,
  43. () => _navigateToGame(context, false),
  44. ),
  45. const SizedBox(height: 20),
  46. // Zen Mode Button
  47. _buildMenuButton(
  48. context,
  49. 'Zen Mode',
  50. 'Pure relaxation, no score',
  51. Icons.self_improvement,
  52. () => _navigateToGame(context, true),
  53. ),
  54. const SizedBox(height: 40),
  55. // Settings hint
  56. Text(
  57. 'Tap anywhere to feel the calm',
  58. style: TextStyle(
  59. color: ZenColors.mutedText,
  60. fontSize: 14,
  61. ),
  62. ),
  63. ],
  64. ),
  65. ),
  66. ),
  67. );
  68. }
  69. Widget _buildMenuButton(
  70. BuildContext context,
  71. String title,
  72. String subtitle,
  73. IconData icon,
  74. VoidCallback onPressed,
  75. ) {
  76. return Container(
  77. width: double.infinity,
  78. margin: const EdgeInsets.symmetric(horizontal: 20),
  79. child: ElevatedButton(
  80. onPressed: onPressed,
  81. style: ElevatedButton.styleFrom(
  82. backgroundColor: ZenColors.buttonBackground,
  83. foregroundColor: ZenColors.buttonText,
  84. padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 30),
  85. shape: RoundedRectangleBorder(
  86. borderRadius: BorderRadius.circular(15),
  87. ),
  88. elevation: 8,
  89. ),
  90. child: Row(
  91. children: [
  92. Icon(
  93. icon,
  94. size: 32,
  95. color: ZenColors.buttonText,
  96. ),
  97. const SizedBox(width: 20),
  98. Expanded(
  99. child: Column(
  100. crossAxisAlignment: CrossAxisAlignment.start,
  101. children: [
  102. Text(
  103. title,
  104. style: const TextStyle(
  105. fontSize: 22,
  106. fontWeight: FontWeight.bold,
  107. color: ZenColors.buttonText,
  108. ),
  109. ),
  110. const SizedBox(height: 4),
  111. Text(
  112. subtitle,
  113. style: TextStyle(
  114. fontSize: 14,
  115. color: ZenColors.buttonText.withValues(alpha: 0.8),
  116. ),
  117. ),
  118. ],
  119. ),
  120. ),
  121. Icon(
  122. Icons.arrow_forward_ios,
  123. color: ZenColors.buttonText.withValues(alpha: 0.7),
  124. size: 20,
  125. ),
  126. ],
  127. ),
  128. ),
  129. );
  130. }
  131. void _navigateToGame(BuildContext context, bool isZenMode) {
  132. Navigator.of(context).push(
  133. MaterialPageRoute(
  134. builder: (context) => GameScreen(isZenMode: isZenMode),
  135. ),
  136. );
  137. }
  138. }