123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import 'package:fitness_dashboard_ui/const/constant.dart';
- import 'package:fitness_dashboard_ui/data/side_menu_data.dart';
- import 'package:flutter/material.dart';
- class SideMenuWidget extends StatefulWidget {
- const SideMenuWidget({super.key});
- @override
- State<SideMenuWidget> createState() => _SideMenuWidgetState();
- }
- class _SideMenuWidgetState extends State<SideMenuWidget> {
- int selectedIndex = 0;
- @override
- Widget build(BuildContext context) {
- final data = SideMenuData();
- return Container(
- padding: const EdgeInsets.symmetric(vertical: 80, horizontal: 20),
- color: const Color(0xFF171821),
- child: ListView.builder(
- itemCount: data.menu.length,
- itemBuilder: (context, index) => buildMenuEntry(data, index),
- ),
- );
- }
- Widget buildMenuEntry(SideMenuData data, int index) {
- final isSelected = selectedIndex == index;
- return Container(
- margin: const EdgeInsets.symmetric(vertical: 5),
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.all(
- Radius.circular(6.0),
- ),
- color: isSelected ? selectionColor : Colors.transparent,
- ),
- child: InkWell(
- onTap: () => setState(() {
- selectedIndex = index;
- }),
- child: Row(
- children: [
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 13, vertical: 7),
- child: Icon(
- data.menu[index].icon,
- color: isSelected ? Colors.black : Colors.grey,
- ),
- ),
- Text(
- data.menu[index].title,
- style: TextStyle(
- fontSize: 16,
- color: isSelected ? Colors.black : Colors.grey,
- fontWeight: isSelected ? FontWeight.w600 : FontWeight.normal,
- ),
- )
- ],
- ),
- ),
- );
- }
- }
|