develop #1
|
@ -4,6 +4,8 @@ import 'package:quiz_app/feature/home/binding/home_binding.dart';
|
|||
import 'package:quiz_app/feature/home/view/home_page.dart';
|
||||
import 'package:quiz_app/feature/login/bindings/login_binding.dart';
|
||||
import 'package:quiz_app/feature/login/view/login_page.dart';
|
||||
import 'package:quiz_app/feature/navigation/bindings/navigation_binding.dart';
|
||||
import 'package:quiz_app/feature/navigation/views/navbar_view.dart';
|
||||
import 'package:quiz_app/feature/register/binding/register_binding.dart';
|
||||
import 'package:quiz_app/feature/register/view/register_page.dart';
|
||||
import 'package:quiz_app/feature/splash_screen/presentation/splash_screen_page.dart';
|
||||
|
@ -32,5 +34,14 @@ class AppPages {
|
|||
binding: HomeBinding(),
|
||||
middlewares: [AuthMiddleware()],
|
||||
),
|
||||
GetPage(
|
||||
name: AppRoutes.mainPage,
|
||||
page: () => NavbarView(),
|
||||
bindings: [
|
||||
NavbarBinding(),
|
||||
HomeBinding(),
|
||||
],
|
||||
middlewares: [AuthMiddleware()],
|
||||
)
|
||||
];
|
||||
}
|
||||
|
|
|
@ -5,4 +5,6 @@ abstract class AppRoutes {
|
|||
static const loginPage = "/login";
|
||||
static const registerPage = "/register";
|
||||
static const homePage = '/home';
|
||||
|
||||
static const mainPage = '/main';
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class HistoryView extends StatelessWidget {
|
||||
const HistoryView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold();
|
||||
}
|
||||
}
|
|
@ -111,5 +111,5 @@ class LoginController extends GetxController {
|
|||
}
|
||||
}
|
||||
|
||||
void goToRegsPage() => Get.toNamed(AppRoutes.registerPage);
|
||||
void goToRegsPage() => Get.toNamed(AppRoutes.mainPage);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// feature/navbar/binding/navbar_binding.dart
|
||||
import 'package:get/get.dart';
|
||||
import 'package:quiz_app/feature/navigation/controllers/navigation_controller.dart';
|
||||
|
||||
class NavbarBinding extends Bindings {
|
||||
@override
|
||||
void dependencies() {
|
||||
Get.lazyPut<NavigationController>(() => NavigationController());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
import 'package:get/get.dart';
|
||||
|
||||
class NavigationController extends GetxController {
|
||||
RxInt selectedIndex = 0.obs;
|
||||
|
||||
void changePage(int page) {
|
||||
selectedIndex.value = page;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:quiz_app/feature/history/view/history_view.dart';
|
||||
import 'package:quiz_app/feature/home/view/home_page.dart';
|
||||
import 'package:quiz_app/feature/navigation/controllers/navigation_controller.dart';
|
||||
import 'package:quiz_app/feature/profile/view/profile_view.dart';
|
||||
import 'package:quiz_app/feature/search/view/search_view.dart';
|
||||
|
||||
class NavbarView extends GetView<NavigationController> {
|
||||
const NavbarView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Obx(() {
|
||||
switch (controller.selectedIndex.value) {
|
||||
case 0:
|
||||
return const HomeView();
|
||||
case 1:
|
||||
return const SearchView();
|
||||
case 2:
|
||||
return const HistoryView();
|
||||
case 3:
|
||||
return const ProfileView();
|
||||
default:
|
||||
return const HomeView();
|
||||
}
|
||||
}),
|
||||
bottomNavigationBar: Obx(
|
||||
() => BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed, // <=== ini tambahan penting!
|
||||
currentIndex: controller.selectedIndex.value,
|
||||
onTap: controller.changePage,
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.home),
|
||||
label: 'Home',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.search),
|
||||
label: 'Search',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.history),
|
||||
label: 'History',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.person),
|
||||
label: 'Profile',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class ProfileView extends StatelessWidget {
|
||||
const ProfileView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class SearchView extends StatelessWidget {
|
||||
const SearchView({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold();
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ class SplashScreenView extends StatelessWidget {
|
|||
await Future.delayed(const Duration(seconds: 2));
|
||||
|
||||
if (isLoggedIn) {
|
||||
Get.offNamed(AppRoutes.homePage);
|
||||
Get.offNamed(AppRoutes.mainPage);
|
||||
} else {
|
||||
Get.offNamed(AppRoutes.loginPage);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue