Skip to content

Commit

Permalink
Merge pull request #126 from Shubham-Zone/main
Browse files Browse the repository at this point in the history
Issue #105 fixed
  • Loading branch information
Yashshukla11 authored Jun 9, 2024
2 parents 1557668 + cfd050c commit 49023de
Show file tree
Hide file tree
Showing 8 changed files with 221 additions and 82 deletions.
80 changes: 48 additions & 32 deletions .idea/libraries/Dart_Packages.xml

Large diffs are not rendered by default.

41 changes: 20 additions & 21 deletions .idea/libraries/Dart_SDK.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/.flutter-plugins-dependencies

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions app/lib/helpers/ThemeProvider.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';

class ThemeProvider extends ChangeNotifier {

ThemeMode themeMode = ThemeMode.light;

bool get isDarkMode => themeMode == ThemeMode.dark;

void toggleTheme(bool isOn) {
themeMode = isOn ? ThemeMode.dark : ThemeMode.light;
notifyListeners();
}
}
100 changes: 90 additions & 10 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import 'package:examtime/screens/discussion/discussion.dart';

import 'dart:developer';

import 'package:examtime/services/SharedServices/Preferences.dart';
import 'package:examtime/services/SharedServices/Sharedservices.dart';
import 'package:examtime/screens/request_notes/request.dart';
Expand All @@ -14,33 +11,114 @@ import 'package:examtime/screens/auth_screen/signin.dart';
import 'package:examtime/screens/auth_screen/signup.dart';
import 'package:examtime/screens/profile/profile.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:examtime/screens/auth_screen/otp.dart';
import 'helpers/ThemeProvider.dart';

final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await LocalNotificationService().init();
preferences = await SharedPreferences.getInstance();
runApp(const MyApp());
runApp(
ChangeNotifierProvider(create: (context)=>ThemeProvider(),
child: const MyApp()
)
);
}

Future<void> backgroundHandler() async {
print("Handling a background message: ");
}

final ThemeData lightTheme = ThemeData(
brightness: Brightness.light,
primaryColor: const Color(0xFF1F2937),
textTheme: const TextTheme(
bodyLarge: TextStyle(color: Colors.black),
bodyMedium: TextStyle(color: Colors.black),
bodySmall: TextStyle(color: Colors.black),
displayLarge: TextStyle(color: Colors.black),
displayMedium: TextStyle(color: Colors.black),
displaySmall: TextStyle(color: Colors.black),
headlineMedium: TextStyle(color: Colors.black),
headlineSmall: TextStyle(color: Colors.black),
titleLarge: TextStyle(color: Colors.black),
titleMedium: TextStyle(color: Colors.black),
titleSmall: TextStyle(color: Colors.black),
labelLarge: TextStyle(color: Colors.black),
labelSmall: TextStyle(color: Colors.black),
),
primaryTextTheme: const TextTheme(
bodyLarge: TextStyle(color: Colors.white),
bodyMedium: TextStyle(color: Colors.white),
bodySmall: TextStyle(color: Colors.white),
displayLarge: TextStyle(color: Colors.white),
displayMedium: TextStyle(color: Colors.white),
displaySmall: TextStyle(color: Colors.white),
headlineMedium: TextStyle(color: Colors.white),
headlineSmall: TextStyle(color: Colors.white),
titleLarge: TextStyle(color: Colors.white),
titleMedium: TextStyle(color: Colors.white),
titleSmall: TextStyle(color: Colors.white),
labelLarge: TextStyle(color: Colors.white),
labelSmall: TextStyle(color: Colors.white),
),
);

