-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e81f1e8
commit ddf81ee
Showing
12 changed files
with
362 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
cleanup() { | ||
git stash pop --index | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
git stash push --keep-index | ||
|
||
dart format . | ||
|
||
flutter analyze | ||
flutter test | ||
|
||
flutter test | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:http/http.dart' as http; | ||
import 'package:package_info_plus/package_info_plus.dart'; | ||
import 'package:splitr/models/app_data.dart'; | ||
import 'package:tuple/tuple.dart'; | ||
|
||
String repository = | ||
'https://api.github.com/repos/bhasherbel/splitr/releases/latest'; | ||
|
||
Future<Tuple3<bool, String, String>> checkForNewRelease() async { | ||
final response = await http.get(Uri.parse(repository)); | ||
|
||
if (response.statusCode != 200) { | ||
return const Tuple3(false, '', ''); | ||
} | ||
|
||
final releaseData = json.decode(response.body); | ||
|
||
String releaseVersion = releaseData['tag_name'] as String; | ||
|
||
String lastChecked = AppData.sharedPreferences.getString('last_version') ?? | ||
(await PackageInfo.fromPlatform()).version; | ||
|
||
if (isNewer(lastChecked, releaseVersion)) { | ||
String url = releaseData['html_url'] as String; | ||
|
||
return Tuple3(true, releaseVersion, url); | ||
} | ||
|
||
return const Tuple3(false, '', ''); | ||
} | ||
|
||
bool isNewer(String old, String new_) { | ||
final parts1 = old.split('+')[0].split('.'); | ||
final parts2 = new_.split('+')[0].split('.'); | ||
|
||
for (int i = 0; i < parts1.length; i++) { | ||
final int part1 = int.parse(parts1[i]); | ||
final int part2 = int.parse(parts2[i]); | ||
|
||
if (part1 != part2) { | ||
return part2 > part1; | ||
} | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
import 'dart:math'; | ||
|
||
import 'package:flutter/services.dart'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:splitr/models/app_data.dart'; | ||
import 'package:url_launcher/url_launcher_string.dart'; | ||
|
||
Future<dynamic> updateBox({ | ||
required BuildContext context, | ||
required String currentVersion, | ||
required String releaseVersion, | ||
required String releaseUrl, | ||
}) { | ||
return showDialog( | ||
context: context, | ||
builder: (context) => AlertDialog( | ||
title: const Text('New Update Available'), | ||
content: | ||
Text('Update from $currentVersion to $releaseVersion is available'), | ||
actions: [ | ||
ButtonBar( | ||
alignment: MainAxisAlignment.spaceBetween, | ||
children: [ | ||
TextButton( | ||
onPressed: () { | ||
AppData.sharedPreferences | ||
.setString('last_version', releaseVersion); | ||
Navigator.of(context).pop(); | ||
}, | ||
child: const Text('Skip'), | ||
), | ||
TextButton( | ||
onPressed: () => Navigator.of(context).pop(), | ||
child: const Text('Later'), | ||
), | ||
TextButton( | ||
onPressed: () async { | ||
await launchUrlString( | ||
releaseUrl, | ||
mode: LaunchMode.externalApplication, | ||
); | ||
if (context.mounted) Navigator.of(context).pop(); | ||
}, | ||
child: const Text('Update'), | ||
), | ||
], | ||
) | ||
], | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:splitr/widgets/header_tile.dart'; | ||
|
||
void main() { | ||
testWidgets('HeaderTile should render correctly with the provided text', | ||
(WidgetTester tester) async { | ||
const text = 'Header Title'; | ||
await tester.pumpWidget( | ||
const MaterialApp( | ||
home: Scaffold( | ||
body: HeaderTile( | ||
text, | ||
smallCaps: false, | ||
), | ||
), | ||
), | ||
); | ||
|
||
expect(find.text(text), findsOneWidget); | ||
}); | ||
} |
Oops, something went wrong.