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

Theme cleanup #131

Open
wants to merge 37 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e7d4e42
migrate ios_app_group to the maintained app_group_directory
Leptopoda Oct 7, 2022
aa02417
mirate snackbar to ScaffoldMessenger
Leptopoda Oct 7, 2022
61c5175
upgrade workmanager for flutter 3
Leptopoda Oct 7, 2022
56d1d8b
null safety migration
Leptopoda Oct 16, 2022
6f55f46
add linting
Leptopoda Oct 14, 2022
f99fddb
fix require_trailing_commas
Leptopoda Oct 14, 2022
5cd37b0
fix avoid_redundant_argument_values
Leptopoda Oct 14, 2022
0b9168b
fix prefer_final lints
Leptopoda Oct 14, 2022
e6497cd
fix prefer_const_constructors
Leptopoda Oct 14, 2022
730a17f
unnecessary_await_in_return
Leptopoda Oct 14, 2022
395fc59
fix curly_braces_in_flow_control_structures
Leptopoda Oct 14, 2022
3b647ba
fix various lints (using dart fix)
Leptopoda Oct 14, 2022
f86e2e7
Sort pub dependencies
Leptopoda Oct 14, 2022
a79bec9
disable lints that require deeper code changes
Leptopoda Oct 14, 2022
a069ba2
manually fix some lints
Leptopoda Oct 13, 2022
eec0f48
fix use_named_constants
Leptopoda Oct 12, 2022
3a472ee
fix avoid_classes_with_only_static_members
Leptopoda Oct 12, 2022
e5729bc
prefer_null_aware_method_calls
Leptopoda Oct 12, 2022
f126dfb
fix errors
Leptopoda Oct 14, 2022
60a2d86
fix join_return_with_assignment
Leptopoda Oct 13, 2022
8ebc4f6
fix type_annotate_public_apis
Leptopoda Oct 13, 2022
155d1d6
fix avoid_setters_without_getters
Leptopoda Oct 13, 2022
519f0e9
fix use_setters_to_change_properties
Leptopoda Oct 14, 2022
9e5429a
removed unused variable
Leptopoda Oct 14, 2022
26d9160
fix use_string_buffers
Leptopoda Oct 14, 2022
8f4ee26
fix leading_newlines_in_multiline_strings
Leptopoda Oct 14, 2022
6cbc255
fix use_decorated_box
Leptopoda Oct 14, 2022
421f678
fix no_leading_underscores_for_local_identifiers
Leptopoda Oct 14, 2022
eb7fd66
fix prefer_constructors_over_static_methods
Leptopoda Oct 14, 2022
b684002
fix error catching stuff
Leptopoda Oct 14, 2022
bfe0250
format code
Leptopoda Oct 16, 2022
1c6bf85
fix depend_on_referenced_packages
Leptopoda Oct 14, 2022
ee4903e
use copy_with_gen
Leptopoda Oct 16, 2022
5e7cdd8
use json_serialisable
Leptopoda Oct 15, 2022
6af1c04
use assets_gen
Leptopoda Oct 15, 2022
e52dfa6
cleanup Theme
Leptopoda Oct 15, 2022
4b266a6
upgrade to dart 2.17
Leptopoda Oct 16, 2022
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
20 changes: 20 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file configures the analyzer to use the lint rule set from `package:lint`

# For apps, use the default set
include: package:lint/analysis_options.yaml

# You might want to exclude auto-generated files from dart analysis
analyzer:
exclude:
- "**.g.dart"

# You can customize the lint rules set to your own liking. A list of all rules
# can be found at https://dart-lang.github.io/linter/lints/options/options.html
linter:
rules:
constant_identifier_names: false
avoid_print: false
avoid_positional_boolean_parameters: false
use_build_context_synchronously: false
parameter_assignments: false
avoid_setters_without_getters: false
36 changes: 36 additions & 0 deletions lib/assets.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions lib/common/appstart/app_initializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import 'package:dhbwstudentapp/common/appstart/localization_initialize.dart';
import 'package:dhbwstudentapp/common/appstart/notification_schedule_changed_initialize.dart';
import 'package:dhbwstudentapp/common/appstart/notifications_initialize.dart';
import 'package:dhbwstudentapp/common/appstart/service_injector.dart';
import 'package:dhbwstudentapp/common/data/preferences/preferences_provider.dart';
import 'package:dhbwstudentapp/common/iap/in_app_purchase_manager.dart';
import 'package:dhbwstudentapp/native/widget/widget_update_callback.dart';
import 'package:dhbwstudentapp/schedule/background/calendar_synchronizer.dart';
import 'package:dhbwstudentapp/schedule/business/schedule_provider.dart';
import 'package:dhbwstudentapp/schedule/business/schedule_source_provider.dart';
import 'package:kiwi/kiwi.dart';
import 'package:dhbwstudentapp/schedule/business/schedule_provider.dart';
import 'package:dhbwstudentapp/common/data/preferences/preferences_provider.dart';
import 'package:timezone/data/latest.dart' as tz;

