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

Adding notifications #135

Merged
merged 20 commits into from
Jun 24, 2024
Merged
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
2 changes: 1 addition & 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' # or: 'dev' or 'beta'
flutter_version: '3.19.5'
flutter_version: '3.22.0'

jobs:
build:
Expand Down
3 changes: 3 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<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"/>

<application
android:label="Infinite Horizons"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">

<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added android/app/src/main/res/raw/break_ended.m4a
Binary file not shown.
Binary file not shown.
14 changes: 9 additions & 5 deletions assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
"tip:": "Tip:",
"next": "Next",
"tip_description": "Tip Description",
"resource" : "Linked Resource",
"resource": "Linked Resource",
"resources": "Resources:",
"dnd":"Do Not Disturb mode",
"dnd": "Do Not Disturb mode",
"close": "Close",
"settings" : "Settings",
"sound" : "Sound",
"settings": "Settings",
"sound": "Sound",
"screen_lock": "Screen Lock",
"ready": "I am ready",
"ready_for_session": "Next Round?",
Expand All @@ -50,5 +50,9 @@
"notes": "Notes",
"famous_methods": "Famous methods",
"recommended": "Recommended",
"maximum_efficiency": "Maximum Efficiency"
"maximum_efficiency": "Maximum Efficiency",
"break": "Take a break",
"new_session": "Press to start a new session",
"study_ended": "You have completed the Study session, take a break",
"break_ended": "Break ended, enter the app to continue to the next session"
}
12 changes: 12 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,16 @@ post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
################ Awesome Notifications pod modification 1 ###################
awesome_pod_file = File.expand_path(File.join('plugins', 'awesome_notifications', 'ios', 'Scripts', 'AwesomePodFile'), '.symlinks')
require awesome_pod_file
update_awesome_pod_build_settings(installer)
################ Awesome Notifications pod modification 1 ###################
end

################ Awesome Notifications pod modification 2 ###################
awesome_pod_file = File.expand_path(File.join('plugins', 'awesome_notifications', 'ios', 'Scripts', 'AwesomePodFile'), '.symlinks')
require awesome_pod_file
update_awesome_main_target_settings('Runner', File.dirname(File.realpath(__FILE__)), flutter_root)
################ Awesome Notifications pod modification 2 ###################

10 changes: 10 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
6482FAA52ED6EDE8E8436926 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F80BBDF2B702494CC7FA307 /* Pods_RunnerTests.framework */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
976B225A2C26CD0500DD4ED6 /* BuildFile in Resources */ = {isa = PBXBuildFile; };
976B225B2C26CD0500DD4ED6 /* BuildFile in Resources */ = {isa = PBXBuildFile; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
Expand Down Expand Up @@ -259,10 +261,12 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
976B225B2C26CD0500DD4ED6 /* BuildFile in Resources */,
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
976B225A2C26CD0500DD4ED6 /* BuildFile in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -468,7 +472,9 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
Expand Down Expand Up @@ -662,7 +668,9 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
Expand Down Expand Up @@ -690,7 +698,9 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
BUILD_LIBRARY_FOR_DISTRIBUTION = NO;
CLANG_ENABLE_MODULES = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
Expand Down
13 changes: 8 additions & 5 deletions ios/Runner/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
Expand All @@ -14,13 +16,14 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="69" y="-34"/>
</scene>
</scenes>
</document>
Empty file added ios/Runner/break_ended.aiff
Empty file.
Empty file.
20 changes: 15 additions & 5 deletions lib/domain/timer_states.dart → lib/domain/energy_level.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class TimerStates {
TimerStates(this.type, this.sessions);
class EnergyLevel {
EnergyLevel(this.type, this.sessions);

factory TimerStates.fromEnergyType(EnergyType type) {
factory EnergyLevel.fromEnergyType(EnergyType type) {
List<TimerSession> states;

switch (type) {
Expand Down Expand Up @@ -34,7 +34,7 @@ class TimerStates {
];
}

return TimerStates(type, states);
return EnergyLevel(type, states);
}

EnergyType type;
Expand All @@ -49,7 +49,7 @@ class TimerStates {
currentState = 0;
return;
}
currentState = currentState + 1;
currentState++;
}
}

Expand All @@ -58,6 +58,7 @@ class TimerSession {

Duration study;
Duration breakDuration;
final Duration getReadyForBreak = const Duration(seconds: 10);
}

enum EnergyType {
Expand Down Expand Up @@ -87,3 +88,12 @@ enum EnergyType {
final String previewName;
final List<String>? tipsId;
}

extension EnergyTypeExtension on EnergyType {
static EnergyType fromString(String typeAsString) {
return EnergyType.values.firstWhere(
(element) => element.toString().split('.').last == typeAsString,
orElse: () => EnergyType.undefined,
);
}
}
29 changes: 29 additions & 0 deletions lib/domain/notifications_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'dart:io';

import 'package:awesome_notifications/awesome_notifications.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:infinite_horizons/presentation/core/theme_data.dart';

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

abstract class NotificationsController {
static NotificationsController? _instance;

static NotificationsController get instance =>
_instance ??= _NotificationsRepository();

void init();

Future send({
required DateTime date,
required String title,
required NotificationVariant variant,
String? body,
});

Future generalPermission();

Future preciseAlarmPermission();

Future cancelAllNotifications();
}
4 changes: 2 additions & 2 deletions lib/domain/player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ abstract class PlayerController {

static PlayerController get instance => _instance ??= _PlayerRepository();

void init();

void setIsSound(bool value);

bool isSound();

void initialize();

Future play(String fileName);
}
11 changes: 11 additions & 0 deletions lib/domain/preferences_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,23 @@ abstract class PreferencesController {

String? getString(String key);

int? getInt(String key);

bool? getBool(String key);

Duration? getDuration(String key);

DateTime? getDateTime(String key);

void remove(String key);

void setString(String key, String value);

void setInt(String key, int value);

void setBool(String key, bool value);

void setDuration(String key, Duration value);

void setDateTime(String key, DateTime value);
}
14 changes: 7 additions & 7 deletions lib/domain/study_type_abstract.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import 'package:collection/collection.dart';
import 'package:flutter/cupertino.dart';
import 'package:infinite_horizons/domain/timer_states.dart';
import 'package:infinite_horizons/domain/energy_level.dart';
import 'package:infinite_horizons/domain/tip.dart';

abstract class StudyTypeAbstract {
StudyTypeAbstract(this.studyType);
StudyTypeAbstract(this.tipType);

static StudyTypeAbstract? instance;

TipType studyType;
TipType tipType;

TimerStates? _timerStates;
EnergyLevel? _timerStates;

void setTimerStates(EnergyType energy) =>
_timerStates = TimerStates.fromEnergyType(energy);
_timerStates = EnergyLevel.fromEnergyType(energy);

TimerStates getTimerStates() =>
_timerStates ?? TimerStates.fromEnergyType(EnergyType.undefined);
EnergyLevel getTimerStates() =>
_timerStates ?? EnergyLevel.fromEnergyType(EnergyType.undefined);

@protected
List<Tip> tips = [];
Expand Down
Loading
Loading