Skip to content

Commit

Permalink
Merge pull request #84 from glennquah/Deployment/MS3
Browse files Browse the repository at this point in the history
Deployment/ms3
  • Loading branch information
glennquah authored Jul 23, 2023
2 parents d585e15 + f7afcc3 commit f8aefd3
Show file tree
Hide file tree
Showing 35 changed files with 608 additions and 525 deletions.
12 changes: 6 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ class MyApp extends StatelessWidget {
value: Auth().user,
initialData: null,
child: MaterialApp(
home: Wrapper(),
home: const Wrapper(),
// to route to a page, use Navigator.pushNamed(context, '/pageName')
routes: {
'/home': (context) => ShowCaseWidget(
builder: Builder(builder: (context) => Home()),
builder: Builder(builder: (context) => const Home()),
),
'/scan': (context) => ShowCaseWidget(
builder: Builder(builder: (context) => OcrScreen()),
builder: Builder(builder: (context) => const OcrScreen()),
),
'/physicalcards': (context) => PhysicalCardPage(),
'/friends': (context) => FriendsCardsPage(),
'/profile': (context) => ProfilePage(),
'/physicalcards': (context) => const PhysicalCardPage(),
'/friends': (context) => const FriendsCardsPage(),
'/profile': (context) => const ProfilePage(),
},
),
);
Expand Down
6 changes: 3 additions & 3 deletions lib/models/Cards.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Purpose: Create a Cards class to store the data of the Name card
// Card class to store the data of the Name card
class Cards {
final String imageUrl;
final String cardName;
Expand All @@ -7,8 +7,8 @@ class Cards {
final String phoneNum;
final String email;
final String companyWebsite;
final String? companyAddress;
final String? personalStatement;
final String? companyAddress; // optional
final String? personalStatement; // optional
final String? moreInfo; // optional as people might not want to add more info

// Cards Constructor
Expand Down
2 changes: 1 addition & 1 deletion lib/models/Friends.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Purpose: Create a Friends class to store UID of the user's friends
//Friends class to store UID of the user's friends
class Friends {
//Only store uid so that we can retrieve the user's data from the database
final String uid;
Expand Down
2 changes: 1 addition & 1 deletion lib/models/FriendsDatabase.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:connectcard/models/Cards.dart';
import 'package:connectcard/models/Friends.dart';

// UserData class which stores the user's data
//Friends data class to store the user's friends data
class FriendsData {
final String uid;
final List<Friends> listOfFriends;
Expand Down
2 changes: 1 addition & 1 deletion lib/models/TheUser.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:connectcard/models/Cards.dart';

// TheUser class
// TheUser class to store the user's UID
class TheUser {
final String uid;

Expand Down
45 changes: 21 additions & 24 deletions lib/profile/editprofilepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:provider/provider.dart';

//profile class to edit profile
//user able to edit name, headline and profile picture
class EditProfilePage extends StatefulWidget {
const EditProfilePage({super.key});

@override
_EditProfilePageState createState() => _EditProfilePageState();
}

class _EditProfilePageState extends State<EditProfilePage> {
final _editprofileKey = GlobalKey<FormState>();

final _Name = GlobalKey<FormState>();
String newName = '';
final _Headline = GlobalKey<FormState>();
String newHeadline = '';

File? image;
String profilepicUrl = '';

Expand All @@ -42,11 +41,11 @@ class _EditProfilePageState extends State<EditProfilePage> {
return Scaffold(
backgroundColor: const Color(0xffFEAA1B),
appBar: AppBar(
title: Text('Edit Profile'),
title: const Text('Edit Profile'),
backgroundColor: const Color(0xffFEAA1B),
),
body: SingleChildScrollView(
padding: EdgeInsets.all(16.0),
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expand All @@ -55,7 +54,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
child: Container(
height: 200,
width: 200,
decoration: BoxDecoration(
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.grey,
),
Expand All @@ -71,15 +70,15 @@ class _EditProfilePageState extends State<EditProfilePage> {
fit: BoxFit.cover,
),
)
: Icon(
: const Icon(
Icons.add_a_photo,
size: 50,
color: Colors.white,
),
),
),
SizedBox(height: 20.0),
Text(
const SizedBox(height: 20.0),
const Text(
'Edit Name',
style: TextStyle(
fontSize: 18.0,
Expand All @@ -88,16 +87,16 @@ class _EditProfilePageState extends State<EditProfilePage> {
),
TextFormField(
initialValue: userData!.name,
decoration: InputDecoration(
decoration: const InputDecoration(
hintText: 'New Name',
prefixIcon: Icon(Icons.person),
),
onChanged: (val) {
setState(() => newName = val);
},
),
SizedBox(height: 20.0),
Text(
const SizedBox(height: 20.0),
const Text(
'Edit Headline',
style: TextStyle(
fontSize: 18.0,
Expand All @@ -106,15 +105,15 @@ class _EditProfilePageState extends State<EditProfilePage> {
),
TextFormField(
initialValue: userData.headLine,
decoration: InputDecoration(
decoration: const InputDecoration(
hintText: 'New Headline',
prefixIcon: Icon(Icons.text_fields),
),
onChanged: (val) {
setState(() => newHeadline = val);
},
),
SizedBox(height: 20.0),
const SizedBox(height: 20.0),
ElevatedButton(
onPressed: () async {
await DatabaseService(uid: user.uid).updateUserData(
Expand All @@ -130,7 +129,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
Navigator.pop(
context); // Navigate back to the previous page
},
child: Text(
child: const Text(
'Save Changes',
style: TextStyle(color: Colors.white),
),
Expand All @@ -153,7 +152,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Center(child: Text('Select an Image')),
title: const Center(child: Text('Select an Image')),
content: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expand All @@ -162,7 +161,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
Navigator.of(context).pop();
await _pickImage(ImageSource.camera);
},
child: CircleAvatar(
child: const CircleAvatar(
radius: 32.0,
backgroundColor: Colors.transparent,
child: Icon(
Expand All @@ -172,13 +171,13 @@ class _EditProfilePageState extends State<EditProfilePage> {
),
),
),
SizedBox(width: 16.0),
const SizedBox(width: 16.0),
GestureDetector(
onTap: () async {
Navigator.of(context).pop();
await _pickImage(ImageSource.gallery);
},
child: CircleAvatar(
child: const CircleAvatar(
radius: 32.0,
backgroundColor: Colors.transparent,
child: Icon(
Expand Down Expand Up @@ -220,9 +219,7 @@ class _EditProfilePageState extends State<EditProfilePage> {

// Update the UI
setState(() {
if (file != null) {
image = File(file.path);
}
image = File(file.path);
});
}
}
54 changes: 33 additions & 21 deletions lib/profile/profilepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';

//profile class to view profile
//1. edit profile
//2. contact customer service thru email or phone
//3. log out
class ProfilePage extends StatelessWidget {
const ProfilePage({super.key});

String? encodeQueryParameters(Map<String, String> params) {
return params.entries
.map((MapEntry<String, String> e) =>
Expand Down Expand Up @@ -36,7 +42,7 @@ class ProfilePage extends StatelessWidget {
return Scaffold(
backgroundColor: bgColor,
appBar: AppBar(
title: Text('View Profile'),
title: const Text('View Profile'),
backgroundColor: const Color(0xffFEAA1B),
),
body: Center(
Expand All @@ -51,25 +57,28 @@ class ProfilePage extends StatelessWidget {
? NetworkImage(userData.profilePic)
: null,
child: userData.profilePic.isEmpty
? Icon(Icons.person, size: 60, color: Colors.white)
? const Icon(Icons.person,
size: 60, color: Colors.white)
: null,
),
SizedBox(height: 20),
const SizedBox(height: 20),
Text(
userData.name,
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
style: const TextStyle(
fontSize: 24, fontWeight: FontWeight.bold),
),
SizedBox(height: 5),
const SizedBox(height: 5),
Text(
'UID: #${user?.uid?.substring(user.uid.length - 4) ?? ''}',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 5),
const SizedBox(height: 5),
Text(
userData.headLine,
style: TextStyle(fontSize: 18),
style: const TextStyle(fontSize: 18),
),
SizedBox(height: 40),
const SizedBox(height: 40),
SizedBox(
width: 200,
child: OvalButton(
Expand All @@ -79,13 +88,13 @@ class ProfilePage extends StatelessWidget {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EditProfilePage(),
builder: (context) => const EditProfilePage(),
),
);
},
),
),
SizedBox(height: 20),
const SizedBox(height: 20),
SizedBox(
width: 200,
child: OvalButton(
Expand All @@ -96,7 +105,7 @@ class ProfilePage extends StatelessWidget {
},
),
),
SizedBox(height: 20),
const SizedBox(height: 20),
SizedBox(
width: 200,
child: OvalButton(
Expand Down Expand Up @@ -129,13 +138,13 @@ class ProfilePage extends StatelessWidget {
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('Select Contact Method'),
title: const Text('Select Contact Method'),
content: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: IconButton(
icon: Icon(Icons.mail, size: 30),
icon: const Icon(Icons.mail, size: 30),
onPressed: () {
Navigator.pop(context);
_sendEmail(context, userData);
Expand All @@ -144,7 +153,7 @@ class ProfilePage extends StatelessWidget {
),
Expanded(
child: IconButton(
icon: Icon(Icons.phone, size: 30),
icon: const Icon(Icons.phone, size: 30),
onPressed: () {
Navigator.pop(context);
_makePhoneCall(context, userData);
Expand All @@ -171,7 +180,7 @@ class ProfilePage extends StatelessWidget {
await launchUrl(emailUri);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
const SnackBar(
content: Text('No email client found'),
),
);
Expand All @@ -184,7 +193,7 @@ class ProfilePage extends StatelessWidget {
await launchUrl(phoneUrl);
} else {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
const SnackBar(
content: Text('Phone app not found'),
),
);
Expand All @@ -198,7 +207,10 @@ class OvalButton extends StatelessWidget {
final VoidCallback onPressed;

OvalButton(
{required this.icon, required this.label, required this.onPressed});
{super.key,
required this.icon,
required this.label,
required this.onPressed});

@override
Widget build(BuildContext context) {
Expand All @@ -208,14 +220,14 @@ class OvalButton extends StatelessWidget {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
padding: EdgeInsets.symmetric(vertical: 10),
padding: const EdgeInsets.symmetric(vertical: 10),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(icon, size: 40),
SizedBox(width: 8),
Text(label, style: TextStyle(fontSize: 16)),
const SizedBox(width: 8),
Text(label, style: const TextStyle(fontSize: 16)),
],
),
);
Expand Down
2 changes: 2 additions & 0 deletions lib/screens/authenticate/authenticate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:flutter/material.dart';

// This class is used to toggle between the sign in and register pages
class Authenticate extends StatefulWidget {
const Authenticate({super.key});

@override
_AuthenticateState createState() => _AuthenticateState();
}
Expand Down
Loading

0 comments on commit f8aefd3

Please sign in to comment.