|
|
|
|
@ -5,16 +5,14 @@ import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
|
|
|
|
|
import '../../models/enums/translation_keys.dart';
|
|
|
|
|
|
|
|
|
|
class AppBottomNavigationBar extends StatefulWidget {
|
|
|
|
|
class AppBottomNavigationBar extends StatelessWidget {
|
|
|
|
|
final Function(int index) onPressed;
|
|
|
|
|
const AppBottomNavigationBar({Key key, @required this.onPressed}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<AppBottomNavigationBar> createState() => _AppBottomNavigationBarState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _AppBottomNavigationBarState extends State<AppBottomNavigationBar> {
|
|
|
|
|
int _selectedIndex = 0;
|
|
|
|
|
final int selectedIndex;
|
|
|
|
|
const AppBottomNavigationBar({
|
|
|
|
|
Key key,
|
|
|
|
|
@required this.onPressed,
|
|
|
|
|
@required this.selectedIndex,
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
@ -27,32 +25,27 @@ class _AppBottomNavigationBarState extends State<AppBottomNavigationBar> {
|
|
|
|
|
),
|
|
|
|
|
child: BottomNavigationBar(
|
|
|
|
|
items: <BottomNavigationBarItem>[
|
|
|
|
|
navBarItem(index: 0, iconName: "overview", label: TranslationKeys.overview),
|
|
|
|
|
navBarItem(index: 1, iconName: "requests", label: TranslationKeys.myRequests),
|
|
|
|
|
navBarItem(index: 2, iconName: "assets", label: TranslationKeys.myAssets),
|
|
|
|
|
navBarItem(index: 3, iconName: "message", label: TranslationKeys.contactUs),
|
|
|
|
|
navBarItem(context, index: 0, iconName: "overview", label: TranslationKeys.overview),
|
|
|
|
|
navBarItem(context, index: 1, iconName: "requests", label: TranslationKeys.myRequests),
|
|
|
|
|
navBarItem(context, index: 2, iconName: "assets", label: TranslationKeys.myAssets),
|
|
|
|
|
navBarItem(context, index: 3, iconName: "message", label: TranslationKeys.contactUs),
|
|
|
|
|
],
|
|
|
|
|
currentIndex: _selectedIndex,
|
|
|
|
|
currentIndex: selectedIndex,
|
|
|
|
|
selectedFontSize: 12,
|
|
|
|
|
onTap: (index) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_selectedIndex = index;
|
|
|
|
|
});
|
|
|
|
|
widget.onPressed(index);
|
|
|
|
|
},
|
|
|
|
|
onTap: onPressed,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BottomNavigationBarItem navBarItem({@required int index, @required String iconName, @required TranslationKeys label}) {
|
|
|
|
|
BottomNavigationBarItem navBarItem(BuildContext context, {@required int index, @required String iconName, @required TranslationKeys label}) {
|
|
|
|
|
return BottomNavigationBarItem(
|
|
|
|
|
icon: Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 10.toScreenHeight),
|
|
|
|
|
child: SvgPicture.asset(
|
|
|
|
|
'assets/images/$iconName.svg',
|
|
|
|
|
width: 24.toScreenWidth,
|
|
|
|
|
color: _selectedIndex == index ? Theme.of(context).bottomNavigationBarTheme.selectedItemColor : Theme.of(context).bottomNavigationBarTheme.unselectedItemColor,
|
|
|
|
|
color: selectedIndex == index ? Theme.of(context).bottomNavigationBarTheme.selectedItemColor : Theme.of(context).bottomNavigationBarTheme.unselectedItemColor,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
label: context.translate(label),
|
|
|
|
|
|