bool isInitialized = false;
Expand Down Expand Up @@ -52,20 +52,21 @@ Future<void> initializeApp(bool isBackground) async {
WidgetUpdateCallback(KiwiContainer().resolve())
.registerCallback(KiwiContainer().resolve());

NotificationsInitialize().setupNotifications();
BackgroundInitialize().setupBackgroundScheduling();
NotificationScheduleChangedInitialize().setupNotification();
const NotificationsInitialize().setupNotifications();
const BackgroundInitialize().setupBackgroundScheduling();
const NotificationScheduleChangedInitialize().setupNotification();

if (isBackground) {
var setup = KiwiContainer().resolve<ScheduleSourceProvider>();
final setup = KiwiContainer().resolve<ScheduleSourceProvider>();
setup.setupScheduleSource();
}

// Callback-Function for synchronizing the device calendar with the schedule, when schedule is updated
CalendarSynchronizer calendarSynchronizer = new CalendarSynchronizer(
KiwiContainer().resolve<ScheduleProvider>(),
KiwiContainer().resolve<ScheduleSourceProvider>(),
KiwiContainer().resolve<PreferencesProvider>());
final CalendarSynchronizer calendarSynchronizer = CalendarSynchronizer(
KiwiContainer().resolve<ScheduleProvider>(),
KiwiContainer().resolve<ScheduleSourceProvider>(),
KiwiContainer().resolve<PreferencesProvider>(),
);

calendarSynchronizer.registerSynchronizationCallback();
calendarSynchronizer.scheduleSyncInAFewSeconds();
Expand Down
6 changes: 4 additions & 2 deletions lib/common/appstart/background_initialize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import 'package:kiwi/kiwi.dart';
/// Note: More or less reliable background scheduling only works on android
///
class BackgroundInitialize {
const BackgroundInitialize();

Future<void> setupBackgroundScheduling() async {
WorkSchedulerService scheduler;
if (Platform.isAndroid) {
Expand All @@ -22,7 +24,7 @@ class BackgroundInitialize {

KiwiContainer().registerInstance<WorkSchedulerService>(scheduler);

var tasks = [
final tasks = [
BackgroundScheduleUpdate(
KiwiContainer().resolve(),
KiwiContainer().resolve(),
Expand All @@ -37,7 +39,7 @@ class BackgroundInitialize {
),
];

for (var task in tasks) {
for (final task in tasks) {
scheduler.registerTask(task);

KiwiContainer().registerInstance(
Expand Down
20 changes: 12 additions & 8 deletions lib/common/appstart/localization_initialize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,28 @@ import 'package:kiwi/kiwi.dart';
/// correct language
///
class LocalizationInitialize {
PreferencesProvider _preferencesProvider;
String _languageCode;
final PreferencesProvider? _preferencesProvider;
final String? _languageCode;

///
/// Initialize the localization using the provided language code
///
LocalizationInitialize.fromLanguageCode(this._languageCode);
const LocalizationInitialize.fromLanguageCode(this._languageCode)
: _preferencesProvider = null;

///
/// Initialize the localization using the locale from the preferences provider
///
LocalizationInitialize.fromPreferences(this._preferencesProvider);
const LocalizationInitialize.fromPreferences(this._preferencesProvider)
: _languageCode = null;

Future<void> setupLocalizations() async {
var localization = L(Locale(
_languageCode ??
(await _preferencesProvider?.getLastUsedLanguageCode() ?? "en"),
));
final localization = L(
Locale(
_languageCode ??
(await _preferencesProvider?.getLastUsedLanguageCode() ?? "en"),
),
);
KiwiContainer().registerInstance(localization);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@ import 'package:kiwi/kiwi.dart';
/// Initializes the notification for when the schedule changed
///
class NotificationScheduleChangedInitialize {
const NotificationScheduleChangedInitialize();

void setupNotification() {
var provider = KiwiContainer().resolve<ScheduleProvider>();
final provider = KiwiContainer().resolve<ScheduleProvider>();

provider.addScheduleEntryChangedCallback(_scheduleChangedCallback);
}

Future<void> _scheduleChangedCallback(ScheduleDiff scheduleDiff) async {
PreferencesProvider preferences = KiwiContainer().resolve();
var doNotify = await preferences.getNotifyAboutScheduleChanges();
final PreferencesProvider preferences = KiwiContainer().resolve();
final doNotify = await preferences.getNotifyAboutScheduleChanges();

if (!doNotify) return;

var notification = ScheduleChangedNotification(
final notification = ScheduleChangedNotification(
KiwiContainer().resolve(),
KiwiContainer().resolve(),
);
Expand Down
7 changes: 5 additions & 2 deletions lib/common/appstart/notifications_initialize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ import 'package:kiwi/kiwi.dart';
/// won't show the notification
///
class NotificationsInitialize {
const NotificationsInitialize();

Future<void> setupNotifications() async {
if (Platform.isAndroid) {
var notificationApi = NotificationApi();
final notificationApi = NotificationApi();

KiwiContainer().registerInstance(notificationApi);

await notificationApi.initialize();
} else {
KiwiContainer().registerInstance<NotificationApi>(VoidNotificationApi());
KiwiContainer()
.registerInstance<NotificationApi>(const VoidNotificationApi());
}
}
}
88 changes: 52 additions & 36 deletions lib/common/appstart/service_injector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,62 @@ bool _isInjected = false;
void injectServices(bool isBackground) {
if (_isInjected) return;

KiwiContainer c = KiwiContainer();
c.registerInstance(PreferencesProvider(
PreferencesAccess(),
SecureStorageAccess(),
));
c.registerInstance(DatabaseAccess());
c.registerInstance(ScheduleEntryRepository(
c.resolve(),
));
c.registerInstance(ScheduleFilterRepository(
c.resolve(),
));
c.registerInstance(ScheduleQueryInformationRepository(
c.resolve(),
));
c.registerInstance(ScheduleSourceProvider(
c.resolve(),
isBackground,
c.resolve(),
c.resolve(),
));
c.registerInstance(ScheduleProvider(
c.resolve(),
c.resolve(),
c.resolve(),
c.resolve(),
c.resolve(),
));
final KiwiContainer c = KiwiContainer();
c.registerInstance(
const PreferencesProvider(
PreferencesAccess(),
SecureStorageAccess(),
),
);
c.registerInstance(const DatabaseAccess());
c.registerInstance(
ScheduleEntryRepository(
c.resolve(),
),
);
c.registerInstance(
ScheduleFilterRepository(
c.resolve(),
),
);
c.registerInstance(
ScheduleQueryInformationRepository(
c.resolve(),
),
);
c.registerInstance(
ScheduleSourceProvider(
c.resolve(),
isBackground,
c.resolve(),
c.resolve(),
),
);
c.registerInstance(
ScheduleProvider(
c.resolve(),
c.resolve(),
c.resolve(),
c.resolve(),
c.resolve(),
),
);
c.registerInstance<DualisScraper>(
FakeAccountDualisScraperDecorator(DualisScraper()),
);
c.registerInstance<DualisService>(CacheDualisServiceDecorator(
DualisServiceImpl(
c.resolve(),
c.registerInstance<DualisService>(
CacheDualisServiceDecorator(
DualisServiceImpl(
c.resolve(),
),
),
));
c.registerInstance(DateEntryProvider(
DateManagementService(),
DateEntryRepository(c.resolve()),
));
);
c.registerInstance(
DateEntryProvider(
const DateManagementService(),
DateEntryRepository(c.resolve()),
),
);
c.registerInstance(WidgetHelper());
c.registerInstance(ListDateEntries30d(List<DateEntry>.empty(growable: true)));

Expand Down
13 changes: 9 additions & 4 deletions lib/common/background/background_work_scheduler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class BackgroundWorkScheduler extends WorkSchedulerService {
///
@override
Future<void> scheduleOneShotTaskIn(
Duration delay, String id, String name) async {
Duration delay,
String id,
String name,
) async {
print(
"Scheduling one shot task: $id. With a delay of ${delay.inMinutes} minutes.",
);
Expand Down Expand Up @@ -103,13 +106,16 @@ class BackgroundWorkScheduler extends WorkSchedulerService {
///
/// Entry point for when a background task is executed
///
static Future<bool> backgroundTaskMain(taskId, inputData) async {
static Future<bool> backgroundTaskMain(
String taskId,
Map<String, dynamic>? inputData,
) async {
try {
print("Background task started: $taskId with data: $inputData");

await initializeApp(true);

WorkSchedulerService scheduler = KiwiContainer().resolve();
final WorkSchedulerService scheduler = KiwiContainer().resolve();

await scheduler.executeTask(taskId);
} catch (e, trace) {
Expand All @@ -129,7 +135,6 @@ class BackgroundWorkScheduler extends WorkSchedulerService {

await workmanager.initialize(
callbackDispatcher,
isInDebugMode: false,
);
}

Expand Down
2 changes: 2 additions & 0 deletions lib/common/background/task_callback.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/// Override this class in order to receive a background callback
///
abstract class TaskCallback {
const TaskCallback();

Future<void> run();

Future<void> schedule();
Expand Down
2 changes: 2 additions & 0 deletions lib/common/background/work_scheduler_service.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:dhbwstudentapp/common/background/task_callback.dart';

abstract class WorkSchedulerService {
const WorkSchedulerService();

Future<void> scheduleOneShotTaskIn(Duration delay, String id, String name);

Future<void> scheduleOneShotTaskAt(
Expand Down
Loading