Skip to content

Commit

Permalink
Merge branch 'ui/redesign' into redesign/exams_page
Browse files Browse the repository at this point in the history
  • Loading branch information
thePeras authored Dec 27, 2024
2 parents 8f33af3 + bb17f36 commit 598d3f3
Show file tree
Hide file tree
Showing 15 changed files with 362 additions and 181 deletions.
2 changes: 1 addition & 1 deletion packages/uni_app/app_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.10.0-beta.35+338
1.10.0-beta.36+339
11 changes: 0 additions & 11 deletions packages/uni_app/lib/model/entities/login_exceptions.dart

This file was deleted.

1 change: 1 addition & 0 deletions packages/uni_app/lib/session/exception.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
enum AuthenticationExceptionType {
internetError,
wrongCredentials,
expiredCredentials,
other,
Expand Down
12 changes: 11 additions & 1 deletion packages/uni_app/lib/session/flows/credentials/request.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'package:http/http.dart' as http;
import 'package:uni/controller/fetchers/faculties_fetcher.dart';
import 'package:uni/session/exception.dart';
Expand Down Expand Up @@ -35,11 +36,20 @@ class CredentialsSessionRequest extends SessionRequest {
'Failed to authenticate user',
AuthenticationExceptionType.expiredCredentials,
);
} else {
} else if (failureReason == LoginFailureReason.internetError) {
throw const AuthenticationException(
'Failed to authenticate user',
AuthenticationExceptionType.internetError,
);
} else if (failureReason == LoginFailureReason.wrongCredentials) {
throw const AuthenticationException(
'Failed to authenticate user',
AuthenticationExceptionType.wrongCredentials,
);
} else {
throw const AuthenticationException(
'Failed to authenticate user',
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class LoginResponse extends SigarraResponse {

enum LoginFailureReason {
serverError,
internetError,
wrongCredentials,
expiredCredentials,
blockedAccount,
Expand Down
71 changes: 43 additions & 28 deletions packages/uni_app/lib/view/login/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:uni/app_links/uni_app_links.dart';
import 'package:uni/controller/networking/url_launcher.dart';
import 'package:uni/generated/l10n.dart';
import 'package:uni/model/entities/login_exceptions.dart';
import 'package:uni/model/providers/startup/session_provider.dart';
import 'package:uni/model/providers/state_providers.dart';
import 'package:uni/session/exception.dart';
import 'package:uni/session/flows/credentials/initiator.dart';
import 'package:uni/session/flows/federated/initiator.dart';
import 'package:uni/utils/constants.dart';
Expand Down Expand Up @@ -99,36 +99,51 @@ class LoginPageViewState extends State<LoginPageView>
_loggingIn = false;
});
}
} catch (err, st) {
} on AuthenticationException catch (err, st) {
setState(() {
_loggingIn = false;
});
if (err is ExpiredCredentialsException) {
_updatePasswordDialog();
} else if (err is InternetStatusException) {
if (mounted) {
unawaited(
ToastMessage.warning(
context,
S.of(context).internet_status_exception,
),
);
}
} else if (err is WrongCredentialsException) {
if (mounted) {
unawaited(
ToastMessage.error(
context,
S.of(context).wrong_credentials_exception,
),
);
}
} else {
Logger().e(err, stackTrace: st);
unawaited(Sentry.captureException(err, stackTrace: st));
if (mounted) {
unawaited(ToastMessage.error(context, S.of(context).failed_login));
}

switch (err.type) {
case AuthenticationExceptionType.expiredCredentials:
_updatePasswordDialog();
case AuthenticationExceptionType.internetError:
if (mounted) {
unawaited(
ToastMessage.warning(
context,
S.of(context).internet_status_exception,
),
);
}
case AuthenticationExceptionType.wrongCredentials:
if (mounted) {
unawaited(
ToastMessage.error(
context,
S.of(context).wrong_credentials_exception,
),
);
}
default:
Logger().e(err, stackTrace: st);
unawaited(Sentry.captureException(err, stackTrace: st));
if (mounted) {
unawaited(
ToastMessage.error(context, S.of(context).failed_login),
);
}
}
}
// Handles other unexpected exceptions
catch (err, st) {
setState(() {
_loggingIn = false;
});
Logger().e(err, stackTrace: st);
unawaited(Sentry.captureException(err, stackTrace: st));
if (mounted) {
unawaited(ToastMessage.error(context, S.of(context).failed_login));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/uni_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish_to: "none" # We do not publish to pub.dev
# To change it manually, override the value in app_version.txt.
# The app version code is automatically also bumped by CI.
# Do not change it manually.
version: 1.10.0-beta.35+338
version: 1.10.0-beta.36+339

environment:
sdk: ">=3.4.0 <4.0.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/uni_ui/lib/cards/course_grade_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class CourseGradeCard extends StatelessWidget {
children: [
Text(
courseName,
style: theme.textTheme.titleLarge,
style: theme.textTheme.bodySmall,
overflow: TextOverflow.ellipsis,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("${ects} ECTS", style: theme.textTheme.bodyLarge),
Text("${grade.toInt()}", style: theme.textTheme.bodyLarge)
Text("${ects} ECTS", style: theme.textTheme.bodySmall),
Text("${grade.toInt()}", style: theme.textTheme.bodySmall)
],
)
],
Expand Down
8 changes: 4 additions & 4 deletions packages/uni_ui/lib/cards/exam_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ExamCard extends StatelessWidget {
Text(
acronym,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.headlineMedium!,
style: Theme.of(context).textTheme.headlineSmall!,
),
const SizedBox(width: 8),
Badge(
Expand All @@ -62,7 +62,7 @@ class ExamCard extends StatelessWidget {
Text(
name,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleLarge!,
style: Theme.of(context).textTheme.bodySmall!,
),
const SizedBox(height: 5),
Row(
Expand All @@ -75,7 +75,7 @@ class ExamCard extends StatelessWidget {
const SizedBox(width: 4),
Text(
startTime ?? "--:--",
style: Theme.of(context).textTheme.bodyMedium!,
style: Theme.of(context).textTheme.labelSmall!,
),
const SizedBox(width: 8),
if (!rooms.isEmpty)
Expand All @@ -101,7 +101,7 @@ class ExamCard extends StatelessWidget {
scrollDirection: Axis.horizontal,
child: Text(
rooms.join(" "),
style: Theme.of(context).textTheme.bodyMedium,
style: Theme.of(context).textTheme.labelSmall,
),
),
),
Expand Down
4 changes: 2 additions & 2 deletions packages/uni_ui/lib/cards/service_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ServiceCard extends StatelessWidget {
Text(
name,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.headlineMedium!,
style: Theme.of(context).textTheme.headlineSmall!,
),
],
),
Expand All @@ -42,7 +42,7 @@ class ServiceCard extends StatelessWidget {
children: openingHours.map((hour) {
return Text(
hour,
style: Theme.of(context).textTheme.bodySmall,
style: Theme.of(context).textTheme.bodyLarge,
);
}).toList(),
)
Expand Down
Loading

0 comments on commit 598d3f3

Please sign in to comment.