mhunt_launcher/lib/Widgets/Home/Sidebar.dart
2024-10-28 17:34:48 +05:30

127 lines
4.6 KiB
Dart

import 'package:flutter/material.dart';
import '../../Backend/Backend.dart';
import '../CustomWidgets.dart';
int selectedSidebarIndex = 0;
Widget SideBar(
{required double width, required double height,required Function(int) onChanged, int selectedIndex = 0}) {
return GlassContainer(
child: Container(
width: width,
height: height,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
children: [
SizedBox(
height: 100,
),
SidebarTitle("Library", Icons.laptop_chromebook_outlined, onChanged,
index: 0),
SidebarTitle("Dashboard", Icons.dashboard,onChanged, index: 1),
SidebarTitle("Downloads", Icons.download,onChanged, index: 2),
],
),
InkWell(
onTap:(){
selectedSidebarIndex=3;
onChanged(3);
},
child: GlassContainer(child: Padding(
padding: const EdgeInsets.fromLTRB(10,0,10,10),
child: Row(
children: [
Icon(Icons.supervised_user_circle_rounded, size: 50),
SizedBox(width: 15,),
Column(crossAxisAlignment:CrossAxisAlignment.start,children: [
Text(Backend.displayName,style: TextStyle(fontSize: 24),),
// Text("Vault credits : 50")
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
padding: EdgeInsets.symmetric(horizontal: 10,vertical: 2),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: Colors.black.withAlpha(100)),
child: Row(
children: [
Container(
height: 30,
width: 30,
child: Image.asset('images/vault.png'),
),
SizedBox(width: 5,),
Text(Backend.vault.vc.toString())
],
),
),
SizedBox(width: 5,),
Container(
padding: EdgeInsets.symmetric(horizontal: 10,vertical: 2),
decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: Colors.black.withAlpha(100)),
child: Row(
children: [
Container(
height: 30,
width: 30,
child: Image.asset('images/token.png'),
),
SizedBox(width: 5,),
Text(Backend.vault.php.toString())
],
),
),
],
)
],
),
],)
],
),
)),
)
],
),
),
opacity: 0.15,
color: Colors.blueGrey);
}
Widget SidebarTitle(String title, IconData iconData, Function(int) onChanged, {int index = 0}) {
return InkWell(
onTap: () {
selectedSidebarIndex = index;
onChanged(index);
},
child: Padding(
padding: EdgeInsets.symmetric(vertical: 0),
child: GlassContainer(
opacity: selectedSidebarIndex == index ? 0.1 : 0,
color:
selectedSidebarIndex == index ? Colors.white : Colors.transparent,
child: Container(
height: 75,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(iconData),
SizedBox(
width: 20,
),
Text(
title,
style: TextStyle(fontSize: 20),
),
],
),
),
),
),
);
}