Skip to content

Commit

Permalink
formatting files
Browse files Browse the repository at this point in the history
  • Loading branch information
GravityDarkLab committed Feb 7, 2024
1 parent 3dc47d3 commit 4c08d86
Show file tree
Hide file tree
Showing 18 changed files with 115 additions and 69 deletions.
3 changes: 2 additions & 1 deletion lib/base/networking/api/handler/auth_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class AuthHandler {
.i('Received HTTP response with status code: ${response.statusCode}');
} catch (e) {
_logger.e(
'Error during basic authentication for user: $username, Error: $e',);
'Error during basic authentication for user: $username, Error: $e',
);
throw AppError.userError();
}
try {
Expand Down
1 change: 0 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class App extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {

final userState = ref.watch(userViewModelProvider);

bool isLoggedIn = ref.watch(userViewModelProvider).user != null;
Expand Down
1 change: 0 additions & 1 deletion lib/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,3 @@ final playbackSpeedsProvider = StateProvider<List<double>>((ref) {
final connectivityProvider = StreamProvider<ConnectivityResult>((ref) {
return Connectivity().onConnectivityChanged;
});

16 changes: 12 additions & 4 deletions lib/view_models/chat_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class ChatViewModel extends StateNotifier<ChatState> {
final messages =
await ChatHandlers(_grpcHandler).getChatMessages(streamId);
state = state.copyWith(
messages: messages, isLoading: false, accessDenied: false,);
messages: messages,
isLoading: false,
accessDenied: false,
);
} catch (e) {
state = state.copyWith(
error: e as AppError,
Expand All @@ -38,10 +41,15 @@ class ChatViewModel extends StateNotifier<ChatState> {
final messages =
await ChatHandlers(_grpcHandler).getChatMessages(streamId);
final combinedMessages = List<ChatMessage>.from(state.messages ?? [])
..addAll(messages
.where((newMessage) => !state.messages!.contains(newMessage)),);
..addAll(
messages
.where((newMessage) => !state.messages!.contains(newMessage)),
);
state = state.copyWith(
messages: combinedMessages, isLoading: false, accessDenied: false,);
messages: combinedMessages,
isLoading: false,
accessDenied: false,
);
} catch (e) {
state = state.copyWith(
error: e as AppError,
Expand Down
18 changes: 12 additions & 6 deletions lib/view_models/download_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ class DownloadViewModel extends StateNotifier<DownloadState> {
}
}

Future<String> downloadVideo(String videoUrl, Stream stream,
String streamName, String streamDate,) async {
Future<String> downloadVideo(
String videoUrl,
Stream stream,
String streamName,
String streamDate,
) async {
try {
final directory = await getApplicationDocumentsDirectory();
final filePath =
Expand All @@ -60,10 +64,12 @@ class DownloadViewModel extends StateNotifier<DownloadState> {
final videoDetailsMap = {
'filePath': filePath,
'name': streamName,
'duration': Tools.formatDuration(stream.end
.toDateTime()
.difference(stream.start.toDateTime())
.inMinutes,),
'duration': Tools.formatDuration(
stream.end
.toDateTime()
.difference(stream.start.toDateTime())
.inMinutes,
),
'description': stream.description,
'date': streamDate,
};
Expand Down
3 changes: 2 additions & 1 deletion lib/views/chat_view/chat_view_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class ChatViewState extends ConsumerState<ChatView> {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'You are sending messages too fast. Please wait a 60 seconds.',),
'You are sending messages too fast. Please wait a 60 seconds.',
),
),
);
});
Expand Down
3 changes: 2 additions & 1 deletion lib/views/chat_view/poll_view_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ class PollViewState extends ConsumerState<PollView> {

return Padding(
padding: const EdgeInsets.all(
8.0,), // Consistent padding with the rest of the layout
8.0,
), // Consistent padding with the rest of the layout
child: ElevatedButton(
onPressed: selectedOptions.containsKey(poll.id)
? () {
Expand Down
8 changes: 5 additions & 3 deletions lib/views/chat_view/suggested_streams_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class SuggestedStreamsWidget extends StatelessWidget {
final stream = suggestedStreams[index];
return ListTile(
leading: const Icon(Icons.play_circle_outline),
title: Text(stream.name != ''
? stream.name
: 'Lecture: ${DateFormat('EEEE. dd', Localizations.localeOf(context).toString()).format(stream.start.toDateTime())}',),
title: Text(
stream.name != ''
? stream.name
: 'Lecture: ${DateFormat('EEEE. dd', Localizations.localeOf(context).toString()).format(stream.start.toDateTime())}',
),
subtitle: Text(
DateFormat('dd MMMM yyyy').format(stream.start.toDateTime()),
),
Expand Down
7 changes: 5 additions & 2 deletions lib/views/course_view/components/course_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ class CourseCard extends StatelessWidget {
child: _buildCourseTitle(themeData.textTheme),
),
if (isPinned)
Icon(Icons.push_pin,
color: themeData.primaryColor, size: 16,),
Icon(
Icons.push_pin,
color: themeData.primaryColor,
size: 16,
),
],
),
),
Expand Down
10 changes: 8 additions & 2 deletions lib/views/course_view/components/small_stream_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,20 @@ class SmallStreamCard extends StatelessWidget {
}

Widget _buildStreamCard(
BuildContext context, ThemeData themeData, double cardWidth,) {
BuildContext context,
ThemeData themeData,
double cardWidth,
) {
return (isDownloaded != null && showDeleteConfirmationDialog != null)
? _buildDownloadedCard(context, themeData, cardWidth)
: _buildLiveCard(themeData, cardWidth);
}

Widget _buildDownloadedCard(
BuildContext context, ThemeData themeData, double cardWidth,) {
BuildContext context,
ThemeData themeData,
double cardWidth,
) {
return Slidable(
key: Key(courseId.toString()),
closeOnScroll: true,
Expand Down
10 changes: 6 additions & 4 deletions lib/views/course_view/components/stream_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ class StreamCardState extends ConsumerState<StreamCard> {
),
padding: const EdgeInsets.all(5),
child: Text(
Tools.formatDuration(widget.stream.end
.toDateTime()
.difference(widget.stream.start.toDateTime())
.inMinutes,),
Tools.formatDuration(
widget.stream.end
.toDateTime()
.difference(widget.stream.start.toDateTime())
.inMinutes,
),
style: themeData.textTheme.labelSmall?.copyWith(
fontSize: 12,
color: Colors.white,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ class DownloadCoursesContentView extends ConsumerWidget {
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 295.0),
child: Text(AppLocalizations.of(context)!
.no_downloaded_courses,),
child: Text(
AppLocalizations.of(context)!.no_downloaded_courses,
),
),
),
),
Expand Down
15 changes: 10 additions & 5 deletions lib/views/notifications_view/notifications_screen_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@ class NotificationsScreen extends ConsumerWidget {
scrollDirection: Axis.vertical,
children: [
_buildSectionHeader(
AppLocalizations.of(context)!.banner_notification,),
AppLocalizations.of(context)!.banner_notification,
),
for (var alert in bannerAlerts) _buildBannerAlert(alert),
_buildSectionHeader(
AppLocalizations.of(context)!.feature_notifications,),
AppLocalizations.of(context)!.feature_notifications,
),
for (var notification in featureNotifications)
_buildFeatureNotification(notification),
_buildSectionHeader(
AppLocalizations.of(context)!.recent_uploads,),
AppLocalizations.of(context)!.recent_uploads,
),
for (var notification in pushNotifications)
_buildPushNotification(notification),
],
Expand Down Expand Up @@ -76,8 +79,10 @@ class NotificationsScreen extends ConsumerWidget {
children: <Widget>[
Expanded(
child: Center(
child: Text(AppLocalizations.of(context)!
.no_notifications_found,),),
child: Text(
AppLocalizations.of(context)!.no_notifications_found,
),
),
),
],
),
Expand Down
54 changes: 28 additions & 26 deletions lib/views/on_boarding_view/welcome_screen_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,29 @@ class WelcomeScreen extends ConsumerWidget {
final connectivityStatus = ref.watch(connectivityProvider);
Logger().i(connectivityStatus.toString());
return connectivityStatus.when(
data: (result) {
// If there's no connectivity, navigate or replace the current view.
if (result == ConnectivityResult.none) {
WidgetsBinding.instance.addPostFrameCallback((_) {

if (ModalRoute.of(context)?.settings.name != '/downloads') {
Navigator.of(context).pushReplacementNamed('/downloads');
}
});
}
return _buildMainLayout(context, ref);
},
loading: () => const Center(child: CircularProgressIndicator()),
error: (error, stackTrace) {
return Center(
child: Text(
AppLocalizations.of(context)!.error_occurred,
style: const TextStyle(color: Colors.red),
),
);
},
data: (result) {
// If there's no connectivity, navigate or replace the current view.
if (result == ConnectivityResult.none) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (ModalRoute.of(context)?.settings.name != '/downloads') {
Navigator.of(context).pushReplacementNamed('/downloads');
}
});
}
return _buildMainLayout(context, ref);
},
loading: () => const Center(child: CircularProgressIndicator()),
error: (error, stackTrace) {
return Center(
child: Text(
AppLocalizations.of(context)!.error_occurred,
style: const TextStyle(color: Colors.red),
),
);
},
);
}


Widget _buildMainLayout(BuildContext context, WidgetRef ref) {
final screenSize = MediaQuery.of(context).size;
final bool isPortrait =
Expand Down Expand Up @@ -173,8 +171,10 @@ class WelcomeScreen extends ConsumerWidget {
valueColor: AlwaysStoppedAnimation<Color>(Colors.white),
),
)
: Text(AppLocalizations.of(context)!.tum_login,
style: const TextStyle(fontSize: 18),),
: Text(
AppLocalizations.of(context)!.tum_login,
style: const TextStyle(fontSize: 18),
),
onPressed: () => handleSSOLogin(context, ref),
);
}
Expand All @@ -190,8 +190,10 @@ class WelcomeScreen extends ConsumerWidget {
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(15.0)),
),
child: Text(AppLocalizations.of(context)!.continue_without,
style: const TextStyle(fontSize: 18),),
child: Text(
AppLocalizations.of(context)!.continue_without,
style: const TextStyle(fontSize: 18),
),
onPressed: () {
Navigator.pushNamed(context, '/publiccourses');
},
Expand Down
8 changes: 5 additions & 3 deletions lib/views/settings_view/edit_profile_screen_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ class EditProfileScreenState extends ConsumerState<EditProfileScreen> {
return AlertDialog(
backgroundColor: Theme.of(context).colorScheme.onPrimary,
title: const Text("Error"),
content: Text(errorMessage == '3 months'
? AppLocalizations.of(context)!.name_change_limitation
: errorMessage,),
content: Text(
errorMessage == '3 months'
? AppLocalizations.of(context)!.name_change_limitation
: errorMessage,
),
actions: <Widget>[
TextButton(
child: const Text("OK"),
Expand Down
7 changes: 5 additions & 2 deletions lib/views/settings_view/settings_screen_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
_buildProfileTile(userState),
const Divider(),
_buildSectionTitle(
AppLocalizations.of(context)!.account_settings,),
AppLocalizations.of(context)!.account_settings,
),
_buildEditableListTile(AppLocalizations.of(context)!.edit_profile,
() async {
bool isAuthenticated =
Expand Down Expand Up @@ -90,7 +91,9 @@ class _SettingsScreenState extends ConsumerState<SettingsScreen> {
const Divider(),
_buildSectionTitle(AppLocalizations.of(context)!.more),
_buildNavigableListTile(
AppLocalizations.of(context)!.about_us, "",),
AppLocalizations.of(context)!.about_us,
"",
),
_buildNavigableListTile(
AppLocalizations.of(context)!.privacy_policy,
"https://live.rbg.tum.de/privacy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class OfflineVideoPlayerPageState
// Initialize the controller manager.
void _initializeControllerManager() {
_controllerManager = OfflineVideoPlayerControllerManager(
localPath: widget.videoDetails.filePath,);
localPath: widget.videoDetails.filePath,
);
}

// Initialize the video player and seek to the last progress.
Expand Down
12 changes: 8 additions & 4 deletions lib/views/video_view/utils/download_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ class DownloadService {
});

Future<void> downloadVideo(
Stream stream, String type, String streamName, String streamDate,) async {
Stream stream,
String type,
String streamName,
String streamDate,
) async {
bool canDownload = await _handleDownloadConnectivity(stream, type);
if (!canDownload) return;

Expand All @@ -54,9 +58,9 @@ class DownloadService {
.downloadVideo(downloadUrl, stream, streamName, streamDate)
.then((localPath) {
if (!isWidgetMounted()) return;
onShowSnackBar(localPath.isNotEmpty
? downloadCompletedMessage
: downloadFailedMessage,);
onShowSnackBar(
localPath.isNotEmpty ? downloadCompletedMessage : downloadFailedMessage,
);
});
}

Expand Down

0 comments on commit 4c08d86

Please sign in to comment.