Skip to content

Commit

Permalink
Studi_admin working
Browse files Browse the repository at this point in the history
  • Loading branch information
prasannan-robots committed Jun 23, 2023
1 parent 4722fa8 commit 8d215a9
Show file tree
Hide file tree
Showing 18 changed files with 1,056 additions and 113 deletions.
3 changes: 2 additions & 1 deletion studi_admin/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ if (flutterVersionName == null) {
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

Expand All @@ -48,7 +49,7 @@ android {
applicationId "com.example.studi_admin"
// 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.
minSdkVersion flutter.minSdkVersion
minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
82 changes: 82 additions & 0 deletions studi_admin/android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"project_info": {
"project_number": "678727118050",
"project_id": "studi-3e797",
"storage_bucket": "studi-3e797.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:678727118050:android:be35ce07f9351bca2ec2bb",
"android_client_info": {
"package_name": "com.example.studi"
}
},
"oauth_client": [
{
"client_id": "678727118050-2bvothljf46pivd4nvbi9i1l7kis8mgo.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBWchD3yuzEkcODIwkSZHVRCgeH76FMRq8"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "678727118050-2bvothljf46pivd4nvbi9i1l7kis8mgo.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "678727118050-4dv57j86fj8t3ali9jg98o5mj27e64lk.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "com.example.studi.RunnerTests"
}
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:678727118050:android:0bb56a8cbf2d79ab2ec2bb",
"android_client_info": {
"package_name": "com.example.studi_admin"
}
},
"oauth_client": [
{
"client_id": "678727118050-2bvothljf46pivd4nvbi9i1l7kis8mgo.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBWchD3yuzEkcODIwkSZHVRCgeH76FMRq8"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "678727118050-2bvothljf46pivd4nvbi9i1l7kis8mgo.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "678727118050-4dv57j86fj8t3ali9jg98o5mj27e64lk.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "com.example.studi.RunnerTests"
}
}
]
}
}
}
],
"configuration_version": "1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Generated file.
//
// If you wish to remove Flutter's multidex support, delete this entire file.
//
// Modifications to this file should be done in a copy under a different name
// as this file may be regenerated.

package io.flutter.app;

import android.app.Application;
import android.content.Context;
import androidx.annotation.CallSuper;
import androidx.multidex.MultiDex;

/**
* Extension of {@link android.app.Application}, adding multidex support.
*/
public class FlutterMultiDexApplication extends Application {
@Override
@CallSuper
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
1 change: 1 addition & 0 deletions studi_admin/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15'
}
}

Expand Down
34 changes: 34 additions & 0 deletions studi_admin/ios/Runner/GoogleService-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>678727118050-unma8s0acr6u0oh5hdrj0jkehf45u2b7.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.678727118050-unma8s0acr6u0oh5hdrj0jkehf45u2b7</string>
<key>API_KEY</key>
<string>AIzaSyDyXoK9UCT-wEYXOBzNOaqozPwVK29jtKU</string>
<key>GCM_SENDER_ID</key>
<string>678727118050</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.example.studiAdmin</string>
<key>PROJECT_ID</key>
<string>studi-3e797</string>
<key>STORAGE_BUCKET</key>
<string>studi-3e797.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:678727118050:ios:e2afab8e0b508a202ec2bb</string>
</dict>
</plist>
7 changes: 7 additions & 0 deletions studi_admin/ios/firebase_app_id_file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"file_generated_by": "FlutterFire CLI",
"purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
"GOOGLE_APP_ID": "1:678727118050:ios:e2afab8e0b508a202ec2bb",
"FIREBASE_PROJECT_ID": "studi-3e797",
"GCM_SENDER_ID": "678727118050"
}
83 changes: 83 additions & 0 deletions studi_admin/lib/firebase_options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// File generated by FlutterFire CLI.
// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;

/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
case TargetPlatform.macOS:
return macos;
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}

