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.

108 lines
3.0 KiB

2 years ago
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. import 'package:my_flutter_puzzle/models/user_info.dart';
  4. import 'package:my_flutter_puzzle/res/palette.dart';
  5. class MultiplayerButton extends ConsumerStatefulWidget {
  6. const MultiplayerButton({
  7. Key? key,
  8. required this.myInfo,
  9. required this.list,
  10. }) : super(key: key);
  11. final UserData myInfo;
  12. final List<int> list;
  13. @override
  14. ConsumerState<ConsumerStatefulWidget> createState() => _MultiplayerButtonState();
  15. }
  16. class _MultiplayerButtonState extends ConsumerState<MultiplayerButton> {
  17. late final List<int> numberList;
  18. @override
  19. void initState() {
  20. super.initState();
  21. numberList = widget.list;
  22. numberList.shuffle();
  23. }
  24. @override
  25. Widget build(BuildContext context) {
  26. return SizedBox(
  27. width: double.maxFinite,
  28. child: OutlinedButton(
  29. style: OutlinedButton.styleFrom(
  30. primary: Palette.violet,
  31. onSurface: Palette.violet,
  32. shape: RoundedRectangleBorder(
  33. borderRadius: BorderRadius.circular(50),
  34. ),
  35. side: const BorderSide(
  36. width: 2,
  37. color: Palette.violet,
  38. ),
  39. ),
  40. onPressed: () {
  41. // ref
  42. // .read(playerMatchingNotifierProvider.notifier)
  43. // .triggerMatching(myInfo: widget.myInfo, numbers: numberList);
  44. },
  45. child: const Padding(
  46. padding: EdgeInsets.all(16.0),
  47. child: Text(
  48. 'Multiplayer',
  49. style: TextStyle(fontSize: 22),
  50. ),
  51. ),
  52. ),
  53. );
  54. }
  55. }
  56. // class MultiplayerButton extends StatefulWidget {
  57. // final UserData myInfo;
  58. // MultiplayerButton({
  59. // Key? key,
  60. // required this.myInfo,
  61. // }) : super(key: key);
  62. // @override
  63. // State<MultiplayerButton> createState() => _MultiplayerButtonState();
  64. // }
  65. // class _MultiplayerButtonState extends State<MultiplayerButton> {
  66. // final numberList = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
  67. // @override
  68. // Widget build(BuildContext context) {
  69. // return SizedBox(
  70. // width: double.maxFinite,
  71. // child: OutlinedButton(
  72. // style: OutlinedButton.styleFrom(
  73. // primary: Palette.violet,
  74. // onSurface: Palette.violet,
  75. // shape: RoundedRectangleBorder(
  76. // borderRadius: BorderRadius.circular(50),
  77. // ),
  78. // side: const BorderSide(
  79. // width: 2,
  80. // color: Palette.violet,
  81. // ),
  82. // ),
  83. // onPressed: () {
  84. // ref.read(playerMatchingNotifierProvider.notifier).triggerMatching(
  85. // myInfo: widget.myInfo,
  86. // numbers: [14, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 15]);
  87. // },
  88. // child: const Padding(
  89. // padding: EdgeInsets.all(16.0),
  90. // child: Text(
  91. // 'Multiplayer',
  92. // style: TextStyle(fontSize: 22),
  93. // ),
  94. // ),
  95. // ),
  96. // );
  97. // }
  98. // }