Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pfe master f3.1 #1003

Merged
merged 29 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f90f55d
implementation of seperate widgets for about_view
charlcl180 Jun 29, 2024
5457642
implementation of seperation widget of author_view
charlcl180 Jun 29, 2024
9889248
impementation of seperation widget of choose_language_view
charlcl180 Jun 29, 2024
eaf523c
implementation of seperation widget of contributors_view
charlcl180 Jun 29, 2024
f9b25f5
implementation of seperation widget of emergency_view
charlcl180 Jun 29, 2024
d8fdb39
implementation of seperation widget of faq_view
charlcl180 Jun 29, 2024
ac8e3da
implementation of seperation widget of feedback view
charlcl180 Jun 29, 2024
7e4605e
implementation of seperation widget of more_view
charlcl180 Jun 29, 2024
ae6a2d5
implementation of seperation widget of grade_view
charlcl180 Jun 29, 2024
be9d469
implementation of seperation widget of grade_details_view +contributors
charlcl180 Jun 29, 2024
b4c34c8
implementation of seperation widget of login_view
charlcl180 Jun 29, 2024
737ab1c
[BOT] Applying format.
charlcl180 Jun 29, 2024
78bab18
fix for test to pass
charlcl180 Jun 29, 2024
6ad718e
Merge branch 'PFE-master-F3.1' of https://github.com/ApplETS/Notre-Da…
charlcl180 Jun 29, 2024
8783679
change name grade session courses
charlcl180 Jun 29, 2024
ddbe929
change in more_view
charlcl180 Jun 29, 2024
3fc8315
[BOT] Applying format.
charlcl180 Jun 29, 2024
d9d39c8
change for warning and imports
charlcl180 Jun 29, 2024
eb47836
Merge branch 'PFE-master-F3.1' of https://github.com/ApplETS/Notre-Da…
charlcl180 Jun 29, 2024
2e26f20
[BOT] Applying format.
charlcl180 Jun 29, 2024
3105a84
change test more_view
charlcl180 Jun 29, 2024
a009e84
Merge branch 'PFE-master-F3.1' of https://github.com/ApplETS/Notre-Da…
charlcl180 Jun 29, 2024
2233b98
change moreview model
charlcl180 Jun 29, 2024
b9780d0
change more view model
charlcl180 Jun 29, 2024
6d67ad5
implementation of seperation widget of dashboard_view
charlcl180 Jun 30, 2024
faab77f
fix so app works but need insert the widgets
charlcl180 Jun 30, 2024
f01dc25
[BOT] Applying format.
charlcl180 Jul 2, 2024
be0b6e7
Fix more viewmodels tests
XavierPaquet-Rapold Jul 6, 2024
5776616
[BOT] Update golden files
XavierPaquet-Rapold Jul 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
418 changes: 81 additions & 337 deletions lib/features/ets/events/author/author_view.dart

Large diffs are not rendered by default.

20 changes: 6 additions & 14 deletions lib/features/ets/events/author/author_viewmodel.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// Package imports:
import 'package:ets_api_clients/models.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:stacked/stacked.dart';

