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

Allow resizing schedule settings #899

Merged
merged 58 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
962b933
Permettre de modifier la taille
LouisPhilippeHeon Nov 21, 2023
82dab70
Fonctionne, excepté que je n'ai pas pu mettre le listtiletheme
LouisPhilippeHeon Nov 22, 2023
813e999
Fixed visual bugs
LouisPhilippeHeon Nov 23, 2023
015b433
Fix pas d'update du calendrier
LouisPhilippeHeon Nov 23, 2023
056476c
Fix tests
LouisPhilippeHeon Nov 24, 2023
13908f5
Merge branch 'master' into Allow-resizing-schedule-settings
LouisPhilippeHeon Nov 24, 2023
1a52739
[BOT] Applying version.
LouisPhilippeHeon Nov 24, 2023
6c1c633
[BOT] Applying format.
clubapplets-server Nov 24, 2023
0ef86e8
[BOT] Update golden files
clubapplets-server Nov 24, 2023
3a0fd1e
Adding tests
LouisPhilippeHeon Jan 5, 2024
b3b59c3
[BOT] Applying format.
LouisPhilippeHeon Jan 5, 2024
0ba6dcd
Migrate service classes to null safety
XavierPaquet-Rapold Nov 22, 2023
e59042f
Migrate constants to null safety
XavierPaquet-Rapold Nov 22, 2023
06cba3c
Migrate utils to null safety
XavierPaquet-Rapold Nov 22, 2023
42d49db
Remove late from GetIt
XavierPaquet-Rapold Nov 22, 2023
c433746
Change @required to required
XavierPaquet-Rapold Nov 22, 2023
e0a239d
Migrate models to null safety
XavierPaquet-Rapold Nov 22, 2023
43d3c5d
Migrate main to null safety
XavierPaquet-Rapold Nov 22, 2023
958ae5d
Migrate managers to null safety
XavierPaquet-Rapold Nov 23, 2023
c78948f
Migrate ViewModels to null safety
XavierPaquet-Rapold Dec 21, 2023
e1b0049
Migrate utils to null safety
XavierPaquet-Rapold Dec 23, 2023
2b3baac
Migrate views to null safety
XavierPaquet-Rapold Dec 23, 2023
483ea4e
Migrate Views to null safety
XavierPaquet-Rapold Dec 23, 2023
e1d8ec2
Migrate mocks to null safety
XavierPaquet-Rapold Jan 4, 2024
e4793a1
Use late for all tests
XavierPaquet-Rapold Jan 4, 2024
b7ecc25
Fix service tests
XavierPaquet-Rapold Jan 4, 2024
354b5be
Migrate helpers to null safety
XavierPaquet-Rapold Jan 4, 2024
8b14791
Migrate managers tests to null safety
XavierPaquet-Rapold Jan 4, 2024
2b87b6a
Migrate ViewModel tests to null safety
XavierPaquet-Rapold Jan 4, 2024
4efbf6b
Managers use mocks for managers
XavierPaquet-Rapold Jan 4, 2024
0aa1bcb
Migrate widget tests to null safety
XavierPaquet-Rapold Jan 4, 2024
7f6217a
Migrate views tests to null safety
XavierPaquet-Rapold Jan 4, 2024
7777171
Fix course_repository_test
XavierPaquet-Rapold Jan 5, 2024
e189861
Fix QuickLinkRepository tests
XavierPaquet-Rapold Jan 5, 2024
eec1cf0
Fix SettingsManagerTests
XavierPaquet-Rapold Jan 5, 2024
970abc7
Fix user repository tests
XavierPaquet-Rapold Jan 5, 2024
eedf8d4
Fix GradeEvaluationTile tests
XavierPaquet-Rapold Jan 8, 2024
559b363
Fix code problems
XavierPaquet-Rapold Jan 8, 2024
3720fe3
Fix DashboardViewModel tests
XavierPaquet-Rapold Jan 8, 2024
d7dc916
Fix FeedbackViewModelTest
XavierPaquet-Rapold Jan 13, 2024
f8c682c
Fix GradeViewModel tests
XavierPaquet-Rapold Jan 13, 2024
fa78729
Fix UserRepositoryMock tests
XavierPaquet-Rapold Jan 13, 2024
604748b
Fix ScheduleSettingsViewModel tests
XavierPaquet-Rapold Jan 13, 2024
2a2e8b2
Fix ScheduleViewModel tests
XavierPaquet-Rapold Jan 13, 2024
604875e
Fix GradeDetailsView tests
XavierPaquet-Rapold Jan 19, 2024
d802300
Fix NotFoundView test
XavierPaquet-Rapold Jan 20, 2024
c70d720
Fix GradeDetailsViewModel tests
XavierPaquet-Rapold Jan 21, 2024
037b648
Fix ScheduleViewModel tests
XavierPaquet-Rapold Jan 22, 2024
51e0f07
Remove use of Future OnError
XavierPaquet-Rapold Feb 1, 2024
3ab1d83
Merge branch 'feature/68-migration-to-null-safety' into Allow-resizin…
LouisPhilippeHeon Feb 6, 2024
fb67612
[BOT] Applying version.
LouisPhilippeHeon Feb 6, 2024
e2f8bf8
[BOT] Applying format.
clubapplets-server Feb 6, 2024
6a99b9c
Merge branch 'master' into Allow-resizing-schedule-settings
LouisPhilippeHeon Mar 14, 2024
6b98154
[BOT] Applying version.
LouisPhilippeHeon Mar 14, 2024
5e17aae
Fix warning
LouisPhilippeHeon Mar 14, 2024
3897ad9
Merge branch 'Allow-resizing-schedule-settings' of https://github.com…
LouisPhilippeHeon Mar 14, 2024
99cad53
Fix test
LouisPhilippeHeon Mar 15, 2024
e393020
[BOT] Update golden files
LouisPhilippeHeon Mar 15, 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
16 changes: 9 additions & 7 deletions lib/ui/views/schedule_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class _ScheduleViewState extends State<ScheduleView>
ViewModelBuilder<ScheduleViewModel>.reactive(
viewModelBuilder: () => ScheduleViewModel(
intl: AppIntl.of(context)!, initialSelectedDate: widget.initialDay),
onModelReady: (model) {
if (model.settings.isEmpty) {
model.loadSettings();
}
},
builder: (context, model, child) => BaseScaffold(
isLoading: model.busy(model.isLoadingEvents),
isInteractionLimitedWhileLoading: false,
Expand Down Expand Up @@ -511,14 +516,11 @@ class _ScheduleViewState extends State<ScheduleView>
onPressed: () async {
_analyticsService.logEvent(tag, "Settings clicked");
await showModalBottomSheet(
isDismissible: true,
enableDrag: true,
isScrollControlled: true,
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
topRight: Radius.circular(10))),
borderRadius:
BorderRadius.vertical(top: Radius.circular(10))),
context: context,
isScrollControlled: true,
builder: (context) => const ScheduleSettings());
model.loadSettings();
}));
Expand Down
129 changes: 72 additions & 57 deletions lib/ui/widgets/schedule_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,65 +27,80 @@ class _ScheduleSettingsState extends State<ScheduleSettings> {

@override
Widget build(BuildContext context) => ViewModelBuilder.reactive(
viewModelBuilder: () => ScheduleSettingsViewModel(),
builder: (context, model, child) => SizedBox(
height: MediaQuery.of(context).size.height * 0.50,
child: Column(
children: [
if (widget.showHandle)
Container(
decoration: BoxDecoration(
color: Utils.getColorByBrightness(
context,
AppTheme.lightThemeBackground,
AppTheme.darkThemeBackground),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(40.0),
topRight: Radius.circular(40.0),
)),
child: Center(
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
height: 5,
width: 50,
decoration: const BoxDecoration(
color: Colors.grey,
borderRadius:
BorderRadius.all(Radius.circular(8.0))),
viewModelBuilder: () => ScheduleSettingsViewModel(),
builder: (context, model, child) => ClipRRect(
borderRadius: const BorderRadius.vertical(top: Radius.circular(10)),
child: DraggableScrollableSheet(
maxChildSize: 0.85,
minChildSize: 0.5,
initialChildSize: 0.55,
expand: false,
snap: true,
snapSizes: const [
0.55,
0.85,
],
builder: (context, ScrollController scrollController) {
LouisPhilippeHeon marked this conversation as resolved.
Show resolved Hide resolved
return Column(children: [
if (widget.showHandle)
Container(
decoration: BoxDecoration(
color: Utils.getColorByBrightness(
context,
AppTheme.lightThemeBackground,
AppTheme.darkThemeBackground),
),
child: Center(
child: Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Container(
height: 5,
width: 50,
decoration: const BoxDecoration(
color: Colors.grey,
borderRadius:
BorderRadius.all(Radius.circular(8.0))),
),
),
),
),
Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Utils.getColorByBrightness(
context,
AppTheme.lightThemeBackground,
AppTheme.darkThemeBackground),
),
child: Center(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 20),
child: Text(
AppIntl.of(context)!.schedule_settings_title,
style: Theme.of(context).textTheme.headline6)),
),
),
),
),
Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Utils.getColorByBrightness(
context,
AppTheme.lightThemeBackground,
AppTheme.darkThemeBackground),
),
child: Center(
child: Padding(
padding: const EdgeInsets.fromLTRB(15, 20, 20, 20),
child: Text(AppIntl.of(context)!.schedule_settings_title,
style: Theme.of(context).textTheme.headline6)),
),
),
Expanded(
child: ListTileTheme(
selectedColor: Theme.of(context).textTheme.bodyText1!.color,
child: ListView(
key: const ValueKey("SettingsScrollingArea"),
children: _buildSettings(
context, model! as ScheduleSettingsViewModel),
),
),
),
],
),
),
);
Expanded(
child: ListTileTheme(
selectedColor:
Theme.of(context).textTheme.bodyText1!.color,
child: Card(
margin: EdgeInsets.zero,
elevation: 0,
shape: const RoundedRectangleBorder(),
color: Colors.transparent,
child: ListView(
controller: scrollController,
key: const ValueKey("SettingsScrollingArea"),
children: _buildSettings(
context, model! as ScheduleSettingsViewModel),
),
),
),
)
]);
}),
));