static const FirebaseOptions web = FirebaseOptions(
apiKey: 'AIzaSyDfEUcEy92RYi5tRp92n5kmx_yHZlP43e4',
appId: '1:678727118050:web:b2c8eab2c0dc42f12ec2bb',
messagingSenderId: '678727118050',
projectId: 'studi-3e797',
authDomain: 'studi-3e797.firebaseapp.com',
storageBucket: 'studi-3e797.appspot.com',
measurementId: 'G-15SHVD5QMP',
);

static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyBWchD3yuzEkcODIwkSZHVRCgeH76FMRq8',
appId: '1:678727118050:android:0bb56a8cbf2d79ab2ec2bb',
messagingSenderId: '678727118050',
projectId: 'studi-3e797',
storageBucket: 'studi-3e797.appspot.com',
);

static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyDyXoK9UCT-wEYXOBzNOaqozPwVK29jtKU',
appId: '1:678727118050:ios:e2afab8e0b508a202ec2bb',
messagingSenderId: '678727118050',
projectId: 'studi-3e797',
storageBucket: 'studi-3e797.appspot.com',
iosClientId: '678727118050-unma8s0acr6u0oh5hdrj0jkehf45u2b7.apps.googleusercontent.com',
iosBundleId: 'com.example.studiAdmin',
);

static const FirebaseOptions macos = FirebaseOptions(
apiKey: 'AIzaSyDyXoK9UCT-wEYXOBzNOaqozPwVK29jtKU',
appId: '1:678727118050:ios:8298acabc55467432ec2bb',
messagingSenderId: '678727118050',
projectId: 'studi-3e797',
storageBucket: 'studi-3e797.appspot.com',
iosClientId: '678727118050-2h90fbprvvkm0fjqevh67rbh7e8qf0ip.apps.googleusercontent.com',
iosBundleId: 'com.example.studiAdmin.RunnerTests',
);
}
127 changes: 127 additions & 0 deletions studi_admin/lib/login_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'notes_page.dart';

class SessionManager {
static const String loggedInKey = 'loggedIn';

static Future<void> saveLoginState(bool isLoggedIn) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setBool(loggedInKey, isLoggedIn);
}

static Future<bool> getLoginState() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
return prefs.getBool(loggedInKey) ?? false;
}
}

class EmailAuth extends StatefulWidget {
const EmailAuth({Key? key});

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

class _EmailAuthState extends State<EmailAuth> {
final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
final FirebaseAuth _auth = FirebaseAuth.instance;
pushNextPage(user) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('userId', user);
await SessionManager.saveLoginState(true);

Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => NotesPage()),
);
}

Future<void> _signIn() async {
try {
UserCredential userCredential = await _auth.signInWithEmailAndPassword(
email: _emailController.text.trim(),
password: _passwordController.text.trim(),
);
// User sign-in successful
User? user = userCredential.user;
if (user != null) {
pushNextPage(user.uid);
}
} catch (e) {
// Handle sign-in errors
print('Sign-in error: $e');
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('Sign-in Failed'),
content: const Text('Invalid email or password.'),
actions: <Widget>[
TextButton(
child: const Text('OK'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
'Studi_admin',
style: TextStyle(color: Colors.white),
),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextField(
cursorColor: Colors.white,
controller: _emailController,
style: TextStyle(color: Colors.white),
decoration: const InputDecoration(
filled: true,
fillColor: Colors.deepPurple,
labelText: 'Email',
labelStyle: TextStyle(color: Colors.white),
),
),
const SizedBox(height: 8.0),
TextField(
cursorColor: Colors.white,
controller: _passwordController,
style: TextStyle(color: Colors.white),
decoration: const InputDecoration(
filled: true,
fillColor: Colors.deepPurple,
labelText: 'Password',
labelStyle: TextStyle(color: Colors.white),
),
obscureText: true,
),
const SizedBox(height: 16.0),
ElevatedButton(
child: const Text('Sign In'),
onPressed: _signIn,
),
],
),
),
),
);
}
}
Loading

0 comments on commit 8d215a9

Please sign in to comment.