// Project imports:
import 'package:notredame/features/app/repository/author_repository.dart';
import 'package:notredame/features/app/repository/news_repository.dart';
import 'package:notredame/utils/locator.dart';
Expand All @@ -14,15 +11,10 @@ class AuthorViewModel extends BaseViewModel implements Initialisable {
final AuthorRepository _authorRepository = locator<AuthorRepository>();
final NewsRepository _newsRepository = locator<NewsRepository>();

/// Localization class of the application.
final AppIntl appIntl;

final String authorId;

/// Author
Organizer? _author;

/// Return the author
Organizer? get author => _author;

final PagingController<int, News> pagingController =
Expand All @@ -35,7 +27,6 @@ class AuthorViewModel extends BaseViewModel implements Initialisable {

@override
Future<void> initialise() async {
// This will be called when init state cycle runs
pagingController.addPageRequestListener((pageKey) {
fetchPage(pageKey);
});
Expand All @@ -58,16 +49,17 @@ class AuthorViewModel extends BaseViewModel implements Initialisable {
}

void notifyMe() {
// TODO activate/deactivate notifications
isNotified = !isNotified;
if (isNotified) {
Fluttertoast.showToast(
msg: appIntl.news_author_notified_for(author?.organization ?? ""),
toastLength: Toast.LENGTH_LONG);
msg: appIntl.news_author_notified_for(author?.organization ?? ""),
toastLength: Toast.LENGTH_LONG,
);
} else {
Fluttertoast.showToast(
msg: appIntl.news_author_not_notified_for(author?.organization ?? ""),
toastLength: Toast.LENGTH_LONG);
msg: appIntl.news_author_not_notified_for(author?.organization ?? ""),
toastLength: Toast.LENGTH_LONG,
);
}
}

Expand Down
111 changes: 111 additions & 0 deletions lib/features/ets/events/author/widget/author_info_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:notredame/features/ets/events/author/author_info_skeleton.dart';
import 'package:notredame/features/ets/events/social/models/social_link.dart';
import 'package:notredame/features/ets/events/social/social_links_card.dart';
import 'package:notredame/features/ets/events/author/author_viewmodel.dart';
import 'package:notredame/utils/utils.dart';
import 'package:notredame/utils/app_theme.dart';
import 'package:stacked/stacked.dart';

class AuthorInfoWidget extends ViewModelWidget<AuthorViewModel> {
const AuthorInfoWidget({super.key});

@override
Widget build(BuildContext context, AuthorViewModel model) {
final author = model.author;

List<SocialLink> socialLinks = [];
if (author != null) {
socialLinks = [
if (author.email != null)
SocialLink(id: 0, name: 'Email', link: author.email!),
if (author.facebookLink != null)
SocialLink(id: 1, name: 'Facebook', link: author.facebookLink!),
if (author.instagramLink != null)
SocialLink(id: 2, name: 'Instagram', link: author.instagramLink!),
if (author.tikTokLink != null)
SocialLink(id: 3, name: 'TikTok', link: author.tikTokLink!),
if (author.xLink != null)
SocialLink(id: 4, name: 'X', link: author.xLink!),
if (author.redditLink != null)
SocialLink(id: 5, name: 'Reddit', link: author.redditLink!),
if (author.discordLink != null)
SocialLink(id: 6, name: 'Discord', link: author.discordLink!),
if (author.linkedInLink != null)
SocialLink(id: 7, name: 'LinkedIn', link: author.linkedInLink!),
];
}

return Padding(
padding: const EdgeInsets.only(top: 76),
child: model.isBusy
? AuthorInfoSkeleton()
: SizedBox(
width: double.infinity,
child: Card(
color: Utils.getColorByBrightnessNullable(
context, AppTheme.newsSecondaryColor, null),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16)),
child: Container(
padding: const EdgeInsets.fromLTRB(32, 64, 32, 16),
child: Column(
children: [
if (author?.organization != null ||
author?.organization != "")
Text(
author?.organization ?? "",
style: const TextStyle(fontSize: 26),
),
if (author?.organization != null &&
author?.organization != "")
const SizedBox(height: 8),
if (author?.profileDescription != null &&
author?.profileDescription != "")
Text(
author?.profileDescription ?? "",
style: TextStyle(
color: Utils.getColorByBrightness(
context,
AppTheme.etsDarkGrey,
AppTheme.newsSecondaryColor),
fontSize: 16,
),
textAlign: TextAlign.center,
),
if (author?.profileDescription != null &&
author?.profileDescription != "")
const SizedBox(height: 8),
IconButton(
onPressed: () async {
await showModalBottomSheet(
isDismissible: true,
enableDrag: true,
isScrollControlled: true,
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10)),
),
builder: (context) =>
SocialLinks(socialLinks: socialLinks),
);
},
icon: FaIcon(
FontAwesomeIcons.link,
color: Utils.getColorByBrightness(
context,
AppTheme.newsAccentColorLight,
AppTheme.newsAccentColorDark),
),
),
],
),
),
),
),
);
}
}
73 changes: 73 additions & 0 deletions lib/features/ets/events/author/widget/avatar_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import 'package:flutter/material.dart';
import 'package:notredame/features/ets/events/author/author_info_skeleton.dart';
import 'package:notredame/features/ets/events/author/author_viewmodel.dart';
import 'package:notredame/utils/utils.dart';
import 'package:notredame/utils/app_theme.dart';
import 'package:stacked/stacked.dart';

