Bot Nav Done

This commit is contained in:
Sewmina Dilshan 2023-06-14 14:34:44 +05:30
parent e59668d36b
commit 4a75200431
10 changed files with 241 additions and 35 deletions

View File

@ -25,8 +25,14 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android { android {
namespace "com.Xperience.FaucetHub.fhub" namespace "com.Xperience.FaucetHub"
compileSdkVersion flutter.compileSdkVersion compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion ndkVersion flutter.ndkVersion
@ -45,7 +51,7 @@ android {
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.Xperience.FaucetHub.fhub" applicationId "com.Xperience.FaucetHub"
// You can update the following values to match your application needs. // 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. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion minSdkVersion flutter.minSdkVersion
@ -54,11 +60,20 @@ android {
versionName flutterVersionName versionName flutterVersionName
} }
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes { buildTypes {
release { release {
// TODO: Add your own signing config for the release build. // TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works. // Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug signingConfig signingConfigs.release
} }
} }
} }

View File

@ -0,0 +1,63 @@
{
"project_info": {
"project_number": "471640736230",
"project_id": "faucethub-6ff75",
"storage_bucket": "faucethub-6ff75.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:471640736230:android:205f06495a3d96b1f41627",
"android_client_info": {
"package_name": "com.Xperience.FaucetHub"
}
},
"oauth_client": [
{
"client_id": "471640736230-264bor5j37konvpp5v6mbmioliqth2gj.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.Xperience.FaucetHub",
"certificate_hash": "9d0ebcd5631981e981ed1b9e7a69a220c0846950"
}
},
{
"client_id": "471640736230-l3f55tf2qmc6nhuus7ha4jg2tlmuep72.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.Xperience.FaucetHub",
"certificate_hash": "7ba8fb82e48d60e8c5ce423488eb6d1a0d9394cc"
}
},
{
"client_id": "471640736230-qblci878igh6ubrokkhlim9u99n19p0k.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.Xperience.FaucetHub",
"certificate_hash": "a766d93f9b8aa6e20fce9357bd401d63e3e69d5c"
}
},
{
"client_id": "471640736230-lm7vslfmt2asvdf7folr7jk14j1culnr.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA2djP4Bm2jyUWtkQ8a7uarkx2AIm29Vyk"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "471640736230-c23m2qce0m281qb2dbdt3pc4vve77q0m.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

View File

@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application <application
android:label="fhub" android:label="Faucet Hub"
android:name="${applicationName}" android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher">
<activity <activity

View File

@ -1,4 +1,4 @@
package com.Xperience.FaucetHub.fhub package com.Xperience.FaucetHub
import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.android.FlutterActivity

View File

@ -1,3 +1,4 @@
import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:fhub/src/CustomWidgets.dart'; import 'package:fhub/src/CustomWidgets.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -9,7 +10,6 @@ class Home extends StatefulWidget {
} }
class _HomeState extends State<Home> { class _HomeState extends State<Home> {
@override @override
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
@ -26,23 +26,68 @@ class _HomeState extends State<Home> {
op3 = 1; op3 = 1;
}); });
} }
int selectedPageId = 0;
String TitleText = "Home";
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final screenHeight = MediaQuery.of(context).size.height;
final screenWidth = MediaQuery.of(context).size.width;
return Scaffold( return Scaffold(
backgroundColor: Colors.black, backgroundColor: Colors.black,
extendBody: true, extendBody: true,
body: SafeArea(child: CustomBody( body: SafeArea(
child: CustomBody(
context: context, context: context,
onAnimEnd: (){setState(() { onAnimEnd: () {
setState(() {});
});}, },
bottomNav: [
BottomNavBarItem(
icon: Icons.home,
active: selectedPageId == 0,
onPressed: () {
setState(() {
TitleText = "Home";
selectedPageId = 0;
});
},
),
BottomNavBarItem(
icon: Icons.wallet,
active: selectedPageId == 1,
onPressed: () {
setState(() {
TitleText = "Wallet";
selectedPageId = 1;
});
}),
BottomNavBarItem(
icon: Icons.settings,
active: selectedPageId == 2,
onPressed: () {
setState(() {
TitleText = "Settings";
selectedPageId = 2;
});
}),
],
child: Padding( child: Padding(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: Column( child: Column(children: [
children:[ Center(
Center(child: GradientText(text: "Home",gradient: LinearGradient(colors: [Colors.redAccent, Colors.pink, Colors.deepPurpleAccent]),style: TextStyle(fontSize: 50,fontWeight: FontWeight.bold),)) child:
] AnimatedSwitcher(
), duration: Duration(milliseconds: 300),
transitionBuilder:
(Widget child, Animation<double> animation) {
return FadeTransition(child: child,opacity: Tween<double>(begin: 0, end: 1).animate(animation));
},
child:
GradientText(key: ValueKey<String>(TitleText),text: TitleText,gradient: LinearGradient(colors: [Colors.deepPurpleAccent, Colors.purple,Colors.purpleAccent]),style: TextStyle(fontSize: 45,fontWeight: FontWeight.bold),),
))
]),
), ),
)), )),
); );