final ThemeData darkTheme = ThemeData(
brightness: Brightness.dark,
primaryColor: const Color(0xFF1F2937),
textTheme: const TextTheme(
bodyLarge: TextStyle(color: Colors.white),
bodyMedium: TextStyle(color: Colors.white),
bodySmall: TextStyle(color: Colors.white),
displayLarge: TextStyle(color: Colors.white),
displayMedium: TextStyle(color: Colors.white),
displaySmall: TextStyle(color: Colors.white),
headlineMedium: TextStyle(color: Colors.white),
headlineSmall: TextStyle(color: Colors.white),
titleLarge: TextStyle(color: Colors.white),
titleMedium: TextStyle(color: Colors.white),
titleSmall: TextStyle(color: Colors.white),
labelLarge: TextStyle(color: Colors.white),
labelSmall: TextStyle(color: Colors.white),
),
primaryTextTheme: const TextTheme(
bodyLarge: TextStyle(color: Colors.black),
bodyMedium: TextStyle(color: Colors.black),
bodySmall: TextStyle(color: Colors.black),
displayLarge: TextStyle(color: Colors.black),
displayMedium: TextStyle(color: Colors.black),
displaySmall: TextStyle(color: Colors.black),
headlineMedium: TextStyle(color: Colors.black),
headlineSmall: TextStyle(color: Colors.black),
titleLarge: TextStyle(color: Colors.black),
titleMedium: TextStyle(color: Colors.black),
titleSmall: TextStyle(color: Colors.black),
labelLarge: TextStyle(color: Colors.black),
labelSmall: TextStyle(color: Colors.black),
),
);

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

const MyApp({super.key});

