Skip to content

Commit

Permalink
Merge pull request #242 from JordyHers-org/dev
Browse files Browse the repository at this point in the history
Merge `dev` into `master`
  • Loading branch information
JordyHers authored Dec 11, 2023
2 parents 11aa929 + d029174 commit 240a1ba
Show file tree
Hide file tree
Showing 114 changed files with 2,037 additions and 1,070 deletions.
3 changes: 3 additions & 0 deletions .idea/libraries/Flutter_Plugins.xml

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

7 changes: 7 additions & 0 deletions .idea/runConfigurations/development.xml

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

7 changes: 7 additions & 0 deletions .idea/runConfigurations/production.xml

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

7 changes: 7 additions & 0 deletions .idea/runConfigurations/staging.xml

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

32 changes: 32 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## How to Contribute

1. **Read The Branch naming convention**
> <a href="https://docs.google.com/viewer?url=https://github.com/JordyHers-org/Times-up-flutter/files/12828818/how_to_create_a_branch.pdf">How to name a branch</a>
2. **Fork and Clone the Project**
```bash
git clone https://github.com/JordyHers-org/Times-up-flutter.git
cd Times-up-flutter/
```

3. **Install Flutter Version**
> Install FVM via Homebrew and use Flutter version 3.7.12.
```bash
brew install fvm
fvm install 3.7.12
```

