Skip to content
Merged

Dev #208

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
4 changes: 3 additions & 1 deletion .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
flutter_channel: 'stable'
flutter_version: '3.22.2'
flutter_version: '3.27.1'

jobs:
build:
Expand All @@ -29,5 +29,7 @@ jobs:
distribution: 'zulu'
- name: Install dependencies
run: flutter pub get
- name: Run Flutter analysis
run: flutter analyze
- name: Run tests
run: flutter test
14 changes: 3 additions & 11 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ analyzer:
missing_required_param: error
missing_return: error
must_be_immutable: error
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
- "**/*.pb.dart"
- "**/*.pbenum.dart"
- "**/*.pbgrpc.dart"
- "**/*.pbjson.dart"
- "**/*.gr.dart"
- "**/*.config.dart"
- "lib/infrastructure/core/gen/**"

linter:
rules:
Expand All @@ -24,4 +14,6 @@ linter:

avoid_classes_with_only_static_members: false

sort_constructors_first: true
sort_constructors_first: true

prefer_single_quotes: true
8 changes: 4 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ android {
ndkVersion flutter.ndkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '17'
jvmTarget = "1.8"
}

sourceSets {
Expand All @@ -51,7 +51,7 @@ android {
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion 26
targetSdkVersion flutter.targetSdkVersion
targetSdkVersion 35
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
6 changes: 0 additions & 6 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
<!-- </intent>-->
<!-- </queries>-->

<!-- <uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />-->
<!-- <uses-permission android:name="android.permission.VIBRATE" />-->
<!-- <uses-permission android:name="android.permission.INTERNET" />-->
<!-- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />-->
<!-- <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />-->
<!-- <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />-->
<!-- <uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />-->
<!-- <uses-permission android:name="android.permission.health.READ_SLEEP" />-->

Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "com.android.application" version "8.1.1" apply false
}

include ":app"
2 changes: 1 addition & 1 deletion codemagic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ workflows:
publishing:
google_play:
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
track: production
track: internal

ios-workflow:
triggering:
Expand Down
6 changes: 5 additions & 1 deletion lib/domain/controllers/dnd_controller.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:flutter_dnd/flutter_dnd.dart';
import 'package:do_not_disturb/do_not_disturb.dart';
import 'package:infinite_horizons/domain/controllers/controllers.dart';
import 'package:universal_io/io.dart';

Expand All @@ -18,4 +18,8 @@ abstract class DndController {
Future<bool> isDnd();

Future<void> disable();

Future<bool> isNotificationPolicyAccessGranted();

Future<void> gotoPolicySettings();
}
2 changes: 1 addition & 1 deletion lib/domain/controllers/permissions_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';

import 'package:awesome_notifications/awesome_notifications.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter_dnd/flutter_dnd.dart';
import 'package:infinite_horizons/domain/controllers/controllers.dart';
import 'package:universal_io/io.dart';

part 'package:infinite_horizons/infrastructure/permissions_repository.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/domain/controllers/vibration_controller.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:universal_io/io.dart';
import 'package:vibration/vibration.dart';

part 'package:infinite_horizons/infrastructure/vibration_repository.dart';

Expand Down
14 changes: 7 additions & 7 deletions lib/domain/objects/tip.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ List<Tip> tipsList = [
resourceLinks: [
Resource(
'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"',
"Go to Sleep to keep your sleep circle and brain in good state",
'Go to Sleep to keep your sleep circle and brain in good state',
link: Uri.parse('https://youtu.be/Ze2pc6NwsHQ?si=wXUetxQZKNsk4wXT'),
),
],
Expand Down Expand Up @@ -211,13 +211,13 @@ List<Tip> tipsList = [
resourceLinks: [
Resource(
'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"',
"Getting expose to sun in the first 30m-60m of the day going to facilitate focus, further release of dopamine and norepinephrine and healthy amounts of cortisol.",
'Getting expose to sun in the first 30m-60m of the day going to facilitate focus, further release of dopamine and norepinephrine and healthy amounts of cortisol.',
link: Uri.parse('https://youtu.be/Ze2pc6NwsHQ?si=wXUetxQZKNsk4wXT'),
),
],
),
Tip(
'Sit in a sun lit environment and turn on as much lights as possible',
'Sit in a sun lit environment and turn on as much lights as possible, open the windows',
reason:
'Increase focus, good for healthy brain productivity, reduce depression and insomnia',
type: TipType.general,
Expand All @@ -230,7 +230,7 @@ List<Tip> tipsList = [
resourceLinks: [
Resource(
'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"',
"Work environment with strong light without hurting your eyes in the first 9 hours of wake to increase focus and for releasing dopamine, norepinephrine, and healthy amounts of cortisol",
'Work environment with strong light without hurting your eyes in the first 9 hours of wake to increase focus and for releasing dopamine, norepinephrine, and healthy amounts of cortisol',
link: Uri.parse('https://youtu.be/Ze2pc6NwsHQ?si=wXUetxQZKNsk4wXT'),
),
],
Expand All @@ -249,7 +249,7 @@ List<Tip> tipsList = [
resourceLinks: [
Resource(
'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"',
"After 9 hours of being awake your should reducing over the head light inorder to shift body production from dopamine and norepinephrine to serotonin and other neuromodulators.",
'After 9 hours of being awake your should reducing over the head light in order to shift body production from dopamine and norepinephrine to serotonin and other neuromodulators.',
link: Uri.parse('https://youtu.be/Ze2pc6NwsHQ?si=wXUetxQZKNsk4wXT'),
),
],
Expand All @@ -267,7 +267,7 @@ List<Tip> tipsList = [
resourceLinks: [
Resource(
'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"',
"After 16 hours of being awake you should keep only the necessary light for the work, more than that will severely deplete your melatonin levels, going to severally shift your circadian clock like traveling to different time zone.",
'After 16 hours of being awake you should keep only the necessary light for the work, more than that will severely deplete your melatonin levels, going to severally shift your circadian clock like traveling to different time zone.',
link: Uri.parse('https://youtu.be/Ze2pc6NwsHQ?si=wXUetxQZKNsk4wXT'),
),
],
Expand Down Expand Up @@ -311,7 +311,7 @@ List<Tip> tipsList = [
resourceLinks: [
Resource(
'YouTube video by Andrew Huberman: "Optimizing Workspace for Productivity, Focus, & Creativity"',
"In the first 9 hours after waking (around 8am-12pm) our brain enters state of high alertness and accurate thinking, which is good for working on analytical and accurate tasks.",
'In the first 9 hours after waking (around 8am-12pm) our brain enters state of high alertness and accurate thinking, which is good for working on analytical and accurate tasks.',
link: Uri.parse('https://www.youtube.com/watch?v=Ze2pc6NwsHQ'),
),
],
Expand Down
38 changes: 29 additions & 9 deletions lib/infrastructure/dnd_repository.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
part of 'package:infinite_horizons/domain/controllers/dnd_controller.dart';

class _DndRepository extends DndController {
// TODO: Switched packages for app to run, code not tested
late DoNotDisturbPlugin dnd;

@override
void init() => supported = Platform.isAndroid;
void init() {
supported = Platform.isAndroid;
if (!supported) {
return;
}
dnd = DoNotDisturbPlugin();
}

@override
Future<void> enable() async {
Expand All @@ -13,9 +22,7 @@ class _DndRepository extends DndController {
if (await PermissionsController.instance
.isNotificationPolicyAccessGranted()) {
// Turn on DND - All notifications are suppressed except priority.
await FlutterDnd.setInterruptionFilter(
FlutterDnd.INTERRUPTION_FILTER_PRIORITY,
);
await dnd.setInterruptionFilter(InterruptionFilter.priority);
} else {
PermissionsController.instance.gotoPolicySettings();
}
Expand All @@ -29,9 +36,7 @@ class _DndRepository extends DndController {

if (await PermissionsController.instance
.isNotificationPolicyAccessGranted()) {
await FlutterDnd.setInterruptionFilter(
FlutterDnd.INTERRUPTION_FILTER_ALL,
);
await dnd.setInterruptionFilter(InterruptionFilter.all);
}
}

Expand All @@ -41,7 +46,22 @@ class _DndRepository extends DndController {
return false;
}

return await FlutterDnd.getCurrentInterruptionFilter() ==
FlutterDnd.INTERRUPTION_FILTER_PRIORITY;
return dnd.isDndEnabled();
}

@override
Future<void> gotoPolicySettings() async {
if (!supported) {
return;
}
await dnd.openNotificationPolicyAccessSettings();
}

@override
Future<bool> isNotificationPolicyAccessGranted() async {
if (!supported) {
return false;
}
return dnd.isNotificationPolicyAccessGranted();
}
}
2 changes: 1 addition & 1 deletion lib/infrastructure/health_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class _HealthRepository extends HealthController {
return;
}
health = Health();
health.configure(useHealthConnectIfAvailable: true);
health.configure();
sleepPermissionGranted = PreferencesController.instance
.getBool(PreferenceKeys.sleepPermissionGranted) ??
false;
Expand Down
8 changes: 4 additions & 4 deletions lib/infrastructure/notifications_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,25 +86,25 @@ class _NotificationsRepository extends NotificationsController {

/// Use this method to detect when the user taps on a notification or action button
/// Also capture when there is a message from firebase messaging
@pragma("vm:entry-point")
@pragma('vm:entry-point')
static Future<void> onActionReceivedMethod(
ReceivedAction receivedAction,
) async {}

/// Use this method to detect when a new notification or a schedule is created
@pragma("vm:entry-point")
@pragma('vm:entry-point')
static Future<void> onNotificationCreatedMethod(
ReceivedNotification receivedNotification,
) async {}

/// Use this method to detect every time that a new notification is displayed
@pragma("vm:entry-point")
@pragma('vm:entry-point')
static Future<void> onNotificationDisplayedMethod(
ReceivedNotification receivedNotification,
) async {}

/// Use this method to detect if the user dismissed a notification
@pragma("vm:entry-point")
@pragma('vm:entry-point')
static Future<void> onDismissActionReceivedMethod(
ReceivedAction receivedAction,
) async {}
Expand Down
7 changes: 3 additions & 4 deletions lib/infrastructure/permissions_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ part of 'package:infinite_horizons/domain/controllers/permissions_controller.dar

class _PermissionsRepository extends PermissionsController {
@override
Future<bool> isNotificationPolicyAccessGranted() async =>
Platform.isAndroid &&
(await FlutterDnd.isNotificationPolicyAccessGranted ?? false);
Future<bool> isNotificationPolicyAccessGranted() =>
DndController.instance.isNotificationPolicyAccessGranted();

@override
void gotoPolicySettings() => FlutterDnd.gotoPolicySettings();
void gotoPolicySettings() => DndController.instance.gotoPolicySettings();

@override
Future generalNotificationPermission() =>
Expand Down
11 changes: 5 additions & 6 deletions lib/infrastructure/vibration_repository.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
part of 'package:infinite_horizons/domain/controllers/vibration_controller.dart';

class _VibrationRepository extends VibrationController {
// TODO: Switched packages for app to run, code not tested
@override
Future init() async => supported = Platform.isAndroid || Platform.isIOS;

Expand All @@ -10,16 +11,14 @@ class _VibrationRepository extends VibrationController {
return;
}

FeedbackType feedbackType;
// TODO: Values are incorrect
switch (type) {
case VibrationType.light:
feedbackType = FeedbackType.success;
Vibration.vibrate(amplitude: 128);
case VibrationType.medium:
feedbackType = FeedbackType.warning;
Vibration.vibrate(duration: 501);
case VibrationType.heavy:
feedbackType = FeedbackType.error;
Vibration.vibrate(duration: 1000);
}

Vibrate.feedback(feedbackType);
}
}
7 changes: 3 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:infinite_horizons/presentation/core/color_schemes.dart';
import 'package:infinite_horizons/presentation/core/theme_data.dart';
import 'package:infinite_horizons/presentation/core/global_variables.dart';
import 'package:infinite_horizons/presentation/pages/pages.dart';

void main() async {
Expand All @@ -27,14 +27,13 @@ class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
final TextTheme textTheme = createTextTheme(context, "Arya", "Arya");
final TextTheme textTheme = createTextTheme(context, 'Arya', 'Arya');

final MaterialTheme theme = MaterialTheme(textTheme);
return MaterialApp(
theme: theme.light(),
darkTheme: theme.dark(),
debugShowCheckedModeBanner: false,
title: AppThemeData.appName,
title: GlobalVariables.appName,
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
Expand Down
Loading
Loading