Skip to content

Commit

Permalink
Reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
GravityDarkLab committed Feb 4, 2024
1 parent 5be000f commit 0ed512c
Show file tree
Hide file tree
Showing 64 changed files with 1,084 additions and 789 deletions.
809 changes: 528 additions & 281 deletions lib/base/networking/api/gocast/api_v2.pb.dart

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/base/networking/api/handler/api_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class ApiHandler {
/// This method takes a [statusCode] and [apiMessage] and throws an [AppError]
/// based on the status code.
static void handleHttpStatus(int? statusCode, String? apiMessage) {
_logger.i('Handling HTTP status code: $statusCode, API message: $apiMessage');
_logger
.i('Handling HTTP status code: $statusCode, API message: $apiMessage');
if (statusCode == null) {
throw AppError.unknownError("Status code is null");
}
Expand Down
8 changes: 5 additions & 3 deletions lib/base/networking/api/handler/auth_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ class AuthHandler {
});
Response response;
try {
response = await dio.post(url, data: formData);
_logger.i('Received HTTP response with status code: ${response.statusCode}');
response = await dio.post(url, data: formData);
_logger
.i('Received HTTP response with status code: ${response.statusCode}');
} catch (e) {
_logger.e('Error during basic authentication for user: $username, Error: $e');
_logger.e(
'Error during basic authentication for user: $username, Error: $e');
throw AppError.userError();
}
try {
Expand Down
1 change: 0 additions & 1 deletion lib/base/networking/api/handler/bookmarks_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class BooKMarkHandler {
);
}


/// Adds a bookmark for the current user.
///
/// Sends a `putUserBookmark` gRPC call with the given [bookmarkData] to add a bookmark.
Expand Down
27 changes: 16 additions & 11 deletions lib/base/networking/api/handler/chat_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ class ChatHandlers {
/// Takes a [emoji] parameter to post a chat reaction.
///
/// returns a [ChatReaction] instance that represents the posted chat reaction.
Future<ChatReaction> postMessageReaction(int messageID,
int streamID,
String emoji,) async {
Future<ChatReaction> postMessageReaction(
int messageID,
int streamID,
String emoji,
) async {
return _grpcHandler.callGrpcMethod(
(client) async {
final response = await client.postChatReaction(
Expand All @@ -80,9 +82,11 @@ class ChatHandlers {
/// Takes a [messageID] parameter to delete a chat reaction for a specific message.
/// Takes a [streamID] parameter to delete a chat reaction for a specific stream.
/// Takes a [reactionID] parameter to delete a chat reaction.
Future<void> deleteMessageReaction(int messageID,
int streamID,
int reactionID,) async {
Future<void> deleteMessageReaction(
int messageID,
int streamID,
int reactionID,
) async {
return _grpcHandler.callGrpcMethod(
(client) async {
await client.deleteChatReaction(
Expand All @@ -105,9 +109,11 @@ class ChatHandlers {
/// Takes a [message] parameter to post a chat reply.
///
/// returns a [ChatMessage] instance that represents the posted chat reply.
Future<ChatMessage> postChatReply(int messageID,
int streamID,
String message,) async {
Future<ChatMessage> postChatReply(
int messageID,
int streamID,
String message,
) async {
return _grpcHandler.callGrpcMethod(
(client) async {
final response = await client.postChatReply(
Expand Down Expand Up @@ -155,5 +161,4 @@ class ChatHandlers {
},
);
}

}
}
4 changes: 2 additions & 2 deletions lib/base/networking/api/handler/course_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:gocast_mobile/base/networking/api/handler/user_handler.dart';
import 'package:logger/logger.dart';
import 'package:tuple/tuple.dart';


class CourseHandler {
static final Logger _logger = Logger();
final GrpcHandler _grpcHandler;
Expand All @@ -23,7 +22,8 @@ class CourseHandler {
},
);
}
/// fetches the semesters and the current semester.

/// fetches the semesters and the current semester.
Future<Tuple2<List<Semester>, Semester>> fetchSemesters() async {
_logger.i('Fetching semesters');
final response = await _grpcHandler.callGrpcMethod(
Expand Down
8 changes: 4 additions & 4 deletions lib/base/networking/api/handler/grpc_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ class GrpcHandler {
final token = await TokenHandler.getToken();
try {
CallOptions callOptions;
if(token.isNotEmpty) {
if (token.isNotEmpty) {
final metadata = <String, String>{
'grpcgateway-cookie': 'jwt=$token',
};
callOptions = CallOptions(metadata: metadata);
}else {
callOptions = CallOptions();
callOptions = CallOptions(metadata: metadata);
} else {
callOptions = CallOptions();
}
return await grpcMethod(APIClient(_channel, options: callOptions));
} on SocketException catch (socketException) {
Expand Down
3 changes: 2 additions & 1 deletion lib/base/networking/api/handler/poll_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class PollHandlers {
);
return _grpcHandler.callGrpcMethod(
(client) async {
await client.postPollVote(PostPollVoteRequest(
await client.postPollVote(
PostPollVoteRequest(
streamID: streamID,
pollOptionID: pollOptionID,
),
Expand Down
1 change: 0 additions & 1 deletion lib/base/networking/api/handler/settings_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:logger/logger.dart';

import 'grpc_handler.dart';


class SettingsHandler {
static final Logger _logger = Logger();
final GrpcHandler _grpcHandler;
Expand Down
4 changes: 1 addition & 3 deletions lib/base/networking/api/handler/token_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class TokenHandler {
static const _storage = FlutterSecureStorage();
static String cachedToken = '';


/// Stores a token.
///
/// This method saves a token to shared preferences. The token is identified
Expand Down Expand Up @@ -113,7 +112,7 @@ class TokenHandler {
}

static Future<String> getToken() async {
if(cachedToken.isNotEmpty) {
if (cachedToken.isNotEmpty) {
_logger.d('Using cached token');
return cachedToken;
}
Expand All @@ -125,5 +124,4 @@ class TokenHandler {
static Future<void> _invalidateToken() async {
cachedToken = '';
}

}
2 changes: 1 addition & 1 deletion lib/l10n/l10n.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class L10n {
const Locale('fr'),
const Locale('es'),
];
}
}
32 changes: 13 additions & 19 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Future<void> main() async {
await UserPreferences.init();

runApp(
const ProviderScope(
const ProviderScope(
child: App(),
),
);
Expand All @@ -36,12 +36,10 @@ Future<void> main() async {
bool isPushNotificationListenerSet = false;

class App extends ConsumerWidget {

const App({
const App({
super.key,
});


@override
Widget build(BuildContext context, WidgetRef ref) {
_checkConnectivityAndRedirect(context, ref);
Expand All @@ -50,7 +48,6 @@ class App extends ConsumerWidget {

bool isLoggedIn = ref.watch(userViewModelProvider).user != null;


_handleErrors(ref, userState);
_setupNotifications(ref, userState);

Expand All @@ -66,26 +63,23 @@ class App extends ConsumerWidget {
locale: Locale(UserPreferences.getLanguage()),
theme: appTheme,
darkTheme: darkAppTheme,
themeMode:
ref.watch(themeModeProvider),
themeMode: ref.watch(themeModeProvider),
navigatorKey: navigatorKey,
scaffoldMessengerKey: scaffoldMessengerKey,
home: !isLoggedIn
? const WelcomeScreen()
: const NavigationTab(),
home: !isLoggedIn ? const WelcomeScreen() : const NavigationTab(),
routes: _buildRoutes(),
);
}

void _checkConnectivityAndRedirect(BuildContext context, WidgetRef ref) {
Connectivity().checkConnectivity().then((connectivityResult) {
if (connectivityResult == ConnectivityResult.none) {
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.of(context).pushNamed('/downloads');
});
}
});
}
void _checkConnectivityAndRedirect(BuildContext context, WidgetRef ref) {
Connectivity().checkConnectivity().then((connectivityResult) {
if (connectivityResult == ConnectivityResult.none) {
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.of(context).pushNamed('/downloads');
});
}
});
}

void _handleErrors(WidgetRef ref, UserState userState) {
// Check for errors in userState and show a SnackBar if there are any
Expand Down
6 changes: 3 additions & 3 deletions lib/models/course/pinned_course_state_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class PinnedCourseState {
isLoading: isLoading ?? this.isLoading,
userPinned: userPinned ?? this.userPinned,
error: error ?? this.error,
displayedPinnedCourses: displayedPinnedCourses ?? this.displayedPinnedCourses,
displayedPinnedCourses:
displayedPinnedCourses ?? this.displayedPinnedCourses,
semesters: semesters ?? this.semesters,
selectedSemester: selectedSemester ?? this.selectedSemester,
semestersAsString: semestersAsString ?? this.semestersAsString,
Expand All @@ -63,5 +64,4 @@ class PinnedCourseState {
currentAsString: currentAsString,
);
}

}
}
14 changes: 6 additions & 8 deletions lib/models/download/download_state_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ class VideoDetails {
date = json['date'];

Map<String, dynamic> toJson() => {
'filePath': filePath,
'name': name,
'duration': duration,
'description': description,
'date': date,
};


'filePath': filePath,
'name': name,
'duration': duration,
'description': description,
'date': date,
};
}
6 changes: 4 additions & 2 deletions lib/models/error/error_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class AppError implements Exception {
factory AppError.unknownError(String? message) =>
AppError('❓An unknown error occurred {message: $message}');

factory AppError.userError() => AppError('🥱Username or password are incorrect');
factory AppError.userError() =>
AppError('🥱Username or password are incorrect');

factory AppError.notificationNotAvailableYet() => AppError('🔕Notification not available yet, Set the FireBase keys first');
factory AppError.notificationNotAvailableYet() =>
AppError('🔕Notification not available yet, Set the FireBase keys first');
}
2 changes: 0 additions & 2 deletions lib/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ final progressProvider = FutureProvider.autoDispose.family<Progress, int>(

final isSearchActiveProvider = StateProvider<bool>((ref) => false);


final playbackSpeedsProvider = StateProvider<List<double>>((ref) {
return [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2];
});

6 changes: 4 additions & 2 deletions lib/utils/UserPreferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ class UserPreferences {

static const _keyLanguage = 'language';

static Future init() async => _preferences = await SharedPreferences.getInstance();
static Future init() async =>
_preferences = await SharedPreferences.getInstance();

static Future setLanguage(String language) async => await _preferences?.setString(_keyLanguage, language);
static Future setLanguage(String language) async =>
await _preferences?.setString(_keyLanguage, language);

static String getLanguage() => _preferences?.getString(_keyLanguage) ?? 'en';

Expand Down
4 changes: 1 addition & 3 deletions lib/utils/tools.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

import 'package:flutter/material.dart';

class Tools {

//private constructor
Tools._();

Expand Down Expand Up @@ -49,4 +47,4 @@ class Tools {
return Colors.grey;
}
}
}
}
Loading

0 comments on commit 0ed512c

Please sign in to comment.