Skip to content

Commit

Permalink
custome bottom navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
MOKTADIR authored and MOKTADIR committed Mar 5, 2023
1 parent 685c5c5 commit 78c2739
Show file tree
Hide file tree
Showing 18 changed files with 620 additions and 14 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,22 @@ After setting up all the needed thing now lets talk about folder structure which
**GET**

```dart
final awardList = RxList<AwardData>();
getAwardList() async {
final postList = RxList<Posts>();
getPostList() async {
showLoading();
var response = await DioClient().get(
url: ApiUrl.allAward,
header: {
"Authorization": "Bearer ${await MySharedPref.getToken()}"
var response = await DioClient().get(url: ApiUrl.allPosts, header: {
'Accept': 'application/json',
'Content-Type': 'application/json',
}).catchError(handleError);
if (response == null) return;
awardList.assignAll(
(response["data"] as List).map((e) => AwardData.fromJson(e)).toList());
postList
.assignAll((response as List).map((e) => Posts.fromJson(e)).toList());
hideLoading();
}
}
```

**POST**
Expand Down
295 changes: 295 additions & 0 deletions lib/app/components/navbar/bottom_navbar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,295 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:getx_standard/app/modules/Page2/views/page2_view.dart';
import 'package:getx_standard/app/modules/Page3/views/page3_view.dart';
import 'package:getx_standard/app/modules/Page4/views/page4_view.dart';
import 'package:getx_standard/app/modules/Page5/views/page5_view.dart';
import 'package:getx_standard/app/modules/home/views/home_view.dart';
import 'package:getx_standard/config/theme/my_fonts.dart';
import 'package:iconly/iconly.dart';
import 'package:iconsax/iconsax.dart';

