Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7272184067 | ||
|
|
1ecbd7b6b1 | ||
|
|
212410f716 | ||
|
|
97c10c8d12 | ||
|
|
02ab7f390d |
No files matched your search
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 6.7 KiB |
|
After Width: | Height: | Size: 47 KiB |
@@ -442,7 +442,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
@@ -500,7 +500,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
|
||||
@@ -1,122 +1 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-20x20@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-20x20@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-29x29@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-29x29@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-29x29@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-40x40@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-40x40@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-60x60@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "60x60",
|
||||
"idiom" : "iphone",
|
||||
"filename" : "Icon-App-60x60@3x.png",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-20x20@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "20x20",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-20x20@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-29x29@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-29x29@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-40x40@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-40x40@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-76x76@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "76x76",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-76x76@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "83.5x83.5",
|
||||
"idiom" : "ipad",
|
||||
"filename" : "Icon-App-83.5x83.5@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "1024x1024",
|
||||
"idiom" : "ios-marketing",
|
||||
"filename" : "Icon-App-1024x1024@1x.png",
|
||||
"scale" : "1x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
{"images":[{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@3x.png","scale":"3x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@3x.png","scale":"3x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@3x.png","scale":"3x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@1x.png","scale":"1x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@3x.png","scale":"3x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@1x.png","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@1x.png","scale":"1x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@1x.png","scale":"1x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@2x.png","scale":"2x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@1x.png","scale":"1x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@2x.png","scale":"2x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@1x.png","scale":"1x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@2x.png","scale":"2x"},{"size":"83.5x83.5","idiom":"ipad","filename":"Icon-App-83.5x83.5@2x.png","scale":"2x"},{"size":"1024x1024","idiom":"ios-marketing","filename":"Icon-App-1024x1024@1x.png","scale":"1x"}],"info":{"version":1,"author":"xcode"}}
|
||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 295 B After Width: | Height: | Size: 749 B |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 282 B After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 704 B After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 406 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 586 B After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 862 B After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 762 B After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 6.6 KiB |
@@ -8,7 +8,9 @@ import 'ui/features/dashboard/views/match_results_view.dart';
|
||||
import 'ui/features/settings/views/settings_view.dart';
|
||||
|
||||
class MobileApp extends StatefulWidget {
|
||||
const MobileApp({super.key});
|
||||
const MobileApp({super.key, this.matchRepository});
|
||||
|
||||
final MatchRepository? matchRepository;
|
||||
|
||||
@override
|
||||
State<MobileApp> createState() => _MobileAppState();
|
||||
@@ -17,14 +19,14 @@ class MobileApp extends StatefulWidget {
|
||||
class _MobileAppState extends State<MobileApp> {
|
||||
late final ThemeController _themeController;
|
||||
late final MatchResultsViewModel _matchResultsViewModel;
|
||||
int _currentTabIndex = 0;
|
||||
bool _showSettings = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_themeController = ThemeController();
|
||||
_matchResultsViewModel = MatchResultsViewModel(
|
||||
repository: MatchRepository(),
|
||||
repository: widget.matchRepository ?? MatchRepository(),
|
||||
);
|
||||
_matchResultsViewModel.loadMatches();
|
||||
}
|
||||
@@ -49,25 +51,30 @@ class _MobileAppState extends State<MobileApp> {
|
||||
themeMode: _themeController.themeMode,
|
||||
home: Builder(
|
||||
builder: (context) {
|
||||
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
return ResponsiveScaffold(
|
||||
selectedIndex: _currentTabIndex,
|
||||
selectedIndex: 0,
|
||||
onDestinationSelected: (index) {
|
||||
setState(() => _currentTabIndex = index);
|
||||
if (index == 0) {
|
||||
setState(() => _showSettings = false);
|
||||
}
|
||||
},
|
||||
appBarTitle: Text(
|
||||
_currentTabIndex == 0 ? 'Match Results' : 'Settings',
|
||||
_showSettings ? 'Settings' : 'Match Results',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
isDarkMode ? Icons.light_mode : Icons.dark_mode,
|
||||
if (_showSettings)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.arrow_back_rounded),
|
||||
tooltip: 'Back to results',
|
||||
onPressed: () => setState(() => _showSettings = false),
|
||||
)
|
||||
else
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings_outlined),
|
||||
tooltip: 'Settings',
|
||||
onPressed: () => setState(() => _showSettings = true),
|
||||
),
|
||||
tooltip: isDarkMode ? 'Switch to light mode' : 'Switch to dark mode',
|
||||
onPressed: _themeController.toggleTheme,
|
||||
),
|
||||
],
|
||||
destinations: const [
|
||||
NavigationDestinationItem(
|
||||
@@ -75,15 +82,10 @@ class _MobileAppState extends State<MobileApp> {
|
||||
selectedIcon: Icon(Icons.sports_hockey),
|
||||
label: 'Results',
|
||||
),
|
||||
NavigationDestinationItem(
|
||||
icon: Icon(Icons.settings_outlined),
|
||||
selectedIcon: Icon(Icons.settings),
|
||||
label: 'Settings',
|
||||
),
|
||||
],
|
||||
body: _currentTabIndex == 0
|
||||
? MatchResultsView(viewModel: _matchResultsViewModel)
|
||||
: SettingsView(themeController: _themeController),
|
||||
body: _showSettings
|
||||
? SettingsView(themeController: _themeController)
|
||||
: MatchResultsView(viewModel: _matchResultsViewModel),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<svg width="800px" height="800px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#33d912" stroke-width="0.00016">
|
||||
<g id="SVGRepo_bgCarrier" stroke-width="0"/>
|
||||
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<g id="SVGRepo_iconCarrier">
|
||||
<path fill="#4ee119" d="M 8 1.25 C 7.273 1.251 6.598 1.627 6.215 2.246 L 6.213 2.25 L 0.538 11.623 L 0.532 11.633 C -0.047 12.622 0.29 13.893 1.283 14.465 C 1.597 14.648 1.953 14.746 2.317 14.75 L 13.683 14.75 C 14.422 14.741 15.102 14.344 15.474 13.705 C 15.844 13.063 15.842 12.273 15.468 11.633 L 9.788 2.25 L 9.785 2.246 C 9.405 1.625 8.728 1.247 8 1.25 Z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 720 B |
@@ -0,0 +1,7 @@
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
␍<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
␍<g id="SVGRepo_bgCarrier" stroke-width="0"/>
|
||||
␍<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
␍<g id="SVGRepo_iconCarrier"> <circle cx="8" cy="8" r="8" fill="#f70202"/> </g>
|
||||
␍</svg>
|
||||
|
After Width: | Height: | Size: 501 B |
@@ -0,0 +1,7 @@
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
␍<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
|
||||
<svg height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-51.2 -51.2 614.40 614.40" xml:space="preserve" fill="#000000">
|
||||
␍<g id="SVGRepo_bgCarrier" stroke-width="0"/>
|
||||
␍<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
␍<g id="SVGRepo_iconCarrier"> <path style="fill:#51be23;" d="M477.636,176.632H275.3v74.67h-56v-74.67c-62.643,0-115.734,40.856-134.118,97.365 c-7.301-4.213-15.774-6.626-24.811-6.626c-27.45,0-49.702,22.252-49.702,49.703c0,27.449,22.253,49.701,49.702,49.701 c8.906,0,17.266-2.344,24.496-6.449c18.083,57.017,71.43,98.34,134.432,98.34c77.882,0,141.017-63.138,141.017-141.015l-0.017-1.44 l117.336-26.88c12.699-2.907,23.695-10.667,23.695-23.696v-65.304C501.331,187.297,490.67,176.632,477.636,176.632z"/> <g> <path style="fill:#000003;" d="M477.636,165.963H275.3c-5.893,0-10.669,4.779-10.669,10.669v64.002h-34.663v-64.002 c0-5.89-4.776-10.669-10.669-10.669c-61.963,0-116.914,37.203-140.205,93.708c-6.016-1.957-12.338-2.969-18.724-2.969 C27.083,256.702,0,283.785,0,317.074c0,33.288,27.083,60.37,60.371,60.37c6.233,0,12.413-0.967,18.304-2.838 c10.406,25.771,27.594,48.022,50.196,64.831c26.296,19.56,57.567,29.897,90.428,29.897c81.262,0,147.804-64.233,151.523-144.588 l109.194-25.015c19.729-4.517,31.984-17.582,31.984-34.096v-65.304C512,181.381,496.585,165.963,477.636,165.963z M490.663,265.635 c0,8.817-10.775,12.236-15.409,13.299l-117.336,26.878c-4.866,1.115-8.308,5.453-8.286,10.446l0.017,1.394 c0,71.874-58.474,130.346-130.348,130.346c-57.082,0-107.019-36.528-124.263-90.897c-0.973-3.067-3.279-5.533-6.275-6.707 c-1.257-0.492-2.578-0.736-3.894-0.736c-1.825,0-3.642,0.467-5.267,1.392c-5.827,3.307-12.476,5.057-19.228,5.057 c-21.524,0-39.035-17.509-39.035-39.033c0-21.523,17.511-39.035,39.034-39.035c6.851,0,13.586,1.797,19.477,5.197 c2.788,1.611,6.154,1.876,9.156,0.721c3.004-1.152,5.328-3.599,6.324-6.659c16.403-50.423,61.152-85.348,113.303-89.565v63.571 c0,5.89,4.776,10.669,10.669,10.669h56c5.892,0,10.669-4.779,10.669-10.669v-64.002h191.667c7.182,0,13.026,5.845,13.026,13.03 V265.635z"/> <path style="fill:#000003;" d="M219.3,405.332h-0.138c-5.889-0.173-10.799,4.476-10.964,10.365 c-0.166,5.89,4.473,10.8,10.364,10.964c0.249,0.009,0.495,0.009,0.738,0.009c5.892,0,10.669-4.776,10.669-10.669 C229.969,410.111,225.192,405.332,219.3,405.332z"/> <path style="fill:#000003;" d="M192.592,401.167c-36.47-11.665-60.973-45.226-60.973-83.516c0-7.662,1.006-15.297,2.99-22.69 c1.526-5.691-1.85-11.541-7.541-13.069c-5.692-1.526-11.541,1.85-13.069,7.541c-2.467,9.195-3.717,18.692-3.717,28.218 c0,47.607,30.467,89.338,75.812,103.839c1.081,0.346,2.175,0.511,3.252,0.511c4.515,0,8.71-2.89,10.16-7.422 C201.299,408.967,198.204,402.962,192.592,401.167z"/> <path style="fill:#000003;" d="M60.371,306.403c-5.874,0-10.667,4.794-10.667,10.667c0,5.879,4.792,10.669,10.667,10.669 s10.669-4.79,10.669-10.669C71.04,311.198,66.245,306.403,60.371,306.403z"/> <path style="fill:#000003;" d="M247.301,124.235c5.892,0,10.669-4.779,10.669-10.669v-60.23c0-5.89-4.776-10.669-10.669-10.669 c-5.891,0-10.669,4.779-10.669,10.669v60.23C236.633,119.456,241.409,124.235,247.301,124.235z"/> <path style="fill:#000003;" d="M189.619,140.298c2.083,2.081,4.814,3.124,7.543,3.124c2.73,0,5.461-1.042,7.544-3.124 c4.166-4.167,4.166-10.923,0.001-15.089l-43.315-43.317c-4.165-4.163-10.921-4.165-15.088,0 c-4.166,4.167-4.166,10.923-0.001,15.089L189.619,140.298z"/> <path style="fill:#000003;" d="M318.415,122.445c2.73,0,5.46-1.042,7.543-3.124l22.339-22.339c4.165-4.165,4.166-10.921,0-15.089 c-4.167-4.163-10.922-4.165-15.089,0l-22.339,22.34c-4.166,4.165-4.166,10.921-0.001,15.089 C312.953,121.402,315.682,122.445,318.415,122.445z"/> <path style="fill:#000003;" d="M297.44,143.421c2.737,0,5.471-1.046,7.556-3.136l0.177-0.177c4.16-4.174,4.151-10.927-0.023-15.088 c-4.171-4.161-10.927-4.151-15.088,0.022l-0.178,0.177c-4.159,4.174-4.15,10.927,0.023,15.088 C291.989,142.384,294.714,143.421,297.44,143.421z"/> </g> </g>
|
||||
␍</svg>
|
||||
|
After Width: | Height: | Size: 4.1 KiB |
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
␍<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="none">
|
||||
␍<g id="SVGRepo_bgCarrier" stroke-width="0"/>
|
||||
␍<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
␍<g id="SVGRepo_iconCarrier">
|
||||
␍<path fill="#f5c000" d="M3.25 1A2.25 2.25 0 001 3.25v9.5A2.25 2.25 0 003.25 15h9.5A2.25 2.25 0 0015 12.75v-9.5A2.25 2.25 0 0012.75 1h-9.5z"/>
|
||||
␍</g>
|
||||
␍</svg>
|
||||
|
After Width: | Height: | Size: 600 B |
@@ -1,18 +1,68 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import '../../domain/models/hockey_game.dart';
|
||||
|
||||
class MatchRepository {
|
||||
MatchRepository({AssetBundle? bundle}) : _bundle = bundle ?? rootBundle;
|
||||
MatchRepository({
|
||||
AssetBundle? bundle,
|
||||
Future<Directory> Function()? documentsDirectoryProvider,
|
||||
}) : _bundle = bundle ?? rootBundle,
|
||||
_documentsDirectoryProvider =
|
||||
documentsDirectoryProvider ?? getApplicationDocumentsDirectory;
|
||||
|
||||
final AssetBundle _bundle;
|
||||
final Future<Directory> Function() _documentsDirectoryProvider;
|
||||
|
||||
Future<List<Match>> loadMatches() async {
|
||||
Future<List<Match>> loadSourceMatches() async {
|
||||
final contents = await _bundle.loadString('lib/data/results.json');
|
||||
final data = jsonDecode(contents) as Map<String, dynamic>;
|
||||
return (data['games'] as List<dynamic>)
|
||||
.map((game) => Match.fromJson(game as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<StoredMatchData> loadStoredData() async {
|
||||
final file = await _storageFile();
|
||||
if (!await file.exists()) {
|
||||
return const StoredMatchData(matches: [], sourceCursor: 0);
|
||||
}
|
||||
|
||||
final data = jsonDecode(await file.readAsString()) as Map<String, dynamic>;
|
||||
final storedMatches = data['matches'] as List<dynamic>? ?? const [];
|
||||
final sourceCursor = data['sourceCursor'];
|
||||
|
||||
return StoredMatchData(
|
||||
matches: storedMatches
|
||||
.map((match) => Match.fromJson(match as Map<String, dynamic>))
|
||||
.toList(),
|
||||
sourceCursor: sourceCursor is int && sourceCursor >= 0 ? sourceCursor : 0,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> saveStoredData(List<Match> matches, int sourceCursor) async {
|
||||
final file = await _storageFile();
|
||||
await file.writeAsString(
|
||||
jsonEncode({
|
||||
'sourceCursor': sourceCursor,
|
||||
'matches': matches.map((match) => match.toJson()).toList(),
|
||||
}),
|
||||
flush: true,
|
||||
);
|
||||
}
|
||||
|
||||
Future<File> _storageFile() async {
|
||||
final directory = await _documentsDirectoryProvider();
|
||||
await directory.create(recursive: true);
|
||||
return File('${directory.path}${Platform.pathSeparator}match-results.json');
|
||||
}
|
||||
}
|
||||
|
||||
class StoredMatchData {
|
||||
const StoredMatchData({required this.matches, required this.sourceCursor});
|
||||
|
||||
final List<Match> matches;
|
||||
final int sourceCursor;
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 1,
|
||||
"card_type": 2,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
@@ -25,13 +25,134 @@
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"score": 1,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 0,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 2
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 0,
|
||||
"elapsed": 32,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 2,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 88,
|
||||
"goal_type": 2,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 32,
|
||||
"goal_type": 1,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"elapsed": 66,
|
||||
"goal_type": 0,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-10-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 2,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 0,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
@@ -62,18 +183,21 @@
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 1
|
||||
"team": 2
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 0,
|
||||
"elapsed": 32,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 2,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
@@ -97,18 +221,621 @@
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 88,
|
||||
"goal_type": 2,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 32,
|
||||
"goal_type": 1,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"elapsed": 66,
|
||||
"goal_type": 0,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-10-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 2,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 0,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 2
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 0,
|
||||
"elapsed": 32,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 2,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 88,
|
||||
"goal_type": 2,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 32,
|
||||
"goal_type": 1,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"elapsed": 66,
|
||||
"goal_type": 0,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-10-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 2,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 0,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 2
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 0,
|
||||
"elapsed": 32,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 2,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 88,
|
||||
"goal_type": 2,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 32,
|
||||
"goal_type": 1,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"elapsed": 66,
|
||||
"goal_type": 0,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-10-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 2,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 0,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 2
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 0,
|
||||
"elapsed": 32,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 2,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 88,
|
||||
"goal_type": 2,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 32,
|
||||
"goal_type": 1,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"elapsed": 66,
|
||||
"goal_type": 0,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-10-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 2,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 0,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 2
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 0,
|
||||
"elapsed": 32,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 2,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 88,
|
||||
"goal_type": 2,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 32,
|
||||
"goal_type": 1,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"elapsed": 66,
|
||||
"goal_type": 0,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-10-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 2,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 0,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"card_type": 0,
|
||||
"datetime": "2023-10-01T12:35:00Z",
|
||||
"duration": 120,
|
||||
"player": 8,
|
||||
"elapsed": 235,
|
||||
"team": 0
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 1,
|
||||
"elapsed": 88,
|
||||
"team": 2
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"goal_type": 0,
|
||||
"elapsed": 32,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"goal_type": 2,
|
||||
"elapsed": 66,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{ "datetime": "2023-11-01T12:00:00Z",
|
||||
"awayScore": 0,
|
||||
"homeScore": 1,
|
||||
"cards": [
|
||||
{
|
||||
"card_type": 1,
|
||||
"datetime": "2023-11-01T12:25:00Z",
|
||||
"duration": 120,
|
||||
"player": 5,
|
||||
"elapsed": 125,
|
||||
"team": 1
|
||||
}
|
||||
],
|
||||
"goals": [
|
||||
{
|
||||
"datetime": "2023-10-01T12:15:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 88,
|
||||
"goal_type": 2,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:20:00Z",
|
||||
"player": 32,
|
||||
"elapsed": 32,
|
||||
"goal_type": 1,
|
||||
"team": 1
|
||||
},
|
||||
{
|
||||
"datetime": "2023-10-01T12:30:00Z",
|
||||
"player": 2,
|
||||
"elapsed": 66,
|
||||
"goal_type": 0,
|
||||
"team": 0
|
||||
}
|
||||
]
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
import 'dart:async';
|
||||
|
||||
import '../../domain/models/hockey_game.dart';
|
||||
import '../repositories/match_repository.dart';
|
||||
|
||||
class MatchDataService {
|
||||
MatchDataService({
|
||||
required this.repository,
|
||||
this.updateInterval = const Duration(seconds: 1),
|
||||
}) : assert(updateInterval > Duration.zero);
|
||||
|
||||
final MatchRepository repository;
|
||||
final Duration updateInterval;
|
||||
|
||||
Timer? _timer;
|
||||
List<Match> _matches = [];
|
||||
List<Match> _sourceMatches = [];
|
||||
int _sourceCursor = 0;
|
||||
bool _isStarted = false;
|
||||
bool _isDelivering = false;
|
||||
bool _isDisposed = false;
|
||||
Future<void> _writeQueue = Future<void>.value();
|
||||
void Function(List<Match>)? _onMatchesChanged;
|
||||
void Function(Object)? _onError;
|
||||
|
||||
Future<void> start({
|
||||
required void Function(List<Match>) onMatchesChanged,
|
||||
required void Function(Object) onError,
|
||||
}) async {
|
||||
if (_isStarted) return;
|
||||
_isStarted = true;
|
||||
_onMatchesChanged = onMatchesChanged;
|
||||
_onError = onError;
|
||||
|
||||
final storedData = await repository.loadStoredData();
|
||||
_matches = List.of(storedData.matches);
|
||||
_sourceCursor = storedData.sourceCursor;
|
||||
_notifyMatchesChanged();
|
||||
|
||||
_sourceMatches = await repository.loadSourceMatches();
|
||||
await _deliverNextMatch();
|
||||
|
||||
if (_sourceCursor < _sourceMatches.length && !_isDisposed) {
|
||||
_timer = Timer.periodic(updateInterval, (_) {
|
||||
unawaited(_deliverNextMatch().catchError(_handleError));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> removeMatch(Match match) async {
|
||||
final matchIndex = _matches.indexWhere(
|
||||
(candidate) => identical(candidate, match),
|
||||
);
|
||||
if (matchIndex == -1) return;
|
||||
|
||||
final updatedMatches = List<Match>.of(_matches)..removeAt(matchIndex);
|
||||
_matches = updatedMatches;
|
||||
_notifyMatchesChanged();
|
||||
await _persist(updatedMatches, _sourceCursor);
|
||||
}
|
||||
|
||||
Future<void> _deliverNextMatch() async {
|
||||
if (_isDisposed || _isDelivering || _sourceCursor >= _sourceMatches.length) {
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
return;
|
||||
}
|
||||
|
||||
_isDelivering = true;
|
||||
try {
|
||||
final updatedMatches = [..._matches, _sourceMatches[_sourceCursor]];
|
||||
final nextCursor = _sourceCursor + 1;
|
||||
await _persist(updatedMatches, nextCursor);
|
||||
if (_isDisposed) return;
|
||||
|
||||
_matches = updatedMatches;
|
||||
_sourceCursor = nextCursor;
|
||||
_notifyMatchesChanged();
|
||||
|
||||
if (_sourceCursor >= _sourceMatches.length) {
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
} finally {
|
||||
_isDelivering = false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _persist(List<Match> matches, int sourceCursor) {
|
||||
final previousWrite = _writeQueue.catchError((Object _) {});
|
||||
final nextWrite = previousWrite.then(
|
||||
(_) => repository.saveStoredData(matches, sourceCursor),
|
||||
);
|
||||
_writeQueue = nextWrite;
|
||||
return nextWrite;
|
||||
}
|
||||
|
||||
void _notifyMatchesChanged() {
|
||||
_onMatchesChanged?.call(List.unmodifiable(_matches));
|
||||
}
|
||||
|
||||
void _handleError(Object error) {
|
||||
_onError?.call(error);
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_isDisposed = true;
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
}
|
||||
@@ -86,17 +86,19 @@ class ResponsiveScaffold extends StatelessWidget {
|
||||
child: body,
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
selectedIndex: selectedIndex,
|
||||
onDestinationSelected: onDestinationSelected,
|
||||
destinations: destinations.map((d) {
|
||||
return NavigationDestination(
|
||||
icon: d.icon,
|
||||
selectedIcon: d.selectedIcon,
|
||||
label: d.label,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
bottomNavigationBar: destinations.length >= 2
|
||||
? NavigationBar(
|
||||
selectedIndex: selectedIndex,
|
||||
onDestinationSelected: onDestinationSelected,
|
||||
destinations: destinations.map((d) {
|
||||
return NavigationDestination(
|
||||
icon: d.icon,
|
||||
selectedIcon: d.selectedIcon,
|
||||
label: d.label,
|
||||
);
|
||||
}).toList(),
|
||||
)
|
||||
: null,
|
||||
floatingActionButton: floatingActionButton,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import '../../../../data/repositories/match_repository.dart';
|
||||
import '../../../../data/services/match_data_service.dart';
|
||||
import '../../../../domain/models/hockey_game.dart';
|
||||
|
||||
class MatchResultsViewModel extends ChangeNotifier {
|
||||
MatchResultsViewModel({required this.repository});
|
||||
MatchResultsViewModel({
|
||||
required MatchRepository repository,
|
||||
Duration updateInterval = const Duration(seconds: 1),
|
||||
}) : _dataService = MatchDataService(
|
||||
repository: repository,
|
||||
updateInterval: updateInterval,
|
||||
);
|
||||
|
||||
final MatchRepository repository;
|
||||
final MatchDataService _dataService;
|
||||
List<Match> _matches = [];
|
||||
bool _isLoading = false;
|
||||
String? _errorMessage;
|
||||
@@ -14,13 +23,31 @@ class MatchResultsViewModel extends ChangeNotifier {
|
||||
bool get isLoading => _isLoading;
|
||||
String? get errorMessage => _errorMessage;
|
||||
|
||||
Future<void> removeMatch(Match match) async {
|
||||
try {
|
||||
await _dataService.removeMatch(match);
|
||||
} catch (_) {
|
||||
_errorMessage = 'Unable to save match results.';
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadMatches() async {
|
||||
_isLoading = true;
|
||||
_errorMessage = null;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
_matches = await repository.loadMatches();
|
||||
await _dataService.start(
|
||||
onMatchesChanged: (matches) {
|
||||
_matches = matches;
|
||||
notifyListeners();
|
||||
},
|
||||
onError: (_) {
|
||||
_errorMessage = 'Unable to save match results.';
|
||||
notifyListeners();
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
_errorMessage = 'Unable to load match results.';
|
||||
} finally {
|
||||
@@ -28,4 +55,10 @@ class MatchResultsViewModel extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_dataService.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../domain/models/hockey_game.dart' show CardType, Match, Team;
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../../../domain/models/hockey_game.dart'
|
||||
show CardType, GoalType, Match, Team;
|
||||
import '../view_models/match_results_view_model.dart';
|
||||
|
||||
class MatchResultsView extends StatelessWidget {
|
||||
@@ -12,51 +16,92 @@ class MatchResultsView extends StatelessWidget {
|
||||
return ListenableBuilder(
|
||||
listenable: viewModel,
|
||||
builder: (context, _) {
|
||||
final matches = viewModel.matches;
|
||||
|
||||
if (viewModel.isLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
if (viewModel.errorMessage != null) {
|
||||
return Center(child: Text(viewModel.errorMessage!));
|
||||
}
|
||||
if (viewModel.matches.isEmpty) {
|
||||
if (matches.isEmpty) {
|
||||
return const Center(child: Text('No match results available.'));
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: viewModel.matches.length,
|
||||
itemBuilder: (context, index) => _MatchCard(
|
||||
match: viewModel.matches[index],
|
||||
),
|
||||
itemCount: matches.length,
|
||||
findChildIndexCallback: (key) {
|
||||
if (key is! ValueKey<Match>) return null;
|
||||
final index = matches.indexWhere(
|
||||
(match) => identical(match, key.value),
|
||||
);
|
||||
return index == -1 ? null : index;
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
final match = matches[index];
|
||||
|
||||
return Dismissible(
|
||||
key: ValueKey(match),
|
||||
direction: DismissDirection.endToStart,
|
||||
background: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Icon(Icons.delete_outline, color: Colors.white),
|
||||
),
|
||||
onDismissed: (_) => viewModel.removeMatch(match),
|
||||
child: _MatchCard(match: match),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _MatchCard extends StatelessWidget {
|
||||
class _MatchCard extends StatefulWidget {
|
||||
const _MatchCard({required this.match});
|
||||
|
||||
final Match match;
|
||||
|
||||
@override
|
||||
State<_MatchCard> createState() => _MatchCardState();
|
||||
}
|
||||
|
||||
class _MatchCardState extends State<_MatchCard> {
|
||||
bool _isExpanded = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final match = widget.match;
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final textTheme = Theme.of(context).textTheme;
|
||||
final date = DateTime.tryParse(match.datetime)?.toLocal();
|
||||
final dateLabel = date == null
|
||||
? match.datetime
|
||||
: '${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
|
||||
final dateLabel = _exportDate(match.datetime);
|
||||
|
||||
return Card(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
child: ExpansionTile(
|
||||
shape: const Border(),
|
||||
collapsedShape: const Border(),
|
||||
onExpansionChanged: (expanded) => setState(() => _isExpanded = expanded),
|
||||
trailing: _isExpanded
|
||||
? IconButton(
|
||||
tooltip: 'Share match',
|
||||
icon: const Icon(Icons.share_outlined),
|
||||
onPressed: () => SharePlus.instance.share(
|
||||
ShareParams(text: _matchShareText(match)),
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(dateLabel, style: textTheme.labelLarge),
|
||||
const SizedBox(height: 12),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -71,21 +116,41 @@ class _MatchCard extends StatelessWidget {
|
||||
const Text('Away'),
|
||||
],
|
||||
),
|
||||
if (match.goals.isNotEmpty || match.cards.isNotEmpty) ...[
|
||||
const Divider(height: 24),
|
||||
...match.goals.map((goal) => _EventLine(
|
||||
icon: Icons.sports_hockey,
|
||||
label: 'Goal · ${_teamName(goal.team)} · #${goal.player}',
|
||||
seconds: goal.seconds,
|
||||
)),
|
||||
...match.cards.map((card) => _EventLine(
|
||||
icon: Icons.style_outlined,
|
||||
label: '${_cardName(card.cardType)} card · ${_teamName(card.team)} · #${card.player}',
|
||||
seconds: card.seconds,
|
||||
)),
|
||||
],
|
||||
],
|
||||
),
|
||||
childrenPadding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
|
||||
children: [
|
||||
...match.goals.map(
|
||||
(goal) => _EventLine(
|
||||
leading: Icon(
|
||||
Icons.sports_hockey,
|
||||
size: 18,
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
),
|
||||
team: _teamName(goal.team),
|
||||
playerNumber: goal.player,
|
||||
eventType: _goalTypeName(goal.goalType),
|
||||
seconds: goal.seconds,
|
||||
),
|
||||
),
|
||||
...match.cards.map(
|
||||
(card) => _EventLine(
|
||||
leading: _CardMarker(cardType: card.cardType),
|
||||
team: _teamName(card.team),
|
||||
playerNumber: card.player,
|
||||
eventType: '${_cardName(card.cardType)} card · ${_cardDurationLabel(card.duration)}',
|
||||
seconds: card.seconds,
|
||||
),
|
||||
),
|
||||
if (match.goals.isEmpty && match.cards.isEmpty)
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(bottom: 8),
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text('No recorded events'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -93,37 +158,205 @@ class _MatchCard extends StatelessWidget {
|
||||
|
||||
class _EventLine extends StatelessWidget {
|
||||
const _EventLine({
|
||||
required this.icon,
|
||||
required this.label,
|
||||
required this.leading,
|
||||
required this.team,
|
||||
required this.playerNumber,
|
||||
required this.eventType,
|
||||
required this.seconds,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final Widget leading;
|
||||
final String team;
|
||||
final int playerNumber;
|
||||
final String eventType;
|
||||
final int seconds;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final minute = seconds ~/ 60;
|
||||
final minute = (seconds ~/ 60).toString().padLeft(2, '0');
|
||||
final second = (seconds % 60).toString().padLeft(2, '0');
|
||||
final playerLabel = '#${playerNumber.toString().padLeft(2, '0')}';
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Icon(icon, size: 18, color: Theme.of(context).colorScheme.secondary),
|
||||
SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: Center(child: leading),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(child: Text(label)),
|
||||
Text('$minute:$second', style: Theme.of(context).textTheme.labelMedium),
|
||||
SizedBox(
|
||||
width: 52,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(team),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 8,
|
||||
child:const Text('·', textAlign: TextAlign.left),
|
||||
|
||||
|
||||
),
|
||||
SizedBox(
|
||||
width: 42,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(playerLabel),
|
||||
),
|
||||
),
|
||||
// SizedBox(
|
||||
// width: 12,
|
||||
// child: Align(
|
||||
// alignment: Alignment.center,
|
||||
// child: const Text('·', textAlign: TextAlign.center),
|
||||
// ),
|
||||
// ),
|
||||
Expanded(
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
eventType,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
'$minute:$second',
|
||||
// style: Theme.of(context).textTheme.labelMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CardMarker extends StatelessWidget {
|
||||
const _CardMarker({required this.cardType});
|
||||
|
||||
final CardType cardType;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final svgPath = switch (cardType) {
|
||||
CardType.green => 'lib/data/icons/green-card.svg',
|
||||
CardType.yellow => 'lib/data/icons/yellow-card.svg',
|
||||
CardType.red => 'lib/data/icons/red-card.svg',
|
||||
};
|
||||
|
||||
return SizedBox(
|
||||
width: 18,
|
||||
height: 18,
|
||||
child: SvgPicture.asset(
|
||||
svgPath,
|
||||
width: 18,
|
||||
height: 18,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _teamName(Team team) => team == Team.home ? 'Home' : 'Away';
|
||||
|
||||
String _matchShareText(Match match) {
|
||||
final buffer = StringBuffer()
|
||||
..writeln('Match result')
|
||||
..writeln(_exportDate(match.datetime))
|
||||
..writeln('Home ${match.homeScore} - ${match.awayScore} Away');
|
||||
|
||||
if (match.goals.isNotEmpty) {
|
||||
buffer.writeln();
|
||||
buffer.writeln('Goals:');
|
||||
for (final goal in match.goals) {
|
||||
buffer.writeln(
|
||||
'- ${_teamName(goal.team)} · #${goal.player.toString().padLeft(2, '0')} · ${_goalTypeName(goal.goalType)} · ${_formatTime(goal.seconds)}',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (match.cards.isNotEmpty) {
|
||||
buffer.writeln();
|
||||
buffer.writeln('Cards:');
|
||||
for (final card in match.cards) {
|
||||
buffer.writeln(
|
||||
'- ${_teamName(card.team)} · #${card.player.toString().padLeft(2, '0')} · ${_cardName(card.cardType)} card · ${_cardDurationLabel(card.duration)} · ${_formatTime(card.seconds)}',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
String _formatTime(int seconds) {
|
||||
final minute = seconds ~/ 60;
|
||||
final second = (seconds % 60).toString().padLeft(2, '0');
|
||||
return '$minute:$second';
|
||||
}
|
||||
|
||||
String _exportDate(String rawDateTime) {
|
||||
final parsed = DateTime.tryParse(rawDateTime)?.toLocal();
|
||||
if (parsed == null) {
|
||||
return rawDateTime;
|
||||
}
|
||||
|
||||
final weekday = _weekdayName(parsed.weekday);
|
||||
final day = parsed.day.toString().padLeft(2, '0');
|
||||
final month = _monthName(parsed.month);
|
||||
final year = parsed.year.toString().substring(2);
|
||||
final hour = parsed.hour.toString().padLeft(2, '0');
|
||||
final minute = parsed.minute.toString().padLeft(2, '0');
|
||||
|
||||
return '$weekday $day-$month-$year $hour:$minute';
|
||||
}
|
||||
|
||||
String _monthName(int month) => switch (month) {
|
||||
1 => 'Jan',
|
||||
2 => 'Feb',
|
||||
3 => 'Mar',
|
||||
4 => 'Apr',
|
||||
5 => 'May',
|
||||
6 => 'Jun',
|
||||
7 => 'Jul',
|
||||
8 => 'Aug',
|
||||
9 => 'Sep',
|
||||
10 => 'Oct',
|
||||
11 => 'Nov',
|
||||
12 => 'Dec',
|
||||
_ => 'Unknown',
|
||||
};
|
||||
|
||||
String _weekdayName(int weekday) => switch (weekday) {
|
||||
DateTime.monday => 'Mon',
|
||||
DateTime.tuesday => 'Tue',
|
||||
DateTime.wednesday => 'Wed',
|
||||
DateTime.thursday => 'Thu',
|
||||
DateTime.friday => 'Fri',
|
||||
DateTime.saturday => 'Sat',
|
||||
DateTime.sunday => 'Sun',
|
||||
_ => 'Unknown',
|
||||
};
|
||||
|
||||
|
||||
String _goalTypeName(GoalType type) => switch (type) {
|
||||
GoalType.fieldGoal => 'Field goal',
|
||||
GoalType.shortCorner => 'Short corner',
|
||||
GoalType.penaltyStroke => 'Penalty stroke',
|
||||
};
|
||||
|
||||
String _cardName(CardType type) => switch (type) {
|
||||
CardType.red => 'Red',
|
||||
CardType.yellow => 'Yellow',
|
||||
CardType.green => 'Green',
|
||||
};
|
||||
CardType.red => 'Red',
|
||||
CardType.yellow => 'Yellow',
|
||||
CardType.green => 'Green',
|
||||
};
|
||||
|
||||
String _cardDurationLabel(int durationSeconds) {
|
||||
final minutes = (durationSeconds ~/ 60).toString().padLeft(2, '0');
|
||||
final seconds = (durationSeconds % 60).toString().padLeft(2, '0');
|
||||
return '$minutes:$seconds';
|
||||
}
|
||||
@@ -1,6 +1,22 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: archive
|
||||
sha256: "6c5bcd986e06b94e3c40244af471750840a3d2341d1f9763a1100a14add517b4"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.3.0"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.7.0"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -25,6 +41,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.1"
|
||||
checked_yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: checked_yaml
|
||||
sha256: "959525d3162f249993882720d52b7e0c833978df229be20702b33d48d91de70f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.4"
|
||||
cli_util:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cli_util
|
||||
sha256: ff6785f7e9e3c38ac98b2fb035701789de90154024a75b6cb926445e83197d1c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.4.2"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -33,6 +65,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
code_assets:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: code_assets
|
||||
sha256: bf394f466ba9205f1812a0433b392d6af280f155f56651eda7c18cc32ed493b8
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -41,6 +81,22 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.19.1"
|
||||
cross_file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cross_file
|
||||
sha256: f141ea4f277af142a0356955707f6556f37b03947d39d55585981a06ca437bd6
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.5+5"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.7"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -57,11 +113,43 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.3"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.1"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fixnum
|
||||
sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_launcher_icons:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_launcher_icons
|
||||
sha256: "10f13781741a2e3972126fae08393d3c4e01fa4cd7473326b94b72cf594195e7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.14.4"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -70,11 +158,88 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.0"
|
||||
flutter_svg:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_svg
|
||||
sha256: "35882981abcbfb8c15b286f0cd690ff25bac12d95eff3e25ee207f37d4c42e7f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
hooks:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: hooks
|
||||
sha256: "9a62a50b50b769a737bc0a8ff381f333529df3ab746b2f6b02e83760231455ba"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http
|
||||
sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.6.0"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_parser
|
||||
sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.2"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image
|
||||
sha256: a1e7f4951e538a568e14b856702afc9ae1d2f4b202daced8d22c1b9cd211ce89
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.10.1"
|
||||
jni:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: jni
|
||||
sha256: f038e58b4dc2c9037f50e233175086337e0b305e356d28211bf55f21c504cbd3
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
jni_flutter:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: jni_flutter
|
||||
sha256: b2310cdd4c18c65c081ab141a41efa94aa26c65431803703ece51996f174f351
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
jni_util:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: jni_util
|
||||
sha256: "1ba86da04a5f2bf18fde2edb235587e70c5b0fc5bd4ba955f46b00942c3fc35f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
json_annotation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: json_annotation
|
||||
sha256: "2a743920d81b7910627f68ee2c9ac1fc0bfee32b9fc3403587d7c6791ca12f80"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.12.0"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -107,6 +272,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.0"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logging
|
||||
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -131,6 +304,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.18.3"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: mime
|
||||
sha256: bd47de35f07e27267e69c8c8b22edf9473bfee170a60d60fcc93730c5144b7f6
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
objective_c:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: objective_c
|
||||
sha256: b7fb95a6d9a4f009edd63dc5ac69f07420b23a16161c6dd8660290b59c602e8e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.5.0"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_config
|
||||
sha256: ffcf4cf3d6c0b74ac43708d9f56625506e8a68aa935abe9d267a7330f320eb5d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -139,6 +336,126 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.1"
|
||||
path_parsing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_parsing
|
||||
sha256: "883402936929eac138ee0a45da5b0f2c80f89913e6dc3bf77eb65b84b409c6ca"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
path_provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path_provider
|
||||
sha256: a7f4874f987173da295a61c181b8ee71dab59b332a486b391babf26a1b884825
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.6"
|
||||
path_provider_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_foundation
|
||||
sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.0"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_linux
|
||||
sha256: "58c2005f147315b11e9b4a7bc889cd5203e250cba8e3f012dae259b4972b5c16"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.2"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
sha256: "484838772624c3a4b94f1e44a3e19897fee738f2d5c4ce448443b0417f7c9dda"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
path_provider_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_windows
|
||||
sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: petitparser
|
||||
sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.2"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform
|
||||
sha256: a36d119c13416516a7b5913fbe8af8531e11633d784c550b2125f76c758524ec
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.0"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.8"
|
||||
posix:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: posix
|
||||
sha256: bc1bad54ad2b735816e31f8d4600cfde6c7839975085ddfbca48b6c9f7c4044e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.5.2"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pub_semver
|
||||
sha256: "261236774e8b1d69cfc6b9eabbc96c40f25e7a2d6b171f3385d4f65d5734fb24"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
record_use:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: record_use
|
||||
sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.0"
|
||||
share_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: share_plus
|
||||
sha256: d7dc0630a923883c6328ca31b89aa682bacbf2f8304162d29f7c6aaff03a27a1
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "11.1.0"
|
||||
share_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: share_plus_platform_interface
|
||||
sha256: "88023e53a13429bd65d8e85e11a9b484f49d4c190abbd96c7932b74d6927cc9a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@@ -192,6 +509,78 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.12"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.0"
|
||||
url_launcher_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_linux
|
||||
sha256: "10f86fef4c2c43563fa6c211ff9cf757adf4d3ab762c56bd430664a947d70cd0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.3"
|
||||
url_launcher_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_platform_interface
|
||||
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
url_launcher_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_web
|
||||
sha256: "85c81589622fbc87c1c683aaea164d3604a7777495a79d91e39ffcdec39ddb34"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.3"
|
||||
url_launcher_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_windows
|
||||
sha256: "6c5ad3f22cd4c38e089b81963b3cd7bb83b111b2df5dce008bb066162f42e429"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.6"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: uuid
|
||||
sha256: "9b129329f58692f6e6578329498a8fe9fbe98f090beb764ffbb8ee2eadd01dcd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.6.0"
|
||||
vector_graphics:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics
|
||||
sha256: "9d0e3b9cb16542ad660daee871e726a10d13a93b7b5391677c3160e8f5e83935"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.3"
|
||||
vector_graphics_codec:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics_codec
|
||||
sha256: "99fd9fbd34d9f9a32efd7b6a6aae14125d8237b10403b422a6a6dfeac2806146"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.13"
|
||||
vector_graphics_compiler:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_graphics_compiler
|
||||
sha256: "4dca4feb77dc3ec7f6e27e49c53241eb8217f55e4f9b12599a27f8903bca5682"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -208,6 +597,46 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "15.3.0"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web
|
||||
sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.15.0"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
xml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xml
|
||||
sha256: "67f0aff7be013d107995e9b75bf4e7f2c3ef2dfdb2c8e68024bba0a7fd5756a4"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.1"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: yaml
|
||||
sha256: f67cdd8e07d3c6329146aaef1ba043542b3134c12489f553ca9a7435d1068aea
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.4"
|
||||
sdks:
|
||||
dart: ">=3.13.3 <4.0.0"
|
||||
flutter: ">=3.18.0-18.0.pre.54"
|
||||
flutter: ">=3.38.4"
|
||||
@@ -31,6 +31,10 @@ dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
|
||||
flutter_svg: ^2.1.0
|
||||
path_provider: ^2.1.6
|
||||
share_plus: ^11.0.0
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^1.0.8
|
||||
@@ -45,6 +49,7 @@ dev_dependencies:
|
||||
# package. See that file for information about deactivating specific lint
|
||||
# rules and activating additional ones.
|
||||
flutter_lints: ^6.0.0
|
||||
flutter_launcher_icons: ^0.14.4
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
@@ -59,6 +64,14 @@ flutter:
|
||||
|
||||
assets:
|
||||
- lib/data/results.json
|
||||
- lib/data/icons/
|
||||
|
||||
flutter_icons:
|
||||
android: true
|
||||
ios: true
|
||||
image_path: "assets/icon.png"
|
||||
min_sdk_android: 21
|
||||
remove_alpha_ios: true
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mobile_app/data/repositories/match_repository.dart';
|
||||
import 'package:mobile_app/ui/features/dashboard/view_models/match_results_view_model.dart';
|
||||
@@ -6,18 +8,58 @@ void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
test('loads match results and their events from bundled JSON', () async {
|
||||
final viewModel = MatchResultsViewModel(repository: MatchRepository());
|
||||
final matches = await MatchRepository().loadSourceMatches();
|
||||
|
||||
expect(matches, hasLength(21));
|
||||
expect(matches.first.homeScore, 1);
|
||||
expect(matches.first.goals, hasLength(2));
|
||||
expect(matches.first.goals.first.seconds, 88);
|
||||
expect(matches.first.goals.first.team.name, 'away');
|
||||
expect(matches.first.cards.first.cardType.name, 'red');
|
||||
});
|
||||
|
||||
test('simulates periodic receipt and persists received matches', () async {
|
||||
final directory = await Directory.systemTemp.createTemp('match-results-');
|
||||
addTearDown(() => directory.delete(recursive: true));
|
||||
final repository = MatchRepository(
|
||||
documentsDirectoryProvider: () async => directory,
|
||||
);
|
||||
final viewModel = MatchResultsViewModel(
|
||||
repository: repository,
|
||||
updateInterval: const Duration(milliseconds: 10),
|
||||
);
|
||||
addTearDown(viewModel.dispose);
|
||||
|
||||
await viewModel.loadMatches();
|
||||
expect(viewModel.matches, hasLength(1));
|
||||
|
||||
await Future<void>.delayed(const Duration(milliseconds: 30));
|
||||
|
||||
expect(viewModel.matches.length, greaterThan(1));
|
||||
final storedData = await repository.loadStoredData();
|
||||
expect(storedData.matches, hasLength(viewModel.matches.length));
|
||||
expect(storedData.sourceCursor, viewModel.matches.length);
|
||||
});
|
||||
|
||||
test('resumes simulation from the persisted source cursor', () async {
|
||||
final directory = await Directory.systemTemp.createTemp('match-results-');
|
||||
addTearDown(() => directory.delete(recursive: true));
|
||||
final repository = MatchRepository(
|
||||
documentsDirectoryProvider: () async => directory,
|
||||
);
|
||||
final sourceMatches = await repository.loadSourceMatches();
|
||||
await repository.saveStoredData([sourceMatches.first], 1);
|
||||
final viewModel = MatchResultsViewModel(
|
||||
repository: repository,
|
||||
updateInterval: const Duration(hours: 1),
|
||||
);
|
||||
addTearDown(viewModel.dispose);
|
||||
|
||||
await viewModel.loadMatches();
|
||||
|
||||
expect(viewModel.isLoading, isFalse);
|
||||
expect(viewModel.errorMessage, isNull);
|
||||
expect(viewModel.matches, hasLength(3));
|
||||
expect(viewModel.matches.first.homeScore, 1);
|
||||
expect(viewModel.matches.first.goals, hasLength(2));
|
||||
expect(viewModel.matches.first.goals.first.seconds, 88);
|
||||
expect(viewModel.matches.first.goals.first.team.name, 'away');
|
||||
expect(viewModel.matches.first.cards.first.cardType.name, 'red');
|
||||
expect(viewModel.matches, hasLength(2));
|
||||
expect(viewModel.matches.first.datetime, sourceMatches.first.datetime);
|
||||
expect(viewModel.matches.last.datetime, sourceMatches[1].datetime);
|
||||
expect((await repository.loadStoredData()).sourceCursor, 2);
|
||||
});
|
||||
}
|
||||
@@ -1,15 +1,47 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mobile_app/app.dart';
|
||||
import 'package:mobile_app/data/repositories/match_repository.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('App smoke test - renders match results, navigates to settings',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const MobileApp());
|
||||
testWidgets('App smoke test - renders match results, navigates to settings', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
final directory = await Directory.systemTemp.createTemp('match-results-');
|
||||
addTearDown(() => directory.delete(recursive: true));
|
||||
await tester.pumpWidget(
|
||||
MobileApp(
|
||||
matchRepository: MatchRepository(
|
||||
documentsDirectoryProvider: () async => directory,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Match Results'), findsOneWidget);
|
||||
expect(find.text('Home'), findsWidgets);
|
||||
expect(find.text('Away'), findsWidgets);
|
||||
expect(
|
||||
find.textContaining(RegExp(r'[A-Z][a-z]{2} \d{2}-\d{2}-\d{2} \d{2}:\d{2}')),
|
||||
findsWidgets,
|
||||
);
|
||||
expect(find.byType(ExpansionTile), findsWidgets);
|
||||
|
||||
await tester.tap(
|
||||
find.textContaining(RegExp(r'[A-Z][a-z]{2} \d{2}-\d{2}-\d{2} \d{2}:\d{2}')).first,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Field goal'), findsWidgets);
|
||||
expect(find.text('Away'), findsWidgets);
|
||||
expect(find.byType(Divider), findsNothing);
|
||||
final matchTile = tester.widget<ExpansionTile>(
|
||||
find.byType(ExpansionTile).first,
|
||||
);
|
||||
expect(matchTile.shape, const Border());
|
||||
expect(matchTile.collapsedShape, const Border());
|
||||
|
||||
// Switch to Settings tab
|
||||
final settingsNav = find.text('Settings');
|
||||
@@ -28,5 +60,14 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Match Results'), findsOneWidget);
|
||||
|
||||
final firstMatchFinder = find.byType(Dismissible).first;
|
||||
final firstMatch = tester.widget<Dismissible>(firstMatchFinder);
|
||||
final firstMatchKey = firstMatch.key;
|
||||
|
||||
await tester.fling(firstMatchFinder, const Offset(-600, 0), 1000);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(firstMatchKey!), findsNothing);
|
||||
});
|
||||
}
|
||||