Skip to content

Commit

Permalink
Merge pull request #3 from shuence/Screen-Responsive-and-BottomBar
Browse files Browse the repository at this point in the history
Added Share Food Cards Feature
  • Loading branch information
shuence authored Apr 30, 2024
2 parents 9204727 + c6687c0 commit e487675
Show file tree
Hide file tree
Showing 41 changed files with 2,380 additions and 782 deletions.
31 changes: 31 additions & 0 deletions lib/common_blocs/common_blocs.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:spoonshare/screens/main_bottom_nav/bloc/main_bottom_nav_bloc.dart';

class CommonBloc {
/// Bloc
static final bottomNavBloc = MainBottomNavBloc();

static final List<BlocProvider> blocProviders = [
BlocProvider<MainBottomNavBloc>(
create: (context) => bottomNavBloc,
),
];

/// Dispose
static void dispose() {
bottomNavBloc.close();
}

static void resetBlocs() {
// bottomNavBloc.add(ResetAuthentication());
}

/// Singleton factory
static final CommonBloc _instance = CommonBloc._internal();

factory CommonBloc() {
return _instance;
}

CommonBloc._internal();
}
8 changes: 8 additions & 0 deletions lib/constants/app_colors.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'package:flutter/material.dart';

class AppColors {
static Color basePrimaryColor = const Color(0xffFF9F1C);
static Color kWhiteColor = const Color(0xffFFFFFF);
static Color kBlackColor = const Color(0xff000000);
static Color kGreenColor = const Color(0xff32B046);
}
2 changes: 2 additions & 0 deletions lib/constants/app_constants.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'app_colors.dart';
export 'app_images.dart';
3 changes: 3 additions & 0 deletions lib/constants/app_images.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class AppImages {
static String spoonShareLogo = "assets/images/spoonshare.png";
}
47 changes: 33 additions & 14 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,48 +1,67 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:spoonshare/firebase_options.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:spoonshare/services/notifications_services.dart';
import 'package:spoonshare/splash_screen.dart';
import 'package:device_preview/device_preview.dart';
import 'common_blocs/common_blocs.dart';

final navigatorKey = GlobalKey<NavigatorState>();

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
NotificationServices().firebaseInit();
await SharedPreferences.getInstance();

runApp(
DevicePreview(
enabled: !kReleaseMode,
enabled: !kReleaseMode,
builder: (context) => const MyApp(),
),
);
}

class MyApp extends StatelessWidget {
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);

@override
State<MyApp> createState() => _MyAppState();
}

NavigatorState? get _navigator => navigatorKey.currentState;

onNavigateSplash() {
_navigator!.pushAndRemoveUntil(MaterialPageRoute(builder: (context) {
return const SplashScreen();
}), (route) => false);
}

