Skip to content

Commit

Permalink
Merge pull request #27 from ubclaunchpad/groupManagement
Browse files Browse the repository at this point in the history
Group management
  • Loading branch information
armintalaie authored Feb 12, 2022
2 parents 66fcfe7 + c77114e commit 26ecb98
Show file tree
Hide file tree
Showing 14 changed files with 466 additions and 431 deletions.
3 changes: 1 addition & 2 deletions frontend/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'src/authentication_home_page.dart';
import 'package:firebase_auth/firebase_auth.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();

await Firebase.initializeApp();

runApp(TaskScheduler());
runApp(const TaskScheduler());
}

class TaskScheduler extends StatelessWidget {
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/src/authentication_home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class LoginPage extends StatelessWidget {
Image.asset(
'lib/assets/icons/homelogo.png',
height: 145,
width: 145,
width: 245,
),
]),
margin: const EdgeInsets.fromLTRB(0, 180, 0, 0),
Expand Down
99 changes: 99 additions & 0 deletions frontend/lib/src/create_group.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

class CreateGroup extends StatefulWidget {
const CreateGroup({Key? key, required this.id}) : super(key: key);
final String id;
@override
State<CreateGroup> createState() => _CreateGroup();
}

class _CreateGroup extends State<CreateGroup> {
final myController = TextEditingController();
DateTime selectedDate = DateTime.now();

@override
void initState() {
super.initState();
}

@override
void dispose() {
myController.dispose();
super.dispose();
}

void createAGroup() async {
CollectionReference ref = FirebaseFirestore.instance.collection("groups");
ref.add({
"groupName": myController.text,
"users": [widget.id],
}).then((value) async {
CollectionReference users =
FirebaseFirestore.instance.collection("users");
DocumentSnapshot doc = await users.doc(widget.id).get();
dynamic groups = doc.data();
Map<String, dynamic> newGroups = groups["groups"];
newGroups[value.id] = myController.text;

users.doc(widget.id).update({"groups": newGroups});
Navigator.pop(context);
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Create A New Group'),
),
body: Container(
margin: const EdgeInsets.only(bottom: 30),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Card(
child: Padding(
padding: EdgeInsets.only(top: 20.0, bottom: 20.0),
child: ListTile(
leading: Icon(Icons.info_outlined),
subtitle: Text(
'After creating a group, you can find the group panel by clicking on the top left corner'),
),
),
),
Text(widget.id),
TextField(
controller: myController,
decoration: const InputDecoration(
//border: InputBorder.none,
hintText: "Group name",
hintStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16,
decoration: TextDecoration.none,
color: Colors.black,
),
),
),
Container(
margin: const EdgeInsets.only(top: 30),
child: Column(
children: [
ElevatedButton(
onPressed: () {
createAGroup();
// Navigator.pop(context);
},
child: const Text('Create'),
),
],
),
// width: MediaQuery.of(context).size.width,
),
]),
),
);
}
}
8 changes: 4 additions & 4 deletions frontend/lib/src/task.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import '../widgets/interactive_task.dart';
import 'package:date_format/date_format.dart';
import 'dart:collection';

class Task extends StatefulWidget {
const Task(
Expand All @@ -26,7 +26,7 @@ class _Task extends State<Task> {
Widget build(BuildContext context) {
String due = "";
int points = 1;
dynamic? data = widget.ds?.data();
dynamic data = widget.ds?.data();
if (data == Null) return Container();
try {
DateTime date = DateTime.parse(data["dueDate"].toDate().toString());
Expand Down Expand Up @@ -110,7 +110,7 @@ class _Task extends State<Task> {
}

Widget status() {
dynamic? data = widget.ds?.data();
dynamic data = widget.ds?.data();
String status = data["status"].toString();
BorderRadiusGeometry radius = const BorderRadius.only(
//bottomLeft: Radius.circular(10.0),
Expand Down
Loading

0 comments on commit 26ecb98

Please sign in to comment.