List<Widget> _buildSettings(
BuildContext context, ScheduleSettingsViewModel model) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: The 4th generation of ÉTSMobile, the main gateway between the Éco
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 4.34.0+1
version: 4.35.0+1

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
Binary file modified test/ui/widgets/goldenFiles/scheduleSettingsView_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 32 additions & 3 deletions test/ui/widgets/schedule_settings_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ void main() {
expect(
find.byWidgetPredicate((widget) =>
widget is Container &&
widget.decoration is BoxDecoration &&
(widget.decoration! as BoxDecoration).color == Colors.grey),
findsOneWidget,
reason: "The handle should be grey");
Expand Down Expand Up @@ -171,6 +172,20 @@ void main() {
isA<Switch>().having((source) => source.value, 'value', isTrue),
reason:
"the settings says that the showTodayBtn is enabled, the UI should reflet that.");

const screenHeight = 600;

final draggableScrollableSheetFinder =
find.byType(DraggableScrollableSheet);
expect(draggableScrollableSheetFinder, findsOneWidget);

final Size initialSize = tester.getSize(draggableScrollableSheetFinder);
expect(initialSize.height, 0.55 * screenHeight);

await tester.fling(
find.byType(ListView), const Offset(0.0, -4000.0), 400.0);
final Size maxSize = tester.getSize(draggableScrollableSheetFinder);
expect(maxSize.height, 0.85 * screenHeight);
});

