Skip to content

Commit

Permalink
Merge branch 'master' into build-homepage-update
Browse files Browse the repository at this point in the history
  • Loading branch information
vyPal committed Sep 20, 2023
2 parents 7fc1376 + 612f9db commit 021cd5e
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-preview-apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "v${{ steps.semver.outputs.version }}"
automatic_release_tag: "v${{ steps.semver.outputs.version }}-${{ github.ref_name }}"
prerelease: true
title: "EduPage2 Preview v${{ steps.semver.outputs.version }} ${{ github.ref_name }}"
files: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
l10n.yaml
lib
android
test
integration_test
build:
runs-on: macos-latest
needs: check_changes
Expand Down
13 changes: 5 additions & 8 deletions integration_test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,27 @@ void main() {

testWidgets('Run app and login', (tester) async {
await prep(tester, username, password, name);

SharedPreferences prefs = await SharedPreferences.getInstance();
expect(prefs.get("email"), equals(username));
expect(prefs.get("password"), equals(password));
expect(find.text("Username"), findsNothing);
});

testWidgets('Test TimeTable page', (tester) async {
await prep(tester, username, password, name);

await tester.tap(find.byType(NavigationDestination).at(1));
await pumpUntilFound(tester, find.textContaining("Today"));
expect(find.textContaining("Today"), findsOneWidget);
expect(find.textContaining("TODAY"), findsOneWidget);
});

testWidgets('Test TimeTable page scroll', (tester) async {
await prep(tester, username, password, name);

await tester.tap(find.byType(NavigationDestination).at(1));
await pumpUntilFound(tester, find.textContaining("Today"));
expect(find.textContaining("Today"), findsOneWidget);
expect(find.textContaining("TODAY"), findsOneWidget);

await tester.tap(find.byKey(const Key("TimeTableScrollForward")));
await pumpUntilFound(tester, find.textContaining("Tomorrow"));
//expect(find.textContaining("Tomorrow"), findsOneWidget);
expect(find.textContaining("TOMORROW"), findsOneWidget);
});
});
}
Expand All @@ -60,5 +57,5 @@ Future<void> prep(
await tester.tap(find.byType(ElevatedButton));

await pumpUntilFound(tester, find.text(name));
await tester.pump(const Duration(seconds: 5));
await tester.pump(const Duration(seconds: 1));
}
2 changes: 1 addition & 1 deletion l10n.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
arb-dir: lib/l10n
template-arb-file: app_cs.arb
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
90 changes: 37 additions & 53 deletions lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:package_info/package_info.dart';
import 'package:restart_app/restart_app.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:shorebird_code_push/shorebird_code_push_web.dart';
import 'package:shorebird_code_push/shorebird_code_push.dart';
import 'package:url_launcher/url_launcher.dart';

class HomePage extends StatefulWidget {
Expand Down Expand Up @@ -193,20 +193,14 @@ class HomePageState extends State<HomePage> {
});

if (isUpdateAvailable) {
_showUpdateAvailableBanner();
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('No update available'),
),
);
_downloadUpdate();
}
}

