Skip to content

Commit

Permalink
Merge pull request #2 from fatimafatimaprogrammer/main
Browse files Browse the repository at this point in the history
Making Data controller file generic
  • Loading branch information
fatimafatimaprogrammer authored May 9, 2023
2 parents 439c45b + 7eadc2c commit 913f8c4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 31 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<<<<<<< HEAD

## Campus Mirador

=======
# campus-mirador
>>>>>>> ab0526c (Initial commit)
40 changes: 20 additions & 20 deletions lib/controllers/data_controller.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'package:cloud_firestore/cloud_firestore.dart';

class DataController {
Future<String> getFirstFloors() async {
Future<String> getFirstFloors(String documentName) async {
final document = await FirebaseFirestore.instance
.collection('buildings')
.doc('seecsUg')
.doc(documentName)
.get();
final data = document.data();
String text = '';
Expand All @@ -24,10 +24,10 @@ class DataController {
return text;
}

Future<String> getSecondFloor() async {
Future<String> getSecondFloor(String documentName) async {
final document = await FirebaseFirestore.instance
.collection('buildings')
.doc('seecsUg')
.doc(documentName)
.get();
final data = document.data();
String text = '';
Expand All @@ -48,10 +48,10 @@ class DataController {
return text;
}

Future<String> getClassrooms() async {
Future<String> getClassrooms(String documentName) async {
final document = await FirebaseFirestore.instance
.collection('buildings')
.doc('seecsUg')
.doc(documentName)
.get();
final data = document.data();
String text = '';
Expand All @@ -62,10 +62,10 @@ class DataController {
return text;
}

Future<String> getLabs() async {
Future<String> getLabs(String documentName) async {
final document = await FirebaseFirestore.instance
.collection('buildings')
.doc('seecsUg')
.doc(documentName)
.get();
final data = document.data();
String text = '';
Expand All @@ -75,10 +75,10 @@ class DataController {
return text;
}

Future<String> getDean() async {
Future<String> getDean(String documentName) async {
final document = await FirebaseFirestore.instance
.collection('buildings')
.doc('seecsUg')
.doc(documentName)
.get();
final data = document.data();
String text = '';
Expand All @@ -89,10 +89,10 @@ class DataController {
return text;
}

Future<String> getHistory() async {
Future<String> getHistory(String documentName) async {
final document = await FirebaseFirestore.instance
.collection('buildings')
.doc('seecsUg')
.doc(documentName)
.get();
final data = document.data();
String text = '';
Expand All @@ -104,10 +104,10 @@ class DataController {
return text;
}

Future<String> getDept() async {
Future<String> getDept(String documentName) async {
final document = await FirebaseFirestore.instance
.collection('buildings')
.doc('seecsUg')
.doc(documentName)
.get();
final data = document.data();
String text = '';
Expand All @@ -119,10 +119,10 @@ class DataController {
return text;
}

Future<String> getFacility() async {
Future<String> getFacility(String documentName) async {
final document = await FirebaseFirestore.instance
.collection('buildings')
.doc('seecsUg')
.doc(documentName)
.get();
final data = document.data();
String text = '';
Expand All @@ -133,10 +133,10 @@ class DataController {
return text;
}

Future<String> getFacultyOffice() async {
Future<String> getFacultyOffice(String documentName) async {
final document = await FirebaseFirestore.instance
.collection('buildings')
.doc('seecsUg')
.doc(documentName)
.get();
final data = document.data();
String text = '';
Expand All @@ -148,10 +148,10 @@ class DataController {
return text;
}

Future<String> getData() async {
Future<String> getData(String documentName) async {
final document = await FirebaseFirestore.instance
.collection('buildings')
.doc('seecsUg')
.doc(documentName)
.get();
final data = document.data();
final firstFloor = data?['floor']?['first'];
Expand Down
23 changes: 12 additions & 11 deletions lib/screens/ar_screens/explore_more.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class _ExploreMoreState extends State<ExploreMore> {
final double avatarRadius = screenSize.width * 0.2;
final double buttonFontSize = screenSize.width * 0.05;

final prediction = 'seecsUg';
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal.shade900,
Expand Down Expand Up @@ -68,7 +69,7 @@ class _ExploreMoreState extends State<ExploreMore> {
child: TextButton(
onPressed: () {
showAlertDialog(context,
value: _dataController.getDean());
value: _dataController.getDean(prediction));
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down Expand Up @@ -104,7 +105,7 @@ class _ExploreMoreState extends State<ExploreMore> {
child: TextButton(
onPressed: () {
showAlertDialog(context,
value: _dataController.getHistory());
value: _dataController.getHistory(prediction));
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down Expand Up @@ -140,7 +141,7 @@ class _ExploreMoreState extends State<ExploreMore> {
child: TextButton(
onPressed: () {
showAlertDialog(context,
value: _dataController.getDept());
value: _dataController.getDept(prediction));
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down Expand Up @@ -184,7 +185,7 @@ class _ExploreMoreState extends State<ExploreMore> {
child: TextButton(
onPressed: () {
showAlertDialog(context,
value: _dataController.getFirstFloors());
value: _dataController.getFirstFloors(prediction));
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down Expand Up @@ -220,7 +221,7 @@ class _ExploreMoreState extends State<ExploreMore> {
child: TextButton(
onPressed: () {
showAlertDialog(context,
value: _dataController.getSecondFloor());
value: _dataController.getSecondFloor(prediction));
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down Expand Up @@ -251,7 +252,7 @@ class _ExploreMoreState extends State<ExploreMore> {
TextButton(
onPressed: () {
showAlertDialog(context,
value: _dataController.getLabs());
value: _dataController.getLabs(prediction));
},
child: Container(
margin: const EdgeInsets.only(left: 10),
Expand Down Expand Up @@ -300,7 +301,7 @@ class _ExploreMoreState extends State<ExploreMore> {
child: TextButton(
onPressed: () {
showAlertDialog(context,
value: _dataController.getClassrooms());
value: _dataController.getClassrooms(prediction));
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down Expand Up @@ -336,7 +337,7 @@ class _ExploreMoreState extends State<ExploreMore> {
child: TextButton(
onPressed: () {
showAlertDialog(context,
value: _dataController.getFacility());
value: _dataController.getFacility(prediction));
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
Expand Down Expand Up @@ -367,7 +368,7 @@ class _ExploreMoreState extends State<ExploreMore> {
TextButton(
onPressed: () {
showAlertDialog(context,
value: _dataController.getFacultyOffice());
value: _dataController.getFacultyOffice(prediction));
},
child: Container(
margin: const EdgeInsets.only(left: 10),
Expand Down Expand Up @@ -478,15 +479,15 @@ class _ExploreMoreState extends State<ExploreMore> {

class MyAlert extends StatelessWidget {
const MyAlert({super.key});

final prediction='seecsUg';
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(20.0),
child: ElevatedButton(
child: const Text('Show alert'),
onPressed: () {
showAlertDialog(context, value: _dataController.getData());
showAlertDialog(context, value: _dataController.getData(prediction));
},
),
);
Expand Down

0 comments on commit 913f8c4

Please sign in to comment.