Skip to content

Commit

Permalink
Merge branch 'dev' into feature/154-revamp-app-look
Browse files Browse the repository at this point in the history
  • Loading branch information
JordyHers authored Oct 31, 2023
2 parents 8840a96 + a63cc2e commit ba595a7
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 71 deletions.
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
6 changes: 3 additions & 3 deletions lib/app/features/child_side/child_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,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 @@ -249,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
83 changes: 41 additions & 42 deletions lib/app/features/parent_side/child_details_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,53 +128,52 @@ class _ChildDetailsPageState extends State<ChildDetailsPage>
return [
SliverAppBar(
actions: [
if (model.image != null)
Row(
children: [
GestureDetector(
onTap: () => showCustomBottomSheet(
context,
animationController: _animationController,
child: Container(
decoration: BoxDecoration(
color: themeData.scaffoldBackgroundColor,
),
height: 200,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Spacer(),
JHCustomButton(
title: ' Bed Time',
backgroundColor: Colors.indigo,
onPress: () async => _sendNotification(
context,
model,
'Hey Go to bed Now',
),
Row(
children: [
GestureDetector(
onTap: () => showCustomBottomSheet(
context,
animationController: _animationController,
child: Container(
decoration: BoxDecoration(
color: themeData.scaffoldBackgroundColor,
),
height: 200,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Spacer(),
JHCustomButton(
title: ' Bed Time',
backgroundColor: Colors.indigo,
onPress: () async => _sendNotification(
context,
model,
'Hey Go to bed Now',
),
JHCustomButton(
title: 'Homework Time',
backgroundColor: CustomColors.indigoLight,
onPress: () async => _sendNotification(
context,
model,
'Homework Time',
),
),
JHCustomButton(
title: 'Homework Time',
backgroundColor: CustomColors.indigoLight,
onPress: () async => _sendNotification(
context,
model,
'Homework Time',
),
const Spacer(),
],
),
),
const Spacer(),
],
),
),
child: ClipOval(
child: Image.network(model.image!),
).p4,
),
],
)
else
const SizedBox.shrink(),
child: ClipOval(
child: model.image != null
? Image.network(model.image!)
: const Icon(Icons.person),
).p4,
),
],
),
],
elevation: 0.5,
shadowColor: CustomColors.indigoLight,
Expand Down
39 changes: 20 additions & 19 deletions lib/app/features/parent_side/edit_child_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,32 +89,33 @@ class _EditChildPageState extends State<EditChildPage> {
Future<void> _submit(XFile? localFile) async {
if (appState == AppState.loading) return;
if (_validateAndSaveForm()) {
if (localFile == null) return;
setState(() {
appState = AppState.loading;
});

id = uuid.v4().substring(0, 8).toUpperCase();
try {
final fileExtension = path.extension(localFile.path);
JHLogger.$.d(fileExtension);
if(localFile!=null) {
try {
final fileExtension = path.extension(localFile.path);
JHLogger.$.d(fileExtension);

final firebaseStorageRef = FirebaseStorage.instance
.ref()
.child('Child/"$id"/$id$fileExtension');
final firebaseStorageRef = FirebaseStorage.instance
.ref()
.child('Child/"$id"/$id$fileExtension');

await firebaseStorageRef
.putFile(File(localFile.path))
.catchError((Function onError) {
JHLogger.$.e(onError);
// ignore: return_of_invalid_type_from_catch_error
return false;
});
final url = await firebaseStorageRef.getDownloadURL();
_imageURL = url;
JHLogger.$.d('download url: $url');
} catch (e) {
JHLogger.$.d('...skipping image upload');
await firebaseStorageRef
.putFile(File(localFile.path))
.catchError((Function onError) {
JHLogger.$.e(onError);
// ignore: return_of_invalid_type_from_catch_error
return false;
});
final url = await firebaseStorageRef.getDownloadURL();
_imageURL = url;
JHLogger.$.d('download url: $url');
} catch (e) {
JHLogger.$.d('...skipping image upload');
}
}

try {
Expand Down
2 changes: 1 addition & 1 deletion lib/app/features/parent_side/notification_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class _NotificationPageState extends State<NotificationPage> {
subtitle: JHDisplayText(
textAlign: TextAlign.start,
text: convertToFormattedString(
data[index].timeStamp.toString(),
data[index].timeStamp,
),
style: const TextStyle(
fontWeight: FontWeight.w400,
Expand Down
6 changes: 3 additions & 3 deletions lib/app/helpers/parsing_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ int getRandom(int maxValue) {
return minRange + random.nextInt(maxRange - minRange + 1);
}

String convertToFormattedString(String input) {
final dateTime = DateTime.parse(input);
final formattedDate = DateFormat('MMMM d y HH:mma').format(dateTime);
String convertToFormattedString(DateTime? dateTime) {
final formattedDate =
dateTime != null ? DateFormat('MMMM d y hh:mm a').format(dateTime) : '';
return formattedDate;
}
11 changes: 10 additions & 1 deletion lib/services/firestore_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:flutter/foundation.dart';
import 'package:times_up_flutter/models/notification_model/notification_model.dart';

import 'package:times_up_flutter/widgets/show_logger.dart';

typedef QueryBuilder<T> = T Function(Map<String, dynamic> data);
Expand Down Expand Up @@ -114,6 +117,7 @@ class FireStoreService {
Stream<List<T>> notificationStream<T>({
required String path,
required T Function(Map<String, dynamic> data, String documentId) builder,
String? childId,
Function(Query query)? queryBuilder,
int Function(T lhs, T rhs)? sort,
}) {
Expand All @@ -122,10 +126,15 @@ class FireStoreService {
query = queryBuilder(query) as CollectionReference<Map<String, dynamic>>;
}
final snapshots = query.snapshots();

return snapshots.map((snapshot) {
final result = snapshot.docs
.map((snapshot) => builder(snapshot.data(), snapshot.id))
.where((value) => value != null)
.where(
(value) =>
value != null &&
(childId == null || (value as NotificationModel).id == childId),
)
.toList();
if (sort != null) {
result.sort(sort);
Expand Down

0 comments on commit ba595a7

Please sign in to comment.