View File

@ -1,6 +1,7 @@
import 'dart:math'; import 'dart:math';
import 'dart:ui'; import 'dart:ui';
import 'package:fhub/home.dart';
import 'package:fhub/src/CustomWidgets.dart'; import 'package:fhub/src/CustomWidgets.dart';
import 'package:fhub/welcome.dart'; import 'package:fhub/welcome.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -23,7 +24,13 @@ class MyApp extends StatelessWidget {
seedColor: Colors.deepPurple, brightness: Brightness.dark), seedColor: Colors.deepPurple, brightness: Brightness.dark),
useMaterial3: true, useMaterial3: true,
), ),
home: const MyHomePage(title: 'Flutter Demo Home Page'), home: const MyHomePage(),
// ignore: prefer_const_literals_to_create_immutables
routes: {
'/splash' : (context) => MyHomePage(),
'/home' : (context) => Home(),
},
); );
} }
} }

View File

@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
double op1 = 0; double op1 = 0;
double op2 = 0; double op2 = 0;
double op3 = 0; double op3 = 0;
Widget CustomBody({required Widget child,required BuildContext context, required Function() onAnimEnd}) { Widget CustomBody({required Widget child,required BuildContext context, required Function() onAnimEnd, List<BottomNavBarItem>? bottomNav}) {
Duration opDuration = const Duration(milliseconds: 1500); Duration opDuration = const Duration(milliseconds: 1500);
var random = new Random(); var random = new Random();
@ -110,11 +110,31 @@ Widget CustomBody({required Widget child,required BuildContext context, required
), ),
), ),
), ),
(bottomNav != null) ? Positioned(
bottom: 20,
right: screenWidth * 0.15,
child: Container(
width: screenWidth * 0.7,
height: 70,
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(50),
boxShadow: [
BoxShadow(
color: Colors.black26, offset: Offset.fromDirection(1, 2))
]),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: bottomNav,
)),
) : Container(),
AnimatedContainer(duration: opDuration,child: child) AnimatedContainer(duration: opDuration,child: child)
])); ]));
} }
Widget NeonButton( Widget NeonButton(
{required void Function() onPressed, {required void Function() onPressed,
required String text, required String text,
@ -171,9 +191,37 @@ Widget NeonButton(
); );
} }
class BottomNavBarItem extends StatelessWidget {
BottomNavBarItem({required this.active,required IconData this.icon, String? this.text, required Function() this.onPressed,});
IconData icon;
String? text;
Function() onPressed;
bool active = false;
@override
Widget build(BuildContext context) {
// TODO: implement build
return InkWell(
onTap: (){
onPressed();
},
child: Container(
margin: EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
AnimatedSize(duration: const Duration(milliseconds: 300),child: Icon(icon,size:active ? 45 : 25, color: active ? Colors.deepPurpleAccent : Colors.blue)),
(text!=null) ? Text(text!) : Container()
],
),
),
);
}
}
class GradientText extends StatelessWidget { class GradientText extends StatelessWidget {
const GradientText( const GradientText(
{required this.text, {super.key, required this.text,
required this.gradient, required this.gradient,
this.style, this.style,
}); });

View File

@ -6,10 +6,10 @@ import 'package:fhub/src/CustomWidgets.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart'; import 'package:google_sign_in/google_sign_in.dart';
class MyHomePage extends StatefulWidget { import 'backend/DebugHelper.dart';
const MyHomePage({super.key, required this.title});
final String title; class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override @override
State<MyHomePage> createState() => _MyHomePageState(); State<MyHomePage> createState() => _MyHomePageState();
@ -17,7 +17,7 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> { class _MyHomePageState extends State<MyHomePage> {
int counter = -1; int counter = -1;
bool loginLoading = false;
@override @override
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
@ -132,7 +132,7 @@ class _MyHomePageState extends State<MyHomePage> {
TextEditingController passwordController = TextEditingController(); TextEditingController passwordController = TextEditingController();
Widget LoginPage() { Widget LoginPage() {
return Header(child: Column(mainAxisSize: MainAxisSize.max, return Header(child: loginLoading ? const Center(child: Text("Loading...")) : Column(mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text("Let's Get you ${isLogin ? "Logged-In" : "Registered"}!", Text("Let's Get you ${isLogin ? "Logged-In" : "Registered"}!",
@ -170,12 +170,17 @@ class _MyHomePageState extends State<MyHomePage> {
Dialogs.showAlertDialog(context, "Invalid Input", "Neither the username nor password can contain spaces"); Dialogs.showAlertDialog(context, "Invalid Input", "Neither the username nor password can contain spaces");
return; return;
} }
setState(() {
loginLoading = true;
});
if(isLogin){ if(isLogin){
int loginResult = await LoginManager.Login(usernameController.text, passwordController.text); int loginResult = await LoginManager.Login(usernameController.text, passwordController.text);
if(loginResult == 0){ if(loginResult == 0){
loadHome(); loadHome();
}else if(loginResult == 5){
Dialogs.showAlertDialog(context, "Login Failed", "Incorrect username or password");
}else{ }else{
Dialogs.showAlertDialog(context, "Login Failed", "Error code : $loginResult"); Dialogs.showAlertDialog(context, "Login Failed", "Error code : $loginResult");
} }
@ -184,10 +189,15 @@ class _MyHomePageState extends State<MyHomePage> {
if(regResult == 0){ if(regResult == 0){
loadHome(); loadHome();
}else if(regResult == 5){
Dialogs.showAlertDialog(context, "Register Failed", "Username Already exists, Please try again with a different username");
}else{ }else{
Dialogs.showAlertDialog(context, "Register Failed", "Error code : $regResult"); Dialogs.showAlertDialog(context, "Register Failed", "Error code : $regResult");
} }
} }
setState(() {
loginLoading = false;
});
}, },
text: isLogin ? "Login" : "Register"), text: isLogin ? "Login" : "Register"),
const SizedBox(height: 10,), const SizedBox(height: 10,),
@ -245,6 +255,9 @@ class _MyHomePageState extends State<MyHomePage> {
} }
Future<void> SignWithGoogle() async { Future<void> SignWithGoogle() async {
setState(() {
loginLoading = true;
});
GoogleSignIn _googleSignIn = GoogleSignIn( GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: [ scopes: [
'email', 'email',
@ -255,14 +268,12 @@ class _MyHomePageState extends State<MyHomePage> {
try { try {
GoogleSignInAccount? account = await _googleSignIn.signIn(); GoogleSignInAccount? account = await _googleSignIn.signIn();
print(account?.email); String email = account!.email;
Debug.LogResponse(email);
int registerResult = await LoginManager.GoogleLogin(account!.email); int registerResult = await LoginManager.GoogleLogin(email);
Dialogs.hide();
if(registerResult == 0){ if(registerResult == 0){
// Dialogs.showAlertDialog(context, "Success", "Login done, congrats!"); loadHome();
Navigator.of(context).pushReplacementNamed('/home');
}else if(registerResult == 1){ }else if(registerResult == 1){
Dialogs.showAlertDialog(context, "Failed", "Servers are unreachable. Please check internet connection and try again."); Dialogs.showAlertDialog(context, "Failed", "Servers are unreachable. Please check internet connection and try again.");
}else if(registerResult == 5){ }else if(registerResult == 5){
@ -274,6 +285,8 @@ class _MyHomePageState extends State<MyHomePage> {
print(error); print(error);
print("google sign in failed"); print("google sign in failed");
} }
setState(() {
loginLoading = false;
});
} }
} }

View File

@ -9,6 +9,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.3" version: "1.3.3"
animated_text_kit:
dependency: "direct main"
description:
name: animated_text_kit
sha256: "37392a5376c9a1a503b02463c38bc0342ef814ddbb8f9977bc90f2a84b22fa92"
url: "https://pub.dev"
source: hosted
version: "4.2.2"
async: async:
dependency: transitive dependency: transitive
description: description:
@ -25,6 +33,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
change_app_package_name:
dependency: "direct dev"
description:
name: change_app_package_name
sha256: f9ebaf68a4b5a68c581492579bb68273c523ef325fbf9ce2f1b57fb136ad023b
url: "https://pub.dev"
source: hosted
version: "1.1.0"
characters: characters:
dependency: transitive dependency: transitive
description: description:

View File

@ -37,16 +37,15 @@ dependencies:
flutter_spinkit: ^5.1.0 flutter_spinkit: ^5.1.0
google_sign_in: ^5.4.4 google_sign_in: ^5.4.4
firebase_auth: ^4.2.5 firebase_auth: ^4.2.5
animated_text_kit: ^4.2.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
change_app_package_name: ^1.1.0
# The "flutter_lints" package below contains a set of recommended lints to # The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is # encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your # activated in the `analysis_options.yaml` file located at the root of your