Skip to content

Commit

Permalink
adding readme
Browse files Browse the repository at this point in the history
  • Loading branch information
RivaanRanawat committed Dec 27, 2021
1 parent 113ea83 commit 57f92e5
Show file tree
Hide file tree
Showing 11 changed files with 351 additions and 282 deletions.
52 changes: 42 additions & 10 deletions README.md
@@ -1,16 +1,48 @@
# instagram_clone_flutter
# Instagram Clone

A new Flutter project.
A completely Responsive Instagram App- Works on Android, iOS & Web!

## Getting Started
## Features
- Responsive Instagram UI
- Email & Password Authentication
- Share Posts with Caption
- Display Posts with Caption
- Like & Comment on Posts
- Search Users
- Follow Users
- Display User Posts, Followers & Following
- EVERYTHING REAL TIME
- Sign Out

This project is a starting point for a Flutter application.
## YouTube
I have created a tutorial based on this, do check it out on my channel [Rivaan Ranawat](https://youtu.be/BBccK1zTgxw)

A few resources to get you started if this is your first Flutter project:
<p align="center">
<img width="600" src="https://github.com/RivaanRanawat/instagram-flutter-clone/blob/master/screenshot.png" alt="Youtube Tutorial Image">
</p>

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

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.
## Installation
After cloning this repository, migrate to ```instagram-flutter-clone``` folder. Then, follow the following steps:
- Create Firebase Project
- Enable Authentication
- Make Firestore Rules
- Create Android, iOS & Web Apps
- Take Web FirebaseOptions and put it in main function in main.dart file replacing my keys (My keys wont work as I deleted my project)
Then run the following commands to run your app:
```bash
flutter pub get
open -a simulator (to get iOS Simulator)
flutter run
flutter run -d chrome --web-renderer html (to see the best output)
```

## Tech Used
**Server**: Firebase Auth, Firebase Storage, Firebase Firestore

**Client**: Flutter, Provider

## Feedback

If you have any feedback, please reach out to me at namanrivaan@gmail.com

4 changes: 4 additions & 0 deletions lib/resources/auth_methods.dart
Expand Up @@ -91,4 +91,8 @@ class AuthMethods {
}
return res;
}

Future<void> signOut() async {
await _auth.signOut();
}
}
28 changes: 13 additions & 15 deletions lib/resources/firestore_methods.dart
Expand Up @@ -98,36 +98,34 @@ class FireStoreMethods {
return res;
}

// Follow user
Future<void> followUser(String uid, String followId) async {

Future<void> followUser(
String uid,
String followId
) async {
try {
DocumentSnapshot snap = await _firestore.collection('users').doc(uid).get();
List following = (snap.data()! as dynamic)['following'];

if (!following.contains(followId)) {
// add follow id to followers list of followed user

if(following.contains(followId)) {
await _firestore.collection('users').doc(followId).update({
'followers': FieldValue.arrayUnion([uid])
'followers': FieldValue.arrayRemove([uid])
});

// add user id to following list of user
await _firestore.collection('users').doc(uid).update({
'following': FieldValue.arrayUnion([followId])
'following': FieldValue.arrayRemove([followId])
});
} else {
// remove follow id to followers list of followed user
await _firestore.collection('users').doc(followId).update({
'followers': FieldValue.arrayRemove([uid])
'followers': FieldValue.arrayUnion([uid])
});

// remove user id to following list of user
await _firestore.collection('users').doc(uid).update({
'following': FieldValue.arrayRemove([followId])
'following': FieldValue.arrayUnion([followId])
});
}
} catch (err) {
print(err.toString());

} catch(e) {
print(e.toString());
}
}
}
28 changes: 13 additions & 15 deletions lib/responsive/web_screen_layout.dart
Expand Up @@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:instagram_clone_flutter/utils/colors.dart';
import 'package:instagram_clone_flutter/utils/global_variable.dart';
import 'package:instagram_clone_flutter/widgets/text_field_input.dart';

class WebScreenLayout extends StatefulWidget {
const WebScreenLayout({Key? key}) : super(key: key);
Expand All @@ -12,8 +11,8 @@ class WebScreenLayout extends StatefulWidget {
}

class _WebScreenLayoutState extends State<WebScreenLayout> {
int _page = 0;
late PageController pageController; // for tabs animation
int _page = 0; // for tabs animation

@override
void initState() {
Expand All @@ -27,24 +26,22 @@ class _WebScreenLayoutState extends State<WebScreenLayout> {
pageController.dispose();
}

navigatePage(int p) {
//Animating Page
pageController.jumpToPage(p);
void onPageChanged(int page) {
setState(() {
_page = p;
_page = page;
});
}

void navigationTapped(int page) {
//Animating Page
pageController.jumpToPage(page);
setState(() {
_page = page;
});
}

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

return Scaffold(
appBar: AppBar(
backgroundColor: mobileBackgroundColor,
Expand All @@ -60,42 +57,43 @@ class _WebScreenLayoutState extends State<WebScreenLayout> {
Icons.home,
color: _page == 0 ? primaryColor : secondaryColor,
),
onPressed: () => navigatePage(0),
onPressed: () => navigationTapped(0),
),
IconButton(
icon: Icon(
Icons.search,
color: _page == 1 ? primaryColor : secondaryColor,
),
onPressed: () => navigatePage(1),
onPressed: () => navigationTapped(1),
),
IconButton(
icon: Icon(
Icons.add_a_photo,
color: _page == 2 ? primaryColor : secondaryColor,
),
onPressed: () => navigatePage(2),
onPressed: () => navigationTapped(2),
),
IconButton(
IconButton(
icon: Icon(
Icons.favorite,
color: _page == 3 ? primaryColor : secondaryColor,
),
onPressed: () => navigatePage(3),
onPressed: () => navigationTapped(3),
),
IconButton(
icon: Icon(
Icons.person,
color: _page == 4 ? primaryColor : secondaryColor,
),
onPressed: () => navigatePage(4),
onPressed: () => navigationTapped(4),
),
],
),
body: PageView(
physics: const NeverScrollableScrollPhysics(),
children: homeScreenItems,
controller: pageController,
onPageChanged: navigatePage,
onPageChanged: onPageChanged,
),
);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/screens/login_screen.dart
Expand Up @@ -64,8 +64,7 @@ class _LoginScreenState extends State<LoginScreen> {
child: Container(
padding: MediaQuery.of(context).size.width > webScreenSize
? EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width /3,
)
horizontal: MediaQuery.of(context).size.width / 3)
: const EdgeInsets.symmetric(horizontal: 32),
width: double.infinity,
child: Column(
Expand Down

0 comments on commit 57f92e5

Please sign in to comment.