Skip to content

Commit

Permalink
Bugfix/remove heuristique (#165)
Browse files Browse the repository at this point in the history
* removed heuristique

* add analytics on clicks

* fix language showing system

* removed unused import and updated version

* [CI UPDATE GOLDENS]

* [CI UPDATE GOLDENS]

fixed tests

* Update golden files

Co-authored-by: AlexandreMarkus <[email protected]>
  • Loading branch information
AlexandreMarkus and AlexandreMarkus authored Jul 22, 2021
1 parent d184b07 commit 08fd695
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 45 deletions.
Binary file removed assets/images/ic_heuristique_red.png
Binary file not shown.
7 changes: 0 additions & 7 deletions lib/core/constants/quick_links.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ List<QuickLink> quickLinks(AppIntl intl) => [
color: AppTheme.etsLightRed,
),
link: 'https://ena.etsmtl.ca/'),
QuickLink(
name: intl.ets_heuristique_title,
image: Image.asset(
'assets/images/ic_heuristique_red.png',
color: AppTheme.etsLightRed,
),
link: 'http://lheuristique.ca'),
QuickLink(
name: intl.ets_schedule_generator,
image: const FaIcon(
Expand Down
14 changes: 4 additions & 10 deletions lib/core/viewmodels/settings_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import 'package:flutter/material.dart';
import 'package:stacked/stacked.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

// CONSTANTS
import 'package:notredame/core/constants/preferences_flags.dart';

// MANAGER
import 'package:notredame/core/managers/settings_manager.dart';

Expand Down Expand Up @@ -39,7 +36,7 @@ class SettingsViewModel extends FutureViewModel {
} else if (_currentLocale == AppIntl.supportedLocales.last.languageCode) {
return _appIntl.settings_french;
} else {
return _appIntl.system_theme;
return "";
}
}

Expand All @@ -54,12 +51,9 @@ class SettingsViewModel extends FutureViewModel {
@override
Future futureToRun() async {
setBusy(true);
await _settingsManager.getString(PreferencesFlag.theme).then((value) =>
_selectedTheme =
ThemeMode.values.firstWhere((e) => e.toString() == value));
await _settingsManager
.getString(PreferencesFlag.locale)
.then((value) => _currentLocale = value);
await _settingsManager.fetchLanguageAndThemeMode();
_currentLocale = _settingsManager.locale.languageCode;
_selectedTheme = _settingsManager.themeMode;
setBusy(false);
return true;
}
Expand Down
1 change: 1 addition & 0 deletions lib/core/viewmodels/web_link_card_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class WebLinkCardViewModel extends BaseViewModel {

/// used to open a website or the security view
Future<void> onLinkClicked(QuickLink link) async {
_analyticsService.logEvent("QuickLink", "QuickLink clicked: ${link.name}");
if (link.link == 'security') {
_navigationService.pushNamed(RouterPaths.security);
} else {
Expand Down
43 changes: 25 additions & 18 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ packages:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.3"
built_collection:
dependency: transitive
description:
Expand Down Expand Up @@ -84,7 +84,7 @@ packages:
name: cli_util
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.1"
version: "0.3.3"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -154,7 +154,7 @@ packages:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.2"
enum_to_string:
dependency: "direct main"
description:
Expand Down Expand Up @@ -210,7 +210,7 @@ packages:
name: firebase_analytics
url: "https://pub.dartlang.org"
source: hosted
version: "8.1.2"
version: "8.2.0"
firebase_analytics_platform_interface:
dependency: transitive
description:
Expand All @@ -231,7 +231,7 @@ packages:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.4.0"
firebase_core_platform_interface:
dependency: transitive
description:
Expand All @@ -252,14 +252,14 @@ packages:
name: firebase_crashlytics
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
version: "2.1.1"
firebase_crashlytics_platform_interface:
dependency: transitive
description:
name: firebase_crashlytics_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.6"
version: "3.1.0"
fixnum:
dependency: transitive
description:
Expand Down Expand Up @@ -363,7 +363,7 @@ packages:
name: get_it
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.1"
version: "7.2.0"
github:
dependency: "direct main"
description:
Expand Down Expand Up @@ -482,7 +482,7 @@ packages:
name: mockito
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.10"
version: "5.0.11"
nested:
dependency: transitive
description:
Expand Down Expand Up @@ -594,7 +594,7 @@ packages:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.1"
process:
dependency: transitive
description:
Expand Down Expand Up @@ -622,7 +622,7 @@ packages:
name: rive
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.22"
version: "0.7.23"
rxdart:
dependency: transitive
description:
Expand Down Expand Up @@ -690,7 +690,7 @@ packages:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
version: "1.0.3"
source_span:
dependency: transitive
description:
Expand Down Expand Up @@ -725,7 +725,7 @@ packages:
name: stacked
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.6"
version: "2.2.2"
stream_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -760,7 +760,7 @@ packages:
name: table_calendar
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.1"
term_glyph:
dependency: transitive
description:
Expand All @@ -782,13 +782,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
universal_io:
dependency: transitive
description:
name: universal_io
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.7"
version: "6.0.9"
url_launcher_linux:
dependency: transitive
description:
Expand All @@ -809,7 +816,7 @@ packages:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.0.4"
url_launcher_web:
dependency: transitive
description:
Expand Down Expand Up @@ -851,14 +858,14 @@ packages:
name: webview_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
version: "2.0.10"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.4"
version: "2.2.5"
xdg_directories:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 4.1.1+1
version: 4.1.2+1

environment:
sdk: ">=2.10.0 <3.0.0"
Expand All @@ -28,7 +28,7 @@ dependencies:
intl: ^0.17.0

# Architecture
get_it: ^6.1.1
get_it: ^7.2.0
provider: ^5.0.0
stacked: ^2.1.0

Expand Down
8 changes: 7 additions & 1 deletion test/mock/managers/settings_manager_mock.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// FLUTTER / DART / THIRD-PARTIES
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:mockito/mockito.dart';

// MANAGER
Expand Down Expand Up @@ -50,4 +50,10 @@ class SettingsManagerMock extends Mock implements SettingsManager {
{Locale toReturn = const Locale('en')}) {
when(mock.locale).thenReturn(toReturn);
}

/// Stub the [themeMode] function of [mock], when called return [toReturn].
static void stubThemeMode(SettingsManagerMock mock,
{ThemeMode toReturn = ThemeMode.system}) {
when(mock.themeMode).thenReturn(toReturn);
}
}
Binary file modified test/ui/views/goldenFiles/quicksLinksView_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/ui/views/goldenFiles/settingsView_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 8 additions & 7 deletions test/viewmodels/settings_viewmodel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ void main() {

group("futureToRun - ", () {
test("The settings are correctly loaded and sets", () async {
SettingsManagerMock.stubGetString(
settingsManager as SettingsManagerMock, PreferencesFlag.locale,
toReturn: 'en');
SettingsManagerMock.stubLocale(settingsManager as SettingsManagerMock);

SettingsManagerMock.stubGetString(
settingsManager as SettingsManagerMock, PreferencesFlag.theme,
toReturn: ThemeMode.system.toString());
SettingsManagerMock.stubThemeMode(
settingsManager as SettingsManagerMock);

await viewModel.futureToRun();
expect(viewModel.currentLocale, 'English');
expect(viewModel.selectedTheme, ThemeMode.system);

verify(settingsManager.getString(any)).called(2);
verifyInOrder([
settingsManager.fetchLanguageAndThemeMode(),
settingsManager.locale,
settingsManager.themeMode
]);
verifyNoMoreInteractions(settingsManager);
});
});
Expand Down

0 comments on commit 08fd695

Please sign in to comment.