-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from robjo82/develop
Version 0.0.1
- Loading branch information
Showing
42 changed files
with
1,251 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"project_info": { | ||
"project_number": "363041976766", | ||
"firebase_url": "https://chat-chuispt-default-rtdb.europe-west1.firebasedatabase.app", | ||
"project_id": "chat-chuispt", | ||
"storage_bucket": "chat-chuispt.appspot.com" | ||
}, | ||
"client": [ | ||
{ | ||
"client_info": { | ||
"mobilesdk_app_id": "1:363041976766:android:1fbc51100b4ad0a1cbc9ef", | ||
"android_client_info": { | ||
"package_name": "com.example.chat_chuispt" | ||
} | ||
}, | ||
"oauth_client": [ | ||
{ | ||
"client_id": "363041976766-bsbrl73aj9euefgqipf7qghk03d2idkf.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
], | ||
"api_key": [ | ||
{ | ||
"current_key": "AIzaSyCGPdadzqssGTDxcVR5VTSox_jzhKeZkIg" | ||
} | ||
], | ||
"services": { | ||
"appinvite_service": { | ||
"other_platform_oauth_client": [ | ||
{ | ||
"client_id": "363041976766-bsbrl73aj9euefgqipf7qghk03d2idkf.apps.googleusercontent.com", | ||
"client_type": 3 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
], | ||
"configuration_version": "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -610,4 +610,4 @@ | |
/* End XCConfigurationList section */ | ||
}; | ||
rootObject = 97C146E61CF9000F007C117D /* Project object */; | ||
} | ||
} |
Binary file modified
BIN
+76 KB
(810%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+284 Bytes
(200%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+927 Bytes
(330%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.72 KB
(490%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+627 Bytes
(320%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.63 KB
(460%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.67 KB
(490%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+927 Bytes
(330%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.43 KB
(530%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3.77 KB
(550%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+3.77 KB
(550%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.03 KB
(410%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.13 KB
(390%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.5 KB
(480%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.85 KB
(450%)
ios/Runner/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
TextStyle normalText = const TextStyle( | ||
color: Colors.white, | ||
fontSize: 15, | ||
fontWeight: FontWeight.w300, | ||
); | ||
|
||
TextStyle titleText = const TextStyle( | ||
color: Colors.white, | ||
fontSize: 40, | ||
fontWeight: FontWeight.w700, | ||
); | ||
|
||
TextStyle titleText2 = const TextStyle( | ||
color: Colors.white, | ||
fontSize: 20, | ||
fontWeight: FontWeight.w500, | ||
); | ||
|
||
ThemeData themeApp = ThemeData( | ||
colorScheme: ColorScheme( | ||
|
||
// ? PRIMAIRES ? // | ||
primary: const Color(0xFF444654), // responses | ||
secondary: const Color(0xFF343541), // questions, text Field and appBar | ||
primaryContainer: const Color(0xFF202123), // drawer | ||
secondaryContainer: const Color(0xFF3E3F4B), //Question grid | ||
error: Colors.red, | ||
|
||
// ? SURFACE ? // | ||
surface: Colors.blueGrey.shade900, | ||
background: const Color(0xFF444654), // like responses | ||
|
||
// ? ON ? // | ||
onPrimary: Colors.white, | ||
onPrimaryContainer: Colors.white, | ||
onSecondary: Colors.white, | ||
onSurface: Colors.white, | ||
onBackground: Colors.white, | ||
onError: Colors.white, | ||
brightness: Brightness.dark), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import 'package:firebase_database/firebase_database.dart'; | ||
|
||
class DatabaseService { | ||
final DatabaseReference _databaseReference = | ||
FirebaseDatabase.instance.ref(''); | ||
|
||
// data format : {responses: {id: {text: text, blue_thumb: blueThumb, red_thumb: redThumb}}, ...} | ||
// Fetches all the data from the database | ||
Stream<List<Map<String, dynamic>>> getData() { | ||
return _databaseReference.child('responses').onValue.map((event) { | ||
final List<Map<String, dynamic>> data = []; | ||
|
||
final Map<dynamic, dynamic>? responses = | ||
event.snapshot.value as Map<dynamic, dynamic>?; | ||
if (responses != null) { | ||
responses.forEach((key, value) { | ||
final Map<dynamic, dynamic>? responseMap = | ||
value as Map<dynamic, dynamic>?; | ||
|
||
final String? text = responseMap?['text'] as String?; | ||
final int? blueThumb = responseMap?['blue_thumb'] as int?; | ||
final int? redThumb = responseMap?['red_thumb'] as int?; | ||
|
||
if (text != null && blueThumb != null && redThumb != null) { | ||
data.add({ | ||
'id': key, | ||
'text': text, | ||
'blue_thumb': blueThumb, | ||
'red_thumb': redThumb, | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
return data; | ||
}); | ||
} | ||
|
||
// add a new answer to the database, with its id, text, blue thumb and red thumb | ||
Future<void> addResponse(String text, int blueThumb, int redThumb) { | ||
final int responseId = DateTime.now().millisecondsSinceEpoch; | ||
return _databaseReference.child('responses/$responseId').set({ | ||
'text': text, | ||
'blue_thumb': blueThumb, | ||
'red_thumb': redThumb, | ||
}); | ||
} | ||
|
||
// Updates the blue thumb of a question | ||
Future<void> updateBlueThumb(String id, int blueThumb) { | ||
return _databaseReference.child('responses').child(id.toString()).update({ | ||
'blue_thumb': blueThumb, | ||
}); | ||
} | ||
|
||
// Updates the red thumb of a question | ||
Future<void> updateRedThumb(String id, int redThumb) { | ||
return _databaseReference.child('responses').child(id.toString()).update({ | ||
'red_thumb': redThumb, | ||
}); | ||
} | ||
|
||
// delete a question | ||
Future<void> deleteResponse(String id) { | ||
return _databaseReference.child('responses').child(id.toString()).remove(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// File generated by FlutterFire CLI. | ||
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members | ||
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; | ||
import 'package:flutter/foundation.dart' | ||
show defaultTargetPlatform, kIsWeb, TargetPlatform; | ||
|
||
/// Default [FirebaseOptions] for use with your Firebase apps. | ||
/// | ||
/// Example: | ||
/// ```dart | ||
/// import 'firebase_options.dart'; | ||
/// // ... | ||
/// await Firebase.initializeApp( | ||
/// options: DefaultFirebaseOptions.currentPlatform, | ||
/// ); | ||
/// ``` | ||
class DefaultFirebaseOptions { | ||
static FirebaseOptions get currentPlatform { | ||
if (kIsWeb) { | ||
throw UnsupportedError( | ||
'DefaultFirebaseOptions have not been configured for web - ' | ||
'you can reconfigure this by running the FlutterFire CLI again.', | ||
); | ||
} | ||
switch (defaultTargetPlatform) { | ||
case TargetPlatform.android: | ||
return android; | ||
case TargetPlatform.iOS: | ||
throw UnsupportedError( | ||
'DefaultFirebaseOptions have not been configured for ios - ' | ||
'you can reconfigure this by running the FlutterFire CLI again.', | ||
); | ||
case TargetPlatform.macOS: | ||
throw UnsupportedError( | ||
'DefaultFirebaseOptions have not been configured for macos - ' | ||
'you can reconfigure this by running the FlutterFire CLI again.', | ||
); | ||
case TargetPlatform.windows: | ||
throw UnsupportedError( | ||
'DefaultFirebaseOptions have not been configured for windows - ' | ||
'you can reconfigure this by running the FlutterFire CLI again.', | ||
); | ||
case TargetPlatform.linux: | ||
throw UnsupportedError( | ||
'DefaultFirebaseOptions have not been configured for linux - ' | ||
'you can reconfigure this by running the FlutterFire CLI again.', | ||
); | ||
default: | ||
throw UnsupportedError( | ||
'DefaultFirebaseOptions are not supported for this platform.', | ||
); | ||
} | ||
} | ||
|
||
static const FirebaseOptions android = FirebaseOptions( | ||
apiKey: 'AIzaSyCGPdadzqssGTDxcVR5VTSox_jzhKeZkIg', | ||
appId: '1:363041976766:android:1fbc51100b4ad0a1cbc9ef', | ||
messagingSenderId: '363041976766', | ||
projectId: 'chat-chuispt', | ||
databaseURL: 'https://chat-chuispt-default-rtdb.europe-west1.firebasedatabase.app', | ||
storageBucket: 'chat-chuispt.appspot.com', | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
import '../../constants.dart'; | ||
import '../../database_service.dart'; | ||
import '../../main.dart'; | ||
|
||
class MyDrawer extends StatelessWidget { | ||
const MyDrawer({Key? key}) : super(key: key); | ||
|
||
//! dialog window of remerciement | ||
void _showThankYouDialog(BuildContext context) { | ||
showDialog( | ||
context: context, | ||
builder: (BuildContext context) { | ||
return AlertDialog( | ||
content: const Text('Merci pour votre contribution !'), | ||
icon: const Icon(Icons.check_circle_outline_outlined), | ||
actions: [ | ||
TextButton( | ||
onPressed: () { | ||
Navigator.of(context).pop(); | ||
}, | ||
child: Text('Fermer', style: normalText), | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
|
||
//! dialog window of contribution | ||
void _showContributionDialog(BuildContext context) { | ||
final DatabaseService _databaseService = DatabaseService(); | ||
final TextEditingController _controller = TextEditingController(); | ||
showDialog( | ||
context: context, | ||
builder: (BuildContext context) { | ||
return AlertDialog( | ||
title: const Text('Contribution'), | ||
content: TextField( | ||
controller: _controller, | ||
decoration: | ||
const InputDecoration(hintText: 'Entrez votre texte ici'), | ||
), | ||
actions: [ | ||
TextButton( | ||
onPressed: () { | ||
Navigator.of(context).pop(); | ||
}, | ||
child: Text('Annuler', style: normalText), | ||
), | ||
TextButton( | ||
onPressed: () { | ||
// Ajoute la nouvelle réponse à la base de données | ||
_databaseService.addResponse(_controller.text, 0, 0); | ||
Navigator.of(context) | ||
.pop(); // Ferme la boîte de dialogue de contribution | ||
_showThankYouDialog( | ||
context); // Affiche le message de remerciement | ||
}, | ||
child: Text('Envoyer', style: normalText), | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
var appState = context.watch<MainAppState>(); // état de l'application | ||
|
||
return Drawer( | ||
backgroundColor: themeApp.colorScheme.primaryContainer.withOpacity(1), | ||
child: ListView( | ||
children: [ | ||
ListTile( | ||
title: Column( | ||
children: [ | ||
const SizedBox(height: 35), | ||
|
||
// * "Contribuer" button * // | ||
TextButton( | ||
onPressed: () { | ||
Navigator.pop(context); // Ferme le drawer | ||
_showContributionDialog(context); | ||
}, | ||
child: Row( | ||
children: [ | ||
Icon(Icons.add_circle_outline, | ||
color: themeApp.colorScheme.onPrimaryContainer), | ||
const SizedBox(width: 25), | ||
Text("Contribuer", style: titleText2), | ||
], | ||
)), | ||
const SizedBox(height: 15), | ||
|
||
// * "Reinitialisation" button * // | ||
TextButton( | ||
onPressed: () { | ||
appState.clearQuestionList(); | ||
}, | ||
child: Row( | ||
children: [ | ||
Icon(Icons.restore, | ||
color: themeApp.colorScheme.onPrimaryContainer), | ||
const SizedBox(width: 25), | ||
Text("Réinitialisation", style: titleText2), | ||
], | ||
)) | ||
], | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.