Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First Version #6

Merged
merged 8 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,41 @@
# pilgrimage
# Pilgrimage

A new Flutter project.
Project for Technical Recruitment for SRMKZILLA.

## Getting Started
Stack used - Flutter as frontend framework, Firestore as database, Cloud Storage as blob storage service and Firebase Authentication as Authentication Service(Only Email and Password).

This project is a starting point for a Flutter application.
### Feautures

A few resources to get you started if this is your first Flutter project:
- Post new Pictures( PNG, JPG, JPEG and GIF supported)
- Images stored in Cloud Storage in Firebase
- Image Metadata stored in Cloud Firestore
- Authentication done with Firebase Authentication using email and password.
- On account creation, user data is stored in cloud Firestore.
- Like Posts
- Delete Posts(Only if the post has been created by the logged in User).
- Save Posts.
- Update User Profile Picture.
- Have Help section to show the use of the app.
- Added Instagram style Like Animation

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
## Home Page
![Home Page](https://firebasestorage.googleapis.com/v0/b/pilgrimage-2b573.appspot.com/o/screenshots%2FScreenshot_20200914-200518.jpg?alt=media&token=b991d21b-a397-49d5-83fa-a7fb4a63c1e3)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
## Auth Screen
![Auth Screen](https://firebasestorage.googleapis.com/v0/b/pilgrimage-2b573.appspot.com/o/screenshots%2FScreenshot_20200914-200709.jpg?alt=media&token=152f1939-09db-450c-859a-c786a25ef723)

## Settings Page
![Settings Page](https://firebasestorage.googleapis.com/v0/b/pilgrimage-2b573.appspot.com/o/screenshots%2FScreenshot_20200914-200550.jpg?alt=media&token=f04083a0-5ebd-475c-9fd5-044e63ac9c78)

## New Post Page
![New Post](https://firebasestorage.googleapis.com/v0/b/pilgrimage-2b573.appspot.com/o/screenshots%2FScreenshot_20200914-200606.jpg?alt=media&token=8711f604-95aa-415a-9a7d-606c7408bc8b)

## APK's

The release version has currently been made only for Android.

Download the Fat APK [here](https://drive.google.com/file/d/1qKkI6KLpREwdEDBsGBFMzcO_0b1AUArr/view?usp=sharing)

The APK has been split by abi [here](https://drive.google.com/drive/folders/1gfOjDDzy0qxJyazVoPv-Qj0Poesk8-VJ?usp=sharing)

To start debugging, fire up VSCode or Android Studio and hit F5 after connecting an emulator or Phone with USB Debugging on. (Flutter needs to be configured beforehand)
Binary file added assets/fonts/Montserrat-Regular.ttf
Binary file not shown.
Binary file added assets/images/auth.flr
Binary file not shown.
3 changes: 3 additions & 0 deletions assets/images/drawer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/instagram_like.flr
Binary file not shown.
Binary file added assets/images/logo.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 added assets/images/no_img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 26 additions & 4 deletions lib/auth/authScreen.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import 'package:flare_flutter/flare_actor.dart';
import 'package:flare_flutter/flare_controls.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:pilgrimage/auth/login.dart';
import 'package:pilgrimage/auth/signup.dart';
import 'package:pilgrimage/constants/controls.dart';
class AuthScreen extends StatefulWidget {
@override
_AuthScreenState createState() => _AuthScreenState();
Expand All @@ -17,6 +20,8 @@ class _AuthScreenState extends State<AuthScreen> {

bool loginState = true;//If true login widget will be shown or sign up widget will be shown.

FlareControls flare = FlareControls();

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -29,12 +34,29 @@ class _AuthScreenState extends State<AuthScreen> {
child: ListView(
children: [
SizedBox(height: 100.0),
SvgPicture.asset(
'assets/images/authPic.svg',
height: 300.0,
// SvgPicture.asset(
// 'assets/images/authPic.svg',
// height: 300.0,
// ),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
),
height: 400,
width: 400,
child: SizedBox(
height: 80,
width: 80,
child: FlareActor(
'assets/images/auth.flr',
controller: flare,
animation: 'idle',
fit: BoxFit.fitHeight,
),
),
),
SizedBox(height: 100),
loginState ? LoginWidget(flagFunc: flagFunc) : SignUpWidget(flagFunc: flagFunc),
loginState ? LoginWidget(flagFunc: flagFunc, flare: flareControls,) : SignUpWidget(flagFunc: flagFunc),
],
),
),
Expand Down
11 changes: 8 additions & 3 deletions lib/auth/login.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'package:flare_flutter/flare_controls.dart';
import 'package:flutter/material.dart';
import 'package:pilgrimage/services/authService.dart';
import 'package:toast/toast.dart';
class LoginWidget extends StatefulWidget {

final VoidCallback flagFunc;

LoginWidget({@required this.flagFunc});
final FlareControls flare;

LoginWidget({@required this.flagFunc, this.flare});

bool loading = false;

Expand Down Expand Up @@ -80,22 +83,24 @@ class _LoginWidgetState extends State<LoginWidget> {
});
print(widget.loading);
try{
//widget.flare.play('success');
await AuthService().signIn(email, password);
}
catch(e){
//await showAlert();
print('Login Exception');
print(e);
//widget.flare.play('test');
Toast.show('An error occured', context, gravity: Toast.BOTTOM, duration: Toast.LENGTH_LONG);
setState(() {
widget.loading = false;
email = null;
password = null;
});
}
setState(() {
setState(() {
widget.loading = false;
});
}
print(widget.loading);
},
child: Text('Log In', style: Theme.of(context).textTheme.bodyText1,),
Expand Down
123 changes: 120 additions & 3 deletions lib/auth/signup.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:mime/mime.dart';
import 'package:pilgrimage/models/user.dart';
import 'package:pilgrimage/pages/home.dart';
import 'package:pilgrimage/services/authService.dart';
Expand All @@ -22,6 +27,84 @@ class _SignUpWidgetState extends State<SignUpWidget> {

bool obscure = true;

File pickedImage = null;

Future<void> pickImage(){
return showDialog(
context: context,
barrierDismissible: true,
builder: (context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25.0),
),
title: Text('Pick an Image',
style: Theme.of(context).textTheme.headline1,
),
content: Text('Select an image to be uploaded.\n Only png, jpg, jpeg and gif supported.',
style: Theme.of(context).textTheme.bodyText1,
),
actions: [
FlatButton(
onPressed: (){
openCamera();
Navigator.pop(context);
},
child: Text('From Camera'),
),
FlatButton(
onPressed: (){
openGallery();
Navigator.pop(context);
},
child: Text('From Gallery')
),
],
);
},
);
}

void openCamera() async {
PickedFile image = await ImagePicker().getImage(source: ImageSource.camera);

if(image != null){
String mimeStr = lookupMimeType(image.path);
var fileType = mimeStr.split('/');
print('$fileType');
if(fileType[fileType.length-1] == 'png' || fileType[fileType.length-1] == 'jpg' || fileType[fileType.length - 1] == 'jpeg'){
setState(() {
pickedImage = File(image.path);
});
}
else{
Toast.show('Wrong file format.', context, duration: Toast.LENGTH_LONG, gravity: Toast.LENGTH_LONG);
}
}

}


void openGallery() async {
PickedFile image = await ImagePicker().getImage(source: ImageSource.gallery);

if(image != null){
String mimeStr = lookupMimeType(image.path);
var fileType = mimeStr.split('/');
print('Gallery File Type : $fileType');
if(fileType[fileType.length-1] == 'png' || fileType[fileType.length-1] == 'jpg' || fileType[fileType.length-1] == 'jpeg'){
setState(() {
pickedImage = File(image.path);
});

}
else{
Toast.show('Wrong file format.', context, duration: Toast.LENGTH_LONG, gravity: Toast.LENGTH_LONG);
}
}

}

@override
Widget build(BuildContext context) {
return widget.loading == true ? Center(child: CircularProgressIndicator()) :
Expand Down Expand Up @@ -71,6 +154,40 @@ class _SignUpWidgetState extends State<SignUpWidget> {
},
),
),
pickedImage == null ? Padding(
padding: const EdgeInsets.all(8.0),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25.0),
),
onPressed: (){
pickImage();
},
child: ListTile(
title: Text('Choose Profile Picture'),
trailing: CircleAvatar(
backgroundImage: NetworkImage('https://firebasestorage.googleapis.com/v0/b/pilgrimage-2b573.appspot.com/o/no_img.png?alt=media&token=da3252c8-3394-4b46-898b-b28c78a114f2'),
),
),
),
) :
Padding(
padding: const EdgeInsets.all(8.0),
child: RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25.0),
),
onPressed: (){
pickImage();
},
child: ListTile(
title: Text('Welcome Aboard!!'),
trailing: CircleAvatar(
backgroundImage: FileImage(pickedImage),
),
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(100.0 , 20.0 , 100.0 , 20.0),
child: RaisedButton(
Expand All @@ -79,7 +196,7 @@ class _SignUpWidgetState extends State<SignUpWidget> {
widget.loading = true;
});
try{
await AuthService().signUp(email, password);
await AuthService().signUp(email, password, pickedImage);
//Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context) => new HomePage()));
}
catch(e){
Expand All @@ -88,10 +205,10 @@ class _SignUpWidgetState extends State<SignUpWidget> {
email = null;
password = null;
});
}
setState(() {
setState(() {
widget.loading = false;
});
}
},
child: Text('Sign Up', style: Theme.of(context).textTheme.bodyText1,),
color: Colors.amber,
Expand Down
8 changes: 8 additions & 0 deletions lib/constants/alertDialog.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:flutter/material.dart';