class AvatarWidget extends ViewModelWidget<AuthorViewModel> {
const AvatarWidget({super.key});

@override
Widget build(BuildContext context, AuthorViewModel model) {
return model.isBusy
? AvatarSkeleton()
: Align(
alignment: Alignment.topCenter,
child: Padding(
padding: const EdgeInsets.only(top: 16),
child: SizedBox(
width: 120,
height: 120,
child: Hero(
tag: 'news_author_avatar',
child: CircleAvatar(
backgroundColor: Utils.getColorByBrightness(context,
AppTheme.lightThemeAccent, AppTheme.darkThemeAccent),
child: Stack(
fit: StackFit.expand,
children: [
if (model.author?.avatarUrl != null &&
model.author!.avatarUrl != "")
ClipRRect(
borderRadius: BorderRadius.circular(120),
child: Image.network(
model.author!.avatarUrl!,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return Center(
child: Text(
model.author?.organization
?.substring(0, 1) ??
'',
style: TextStyle(
fontSize: 56,
color: Utils.getColorByBrightness(
context,
Colors.black,
Colors.white)),
),
);
},
),
),
if (model.author?.avatarUrl == null ||
model.author!.avatarUrl == "")
Center(
child: Text(
model.author?.organization?.substring(0, 1) ?? '',
style: TextStyle(
fontSize: 56,
color: Utils.getColorByBrightness(
context, Colors.black, Colors.white)),
),
),
],
),
),
),
),
),
);
}
}
13 changes: 13 additions & 0 deletions lib/features/ets/events/author/widget/back_button_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';

class BackButtonWidget extends StatelessWidget {
const BackButtonWidget({super.key});

@override
Widget build(BuildContext context) {
return IconButton(
icon: const Icon(Icons.arrow_back),
onPressed: () => Navigator.of(context).pop(),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class NoMoreNewsCardWidget extends StatelessWidget {
const NoMoreNewsCardWidget({super.key});

@override
Widget build(BuildContext context) {
return Column(
children: [
const SizedBox(height: 16),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Divider(),
),
const SizedBox(height: 16),
Card(
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: const EdgeInsets.fromLTRB(0, 8, 8, 8),
child: Row(
children: [
const Icon(Icons.check, color: Colors.blue, size: 40),
const SizedBox(width: 16),
Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(AppIntl.of(context)!.news_no_more_card_title,
style: const TextStyle(fontSize: 24)),
const SizedBox(height: 16),
Text(
AppIntl.of(context)!.news_no_more_card,
textAlign: TextAlign.justify,
),
],
),
),
],
),
),
],
),
),
),
],
);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
// Flutter imports:
import 'package:flutter/material.dart';

// Package imports:
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:notredame/features/ets/quick-link/widgets/security-info/widget/emergency_floating_button.dart';
import 'package:webview_flutter/webview_flutter.dart';

// Project imports:
import 'package:notredame/features/app/presentation/webview_controller_extension.dart';
import 'package:notredame/utils/utils.dart';
import 'package:notredame/utils/app_theme.dart';

class EmergencyView extends StatefulWidget {
final String title;
Expand All @@ -25,26 +18,11 @@ class _EmergencyViewState extends State<EmergencyView> {
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: Text(widget.title)),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton.extended(
onPressed: () {
Utils.launchURL(
'tel:${AppIntl.of(context)!.security_emergency_number}',
AppIntl.of(context)!)
.catchError((error) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(error.toString())));
});
},
label: Text(
AppIntl.of(context)!.security_reach_security,
style: const TextStyle(color: Colors.white, fontSize: 20),
),
icon: const Icon(Icons.phone, size: 30, color: Colors.white),
backgroundColor: AppTheme.etsLightRed,
),
floatingActionButton: const EmergencyFloatingButton(),
body: WebViewWidget(
controller: WebViewControllerExtension(WebViewController())
..loadHtmlFromAssets(
widget.description, Theme.of(context).brightness)),
controller: WebViewControllerExtension(WebViewController())
..loadHtmlFromAssets(
widget.description, Theme.of(context).brightness),
),
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:notredame/utils/utils.dart';
import 'package:notredame/utils/app_theme.dart';

class EmergencyFloatingButton extends StatelessWidget {
const EmergencyFloatingButton({super.key});

@override
Widget build(BuildContext context) {
return FloatingActionButton.extended(
onPressed: () {
Utils.launchURL('tel:${AppIntl.of(context)!.security_emergency_number}',
AppIntl.of(context)!)
.catchError((error) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(error.toString())));
});
},
label: Text(
AppIntl.of(context)!.security_reach_security,
style: const TextStyle(color: Colors.white, fontSize: 20),
),
icon: const Icon(Icons.phone, size: 30, color: Colors.white),
backgroundColor: AppTheme.etsLightRed,
);
}
}
Loading
Loading