@override
Widget build(BuildContext context) {

final themeProvider = Provider.of<ThemeProvider>(context);

return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'ExamTime',
theme: ThemeData(
primaryColor: const Color(0xFF1F2937),
),
theme: lightTheme,
darkTheme: darkTheme,
themeMode: themeProvider.themeMode,
initialRoute: '/',
routes: {
'/': (context) => const LoadingScreen(),
Expand All @@ -67,6 +145,7 @@ class LoadingScreen extends StatefulWidget {

class _LoadingScreenState extends State<LoadingScreen>
with SingleTickerProviderStateMixin {

late AnimationController _animationController;
late Animation<Color?> _backgroundColorAnimation;

Expand Down Expand Up @@ -114,8 +193,8 @@ class _LoadingScreenState extends State<LoadingScreen>
children: [
CachedNetworkImage(
imageUrl: 'https://i.postimg.cc/02pnpHXG/logo-1.png',
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
placeholder: (context, url) => const CircularProgressIndicator(),
errorWidget: (context, url, error) => const Icon(Icons.error),
width: 200,
height: 200,
),
Expand All @@ -133,4 +212,5 @@ class _LoadingScreenState extends State<LoadingScreen>
),
);
}

}
11 changes: 8 additions & 3 deletions app/lib/screens/landing_screen/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'dart:io';
import 'package:open_file/open_file.dart';
import 'package:provider/provider.dart';
import 'package:share_plus/share_plus.dart';
import '../../helpers/ThemeProvider.dart';
import '../../model/user.dart';
import '../../services/SharedServices/Sharedservices.dart';
import 'navbar.dart';
Expand Down Expand Up @@ -109,13 +111,16 @@ class _DashboardPageState extends State<DashboardPage> {

@override
Widget build(BuildContext context) {

final themeProvider = Provider.of<ThemeProvider>(context);

return WillPopScope(
onWillPop: () async {
return false; // Disables the back button
},
child: Scaffold(
appBar: const CommonNavBar(),
drawer: AppDrawer(), // Use the CommonNavBar as the app bar
drawer: const AppDrawer(), // Use the CommonNavBar as the app bar
body: isLoading
? const Center(
child: CircularProgressIndicator(
Expand All @@ -136,7 +141,7 @@ class _DashboardPageState extends State<DashboardPage> {
focusNode: focusNode,
decoration: InputDecoration(
labelText: 'Search Notes ...',
prefixIcon: Icon(Icons.search),
prefixIcon: const Icon(Icons.search),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16.0),
),
Expand Down Expand Up @@ -164,7 +169,7 @@ class _DashboardPageState extends State<DashboardPage> {
margin: const EdgeInsets.all(20),
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.white,
color: themeProvider.isDarkMode ? Colors.grey[850] : Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
Expand Down
55 changes: 40 additions & 15 deletions app/lib/screens/landing_screen/drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import 'package:examtime/services/SharedServices/Sharedservices.dart';
import 'package:flutter/material.dart';
import 'package:examtime/screens/profile/profile.dart';
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
import '../../helpers/ThemeProvider.dart';
import '../auth_screen/signin.dart';
import '../liked_notes/liked.dart';
import '../request_notes/request.dart';
import 'dashboard.dart';

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

@override
Widget build(BuildContext context) {
final themeProvider = Provider.of<ThemeProvider>(context);
var media = MediaQuery.of(context).size;
return Drawer(
width: media.width,
Expand All @@ -28,7 +33,7 @@ class AppDrawer extends StatelessWidget {
),
Container(
width: media.width * 0.70,
decoration: const BoxDecoration(color: Colors.white),
decoration: BoxDecoration(color: themeProvider.isDarkMode ? Colors.grey[850] : Colors.white,),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.all(12),
Expand All @@ -54,7 +59,7 @@ class AppDrawer extends StatelessWidget {
),
),
),
SizedBox(width: 20),
const SizedBox(width: 20),
Expanded(
child: Text(
SharedServices.getLoginDetails()
Expand Down Expand Up @@ -94,7 +99,7 @@ class AppDrawer extends StatelessWidget {
height: 15,
),
ListTile(
leading: Icon(Icons.account_circle),
leading: const Icon(Icons.account_circle),
title: const Text('My Profile'),
onTap: () {
Navigator.pushNamed(
Expand All @@ -105,8 +110,8 @@ class AppDrawer extends StatelessWidget {
height: 15,
),
ListTile(
leading: Icon(Icons.favorite),
title: Text('Liked Notes'),
leading: const Icon(Icons.favorite),
title: const Text('Liked Notes'),
onTap: () {
Navigator.pushNamed(
context, LikedNotesPage.routeName);
Expand All @@ -116,8 +121,8 @@ class AppDrawer extends StatelessWidget {
height: 15,
),
ListTile(
leading: Icon(Icons.request_page),
title: Text('Request Notes'),
leading: const Icon(Icons.request_page),
title: const Text('Request Notes'),
onTap: () {
Navigator.pushNamed(
context, RequestNotesPage.routeName);
Expand All @@ -127,21 +132,41 @@ class AppDrawer extends StatelessWidget {
height: 15,
),
ListTile(
leading: Icon(Icons.logout),
title: Text('Logout'),
leading: const Icon(Icons.logout),
title: const Text('Logout'),
onTap: () {
SharedServices.logout(context);
Navigator.pushNamed(
context, LoginPage.routeName);
},
),
ListTile(
leading: Icon(Icons.forum),
title: Text('Discuss'),
ListTile(
leading: const Icon(Icons.forum),
title: const Text('Discuss'),
onTap: () {
Navigator.pushNamed(context, DiscussionPage.routeName);
},
),
const SizedBox(height: 10,),
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Row(

children: [
Switch(
value: themeProvider.isDarkMode,
onChanged: (value) {
themeProvider.toggleTheme(value);
},
),
const SizedBox(
width: 5,
),
Text(themeProvider.isDarkMode ? "Dark mode" : "Light mode", style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),),
],
),
)

],
),
),
Expand All @@ -154,12 +179,12 @@ class AppDrawer extends StatelessWidget {
),
GestureDetector(
onTap: () {},
child: Container(
child: SizedBox(
height: kTextTabBarHeight,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
const Text(
"Switch Account",
style: TextStyle(
fontSize: 18,
Expand All @@ -182,6 +207,6 @@ class AppDrawer extends StatelessWidget {
),


);
);
}
}
Loading

0 comments on commit 49023de

Please sign in to comment.