Future<void> generalAlertDialog(context){
return showDialog(
context: context

);
}
3 changes: 3 additions & 0 deletions lib/constants/controls.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'package:flare_flutter/flare_controls.dart';

FlareControls flareControls = new FlareControls();
46 changes: 40 additions & 6 deletions lib/constants/logoAppBar.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@




import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:pilgrimage/pages/intro.dart';
import 'package:pilgrimage/services/authService.dart';
SliverAppBar logoAppBar({
SliverAppBar logoAppBar(
context,
{
@required String title,
final List<Widget> actions,
final VoidCallback onLogoTap,
Expand All @@ -15,9 +22,9 @@ SliverAppBar logoAppBar({
),
floating: true,
pinned: false,
onStretchTrigger: () async {
return await true;
},
// onStretchTrigger: () async {
// return await true;
// },
stretch: true,
toolbarHeight: 80.0,
collapsedHeight: 90.0,
Expand All @@ -37,8 +44,8 @@ SliverAppBar logoAppBar({
),
),
),
onTap: (){
AuthService().signOut();
onTap: () async {
await helpDialog(context);
},
),
],
Expand All @@ -50,5 +57,32 @@ SliverAppBar logoAppBar({
),
),
),

);
}

Future<void> helpDialog(context){
return showDialog(
context: context,
builder: (context){
return AlertDialog(
title: Text('Get to know more'),
titleTextStyle: Theme.of(context).textTheme.headline1,
actions: [
FlatButton(
onPressed: (){
Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context) => new IntroPage()));
},
child: Text('Help'),
),
FlatButton(
onPressed: (){
return showAboutDialog(context: context);
},
child: Text('About'),
),
],
);
}
);
}
Loading