Skip to content

Commit

Permalink
chore: organized academia's core pages into well layed out structure
Browse files Browse the repository at this point in the history
# Pages Changed
- Auth - For authentication pages
- Courses - For course and course related pages
- Util pages - For supporting pages such as webviews and pdf views
- Other standalone pages
  • Loading branch information
IamMuuo committed Jun 26, 2024
1 parent 379008b commit 7bacd92
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 86 deletions.
22 changes: 0 additions & 22 deletions lib/controllers/user_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,6 @@ class UserController extends GetxController {
final loadedUser = await loadUserFromDisk();

if (loadedUser != null) {
// login(user.value!.admissionNumber, user.value!.password).then((value) {
// value.fold((l) {
// HapticFeedback.heavyImpact().then(
// (value) {
// Get.rawSnackbar(
// messageText: Text(
// l,
// textAlign: TextAlign.center,
// style: const TextStyle(
// color: Colors.white,
// ),
// ),
// duration: const Duration(days: 1),
// isDismissible: true,
// snackPosition: SnackPosition.TOP,
// backgroundColor: Colors.red[400]!,
// icon: const Icon(Ionicons.flash_outline, color: Colors.white),
// );
// },
// );
// }, (r) {});
// });
user.value = loadedUser;
isLoggedIn.value = true;
}
Expand Down
12 changes: 3 additions & 9 deletions lib/exports/barrel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ export 'package:ionicons/ionicons.dart';
export 'package:academia/controllers/notifications_controller.dart';
export 'package:percent_indicator/percent_indicator.dart';
export 'package:academia/controllers/settings_controller.dart';
export 'package:academia/pages/home_page.dart';
export 'package:academia/pages/intro_page.dart';
export 'package:academia/themes/theme.dart';
export 'package:magnet/magnet.dart';
export 'package:screenshot/screenshot.dart';
Expand All @@ -18,13 +16,6 @@ export 'package:academia/controllers/dashboard_controller.dart';
export 'package:flutter_carousel_widget/flutter_carousel_widget.dart';
export 'package:academia/tools/exam_timetable/exams_timetable_page.dart';
export 'package:academia/tools/fees/fees_page.dart';
export 'package:academia/pages/pdf_viewer.dart';
export 'package:academia/pages/webview_page.dart';
export 'package:academia/pages/courses_page.dart';
export 'package:academia/pages/dashboard.dart';
export 'package:academia/pages/settings_page.dart';
export 'package:academia/pages/tool_page.dart';
export 'package:academia/pages/login_page.dart';
export 'package:flutter_pdfview/flutter_pdfview.dart';
export 'package:academia/widgets/info_card.dart';
export 'package:cached_network_image/cached_network_image.dart';
Expand All @@ -35,3 +26,6 @@ export 'package:academia/controllers/controllers.dart';
export 'package:awesome_notifications/awesome_notifications.dart';
export 'package:academia/tools/todo/todo.dart';
export 'package:academia/tools/tools.dart';

// academia core pages
export '../pages/pages.dart';
35 changes: 5 additions & 30 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Academia extends StatelessWidget {
Get.put(RewardController());
Get.put(CoursesController());

// Prompt for permission
// Prompt for notification permission
AwesomeNotifications().isNotificationAllowed().then(
(value) {
if ((!value) && (Platform.isAndroid || Platform.isIOS)) {
Expand Down Expand Up @@ -82,35 +82,10 @@ class Academia extends StatelessWidget {
}
},
);

return FutureBuilder(
future: userController.loadUserFromDisk(),
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Image.asset(
"assets/icons/academia.png",
height: 200,
),
const SizedBox(height: 22),
Text(
"Let the past die, kill it if you have to ~ The Last Jedi",
style: Theme.of(context).textTheme.titleLarge,
textAlign: TextAlign.center,
),
],
),
),
);
}
return snapshot.hasData ? const HomePage() : const IntroPage();
},
return Obx(
() => userController.isLoggedIn.value
? const LayoutPage()
: const IntroPage(),
);
}
}
2 changes: 2 additions & 0 deletions lib/pages/auth/auth.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'login_page.dart';
export 'register_page.dart';
3 changes: 1 addition & 2 deletions lib/pages/login_page.dart → lib/pages/auth/login_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:academia/exports/barrel.dart';
import 'package:academia/pages/register_page.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:lottie/lottie.dart';
Expand Down Expand Up @@ -51,7 +50,7 @@ class _LoginPageState extends State<LoginPage> {
if (userController.isLoggedIn.value) {
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => const HomePage(),
builder: (context) => const LayoutPage(),
),
);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class _RegisterPageState extends State<RegisterPage> {
});
Navigator.of(context).pushReplacement(
MaterialPageRoute(
builder: (context) => const HomePage(),
builder: (context) => const LayoutPage(),
),
);
return;
Expand Down
1 change: 1 addition & 0 deletions lib/pages/courses/courses.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'courses_page.dart';
File renamed without changes.
20 changes: 11 additions & 9 deletions lib/pages/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ class DashBoard extends StatelessWidget {
floating: false,
snap: false,
),
SliverVisibility(
visible: storyController.stories.isNotEmpty,
sliver: const SliverToBoxAdapter(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
HomeScreenStoryWidget(),
],
Obx(
() => SliverVisibility(
visible: storyController.stories.isNotEmpty,
sliver: const SliverToBoxAdapter(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
HomeScreenStoryWidget(),
],
),
),
),
),
Expand Down
25 changes: 14 additions & 11 deletions lib/pages/home_page.dart → lib/pages/layout_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@ import 'package:academia/exports/barrel.dart';
import 'package:academia/pages/profile_page.dart';
import 'package:get/get.dart';

class HomePage extends StatefulWidget {
const HomePage({super.key});
class LayoutPage extends StatefulWidget {
const LayoutPage({super.key});

@override
State<HomePage> createState() => _HomePageState();
State<LayoutPage> createState() => _LayoutPageState();
}

class _HomePageState extends State<HomePage> {
class _LayoutPageState extends State<LayoutPage> {
int currentIndex = 0;
final pages = const [
DashBoard(),
ToolsPage(),
CoursesPage(),
ProfilePage(),
];
@override
Widget build(BuildContext context) {
Get.put(StoryController());

return Scaffold(
body: SafeArea(
child: IndexedStack(index: currentIndex, children: pages),
child: IndexedStack(
index: currentIndex,
children: const [
DashBoard(),
ToolsPage(),
CoursesPage(),
ProfilePage(),
],
),
),
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
Expand Down
10 changes: 10 additions & 0 deletions lib/pages/pages.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export 'dashboard.dart';
export 'layout_page.dart';
export 'profile_page.dart';
export 'settings_page.dart';
export 'tool_page.dart';

// Supporting pages
export 'auth/auth.dart';
export 'courses/courses.dart';
export 'util_pages/util_pages.dart';
3 changes: 1 addition & 2 deletions lib/pages/profile_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:academia/exports/barrel.dart';
import 'package:academia/pages/membership_pages.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:get/get.dart';

class ProfilePage extends StatelessWidget {
const ProfilePage({super.key});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions lib/pages/util_pages/util_pages.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export 'intro_page.dart';
export 'membership_pages.dart';
export 'pdf_viewer.dart';
export 'webview_page.dart';
File renamed without changes.

0 comments on commit 7bacd92

Please sign in to comment.