Skip to content

Commit

Permalink
Merge pull request #18 from Smalick0478/v2
Browse files Browse the repository at this point in the history
🎉 Pull Request: Flutter Migration & Feature Enhancements 🚀
  • Loading branch information
rafay99-epic authored May 26, 2024
2 parents a83b9fa + cdc1a55 commit 015b399
Show file tree
Hide file tree
Showing 8 changed files with 392 additions and 91 deletions.
10 changes: 7 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace "com.rafay99.rafay_portfolio"
namespace "com.example.rafay_portfolio"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

Expand All @@ -40,11 +40,12 @@ android {
}

defaultConfig {
applicationId "com.rafayportfolio.myapp"
applicationId "com.example.rafay_portfolio"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

buildTypes {
Expand All @@ -60,4 +61,7 @@ flutter {
source '../..'
}

dependencies {}
dependencies {
implementation "androidx.multidex:multidex:2.0.1"

}
12 changes: 6 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafayPortfolio;
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafay_portfolio;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand All @@ -384,7 +384,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafayPortfolio.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafay_portfolio.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -402,7 +402,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafayPortfolio.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafay_portfolio.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
Expand All @@ -418,7 +418,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafayPortfolio.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafay_portfolio.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
Expand Down Expand Up @@ -545,7 +545,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafayPortfolio;
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafay_portfolio;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand All @@ -567,7 +567,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafayPortfolio;
PRODUCT_BUNDLE_IDENTIFIER = com.example.rafay_portfolio;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/GoogleService-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.example.rafayPortfolio</string>
<string>com.example.rafay_portfolio</string>
<key>PROJECT_ID</key>
<string>portfolio-f4698</string>
<key>STORAGE_BUCKET</key>
Expand Down
115 changes: 72 additions & 43 deletions lib/backend/auth/authService.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import 'package:flutter/material.dart';
import 'package:rafay_portfolio/frontend/admin/pages/auth/opt.dart';
import 'package:rafay_portfolio/frontend/admin/pages/auth/otp_email.dart';
import 'package:rafay_portfolio/frontend/admin/pages/dashboardPage.dart';
import 'package:rafay_portfolio/constants/widgets/dialogBox/dialogbox.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:email_otp/email_otp.dart';
import 'package:flutter/material.dart';

class AuthService {
final FirebaseAuth _auth = FirebaseAuth.instance;

EmailOTP myauth = EmailOTP();
Future<UserCredential?> signInWithEmailAndPassword(
BuildContext context, String email, String password) async {
try {
Expand Down Expand Up @@ -38,50 +41,76 @@ class AuthService {

// If the user is authenticated, start the phone number verification process
if (userCredential != null && userCredential.user != null) {
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: phoneNumber,
verificationCompleted: (PhoneAuthCredential credential) async {
await FirebaseAuth.instance.signInWithCredential(credential);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const DashboardPage(),
),
);
},
verificationFailed: (FirebaseAuthException e) {
showDialogBox(
context,
Icons.error,
Colors.red,
Colors.red,
'Error',
e.message ?? 'An error occurred.',
() => Navigator.of(context).pop(),
);
},
codeSent: (String verificationId, int? resendToken) {
Navigator.push(
// await FirebaseAuth.instance.verifyPhoneNumber(
// phoneNumber: phoneNumber,
// verificationCompleted: (PhoneAuthCredential credential) async {
// await FirebaseAuth.instance.signInWithCredential(credential);
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const DashboardPage(),
// ),
// );
// },
// verificationFailed: (FirebaseAuthException e) {
// showDialogBox(
// context,
// Icons.error,
// Colors.red,
// Colors.red,
// 'Error',
// e.message ?? 'An error occurred.',
// () => Navigator.of(context).pop(),
// );
// },
// codeSent: (String verificationId, int? resendToken) {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => OtpPage(
// verificationId: verificationId,
// ),
// ),
// );
// },
// codeAutoRetrievalTimeout: (String verificationId) {
// showDialogBox(
// context,
// Icons.error,
// Colors.red,
// Colors.red,
// 'Error',
// 'Sorry OTP Expired',
// () => Navigator.of(context).pop(),
// );
// },
// );

myauth.setConfig(
appEmail: "[email protected]",
appName: "Admin",
userEmail: email,
otpLength: 4,
otpType: OTPType.digitsOnly);

var template =
'Hi {{app_name}} Your OTP Code For Admin Dashboard is {{otp}}.';
myauth.setTemplate(render: template);
if (await myauth.sendOTP() == true) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text("OTP has been sent"),
));
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => OtpPage(
verificationId: verificationId,
),
),
);
},
codeAutoRetrievalTimeout: (String verificationId) {
showDialogBox(
context,
Icons.error,
Colors.red,
Colors.red,
'Error',
'Sorry OTP Expired',
() => Navigator.of(context).pop(),
);
},
);
builder: (context) => OtpEmailVerifyScreen(
myauth: myauth,
)));
} else {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text("Oops, OTP send failed"),
));
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/firebase_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class DefaultFirebaseOptions {
messagingSenderId: '182119041017',
projectId: 'portfolio-f4698',
storageBucket: 'portfolio-f4698.appspot.com',
iosBundleId: 'com.example.rafayPortfolio',
iosBundleId: 'com.example.rafay_portfolio',
);

static const FirebaseOptions macos = FirebaseOptions(
Expand All @@ -76,6 +76,6 @@ class DefaultFirebaseOptions {
messagingSenderId: '182119041017',
projectId: 'portfolio-f4698',
storageBucket: 'portfolio-f4698.appspot.com',
iosBundleId: 'com.example.rafayPortfolio.RunnerTests',
iosBundleId: 'com.example.rafay_portfolio.RunnerTests',
);
}
Loading

0 comments on commit 015b399

Please sign in to comment.