4. **Request Firebase Options File**
> Request the Firebase options file from the Project Owner and place it in the appropriate location. From discord server
Jordyhers [Discord- JordyHers](https://discord.gg/e4ppDx9Zcy)

5. **Extra**
> For child's pictures feel free to use any of the pictures available.
| | | |
|-|-|-|
| <img width="115" alt="Neymar" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/c04ab191-c498-4ca1-bdab-84111babe6b3"> | <img width="115" alt="Momo" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/db2f3dd2-2a09-4e82-b26b-50f860679f3f"> | <img width="115" alt="Gareth" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/8faee404-8fb4-497d-abaf-82576df91621">
| <img width="115" alt="Titi" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/48ab9c3d-e180-482f-a295-54a00b76607b"> | <img width="115" alt="Bruyne" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/fa620a3e-2450-4434-b84d-70afbacdc2ec"> | <img width="115" alt="Kylian" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/bb6c2be5-b8fc-4178-8794-2c0e6e1349db">
| <img width="115" alt="Leo" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/9a093894-06af-487e-8ca1-edf35c9ece03"> | <img width="115" alt="Sally" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/31155608-2cc2-4e3e-815c-07f90aa1c27a"> | <img width="115" alt="Harry" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/c9302548-564c-490a-b0a5-feb74d2113cf"> |
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ settled for user, and doesn't collect data for third parties companies.
| | | |
|-|-|-|
| <img width="215" alt="Onboarding" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/cfdd94f2-9e59-40c4-a618-f8d5ca24fb71"> | <img width="215" alt="Sign_in_page" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/f93770ee-5516-4851-adc5-4ef71938316b"> | <img width="215" alt="child_list_page" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/fa161844-7cc7-4189-bab3-230d3da41dd4">
| <img width="215" alt="ChildDetailsPage" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/2bc18783-d2c3-4cc3-8c59-4e04fabd256b"> | <img width="215" alt="ChildNotificationRemoval" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/f6be1a2e-9218-4eec-b3bb-426dce5cf1ab"> | <img width="215" alt="GuidedTour" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/9e14dda2-6694-4719-9eea-ec8cbb465de9">
| <img width="215" alt="NotificationSending" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/32a04552-a2a2-4806-b861-59c2eda0273d"> | <img width="215" alt="ChildLocation" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/1e300516-f3ab-4f5b-8181-e7eeabdddf56"> | <img width="215" alt="settings_page" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/4a14fee8-bde0-428f-a894-b5ed8129adad"> |
| <img width="215" alt="ChildDetailsPage" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/59e8f37a-fc39-4bae-8ad2-15fc2c455f36"> | <img width="215" alt="ChildNotificationRemoval" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/f6be1a2e-9218-4eec-b3bb-426dce5cf1ab"> | <img width="215" alt="GuidedTour" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/9e14dda2-6694-4719-9eea-ec8cbb465de9">
| <img width="215" alt="NotificationSending" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/32a04552-a2a2-4806-b861-59c2eda0273d"> | <img width="215" alt="ChildLocation" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/1e300516-f3ab-4f5b-8181-e7eeabdddf56"> | <img width="215" alt="settings_page" src="https://github.com/JordyHers-org/Times-up-flutter/assets/49708438/5e5e1d86-2859-46b2-8d75-49cebc8be625"> |

## Application Feature: Child Side

Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 33
compileSdkVersion 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
16 changes: 8 additions & 8 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
/>
<uses-permission android:minSdkVersion="34" android:name="android.permission.USE_EXACT_ALARM" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

<application
android:label="Time's Up"
Expand Down
11 changes: 4 additions & 7 deletions lib/app/app.dart
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:times_up_flutter/app/config/screencontroller_config.dart';
import 'package:times_up_flutter/app/features/parent_side/language/language_notififier.dart';
import 'package:times_up_flutter/app/screen_controller.dart';
import 'package:times_up_flutter/l10n/l10n.dart';
import 'package:times_up_flutter/theme/theme.dart';
import 'package:times_up_flutter/theme/theme_notifier.dart';
import 'package:times_up_flutter/utils/app_strings.dart';

class TimesUpApp extends StatefulWidget {
class TimesUpApp extends StatelessWidget {
const TimesUpApp({Key? key}) : super(key: key);

@override
State<TimesUpApp> createState() => _TimesUpAppState();
}

class _TimesUpAppState extends State<TimesUpApp> with WidgetsBindingObserver {
@override
Widget build(BuildContext context) {
SystemChrome.setPreferredOrientations([
Expand All @@ -24,6 +20,7 @@ class _TimesUpAppState extends State<TimesUpApp> with WidgetsBindingObserver {

return MaterialApp(
debugShowCheckedModeBanner: false,
locale: Provider.of<LanguageNotifier>(context).locale,
title: Strings.appName,
theme: AppTheme.lightTheme,
darkTheme: AppTheme.darkTheme,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:provider/provider.dart';
import 'package:times_up_flutter/app/bloc/child_side_bloc.dart';
import 'package:times_up_flutter/app/features/child_side/bloc/child_side_bloc.dart';
import 'package:times_up_flutter/app/features/child_side/set_child_page.dart';
import 'package:times_up_flutter/app/features/landing_page.dart';
import 'package:times_up_flutter/app/helpers/parsing_extension.dart';
import 'package:times_up_flutter/app/landing_page.dart';
import 'package:times_up_flutter/app/pages/set_child_page.dart';
import 'package:times_up_flutter/common_widgets/jh_display_text.dart';
import 'package:times_up_flutter/common_widgets/jh_empty_content.dart';
import 'package:times_up_flutter/models/child_model/child_model.dart';
import 'package:times_up_flutter/models/notification_model/notification_model.dart';
import 'package:times_up_flutter/services/app_usage_service.dart';
import 'package:times_up_flutter/services/database.dart';
import 'package:times_up_flutter/services/geo_locator_service.dart';
import 'package:times_up_flutter/theme/theme.dart';
import 'package:times_up_flutter/widgets/jh_display_text.dart';
import 'package:times_up_flutter/widgets/jh_empty_content.dart';
import 'package:times_up_flutter/widgets/show_logger.dart';

class ChildPage extends StatefulWidget {
const ChildPage({
Expand Down Expand Up @@ -66,11 +67,23 @@ class _ChildPageState extends State<ChildPage> with WidgetsBindingObserver {
Navigator.pop(context);
}

@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}

@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
Timer.periodic(const Duration(minutes: 5), (timer) {
widget.database
?.liveUpdateChild(widget.child!, timer.tick, widget.appUsage);
Timer.periodic(const Duration(seconds: 5), (timer) async {
await widget.database?.liveUpdateChild(widget.child!, widget.appUsage);
JHLogger.$.d('${timer.tick} - $state');
});
super.didChangeAppLifecycleState(state);
}
Expand Down Expand Up @@ -202,7 +215,7 @@ class _ChildPageState extends State<ChildPage> with WidgetsBindingObserver {
} else if (state is ChildSideFetching) {
return _buildLoading();
} else if (state is ChildSideNotification) {
return _buildNotification();
return _buildNotification(widget.child!);
} else if (state is ChildSideAppList) {
return _buildAppList(widget.appUsage);
} else {
Expand Down Expand Up @@ -236,9 +249,9 @@ class _ChildPageState extends State<ChildPage> with WidgetsBindingObserver {
);
}

Widget _buildNotification() {
Widget _buildNotification(ChildModel child) {
return StreamBuilder<List<NotificationModel>>(
stream: widget.database!.notificationStream(childId: ''),
stream: widget.database!.notificationStream(childId: child.id),
builder: (BuildContext context, snapshot) {
if (snapshot.hasData) {
final data = snapshot.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import 'package:battery_plus/battery_plus.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:times_up_flutter/app/features/child_side/child_page.dart';
import 'package:times_up_flutter/app/helpers/parsing_extension.dart';
import 'package:times_up_flutter/app/pages/child_page.dart';
import 'package:times_up_flutter/common_widgets/jh_display_text.dart';
import 'package:times_up_flutter/common_widgets/jh_form_submit_button.dart';
import 'package:times_up_flutter/common_widgets/show_alert_dialog.dart';
import 'package:times_up_flutter/common_widgets/show_logger.dart';
import 'package:times_up_flutter/models/child_model/child_model.dart';
import 'package:times_up_flutter/services/app_usage_service.dart';
import 'package:times_up_flutter/services/database.dart';
import 'package:times_up_flutter/services/geo_locator_service.dart';
import 'package:times_up_flutter/widgets/jh_display_text.dart';
import 'package:times_up_flutter/widgets/jh_form_submit_button.dart';
import 'package:times_up_flutter/widgets/show_alert_dialog.dart';
import 'package:times_up_flutter/widgets/show_logger.dart';

enum AppState { loading, complete }

Expand Down Expand Up @@ -56,26 +56,27 @@ class _SetChildPageState extends State<SetChildPage> {
}

Future<void> _submit(String name, String key, BuildContext context) async {
final database = Provider.of<Database>(context, listen: false);
final databaseStore = Provider.of<Database>(context, listen: false);
final geo = Provider.of<GeoLocatorService>(context, listen: false);
final apps = Provider.of<AppUsageService>(context, listen: false);
final appUsage = Provider.of<AppUsageService>(context, listen: false);
final position = await geo.getInitialLocation();
final battery = await Battery().batteryLevel;

try {
final response = await database.getUserCurrentChild(
final response = await databaseStore.getUserCurrentChild(
key,
apps,
appUsage,
GeoPoint(position.latitude, position.longitude),
battery: battery.toString(),
);
JHLogger.$.d('RESPONSE : $response');

try {
if (mounted) {
await Navigator.of(context).pushReplacement(
MaterialPageRoute<ChildPage>(
fullscreenDialog: true,
builder: (context) =>
ChildPage.create(context, database, response),
ChildPage.create(context, databaseStore, response),
),
);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/app/landing_page.dart → lib/app/features/landing_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:showcaseview/showcaseview.dart';
import 'package:times_up_flutter/app/pages/parent_page.dart';
import 'package:times_up_flutter/app/pages/set_child_page.dart';
import 'package:times_up_flutter/common_widgets/jh_loading_widget.dart';
import 'package:times_up_flutter/app/features/child_side/set_child_page.dart';
import 'package:times_up_flutter/app/features/parent_side/parent_page.dart';
import 'package:times_up_flutter/app/features/sign_in/sign_in_page.dart';
import 'package:times_up_flutter/services/app_usage_service.dart';
import 'package:times_up_flutter/services/auth.dart';
import 'package:times_up_flutter/services/database.dart';
import 'package:times_up_flutter/services/geo_locator_service.dart';
import 'package:times_up_flutter/services/shared_preferences.dart';
import 'package:times_up_flutter/sign_in/sign_in_page.dart';
import 'package:times_up_flutter/widgets/jh_loading_widget.dart';

enum AppSide { parent, child }

Expand All @@ -32,7 +32,7 @@ class _LandingPageState extends State<LandingPage> {
}

Future<void> _setFlagParentOrChild() async {
final isParent = await SharedPreference().getParentOrChild();
final isParent = await CacheService.getParentOrChild();
setState(() {
isParent ? _side = AppSide.parent : _side = AppSide.child;
});
Expand Down
88 changes: 88 additions & 0 deletions lib/app/features/parent_side/app_list_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import 'package:flutter/material.dart';
import 'package:times_up_flutter/app/helpers/parsing_extension.dart';
import 'package:times_up_flutter/models/child_model/child_model.dart';

class AppListPage extends StatelessWidget {
const AppListPage({
required this.childModel,
Key? key,
}) : super(key: key);

final ChildModel childModel;

static Future<void> show(BuildContext context, ChildModel model) async {
await Navigator.of(context).push(
PageRouteBuilder<Widget>(
pageBuilder: (context, animation, secondaryAnimation) {
return AppListPage(childModel: model);
},
transitionsBuilder: (context, animation, secondaryAnimation, child) {
const begin = Offset(1, 0);
const end = Offset.zero;
const curve = Curves.easeInOut;
final tween =
Tween(begin: begin, end: end).chain(CurveTween(curve: curve));
final offsetAnimation = animation.drive(tween);
return SlideTransition(
position: offsetAnimation,
child: child,
);
},
transitionDuration: const Duration(milliseconds: 400),
),
);
}

@override
Widget build(BuildContext context) {
final themeData = Theme.of(context);

return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.chevron_left),
onPressed: () => Navigator.of(context).pop(),
),
elevation: 0,
backgroundColor: themeData.scaffoldBackgroundColor,
),
body: ListView.builder(
physics: const BouncingScrollPhysics(
decelerationRate: ScrollDecelerationRate.fast,
),
itemCount: childModel.appsUsageModel.length,
itemBuilder: (context, index) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
leading: childModel.appsUsageModel[index].appIcon != null
? Image.memory(
childModel.appsUsageModel[index].appIcon!,
height: 35,
)
: const Icon(Icons.android),
title: Text(
childModel.appsUsageModel[index].appName,
style: TextStyle(
fontSize: 15,
fontWeight: FontWeight.bold,
color: themeData.dividerColor,
),
),
trailing: Text(
childModel.appsUsageModel[index].usage.toString().t(),
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: themeData.dividerColor,
),
),
),
],
);
},
),
);
}
}
Loading

0 comments on commit 240a1ba

Please sign in to comment.