diff --git a/README.md b/README.md index f1e5097..38477a8 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ and the Flutter guide for [developing packages and plugins](https://flutter.dev/developing-packages). --> +![testing workflow](https://github.com/ThomasDevApps/lottery/actions/workflows/testing.yml/badge.svg) + # Lottery ## Features diff --git a/coverage/lcov.info b/coverage/lcov.info index 091939e..4e3e692 100644 --- a/coverage/lcov.info +++ b/coverage/lcov.info @@ -1,64 +1,75 @@ SF:lib\lottery.dart DA:30,1 DA:33,1 -DA:37,1 -DA:44,1 -DA:45,1 -DA:46,1 -DA:51,2 -DA:53,2 +DA:47,1 DA:54,1 -DA:55,6 -DA:57,6 -DA:59,2 +DA:55,1 +DA:56,1 +DA:58,2 +DA:60,2 DA:61,1 -DA:63,1 +DA:62,5 +DA:64,4 +DA:65,1 +DA:67,1 +DA:68,1 DA:69,1 -DA:71,2 -DA:73,2 -DA:74,2 -DA:75,3 -DA:78,2 -DA:79,2 -DA:80,3 -DA:85,1 -DA:86,2 -DA:89,0 -DA:90,0 -DA:91,0 -DA:92,0 -DA:96,0 -DA:98,0 -DA:100,0 -DA:101,0 -DA:102,0 -DA:103,0 -DA:104,0 -DA:109,1 -DA:111,1 -DA:112,2 -DA:113,2 -DA:114,1 -DA:120,1 -LF:41 -LH:30 +DA:72,2 +DA:74,1 +DA:76,1 +DA:82,1 +DA:85,2 +DA:87,2 +DA:88,2 +DA:89,3 +DA:92,2 +DA:93,2 +DA:94,3 +DA:103,1 +DA:104,4 +DA:109,0 +DA:110,0 +DA:111,0 +DA:112,0 +DA:116,0 +DA:119,0 +DA:121,0 +DA:122,0 +DA:123,0 +DA:124,0 +DA:125,0 +DA:141,1 +DA:144,1 +DA:145,2 +DA:146,2 +DA:147,1 +DA:153,1 +LF:45 +LH:34 end_of_record SF:lib\src\core\utils\csv_utils.dart DA:4,1 -DA:10,2 +DA:8,2 +DA:11,2 DA:12,1 -DA:16,0 -DA:19,0 -DA:20,0 -DA:21,0 +DA:13,1 +DA:14,2 +DA:19,1 LF:7 -LH:3 +LH:7 end_of_record SF:lib\src\models\grid_model\grid_model.dart -DA:13,0 -DA:14,0 -LF:2 -LH:0 +DA:9,3 +DA:17,0 +DA:18,0 +DA:20,2 +DA:22,2 +DA:23,6 +DA:24,6 +DA:27,0 +DA:29,0 +LF:9 +LH:5 end_of_record SF:lib\src\models\grid_model\grid_model.g.dart DA:9,0 @@ -67,155 +78,162 @@ DA:11,0 DA:12,0 DA:13,0 DA:14,0 -DA:17,0 +DA:15,0 DA:18,0 DA:19,0 DA:20,0 -LF:10 +DA:21,0 +DA:22,0 +LF:12 LH:0 end_of_record SF:lib\src\view\screens\lottery_screen.dart -DA:13,0 -DA:23,0 -DA:25,0 -DA:26,0 DA:27,0 -DA:29,0 -DA:31,0 -DA:32,0 -DA:34,0 -DA:35,0 -DA:36,0 -DA:37,0 DA:38,0 -DA:39,0 +DA:40,0 +DA:41,0 DA:42,0 -DA:43,0 DA:44,0 -DA:45,0 DA:46,0 DA:47,0 -DA:59,0 +DA:49,0 +DA:50,0 +DA:51,0 +DA:52,0 +DA:53,0 +DA:54,0 +DA:57,0 +DA:58,0 DA:60,0 DA:61,0 DA:62,0 DA:63,0 DA:64,0 -LF:26 +DA:65,0 +DA:78,0 +DA:79,0 +DA:80,0 +DA:81,0 +DA:82,0 +DA:83,0 +LF:28 LH:0 end_of_record SF:lib\src\view\widgets\lottery_number_item.dart -DA:7,0 -DA:17,0 -DA:23,0 -DA:25,0 +DA:8,0 +DA:18,0 +DA:24,0 DA:26,0 -DA:28,0 -DA:32,0 -DA:34,0 +DA:27,0 +DA:29,0 +DA:33,0 DA:35,0 DA:36,0 DA:37,0 -DA:39,0 +DA:38,0 +DA:40,0 LF:12 LH:0 end_of_record SF:lib\src\view\widgets\lottery_outputs.dart -DA:14,0 -DA:30,0 -DA:37,0 -DA:39,0 -DA:40,0 -DA:42,0 -DA:43,0 -DA:44,0 -DA:45,0 -DA:46,0 -DA:47,0 -DA:48,0 -DA:51,0 -DA:53,0 -DA:54,0 -DA:56,0 -DA:57,0 -DA:58,0 +DA:28,0 +DA:52,0 DA:59,0 +DA:61,0 +DA:62,0 +DA:64,0 +DA:65,0 DA:66,0 DA:67,0 +DA:68,0 DA:69,0 -DA:72,0 -DA:74,0 +DA:70,0 +DA:73,0 +DA:75,0 DA:76,0 -DA:77,0 +DA:78,0 +DA:79,0 DA:80,0 -DA:83,0 -DA:104,0 -DA:110,0 -DA:112,0 -DA:113,0 -DA:114,0 -DA:115,0 -DA:116,0 -DA:117,0 -DA:119,0 -DA:120,0 -DA:121,0 -DA:123,0 -DA:125,0 -DA:127,0 -DA:129,0 -DA:130,0 -DA:131,0 +DA:81,0 +DA:88,0 +DA:89,0 +DA:91,0 +DA:94,0 +DA:96,0 +DA:98,0 +DA:99,0 +DA:102,0 +DA:105,0 +DA:126,0 DA:132,0 -DA:133,0 +DA:134,0 +DA:135,0 +DA:136,0 +DA:137,0 +DA:138,0 DA:139,0 -DA:140,0 DA:141,0 DA:142,0 DA:143,0 -DA:144,0 -DA:158,0 -DA:159,0 -DA:160,0 +DA:145,0 +DA:147,0 +DA:149,0 +DA:151,0 +DA:152,0 +DA:153,0 +DA:154,0 +DA:155,0 DA:161,0 +DA:162,0 DA:163,0 DA:164,0 +DA:165,0 +DA:166,0 +DA:181,0 +DA:182,0 +DA:183,0 +DA:184,0 +DA:186,0 +DA:187,0 LF:59 LH:0 end_of_record SF:lib\src\view\widgets\lottery_random_pick.dart -DA:10,0 -DA:18,0 -DA:19,0 -DA:27,0 -DA:28,0 +DA:20,0 +DA:29,0 DA:30,0 -DA:31,0 -DA:32,0 -DA:34,0 -DA:37,0 DA:38,0 -DA:40,0 -DA:47,0 +DA:39,0 +DA:41,0 +DA:42,0 +DA:43,0 +DA:45,0 +DA:48,0 DA:49,0 -DA:50,0 -DA:52,0 -DA:54,0 -DA:55,0 -DA:56,0 -DA:57,0 +DA:51,0 DA:58,0 -DA:59,0 +DA:60,0 DA:61,0 DA:62,0 -DA:63,0 DA:64,0 +DA:66,0 +DA:67,0 +DA:68,0 DA:69,0 DA:70,0 -DA:72,0 +DA:71,0 DA:73,0 DA:74,0 DA:75,0 -LF:32 +DA:76,0 +DA:81,0 +DA:82,0 +DA:84,0 +DA:85,0 +DA:86,0 +DA:87,0 +DA:89,0 +DA:90,0 +LF:35 LH:0 end_of_record diff --git a/example/assets/data_test.csv b/example/assets/data_test.csv index 856e3df..0ad6c6d 100644 --- a/example/assets/data_test.csv +++ b/example/assets/data_test.csv @@ -1,3 +1,3 @@ -10;13;14;25;1;35;5 -1;16;19;6;39;37;2 -1;6;25;14;33;39;2 +10;13;14;25;1;35;5;18/04/2024 +1;16;10;6;39;37;2;22/04/2024 +1;6;25;10;33;39;2;25/04/2024 diff --git a/example/lib/main.dart b/example/lib/main.dart index ef3a3ff..a6479ee 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -7,6 +7,7 @@ Future main() async { pathCsv: 'assets\\data_test.csv', numberColumnIndexes: [0, 1, 2, 3], specialNumberColumnIndexes: [4, 5, 6], + dateTimeColumnIndex: 7, ); runApp(const MyApp()); } diff --git a/example/pubspec.lock b/example/pubspec.lock index 5a9cfe0..129bb46 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -137,7 +137,7 @@ packages: path: ".." relative: true source: path - version: "0.0.6" + version: "0.0.7" matcher: dependency: transitive description: diff --git a/lib/src/view/screens/lottery_screen.dart b/lib/src/view/screens/lottery_screen.dart index 8a4b4c8..6384e94 100644 --- a/lib/src/view/screens/lottery_screen.dart +++ b/lib/src/view/screens/lottery_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:lottery/lottery.dart'; +import 'package:lottery/src/view/widgets/lottery_last_grid_drawn.dart'; import 'package:lottery/src/view/widgets/lottery_random_pick.dart'; class LotteryScreen extends StatelessWidget { @@ -57,12 +58,21 @@ class LotteryScreen extends StatelessWidget { Expanded( child: Padding( padding: const EdgeInsets.symmetric(horizontal: 5.0), - child: LotteryRandomPick( - numbersLength: numbersLength, - specialNumbersLength: specialNumbersLength, - numberDecoration: numberDecoration, - specialNumberDecoration: specialNumberDecoration, - cardColor: cardColor, + child: Column( + children: [ + LotteryLastGridDrawn( + numberDecoration: numberDecoration, + specialNumberDecoration: specialNumberDecoration, + cardColor: cardColor, + ), + LotteryRandomPick( + numbersLength: numbersLength, + specialNumbersLength: specialNumbersLength, + numberDecoration: numberDecoration, + specialNumberDecoration: specialNumberDecoration, + cardColor: cardColor, + ), + ], ), ), ), diff --git a/lib/src/view/widgets/lottery_last_grid_drawn.dart b/lib/src/view/widgets/lottery_last_grid_drawn.dart new file mode 100644 index 0000000..f9bc385 --- /dev/null +++ b/lib/src/view/widgets/lottery_last_grid_drawn.dart @@ -0,0 +1,57 @@ +import 'package:flutter/material.dart'; +import 'package:lottery/lottery.dart'; + +class LotteryLastGridDrawn extends StatelessWidget { + final Color? cardColor; + + /// Decoration for numbers. + final LotteryNumberItemDecoration numberDecoration; + + /// Decoration for special numbers. + final LotteryNumberItemDecoration specialNumberDecoration; + + const LotteryLastGridDrawn({ + super.key, + required this.numberDecoration, + required this.specialNumberDecoration, + this.cardColor, + }); + + @override + Widget build(BuildContext context) { + final gridModel = Lottery().gridsFromCsv.first; + return Card( + color: cardColor, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Last grid drawn (${gridModel.drawnAt})', + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox(height: 16), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ...gridModel.numbers.map( + (e) => LotteryNumberItem( + number: e, + decoration: numberDecoration, + ), + ), + ...gridModel.specialNumbers.map( + (e) => LotteryNumberItem( + number: e, + decoration: specialNumberDecoration, + ), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/src/view/widgets/lottery_random_pick.dart b/lib/src/view/widgets/lottery_random_pick.dart index 520a403..1d8bea1 100644 --- a/lib/src/view/widgets/lottery_random_pick.dart +++ b/lib/src/view/widgets/lottery_random_pick.dart @@ -57,44 +57,47 @@ class _LotteryRandomPickState extends State { @override Widget build(BuildContext context) { - return Card( - color: widget.cardColor, - child: Padding( - padding: const EdgeInsets.all(24.0), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ElevatedButton( - onPressed: () { - final grid = Lottery().draw( - length: widget.numbersLength, - specialLength: widget.specialNumbersLength, - ); - setState(() { - numbersDrawn = grid.numbers.toList(); - specialNumbersDrawn = grid.specialNumbers.toList(); - winningGrid = Lottery().wasWinningGrid(grid); - }); - }, - child: const Text('Drawn'), - ), - if (numbersDrawn != null && specialNumbersDrawn != null) - Padding( - padding: const EdgeInsets.only(top: 24.0), - child: Column( - children: [ - displayGridModel(), - if (winningGrid != null) ...[ - const SizedBox(height: 32), - Text( - 'Grille gagnante ! (TAS le ${winningGrid?.drawnAt ?? '??'})', - style: const TextStyle(color: Colors.amber), - ), + return SizedBox( + width: MediaQuery.of(context).size.width, + child: Card( + color: widget.cardColor, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + ElevatedButton( + onPressed: () { + final grid = Lottery().draw( + length: widget.numbersLength, + specialLength: widget.specialNumbersLength, + ); + setState(() { + numbersDrawn = grid.numbers.toList(); + specialNumbersDrawn = grid.specialNumbers.toList(); + winningGrid = Lottery().wasWinningGrid(grid); + }); + }, + child: const Text('Drawn'), + ), + if (numbersDrawn != null && specialNumbersDrawn != null) + Padding( + padding: const EdgeInsets.only(top: 24.0), + child: Column( + children: [ + displayGridModel(), + if (winningGrid != null) ...[ + const SizedBox(height: 32), + Text( + 'Grille gagnante ! (TAS le ${winningGrid?.drawnAt ?? '??'})', + style: const TextStyle(color: Colors.amber), + ), + ], ], - ], + ), ), - ), - ], + ], + ), ), ), ); diff --git a/pubspec.yaml b/pubspec.yaml index cb20dfa..8bc897a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: lottery description: "A new Flutter project." -version: 0.0.6 +version: 0.0.7 environment: sdk: '>=3.3.3 <4.0.0'