void _showDownloadingBanner() {
ScaffoldMessenger.of(context).showMaterialBanner(
const MaterialBanner(
content: Text('Downloading...'),
content: Text('Downloading patch...'),
actions: [
SizedBox(
height: 14,
Expand All @@ -220,26 +214,6 @@ class HomePageState extends State<HomePage> {
);
}

void _showUpdateAvailableBanner() {
ScaffoldMessenger.of(context).showMaterialBanner(
MaterialBanner(
content: const Text('Update available'),
actions: [
TextButton(
onPressed: () async {
ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
await _downloadUpdate();

if (!mounted) return;
ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
},
child: const Text('Download'),
),
],
),
);
}

void _showRestartBanner() {
ScaffoldMessenger.of(context).showMaterialBanner(
const MaterialBanner(
Expand Down Expand Up @@ -291,7 +265,14 @@ class HomePageState extends State<HomePage> {
});
}

Map<String, dynamic> user = await widget.sessionManager.get('user');
Map<String, dynamic>? user = await widget.sessionManager.get('user');
if (user == null) {
apidataTT = {};
setState(() {
loading = false;
});
return;
}
username = user["firstname"] + " " + user["lastname"];
String token = sharedPreferences.getString("token")!;

Expand Down Expand Up @@ -473,8 +454,8 @@ class HomePageState extends State<HomePage> {
Icons.circle,
color: Color.fromARGB(
255,
_lessonStatus.hasLesson ? 0 : 255,
_lessonStatus.hasLesson ? 255 : 0,
_lessonStatus.hasLesson ? 0 : 255,
0),
size: 8,
),
Expand Down Expand Up @@ -517,27 +498,29 @@ class HomePageState extends State<HomePage> {
widget.onDestinationSelected(1);
},
child: Card(
child: Padding(
padding: const EdgeInsets.all(10),
child: Column(
children: [
Text(
lesson["period"]["name"] + ".",
style:
const TextStyle(fontSize: 10),
),
Text(
lesson["subject"]["short"],
style:
const TextStyle(fontSize: 20),
),
Text(
lesson["classrooms"][0]["short"],
style:
const TextStyle(fontSize: 14),
),
],
),
child: Padding(
padding: const EdgeInsets.all(10),
child: Column(
children: [
Text(
lesson["period"]["name"] + ".",
style:
const TextStyle(fontSize: 10),
),
Text(
lesson["subject"]["short"],
style:
const TextStyle(fontSize: 20),
),
Text(
lesson["classrooms"].length > 0
? lesson["classrooms"][0]
["short"]
: "?",
style:
const TextStyle(fontSize: 14),
),
],
),
),
),
Expand All @@ -555,7 +538,8 @@ class HomePageState extends State<HomePage> {
final url = Uri.parse(
'https://github.com/DislikesSchool/EduPage2/releases/latest');
if (await canLaunchUrl(url)) {
await launchUrl(url);
await launchUrl(url,
mode: LaunchMode.externalApplication);
} else {
throw 'Could not launch $url';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/load.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LoadingScreenState extends State<LoadingScreen> {

Dio dio = Dio();
double progress = 0.0;
String loaderText = "Načítání...";
String loaderText = "Loading...";

String baseUrl = "https://lobster-app-z6jfk.ondigitalocean.app/api";

Expand Down
3 changes: 2 additions & 1 deletion lib/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ class MessagePageState extends State<MessagePage> {
}

Future<void> _onOpen(LinkableElement link) async {
if (!await launchUrl(Uri.parse(link.url))) {
if (!await launchUrl(Uri.parse(link.url),
mode: LaunchMode.externalApplication)) {
throw Exception('Could not launch ${link.url}');
}
}
2 changes: 2 additions & 0 deletions lib/timetable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class TimeTableClass {
Widget getTimeTable(TimeTableData tt, int daydiff, Function(int) modifyDayDiff,
AppLocalizations? local, bool userInteracted, BuildContext context) {
List<TableRow> rows = <TableRow>[];
/*
if (daydiff == 0 && tt.classes.isNotEmpty) {
String endTime = tt.classes.last.endTime;
DateTime now = DateTime.now();
Expand All @@ -271,6 +272,7 @@ Widget getTimeTable(TimeTableData tt, int daydiff, Function(int) modifyDayDiff,
modifyDayDiff(1);
}
}
*/
for (TimeTableClass ttclass in tt.classes) {
List<Widget> extrasRow = <Widget>[];
if (ttclass.data['curriculum'] != null) {
Expand Down
2 changes: 1 addition & 1 deletion shorebird.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ app_id: 0f4dc1a8-0c38-409f-838c-9bca97783f4a
# If auto_update: false, you will need to use package:shorebird_code_push to trigger updates.
# https://pub.dev/packages/shorebird_code_push
# Uncomment the following line to disable automatic updates.
auto_update: true
auto_update: false

0 comments on commit 021cd5e

Please sign in to comment.