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

Replace dart dependencies #1077

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 3 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
include: package:lint/analysis_options.yaml
include: package:flutter_lints/flutter.yaml

linter:
rules:
sort_pub_dependencies: false
directives_ordering: false
require_trailing_commas: false
depend_on_referenced_packages: false
library_private_types_in_public_api: false
use_key_in_widget_constructors: false
analyzer:
exclude:
- "lib/generated"
Expand Down
3 changes: 1 addition & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ if (keystorePropertiesFile.exists()) {
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply from: project(':flutter_config').projectDir.getPath() + "/dotenv.gradle"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

Expand All @@ -50,7 +49,7 @@ android {
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
manifestPlaceholders += [mapsApiKey: project.env.get("MAPS_API_KEY") ?:"$System.env.MAPS_API_KEY"]
manifestPlaceholders += [mapsApiKey: "$System.env.MAPS_API_KEY"]
}

signingConfigs {
Expand Down
6 changes: 0 additions & 6 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ PODS:
- PromisesSwift (~> 2.1)
- FirebaseSharedSwift (10.29.0)
- Flutter (1.0.0)
- flutter_config (0.0.1):
- Flutter
- flutter_custom_tabs_ios (2.0.0):
- Flutter
- flutter_secure_storage (6.0.0):
Expand Down Expand Up @@ -205,7 +203,6 @@ DEPENDENCIES:
- firebase_crashlytics (from `.symlinks/plugins/firebase_crashlytics/ios`)
- firebase_remote_config (from `.symlinks/plugins/firebase_remote_config/ios`)
- Flutter (from `Flutter`)
- flutter_config (from `.symlinks/plugins/flutter_config/ios`)
- flutter_custom_tabs_ios (from `.symlinks/plugins/flutter_custom_tabs_ios/ios`)
- flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
Expand Down Expand Up @@ -260,8 +257,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/firebase_remote_config/ios"
Flutter:
:path: Flutter
flutter_config:
:path: ".symlinks/plugins/flutter_config/ios"
flutter_custom_tabs_ios:
:path: ".symlinks/plugins/flutter_custom_tabs_ios/ios"
flutter_secure_storage:
Expand Down Expand Up @@ -314,7 +309,6 @@ SPEC CHECKSUMS:
FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc
FirebaseSharedSwift: 20530f495084b8d840f78a100d8c5ee613375f6e
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_config: f48f0d47a284f1791aacce2687eabb3309ba7a41
flutter_custom_tabs_ios: a651b18786388923b62de8c0537607de87c2eccf
flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12
fluttertoast: 9f2f8e81bb5ce18facb9748d7855bf5a756fe3db
Expand Down
3 changes: 1 addition & 2 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import UIKit
import Flutter
import GoogleMaps
import flutter_config

@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GMSServices.provideAPIKey(FlutterConfigPlugin.env(for: "MAPS_API_KEY") ?? "\(Bundle.main.object(forInfoDictionaryKey: "MAPS_API_KEY"))")
GMSServices.provideAPIKey("\(Bundle.main.object(forInfoDictionaryKey: "MAPS_API_KEY"))")
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
Expand Down
5 changes: 1 addition & 4 deletions lib/constants/preferences_flags.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Package imports:
import 'package:enum_to_string/enum_to_string.dart';

enum PreferencesFlag {
// Meta flag concerning the app versioning
appVersion,
Expand Down Expand Up @@ -65,7 +62,7 @@ class DynamicPreferencesFlag {

@override
String toString() {
return EnumToString.convertToString(groupAssociationFlag) +
return groupAssociationFlag.name +
separator +
uniqueKey;
}
Expand Down
12 changes: 1 addition & 11 deletions lib/features/app/integration/github_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
import 'dart:convert';
import 'dart:io';

// Flutter imports:
import 'package:flutter/foundation.dart';

// Package imports:
import 'package:flutter_config/flutter_config.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:github/github.dart';
import 'package:logger/logger.dart';
Expand Down Expand Up @@ -37,13 +33,7 @@ class GithubApi {
locator<InternalInfoService>();

GithubApi() {
String githubApiToken;
if (kDebugMode &&
FlutterConfig.variables.containsKey(_envVariableGithubAPIKey)) {
githubApiToken = FlutterConfig.get(_envVariableGithubAPIKey).toString();
} else {
githubApiToken = const String.fromEnvironment(_envVariableGithubAPIKey);
}
final githubApiToken = const String.fromEnvironment(_envVariableGithubAPIKey);
_github = GitHub(auth: Authentication.withToken(githubApiToken));
}

Expand Down
74 changes: 43 additions & 31 deletions lib/features/more/settings/settings_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/material.dart';

// Package imports:
import 'package:calendar_view/calendar_view.dart';
import 'package:enum_to_string/enum_to_string.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:intl/intl.dart';
import 'package:logger/logger.dart';
Expand Down Expand Up @@ -130,8 +129,8 @@ class SettingsManager with ChangeNotifier {
_preferencesService.setString(PreferencesFlag.theme, value.toString());

_analyticsService.logEvent(
"${tag}_${EnumToString.convertToString(PreferencesFlag.theme)}",
EnumToString.convertToString(value));
"${tag}_${PreferencesFlag.theme.name}",
value.name);
_themeMode = value;
notifyListeners();
}
Expand All @@ -140,7 +139,7 @@ class SettingsManager with ChangeNotifier {
_locale = AppIntl.supportedLocales.firstWhere((e) => e.toString() == value);

_analyticsService.logEvent(
"${tag}_${EnumToString.convertToString(PreferencesFlag.locale)}",
"${tag}_${PreferencesFlag.locale.name}",
_locale?.languageCode ?? 'Not found');

if (_locale != null) {
Expand All @@ -155,30 +154,43 @@ class SettingsManager with ChangeNotifier {
Future<Map<PreferencesFlag, dynamic>> getScheduleSettings() async {
final Map<PreferencesFlag, dynamic> settings = {};

final calendarFormat = await _preferencesService
.getString(PreferencesFlag.scheduleCalendarFormat)
.then((value) => value == null
? CalendarFormat.week
: EnumToString.fromString(CalendarFormat.values, value) ??
CalendarFormat.week);
settings.putIfAbsent(
PreferencesFlag.scheduleCalendarFormat, () => calendarFormat);
var calendarFormat = CalendarFormat.week;
var startingWeekDay = StartingDayOfWeek.monday;
var otherWeekDay = WeekDays.monday;

final calendarFormatValue = await _preferencesService.getString(PreferencesFlag.scheduleCalendarFormat);
final startingWeekDayValue = await _preferencesService.getString(PreferencesFlag.scheduleStartWeekday);
final otherWeekDayValue = await _preferencesService.getString(PreferencesFlag.scheduleOtherWeekday);

try {
calendarFormat = calendarFormatValue == null
? CalendarFormat.week
: CalendarFormat.values.byName(calendarFormatValue);
} catch(e) {
// Catch error
} finally {
settings[PreferencesFlag.scheduleCalendarFormat] = calendarFormat;
}

final startingWeekDay = await _preferencesService
.getString(PreferencesFlag.scheduleStartWeekday)
.then((value) => value == null
? StartingDayOfWeek.monday
: EnumToString.fromString(StartingDayOfWeek.values, value));
settings.putIfAbsent(
PreferencesFlag.scheduleStartWeekday, () => startingWeekDay);
try {
startingWeekDay = startingWeekDayValue == null
? StartingDayOfWeek.monday
: StartingDayOfWeek.values.byName(startingWeekDayValue);
} catch(e) {
// Catch error
} finally {
settings[PreferencesFlag.scheduleStartWeekday] = startingWeekDay;
}

final otherWeekDay = await _preferencesService
.getString(PreferencesFlag.scheduleOtherWeekday)
.then((value) => value == null
? WeekDays.monday
: EnumToString.fromString(WeekDays.values, value));
settings.putIfAbsent(
PreferencesFlag.scheduleOtherWeekday, () => otherWeekDay);
try {
otherWeekDay = otherWeekDayValue == null
? WeekDays.monday
: WeekDays.values.byName(otherWeekDayValue);
} catch(e) {
// Catch error
} finally {
settings[PreferencesFlag.scheduleOtherWeekday] = otherWeekDay;
}

final showTodayBtn = await _preferencesService
.getBool(PreferencesFlag.scheduleShowTodayBtn) ??
Expand Down Expand Up @@ -207,7 +219,7 @@ class SettingsManager with ChangeNotifier {
Future<bool> setString(PreferencesFlag flag, String? value) async {
// Log the event
_analyticsService.logEvent(
"${tag}_${EnumToString.convertToString(flag)}", value.toString());
"${tag}_${flag.name}", value.toString());

if (value == null) {
return _preferencesService.removePreferencesFlag(flag);
Expand All @@ -232,15 +244,15 @@ class SettingsManager with ChangeNotifier {
Future<bool> setInt(PreferencesFlag flag, int value) async {
// Log the event
_analyticsService.logEvent(
"${tag}_${EnumToString.convertToString(flag)}", value.toString());
"${tag}_${flag.name}", value.toString());
return _preferencesService.setInt(flag, value);
}

/// Get the value of [flag]
Future<String?> getString(PreferencesFlag flag) async {
// Log the event
_analyticsService.logEvent(
"${tag}_${EnumToString.convertToString(flag)}", 'getString');
"${tag}_${flag.name}", 'getString');
return _preferencesService.getString(flag);
}

Expand All @@ -256,15 +268,15 @@ class SettingsManager with ChangeNotifier {
Future<bool> setBool(PreferencesFlag flag, bool value) async {
// Log the event
_analyticsService.logEvent(
"${tag}_${EnumToString.convertToString(flag)}", value.toString());
"${tag}_${flag.name}", value.toString());
return _preferencesService.setBool(flag, value: value);
}

/// Get the value of [flag]
Future<bool?> getBool(PreferencesFlag flag) async {
// Log the event
_analyticsService.logEvent(
"${tag}_${EnumToString.convertToString(flag)}", 'getBool');
"${tag}_${flag.name}", 'getBool');
return _preferencesService.getBool(flag);
}

Expand Down
7 changes: 3 additions & 4 deletions lib/features/schedule/schedule_settings_viewmodel.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Package imports:
import 'package:calendar_view/calendar_view.dart';
import 'package:collection/collection.dart';
import 'package:enum_to_string/enum_to_string.dart';
import 'package:stacked/stacked.dart';
import 'package:table_calendar/table_calendar.dart';

Expand All @@ -28,7 +27,7 @@ class ScheduleSettingsViewModel
set calendarFormat(CalendarFormat? format) {
setBusy(true);
_settingsManager.setString(PreferencesFlag.scheduleCalendarFormat,
EnumToString.convertToString(format));
format?.name);
_calendarFormat = format;
setBusy(false);
}
Expand All @@ -48,7 +47,7 @@ class ScheduleSettingsViewModel
set startingDayOfWeek(StartingDayOfWeek? day) {
setBusy(true);
_settingsManager.setString(PreferencesFlag.scheduleStartWeekday,
EnumToString.convertToString(day));
day?.name);
_startingDayOfWeek = day;
setBusy(false);
}
Expand All @@ -68,7 +67,7 @@ class ScheduleSettingsViewModel
set otherDayOfWeek(WeekDays? day) {
setBusy(true);
_settingsManager.setString(PreferencesFlag.scheduleOtherWeekday,
EnumToString.convertToString(day));
day?.name);
_otherDayOfWeek = day;
setBusy(false);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/features/schedule/schedule_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
// Package imports:
import 'package:calendar_view/calendar_view.dart';
import 'package:collection/collection.dart';
import 'package:enum_to_string/enum_to_string.dart';
import 'package:feature_discovery_fork/feature_discovery.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:fluttertoast/fluttertoast.dart';
Expand Down Expand Up @@ -374,7 +373,7 @@ class ScheduleViewModel extends FutureViewModel<List<CourseActivity>> {
calendarFormat = format;
settings[PreferencesFlag.scheduleCalendarFormat] = calendarFormat;
_settingsManager.setString(PreferencesFlag.scheduleCalendarFormat,
EnumToString.convertToString(calendarFormat));
calendarFormat.name);
}

Future<void> refresh() async {
Expand Down
5 changes: 0 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import 'dart:async';

// Flutter imports:
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

// Package imports:
Expand All @@ -11,7 +10,6 @@ import 'package:feature_discovery_fork/feature_discovery.dart';
import 'package:feedback/feedback.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter_config/flutter_config.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -50,9 +48,6 @@ Future<void> main() async {
final HelloAPIClient helloApiClient = locator<HelloAPIClient>();
helloApiClient.apiLink = remoteConfigService.helloApiUrl;

if (kDebugMode) {
FlutterConfig.loadEnvVariables();
}
runZonedGuarded(() {
runApp(
ETSMobile(settingsManager),
Expand Down
Loading
Loading