Skip to content

Commit

Permalink
Merge pull request #9 from robjo82/develop
Browse files Browse the repository at this point in the history
Version 0.0.1
  • Loading branch information
robjo82 authored Mar 27, 2023
2 parents 2741977 + e397ea7 commit 5cc2088
Show file tree
Hide file tree
Showing 42 changed files with 1,251 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ migrate_working_dir/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
.vscode/

# Flutter/Dart/Pub related
**/doc/api/
Expand Down
6 changes: 5 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ if (flutterVersionName == null) {
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion flutter.compileSdkVersion
Expand All @@ -47,10 +48,11 @@ android {
applicationId "com.example.chat_chuispt"
// 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 flutter.minSdkVersion
minSdkVersion 31
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
minSdkVersion 21
}

buildTypes {
Expand All @@ -68,4 +70,6 @@ flutter {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:31.2.3')
implementation 'com.google.firebase:firebase-analytics-ktx'
}
40 changes: 40 additions & 0 deletions android/app/google-services.json
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"
}
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.chat_chuispt">
<application
android:label="chat_chuispt"
android:label="Chat Chuispt"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
Expand Down
Binary file modified android/app/src/main/res/mipmap-hdpi/ic_launcher.png
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 android/app/src/main/res/mipmap-mdpi/ic_launcher.png
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 android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
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 android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
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 android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15'
}
}

Expand Down
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -610,4 +610,4 @@
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
}
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 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 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 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 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 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 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 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 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 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 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 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 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.
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 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.
43 changes: 43 additions & 0 deletions lib/constants.dart
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),
);
67 changes: 67 additions & 0 deletions lib/database_service.dart
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();
}
}
63 changes: 63 additions & 0 deletions lib/firebase_options.dart
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',
);
}
119 changes: 119 additions & 0 deletions lib/main page/components/Drawer.dart
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),
],
))
],
),
),
],
),
);
}
}
Loading

0 comments on commit 5cc2088

Please sign in to comment.