Skip to content

Commit

Permalink
Merge pull request #1 from uchamod/firebase_setup
Browse files Browse the repository at this point in the history
Firebase setup
  • Loading branch information
uchamod authored Jul 23, 2024
2 parents edd3b85 + d067a34 commit 54a8904
Show file tree
Hide file tree
Showing 15 changed files with 333 additions and 5 deletions.
14 changes: 13 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
id 'com.google.gms.google-services'
}

def localProperties = new Properties()
Expand Down Expand Up @@ -38,7 +39,7 @@ android {
applicationId = "com.example.instagram_clone"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdk = flutter.minSdkVersion
minSdk = 23
targetSdk = flutter.targetSdkVersion
versionCode = flutterVersionCode.toInteger()
versionName = flutterVersionName
Expand All @@ -56,3 +57,14 @@ android {
flutter {
source = "../.."
}

dependencies {
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:33.1.2')


// TODO: Add the dependencies for Firebase products you want to use
// When using the BoM, don't specify versions in Firebase dependencies
// https://firebase.google.com/docs/android/setup#available-libraries
}

29 changes: 29 additions & 0 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "1069404306101",
"project_id": "instagram-clone-5457e",
"storage_bucket": "instagram-clone-5457e.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:1069404306101:android:6c67d73fa1d084a0011cfc",
"android_client_info": {
"package_name": "com.example.instagram_clone"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyD7hWyFWyOb4C2tXAijhPzyTrE2F-GqMqw"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
13 changes: 13 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
buildscript {
ext.kotlin_version = '2.0.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15'
}
}

allprojects {
repositories {
google()
Expand Down
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "org.jetbrains.kotlin.android" version "2.0.0" apply false
}

include ":app"
32 changes: 29 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:instagram_clone/responsive/mobilescreenLayout.dart';
import 'package:instagram_clone/responsive/responsiveLauout.dart';
import 'package:instagram_clone/responsive/webscreenLayout.dart';
import 'package:instagram_clone/util/colors.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
//check if app run on mobile or web
if (kIsWeb) {
await Firebase.initializeApp(
options: const FirebaseOptions(
apiKey: "AIzaSyDJllauOFYERnL7Yf4SVyuOtAueB7hjgJg",
appId: "1:1069404306101:web:03f568e7f4e555f5011cfc",
messagingSenderId: "1069404306101",
projectId: "instagram-clone-5457e",
storageBucket: "instagram-clone-5457e.appspot.com"),
);
} else {
await Firebase.initializeApp();
}

void main() {
runApp(const MyApp());
}

Expand All @@ -9,10 +30,15 @@ class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const MaterialApp(
return MaterialApp(
title: "Instagram clone",
debugShowCheckedModeBanner: false,
home: Scaffold(),
theme: ThemeData.dark()
.copyWith(scaffoldBackgroundColor: mobileBackgroundColor),
home: const ResponsiveLayout(
webScreen: Webscreenlayout(),
mobileScreen: MobileScreenlayout(),
),
);
}
}
17 changes: 17 additions & 0 deletions lib/responsive/mobilescreenLayout.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';

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

@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Text(
"this is mobile layout",
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
),
),
);
}
}
29 changes: 29 additions & 0 deletions lib/responsive/responsiveLauout.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'package:flutter/material.dart';
import 'package:instagram_clone/util/variabals.dart';

class ResponsiveLayout extends StatefulWidget {
final Widget webScreen;
final Widget mobileScreen;

const ResponsiveLayout(
{super.key, required this.webScreen, required this.mobileScreen});

@override
State<ResponsiveLayout> createState() => _ResponsiveLayoutState();
}

class _ResponsiveLayoutState extends State<ResponsiveLayout> {
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
if (constraints.maxWidth < webScreenBreakPoint) { //check screen width
//mobile layout
return widget.mobileScreen;
}
//web layout
return widget.webScreen;
},
);
}
}
14 changes: 14 additions & 0 deletions lib/responsive/webscreenLayout.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:flutter/material.dart';

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

@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Text("this is web layout"),
),
);
}
}
8 changes: 8 additions & 0 deletions lib/util/colors.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:flutter/material.dart';

const mobileBackgroundColor = Color.fromRGBO(0, 0, 0, 1);
const webBackgroundColor = Color.fromRGBO(18, 18, 18, 1);
const mobileSearchColor = Color.fromRGBO(38, 38, 38, 1);
const blueColor = Color.fromRGBO(0, 149, 246, 1);
const primaryColor = Colors.white;
const secondaryColor = Colors.grey;
3 changes: 3 additions & 0 deletions lib/util/variabals.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'package:flutter/material.dart';

const webScreenBreakPoint = 600;
8 changes: 8 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
import FlutterMacOS
import Foundation

import cloud_firestore
import firebase_auth
import firebase_core
import firebase_storage

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin"))
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTFirebaseStoragePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseStoragePlugin"))
}
Loading

0 comments on commit 54a8904

Please sign in to comment.