class BottomNavbar extends StatelessWidget {
BottomNavbar({Key? key}) : super(key: key);

List navigation = [
const HomeView(),
const Page2View(),
const Page3View(),
const Page4View(),
const Page5View(),
];
int _selectedIndex = 0;

@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
void _onTap(int index) {
_selectedIndex = index;

(context as Element).markNeedsBuild();
}

return Scaffold(
body: navigation[_selectedIndex],
bottomNavigationBar: Container(
width: MediaQuery.of(context).size.width,
height: 100.h,
decoration: BoxDecoration(
color: Colors.white,
// borderRadius: BorderRadius.circular(50),
boxShadow: [
BoxShadow(
color: theme.colorScheme.secondary.withOpacity(1),
spreadRadius: 0,
blurRadius: 20),
],
),
// margin: const EdgeInsets.only(left: 0, right: 0, bottom: 0, top: 0),
padding: const EdgeInsets.only(bottom: 18),
child: SizedBox(
width: MediaQuery.of(context).size.width,
height: 100.h,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.zero,
splashFactory: NoSplash.splashFactory,
backgroundColor: Colors.white,
),
onPressed: () {
_onTap(0);
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
height: 40.h,
width: 40.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _selectedIndex == 0
? theme.colorScheme.secondary
: Colors.white,
),
child: Center(
child: Icon(
_selectedIndex == 0
? IconlyBold.home
: IconlyLight.home,
color: _selectedIndex == 0
? Colors.white
: theme.primaryColor.withOpacity(.5),
),
),
),
const SizedBox(height: 5),
Text(
"Home",
style: TextStyle(
color: _selectedIndex == 0
? theme.primaryColor
: theme.primaryColor.withOpacity(.5),
fontSize: MyFonts.body2TextSize),
),
],
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 40.h,
width: 40.w,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.zero,
splashFactory: NoSplash.splashFactory,
backgroundColor: Colors.white,
),
onPressed: () {
_onTap(1);
},
child: Container(
height: 40.h,
width: 40.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _selectedIndex == 1
? theme.colorScheme.secondary
: Colors.white,
),
child: Center(
child: Icon(
Iconsax.activity,
color: _selectedIndex == 1
? Colors.white
: theme.primaryColor.withOpacity(.5),
),
),
),
),
),
const SizedBox(height: 5),
Text(
"Page2",
style: TextStyle(
color: _selectedIndex == 1
? theme.primaryColor
: theme.primaryColor.withOpacity(.5),
fontSize: MyFonts.body2TextSize),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 40.h,
width: 40.w,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.zero,
splashFactory: NoSplash.splashFactory,
backgroundColor: Colors.white,
),
onPressed: () {
_onTap(2);
},
child: Container(
height: 40.h,
width: 40.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _selectedIndex == 2
? theme.colorScheme.secondary
: Colors.white,
),
child: Center(
child: Icon(
Iconsax.magic_star,
size: 20,
color: _selectedIndex == 2
? Colors.white
: theme.primaryColor.withOpacity(.5),
),
),
),
),
),
const SizedBox(height: 5),
Text(
"Page3",
style: TextStyle(
color: _selectedIndex == 2
? theme.primaryColor
: theme.primaryColor.withOpacity(.5),
fontSize: MyFonts.body2TextSize),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 40.h,
width: 40.w,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.zero,
splashFactory: NoSplash.splashFactory,
backgroundColor: Colors.white,
),
onPressed: () {
_onTap(3);
},
child: Container(
height: 40.h,
width: 40.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _selectedIndex == 3
? theme.colorScheme.secondary
: Colors.white,
),
child: Center(
child: Icon(
IconlyLight.profile,
size: 20,
color: _selectedIndex == 3
? Colors.white
: theme.primaryColor.withOpacity(.5),
),
),
),
),
),
const SizedBox(height: 5),
Text(
"Page4",
style: TextStyle(
color: _selectedIndex == 3
? theme.primaryColor
: theme.primaryColor.withOpacity(.5),
fontSize: MyFonts.body2TextSize),
)
],
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 40.h,
width: 40.h,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
padding: EdgeInsets.zero,
splashFactory: NoSplash.splashFactory,
backgroundColor: Colors.white,
),
onPressed: () {
_onTap(4);
},
child: Container(
height: 40.h,
width: 40.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: _selectedIndex == 4
? theme.colorScheme.secondary
: Colors.white,
),
child: Center(
child: Icon(
IconlyLight.buy,
size: 20,
color: _selectedIndex == 3
? Colors.white
: theme.primaryColor.withOpacity(.5),
),
),
),
),
),
const SizedBox(height: 5),
Text(
"Page5",
style: TextStyle(
color: _selectedIndex == 4
? theme.primaryColor
: theme.primaryColor.withOpacity(.5),
fontSize: MyFonts.body2TextSize),
)
],
),
],
),
),
),
);
}
}
28 changes: 28 additions & 0 deletions lib/app/components/navbar/navbar_binding.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import 'package:get/get.dart';
import 'package:getx_standard/app/modules/Page2/controllers/page2_controller.dart';
import 'package:getx_standard/app/modules/Page3/controllers/page3_controller.dart';
import 'package:getx_standard/app/modules/home/controllers/home_controller.dart';

import '../../modules/Page4/controllers/page4_controller.dart';
import '../../modules/Page5/controllers/page5_controller.dart';

class NavbarBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut<HomeController>(
() => HomeController(),
);
Get.lazyPut<Page2Controller>(
() => Page2Controller(),
);
Get.lazyPut<Page3Controller>(
() => Page3Controller(),
);
Get.lazyPut<Page4Controller>(
() => Page4Controller(),
);
Get.lazyPut<Page5Controller>(
() => Page5Controller(),
);
}
}
12 changes: 12 additions & 0 deletions lib/app/modules/Page2/bindings/page2_binding.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:get/get.dart';

import '../controllers/page2_controller.dart';

class Page2Binding extends Bindings {
@override
void dependencies() {
Get.lazyPut<Page2Controller>(
() => Page2Controller(),
);
}
}
23 changes: 23 additions & 0 deletions lib/app/modules/Page2/controllers/page2_controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:get/get.dart';

class Page2Controller extends GetxController {
//TODO: Implement Page2Controller

final count = 0.obs;
@override
void onInit() {
super.onInit();
}

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

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

void increment() => count.value++;
}
Loading

0 comments on commit 78c2739

Please sign in to comment.