Skip to content

Commit

Permalink
updated login signup data_controller. made view_stats responsive. add…
Browse files Browse the repository at this point in the history
…ed pop to ar overlay and explore more screens
  • Loading branch information
maryam-fatima committed May 7, 2023
1 parent f2ed891 commit 439c45b
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 156 deletions.
19 changes: 10 additions & 9 deletions lib/controllers/data_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DataController {
String text = '';
final firstFloor = data?['floor']?['first'];
final secondFloor = data?['floor']?['second'];
final classrooms = firstFloor['classrooms'] + secondFloor['classroons'];
final classrooms = firstFloor['classrooms'] + secondFloor['classrooms'];
text += 'Classrooms: ${classrooms?.toString() ?? 'N/A'}\n';
return text;
}
Expand Down Expand Up @@ -126,10 +126,10 @@ class DataController {
.get();
final data = document.data();
String text = '';
final firstFloor = data?['floor']?['first'];
final secondFloor = data?['floor']?['second'];
final classrooms = firstFloor['classrooms'] + secondFloor['classroons'];
text += 'Classrooms: ${classrooms?.toString() ?? 'N/A'}\n';
final firstFloor = data?['floor']?['first'] ?? [];
final secondFloor = data?['floor']?['second'] ?? [];
final facilities = firstFloor['facilities'] + secondFloor['facilities'];
text += 'Facilities: ${facilities?.toString() ?? 'N/A'}\n';
return text;
}

Expand All @@ -140,10 +140,11 @@ class DataController {
.get();
final data = document.data();
String text = '';
final firstFloor = data?['floor']?['first'];
final secondFloor = data?['floor']?['second'];
final classrooms = firstFloor['classrooms'] + secondFloor['classroons'];
text += 'Classrooms: ${classrooms?.toString() ?? 'N/A'}\n';
final firstFloor = data?['floor']?['first'] ?? [];
final secondFloor = data?['floor']?['second'] ?? [];
final facultyOffices =
'\nFirst Floor: ${firstFloor['facultyOffices']}\nSecond Floor: ${secondFloor['facultyOffices']}\n';
text += 'Faculty Offices: ${facultyOffices ?? 'N/A'}\n';
return text;
}

