mirror of
https://bitbucket.org/myhomie/myhomie_app.git
synced 2025-12-06 09:01:20 +00:00
81 lines
2.2 KiB
Dart
81 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flare_flutter/flare_actor.dart';
|
|
import 'package:myhomie_app/Screens/Main/MainPage.dart';
|
|
import 'package:myhomie_app/Screens/Main/index.dart';
|
|
import 'package:myhomie_app/constants.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class CustomNavItem extends StatelessWidget {
|
|
final NavItemIcon icon;
|
|
final int id;
|
|
final Function setPage;
|
|
|
|
const CustomNavItem({required this.setPage, required this.icon, required this.id});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final index = Provider.of<Index>(context);
|
|
Size size = MediaQuery.of(context).size;
|
|
return GestureDetector(
|
|
onTap: () {
|
|
currentIndex = id;
|
|
index.setIndex(currentIndex);
|
|
setPage();
|
|
},
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(25),
|
|
color: kMainColor,
|
|
),
|
|
width: 55,
|
|
height: 55,
|
|
child: getIconSvg(icon, size.width * 0.1, index.getIndex()),
|
|
),
|
|
);
|
|
}
|
|
|
|
getIconSvg(NavItemIcon icon, double size, int index) {
|
|
switch(icon.name) {
|
|
case 'home':
|
|
return Icon(
|
|
Icons.home,
|
|
size: 25,
|
|
color: Colors.white,
|
|
);
|
|
case 'security':
|
|
return Icon(
|
|
Icons.security,
|
|
size: 25,
|
|
color: Colors.white,
|
|
);
|
|
case 'automations':
|
|
return Icon(
|
|
Icons.cable_rounded,
|
|
size: 25,
|
|
color: Colors.white,
|
|
);
|
|
case 'devices':
|
|
return Icon(
|
|
Icons.devices_other,
|
|
size: 25,
|
|
color: Colors.white,
|
|
);
|
|
case 'energy':
|
|
return Icon(
|
|
Icons.bolt,
|
|
size: 25,
|
|
color: Colors.white,
|
|
);
|
|
/*case 'profile': //Todo show user image ?
|
|
return Icon(
|
|
Icons.person,
|
|
size: 25,
|
|
color: Colors.white,
|
|
);*/
|
|
}
|
|
//return new FlareActor("assets/animations/bottom_navigation/"+ icon.toString().split(".").last +".flr", alignment:Alignment.center, fit:BoxFit.contain, animation: index == icon.index ? "Selected" : "Unselected"); //icon.index
|
|
}
|
|
|
|
}
|
|
|
|
enum NavItemIcon { home, security, automations, devices, energy, profile } |