You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
6.2 KiB

2 years ago
  1. // import 'package:cloud_firestore/cloud_firestore.dart';
  2. // import 'package:flutter/material.dart';
  3. // import 'package:flutter_riverpod/flutter_riverpod.dart';
  4. // import 'package:my_flutter_puzzle/application/states/player_matching_state.dart';
  5. // import 'package:my_flutter_puzzle/models/user_info.dart';
  6. // import 'package:my_flutter_puzzle/providers.dart';
  7. // import 'package:my_flutter_puzzle/res/palette.dart';
  8. // import 'package:my_flutter_puzzle/utils/database_client.dart';
  9. // import 'package:my_flutter_puzzle/screens/puzzle_screen.dart';
  10. // import 'package:my_flutter_puzzle/widgets/menu_widgets/menu_widgets.dart';
  11. // class MenuScreen extends ConsumerStatefulWidget {
  12. // const MenuScreen({
  13. // Key? key,
  14. // required this.userData,
  15. // }) : super(key: key);
  16. // final UserData userData;
  17. // @override
  18. // ConsumerState<ConsumerStatefulWidget> createState() => _MenuScreenState();
  19. // }
  20. // class _MenuScreenState extends ConsumerState<MenuScreen> {
  21. // final numberList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
  22. // late final UserData userData;
  23. // @override
  24. // void initState() {
  25. // super.initState();
  26. // userData = widget.userData;
  27. // numberList.shuffle();
  28. // }
  29. // @override
  30. // Widget build(BuildContext context) {
  31. // var screenSize = MediaQuery.of(context).size;
  32. // ref.listen(playerMatchingNotifierProvider, (previous, next) {
  33. // if (next is PlayerMatched) {
  34. // Navigator.of(context).push(
  35. // MaterialPageRoute(
  36. // builder: (context) => PuzzleScreen(
  37. // initialList: numberList,
  38. // id: next.id,
  39. // myInfo: userData,
  40. // ),
  41. // ),
  42. // );
  43. // }
  44. // });
  45. // return Scaffold(
  46. // backgroundColor: Colors.white,
  47. // body: Center(
  48. // child: SizedBox(
  49. // width: screenSize.width * 0.5,
  50. // child: Consumer(
  51. // builder: (context, ref, child) {
  52. // final state = ref.watch(playerMatchingNotifierProvider);
  53. // return state.when(
  54. // () => Column(
  55. // mainAxisAlignment: MainAxisAlignment.center,
  56. // children: [
  57. // const Text(
  58. // 'Game Mode',
  59. // style: TextStyle(
  60. // fontSize: 30,
  61. // // fontWeight: FontWeight.bold,
  62. // color: Palette.crimson,
  63. // ),
  64. // ),
  65. // const SizedBox(height: 24),
  66. // MultiplayerButton(
  67. // myInfo: userData,
  68. // list: numberList,
  69. // ),
  70. // const SizedBox(height: 16),
  71. // const SoloButton(),
  72. // const SizedBox(height: 30),
  73. // ],
  74. // ),
  75. // processing: () => Row(
  76. // mainAxisAlignment: MainAxisAlignment.center,
  77. // children: const [
  78. // CircularProgressIndicator(
  79. // valueColor:
  80. // AlwaysStoppedAnimation<Color>(Palette.violet),
  81. // ),
  82. // SizedBox(width: 16),
  83. // Text(
  84. // 'Finding player ...',
  85. // style: TextStyle(
  86. // fontSize: 24,
  87. // ),
  88. // ),
  89. // ],
  90. // ),
  91. // isMatched: (id) => Row(
  92. // mainAxisAlignment: MainAxisAlignment.center,
  93. // children: const [
  94. // Icon(
  95. // Icons.check_circle,
  96. // color: Palette.violet,
  97. // size: 50,
  98. // ),
  99. // SizedBox(width: 16),
  100. // Text(
  101. // 'Found player',
  102. // style: TextStyle(
  103. // fontSize: 24,
  104. // ),
  105. // ),
  106. // ],
  107. // ),
  108. // isQueued: () => PlayerQueuedWidget(
  109. // myInfo: userData,
  110. // ),
  111. // error: (message) => Text(
  112. // message.toString(),
  113. // style: const TextStyle(
  114. // fontSize: 24,
  115. // ),
  116. // ),
  117. // );
  118. // },
  119. // ),
  120. // ),
  121. // ));
  122. // }
  123. // }
  124. // class PlayerQueuedWidget extends ConsumerWidget {
  125. // PlayerQueuedWidget({
  126. // Key? key,
  127. // required this.myInfo,
  128. // }) : super(key: key);
  129. // final UserData myInfo;
  130. // final _databaseClient = DatabaseClient();
  131. // @override
  132. // Widget build(BuildContext context, WidgetRef ref) {
  133. // return StreamBuilder<DocumentSnapshot>(
  134. // stream: _databaseClient.isMatched(myInfo: myInfo),
  135. // builder: (context, snapshot) {
  136. // if (snapshot.hasData && snapshot.data!.data() != null) {
  137. // final queuedUserData =
  138. // snapshot.data!.data() as Map<String, dynamic>;
  139. // bool isMatched = queuedUserData['ismatched'];
  140. // if (isMatched) {
  141. // WidgetsBinding.instance?.addPostFrameCallback((_) {
  142. // ref
  143. // .read(playerMatchingNotifierProvider.notifier)
  144. // .foundUser(myInfo: myInfo);
  145. // });
  146. // }
  147. // }
  148. // return Row(
  149. // mainAxisAlignment: MainAxisAlignment.center,
  150. // children: const [
  151. // CircularProgressIndicator(
  152. // valueColor: AlwaysStoppedAnimation<Color>(Palette.violet),
  153. // ),
  154. // SizedBox(width: 16),
  155. // Text(
  156. // 'Your are in queue ...',
  157. // style: TextStyle(
  158. // fontSize: 24,
  159. // ),
  160. // ),
  161. // ],
  162. // );
  163. // });
  164. // }
  165. // }