class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: const Size(360, 700),
minTextAdapt: true,
splitScreenMode: true,
builder: (_, child) {
return MaterialApp(
return MultiBlocProvider(
providers: CommonBloc.blocProviders,
child: ScreenUtilInit(
designSize: const Size(360, 800),
minTextAdapt: true,
splitScreenMode: true,
child: MaterialApp(
navigatorKey: navigatorKey,
debugShowCheckedModeBanner: false,
title: 'Spoon Share',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.orange),
colorScheme: ColorScheme.fromSeed(seedColor: const Color(0xffFF9F1C)),
useMaterial3: true,
),
home: child,
);
},
child: const SplashScreen(),
home: const SplashScreen(),
),
),
);
}
}
2 changes: 2 additions & 0 deletions lib/models/users/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,6 @@ class UserProfile {
String getOrganisation() {
return organisation;
}

void cancelStreams() {}
}
3 changes: 3 additions & 0 deletions lib/onboarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class Onboarding extends StatelessWidget {
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top,
),
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
Expand Down
61 changes: 26 additions & 35 deletions lib/screens/admin/admin_home.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// ignore_for_file: use_build_context_synchronously

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:spoonshare/models/users/user.dart';
import 'package:spoonshare/screens/admin/ngo_management.dart';
import 'package:spoonshare/screens/admin/verify_donated_food.dart';
Expand All @@ -24,9 +23,6 @@ class _AdminHomeScreenState extends State<AdminHomeScreen> {
String? organization;
bool isLoading = true;

// UserProfile instance
final UserProfile _userProfile = UserProfile();

@override
void initState() {
super.initState();
Expand All @@ -35,31 +31,40 @@ class _AdminHomeScreenState extends State<AdminHomeScreen> {

Future<void> fetchUserProfile() async {
try {
await _userProfile.loadUserProfile();
role = _userProfile.getRole();
fullName = _userProfile.getFullName();
email = _userProfile.getEmail();
contactNumber = _userProfile.getContactNumber();
organization = _userProfile.getOrganisation();
final userProfile = UserProfile(); // Initialize here
await userProfile.loadUserProfile();
role = userProfile.getRole();
fullName = userProfile.getFullName();
email = userProfile.getEmail();
contactNumber = userProfile.getContactNumber();
organization = userProfile.getOrganisation();
} catch (e) {
showErrorSnackbar(context, 'Error fetching user profile: $e');
if (mounted) {
showErrorSnackbar(context, 'Error fetching user profile: $e');
}
} finally {
setState(() {
isLoading = false;
});
if (mounted) {
setState(() {
isLoading = false;
});
}
}
}

@override
void dispose() {
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
body: _buildVerifiedContent(),

);
}

Widget _buildVerifiedContent() {
return Center(
return SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(16.0),
child: Column(
Expand Down Expand Up @@ -96,20 +101,6 @@ class _AdminHomeScreenState extends State<AdminHomeScreen> {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 42,
height: 42,
decoration: ShapeDecoration(
color: Colors.black.withOpacity(0.08),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
),
child: IconButton(
icon: const Icon(Icons.search),
onPressed: () {},
),
),
const SizedBox(width: 8),
Container(
width: 42,
Expand Down Expand Up @@ -221,8 +212,8 @@ Widget _buildCard({
children: [
Text(
title,
style: const TextStyle(
fontSize: 18,
style: TextStyle(
fontSize: 16.sp,
fontFamily: 'DM Sans',
fontWeight: FontWeight.bold,
),
Expand All @@ -233,8 +224,8 @@ Widget _buildCard({
const SizedBox(height: 8),
Text(
description,
style: const TextStyle(
fontSize: 16,
style: TextStyle(
fontSize: 14.sp,
fontFamily: 'DM Sans',
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/screens/admin/all_ngos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class _AllNGOScreenState extends State<AllNGOScreen> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('All NGO\s'),
title: const Text('All NGOs'),
backgroundColor: const Color(0xFFFF9F1C),
titleTextStyle: const TextStyle(
color: Colors.white,
Expand Down
34 changes: 21 additions & 13 deletions lib/screens/auth/signin.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:spoonshare/controllers/auth/signin_controller.dart';
import 'package:spoonshare/screens/auth/forgot_password.dart';
import 'package:spoonshare/screens/auth/signup.dart';
Expand All @@ -18,7 +19,6 @@ class _SignInScreenState extends State<SignInScreen> {
final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
bool _isPasswordVisible = false;


@override
void dispose() {
Expand All @@ -34,7 +34,7 @@ class _SignInScreenState extends State<SignInScreen> {
child: Center(
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
height: MediaQuery.of(context).size.height + 10.h,
clipBehavior: Clip.antiAlias,
decoration: const BoxDecoration(color: Colors.white),
child: Column(
Expand All @@ -54,7 +54,8 @@ class _SignInScreenState extends State<SignInScreen> {
padding: const EdgeInsets.only(
top: 4,
),
decoration: const BoxDecoration(color: Color(0xFFFF9F1C)),
decoration:
const BoxDecoration(color: Color(0xFFFF9F1C)),
child: const Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expand Down Expand Up @@ -118,7 +119,8 @@ class _SignInScreenState extends State<SignInScreen> {
'Explore nearby food or join us to make a difference!',
textAlign: TextAlign.center,
style: TextStyle(
color: Colors.black.withOpacity(0.800000011920929),
color: Colors.black
.withOpacity(0.800000011920929),
fontSize: 14,
fontFamily: 'DM Sans',
fontWeight: FontWeight.w500,
Expand Down Expand Up @@ -154,7 +156,8 @@ class _SignInScreenState extends State<SignInScreen> {
height: 18,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/google.png"),
image: AssetImage(
"assets/images/google.png"),
fit: BoxFit.fill,
),
),
Expand Down Expand Up @@ -185,7 +188,8 @@ class _SignInScreenState extends State<SignInScreen> {
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
padding:
const EdgeInsets.symmetric(horizontal: 8),
child: Text(
'OR',
style: TextStyle(
Expand All @@ -209,7 +213,8 @@ class _SignInScreenState extends State<SignInScreen> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 16),
InputField(label: 'Email', controller: _emailController),
InputField(
label: 'Email', controller: _emailController),
const SizedBox(height: 16),
InputField(
label: 'Password',
Expand All @@ -229,13 +234,15 @@ class _SignInScreenState extends State<SignInScreen> {
onTap: () {
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => ForgotPasswordScreen()),
builder: (context) =>
ForgotPasswordScreen()),
);
},
child: const Align(
alignment: Alignment.bottomRight,
child: Padding(
padding: EdgeInsets.only(top: 8.0, right: 36.0),
padding:
EdgeInsets.only(top: 8.0, right: 36.0),
child: Text(
'forgot password?',
style: TextStyle(
Expand Down Expand Up @@ -324,8 +331,8 @@ class _SignInScreenState extends State<SignInScreen> {
TextSpan(
text: 'Don\'t have an account?',
style: TextStyle(
color:
Colors.black.withOpacity(0.699999988079071),
color: Colors.black
.withOpacity(0.699999988079071),
fontSize: 16,
fontFamily: 'Roboto',
fontWeight: FontWeight.w500,
Expand Down Expand Up @@ -372,10 +379,11 @@ class _SignInScreenState extends State<SignInScreen> {
context: context,
);
// Hide loading indicator
Navigator.push(
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => const HomeScreen()),
ModalRoute.withName('/'),
);
} catch (e) {
// Handle any exceptions during signup
Expand All @@ -393,7 +401,7 @@ class _SignInScreenState extends State<SignInScreen> {
),
),
child: const SizedBox(
width: 312,
width: 250,
height: 45,
child: Center(
child: Text(
Expand Down
Loading

0 comments on commit e487675

Please sign in to comment.