testWidgets("Without handle", (WidgetTester tester) async {
Expand All @@ -184,6 +199,7 @@ void main() {
expect(
find.byWidgetPredicate((widget) =>
widget is Container &&
widget.decoration is BoxDecoration &&
(widget.decoration! as BoxDecoration).color == Colors.grey),
findsNothing,
reason: "There should not have a handle.");
Expand Down Expand Up @@ -256,6 +272,20 @@ void main() {
isA<Switch>().having((source) => source.value, 'value', isTrue),
reason:
"the settings says that the showTodayBtn is enabled, the UI should reflet that.");

const screenHeight = 600;

final draggableScrollableSheetFinder =
find.byType(DraggableScrollableSheet);
expect(draggableScrollableSheetFinder, findsOneWidget);

final Size initialSize = tester.getSize(draggableScrollableSheetFinder);
expect(initialSize.height, 0.55 * screenHeight);

await tester.fling(
find.byType(ListView), const Offset(0.0, -4000.0), 400.0);
final Size maxSize = tester.getSize(draggableScrollableSheetFinder);
expect(maxSize.height, 0.85 * screenHeight);
});
});

Expand Down Expand Up @@ -400,9 +430,8 @@ void main() {
ListTile, intl.schedule_settings_show_today_btn_pref,
skipOffstage: false);

expect(find.byType(Switch, skipOffstage: false), findsOneWidget);
// Currently the await tester.tap on a switch in a tile isn't working. Workaround:
(find.byType(Switch, skipOffstage: false).evaluate().single.widget
expect(find.byType(Switch, skipOffstage: false), findsNWidgets(2));
(find.byType(Switch, skipOffstage: false).evaluate().first.widget
as Switch)
.onChanged!(false);

Expand Down
Loading