Expand Down
4 changes: 4 additions & 0 deletions lib/screens/ar_screens/ar_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class _AROverlayState extends State<AROverlay> {
),
onPressed: () async {
await FirebaseServices().googleSignOut();
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(
Expand Down
7 changes: 5 additions & 2 deletions lib/screens/ar_screens/explore_more.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:google_fonts/google_fonts.dart';

import '../../controllers/data_controller.dart';
Expand Down Expand Up @@ -424,6 +422,11 @@ class _ExploreMoreState extends State<ExploreMore> {
),
onPressed: () async {
await FirebaseServices().googleSignOut();
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context);
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(
Expand Down
18 changes: 9 additions & 9 deletions lib/screens/authentication/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,19 @@ class _LoginScreenState extends State<LoginScreen> {
final result =
await FirebaseServices().signInWithGoogle();

// Wait for a short delay to allow the user to choose their account.
await Future.delayed(Duration(seconds: 1));

// If the user didn't select an account, cancel the sign-in process.
if (result == null) {
// If the user didn't select an account, return and do not navigate to the HomeScreen.
if (result == false) {
return;
}

// Navigate to the home screen if the sign-in process was successful.
// Wait for a short delay to allow the user to choose their account.
await Future.delayed(const Duration(seconds: 1));

// Navigate to the HomeScreen.
Navigator.push(
context,
MaterialPageRoute(builder: (context) => HomeScreen()),
);
context,
MaterialPageRoute(
builder: (context) => const HomeScreen()));
},
child: Row(
children: [
Expand Down
21 changes: 17 additions & 4 deletions lib/screens/authentication/signup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,24 @@ class _SignUpScreenState extends State<SignUpScreen> {
borderRadius: BorderRadius.circular(28)),
child: TextButton(
onPressed: () async {
await FirebaseServices().signInWithGoogle();
// Start the Google sign-in process.
final result =
await FirebaseServices().signInWithGoogle();

// If the user didn't select an account, return and do not navigate to the HomeScreen.
if (result == false) {
return;
}

// Wait for a short delay to allow the user to choose their account.
await Future.delayed(const Duration(seconds: 1));

// Navigate to the HomeScreen.
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const HomeScreen()));
context,
MaterialPageRoute(
builder: (context) => const HomeScreen()),
);
},
child: Row(
children: [
Expand Down
193 changes: 62 additions & 131 deletions lib/screens/features/view_stats.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,39 @@ class ViewStats extends StatelessWidget {
final Size screenSize = MediaQuery.of(context).size;

return Scaffold(
appBar: AppBar(
backgroundColor: Colors.teal.shade900,
title: const Text('Mirador'),
),
body: SingleChildScrollView(
child: Column(
children: [
Container(
color: Colors.teal.shade100,
child: Padding(
padding: EdgeInsets.only(left: screenSize.width * 0.03),
child: Row(
children: [
SizedBox(
height: screenSize.height * 0.07,
),
const PeopleCount(
name: "Undergraduates",
value: 1559,
),
SizedBox(
width: screenSize.width * 0.14,
),
const PeopleCount(
name: "Postgraduates",
value: 1559,
),
SizedBox(
width: screenSize.width * 0.15,
),
const PeopleCount(
name: "Faculty",
value: 1559,
)
],
),
),
),
SizedBox(
height: screenSize.height * 0.01,
),
const AboutBuildingContainer(),
const Gallery(),
const SizedBox(
height: 15,
appBar: AppBar(
backgroundColor: Colors.teal.shade900,
title: const Text('Mirador'),
),
body: SingleChildScrollView(
child: Column(
children: [
Container(
color: Colors.teal.shade100,
padding: EdgeInsets.only(left: screenSize.width * 0.03),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
PeopleCount(name: "Undergraduates", value: 1559),
PeopleCount(name: "Postgraduates", value: 1559),
PeopleCount(name: "Faculty", value: 1559)
],
),
const ImportantLinks(),
const Footer(),
],
),
));
),
SizedBox(
height: screenSize.height * 0.01,
),
const AboutBuildingContainer(),
const Gallery(),
const SizedBox(
height: 15,
),
const ImportantLinks(),
const Footer(),
],
),
),
);
}
}

Expand All @@ -91,18 +73,8 @@ class AboutBuildingContainer extends StatelessWidget {
height: screenHeight * 0.02,
),
Align(
alignment: Alignment.topLeft,
child: Text(
' Welcome to Seecs',
style: GoogleFonts.montserrat(
textStyle: TextStyle(
fontSize: screenWidth * 0.05,
color: Colors.black,
fontWeight: FontWeight.w700,
),
),
),
),
alignment: Alignment.topLeft,
child: _heading('Welcome to SEECS', screenWidth)),
const SizedBox(
height: 5,
),
Expand Down Expand Up @@ -147,9 +119,6 @@ class PeopleCount extends StatelessWidget {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final screenHeight = MediaQuery.of(context).size.height;

return Column(
children: [
Text(
Expand Down Expand Up @@ -189,44 +158,17 @@ class Gallery extends StatelessWidget {
height: screenHeight * 0.01,
),
Align(
alignment: Alignment.topLeft,
child: Text(
' Departments',
style: GoogleFonts.montserrat(
textStyle: TextStyle(
fontSize: screenWidth * 0.05,
color: Colors.black,
fontWeight: FontWeight.w700,
),
),
),
),
alignment: Alignment.topLeft,
child: _heading('Departments', screenWidth)),
SizedBox(
height: screenHeight * 0.01,
),
Row(
children: [
SizedBox(
width: screenWidth * 0.04,
),
const ImageWithText(
url: 'images/SEECS_UG.JPG',
description: 'UG',
),
SizedBox(
width: screenWidth * 0.04,
),
const ImageWithText(
url: 'images/SEECS_PG.JPG',
description: 'PG',
),
SizedBox(
width: screenWidth * 0.04,
),
const ImageWithText(
url: 'images/IAEC.JPG',
description: 'IAEC',
),
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
ImageWithText(url: 'images/SEECS_UG.JPG', description: 'UG'),
ImageWithText(url: 'images/SEECS_PG.JPG', description: 'PG'),
ImageWithText(url: 'images/IAEC.JPG', description: 'IAEC'),
],
),
],
Expand All @@ -243,9 +185,6 @@ class ImageWithText extends StatelessWidget {

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.of(context).size.width;
final screenHeight = MediaQuery.of(context).size.height;

return Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expand Down Expand Up @@ -289,43 +228,22 @@ class ImportantLinks extends StatelessWidget {
height: 5,
),
Align(
alignment: Alignment.topLeft,
child: Text(
' Important Links',
style: GoogleFonts.montserrat(
textStyle: TextStyle(
fontSize: screenWidth * 0.05,
color: Colors.black,
fontWeight: FontWeight.w700,
),
),
),
),
alignment: Alignment.topLeft,
child: _heading('Important Links', screenWidth)),
SizedBox(
height: screenHeight * 0.02,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const LinkToLoc(
name: "LMS",
),
SizedBox(
width: screenWidth * 0.03,
),
const LinkToLoc(
name: "Qalam",
),
SizedBox(
width: screenWidth * 0.03,
),
const LinkToLoc(
name: "Support",
),
children: const [
LinkToLoc(name: "LMS"),
LinkToLoc(name: "Qalam"),
LinkToLoc(name: "Support"),
],
),
SizedBox(
height: screenHeight * 0.03,
height: screenHeight * 0.02,
)
],
),
Expand Down Expand Up @@ -366,3 +284,16 @@ class LinkToLoc extends StatelessWidget {
));
}
}

Widget _heading(String text, final screenWidth) {
return Text(
text,
style: GoogleFonts.montserrat(
textStyle: TextStyle(
fontSize: screenWidth * 0.05,
color: Colors.black,
fontWeight: FontWeight.w700,
),
),
);
}
5 changes: 4 additions & 1 deletion lib/services/firebase_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FirebaseServices {
}
}

signInWithGoogle() async {
Future<bool> signInWithGoogle() async {
try {
final GoogleSignInAccount? googleSignInAccount =
await _googleSignIn.signIn();
Expand All @@ -40,6 +40,9 @@ class FirebaseServices {
accessToken: googleSignInAuthentication.accessToken,
idToken: googleSignInAuthentication.idToken);
await _auth.signInWithCredential(authCredential);
return true; // Return true if sign-in is successful
} else {
return false; // Return false if user cancels sign-in process
}
} on FirebaseAuthException catch (e) {
print(e.message);
Expand Down

0 comments on commit 439c45b

Please sign in to comment.