You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.7 KiB
Dart
68 lines
2.7 KiB
Dart
|
2 years ago
|
import 'package:flutter/material.dart';
|
||
|
|
import 'package:flutter_svg/svg.dart';
|
||
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
||
|
|
|
||
|
2 years ago
|
import '../../models/enums/translation_keys.dart';
|
||
|
|
import '../app_style/app_color.dart';
|
||
|
2 years ago
|
|
||
|
2 years ago
|
class AppBottomNavigationBar extends StatefulWidget {
|
||
|
|
final Function(int index) onPressed;
|
||
|
|
const AppBottomNavigationBar({Key key, @required this.onPressed}) : super(key: key);
|
||
|
2 years ago
|
|
||
|
|
@override
|
||
|
2 years ago
|
State<AppBottomNavigationBar> createState() => _AppBottomNavigationBarState();
|
||
|
2 years ago
|
}
|
||
|
|
|
||
|
2 years ago
|
class _AppBottomNavigationBarState extends State<AppBottomNavigationBar> {
|
||
|
2 years ago
|
int _selectedIndex = 0;
|
||
|
|
|
||
|
|
void _onItemTapped(int index) {
|
||
|
|
setState(() {
|
||
|
|
_selectedIndex = index;
|
||
|
|
});
|
||
|
|
widget.onPressed.call(index);
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return Material(
|
||
|
|
elevation: 20,
|
||
|
2 years ago
|
borderRadius: const BorderRadius.only(topLeft: Radius.circular(20.0), topRight: Radius.circular(20.0)),
|
||
|
2 years ago
|
child: SizedBox(
|
||
|
|
height: 100,
|
||
|
|
child: ClipRRect(
|
||
|
|
borderRadius: const BorderRadius.all(Radius.circular(20.0)),
|
||
|
|
child: BottomNavigationBar(
|
||
|
2 years ago
|
items: <BottomNavigationBarItem>[
|
||
|
2 years ago
|
BottomNavigationBarItem(
|
||
|
2 years ago
|
icon: SvgPicture.asset('assets/images/Overview.svg', width: 24, height: 24, color: _selectedIndex == 0 ? AppColor.primary70 : AppColor.neutral20),
|
||
|
2 years ago
|
label: context.translate(TranslationKeys.overview),
|
||
|
|
),
|
||
|
|
BottomNavigationBarItem(
|
||
|
2 years ago
|
icon: SvgPicture.asset('assets/images/requests.svg', width: 24, height: 24, color: _selectedIndex == 1 ? AppColor.primary70 : AppColor.neutral20),
|
||
|
2 years ago
|
label: context.translate(TranslationKeys.myRequest),
|
||
|
|
),
|
||
|
|
BottomNavigationBarItem(
|
||
|
2 years ago
|
icon: SvgPicture.asset('assets/images/assets.svg', width: 24, height: 24, color: _selectedIndex == 2 ? AppColor.primary70 : AppColor.neutral20),
|
||
|
2 years ago
|
label: context.translate(TranslationKeys.myRequest),
|
||
|
|
),
|
||
|
|
BottomNavigationBarItem(
|
||
|
2 years ago
|
icon: SvgPicture.asset('assets/images/message.svg', width: 24, height: 24, color: _selectedIndex == 3 ? AppColor.primary70 : AppColor.neutral20),
|
||
|
2 years ago
|
label: context.translate(TranslationKeys.contactUs),
|
||
|
|
),
|
||
|
|
],
|
||
|
|
currentIndex: _selectedIndex,
|
||
|
|
type: BottomNavigationBarType.fixed,
|
||
|
|
unselectedFontSize: 14,
|
||
|
|
unselectedLabelStyle: const TextStyle(height: 2),
|
||
|
|
selectedLabelStyle: const TextStyle(height: 2),
|
||
|
|
selectedItemColor: AppColor.primary70,
|
||
|
|
unselectedItemColor: AppColor.neutral20,
|
||
|
|
onTap: _onItemTapped,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|