121 lines
2.9 KiB
Dart
121 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:ride/constant/colors.dart';
|
|
import 'package:ride/constant/credential.dart';
|
|
|
|
class BottomBarController extends GetxController {
|
|
var currentIndex = 0.obs;
|
|
|
|
void changePage(int index) {
|
|
currentIndex.value = index;
|
|
}
|
|
}
|
|
|
|
class HomeScreen extends StatelessWidget {
|
|
final BottomBarController controller = Get.put(BottomBarController());
|
|
|
|
HomeScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Bottom Bar Example'),
|
|
),
|
|
body: Obx(() => IndexedStack(
|
|
index: controller.currentIndex.value,
|
|
children: [
|
|
HomeView(),
|
|
const ProfileView(),
|
|
const StatisticsView(),
|
|
const WalletView(),
|
|
],
|
|
)),
|
|
bottomNavigationBar: Obx(() => BottomNavigationBar(
|
|
backgroundColor: Colors.greenAccent,
|
|
currentIndex: controller.currentIndex.value,
|
|
onTap: controller.changePage,
|
|
items: const [
|
|
BottomNavigationBarItem(
|
|
icon: Icon(
|
|
Icons.home,
|
|
color: AppColor.primaryColor,
|
|
),
|
|
label: 'Home',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(
|
|
Icons.person,
|
|
color: AppColor.primaryColor,
|
|
),
|
|
label: 'Profile',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(
|
|
Icons.bar_chart,
|
|
color: AppColor.primaryColor,
|
|
),
|
|
label: 'Statistics',
|
|
),
|
|
BottomNavigationBarItem(
|
|
icon: Icon(
|
|
Icons.account_balance_wallet,
|
|
color: AppColor.primaryColor,
|
|
),
|
|
label: 'Wallet',
|
|
),
|
|
],
|
|
)),
|
|
);
|
|
}
|
|
}
|
|
|
|
class HomeView extends StatelessWidget {
|
|
const HomeView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Map<String, dynamic> data;
|
|
return Center(
|
|
child: Column(
|
|
children: [
|
|
Text('Home View'),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class ProfileView extends StatelessWidget {
|
|
const ProfileView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const Center(
|
|
child: Text('Profile View'),
|
|
);
|
|
}
|
|
}
|
|
|
|
class StatisticsView extends StatelessWidget {
|
|
const StatisticsView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const Center(
|
|
child: Text('Statistics View'),
|
|
);
|
|
}
|
|
}
|
|
|
|
class WalletView extends StatelessWidget {
|
|
const WalletView({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const Center(
|
|
child: Text('Wallet View'),
|
|
);
|
|
}
|
|
}
|