import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class HomeAppbar extends StatefulWidget { final List topNav; final void Function(int) changeNav; const HomeAppbar({super.key, required this.topNav, required this.changeNav}); @override State createState() => _HomeAppbarState(); } class _HomeAppbarState extends State { int active = 0; @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top), child: Container( height: ScreenUtil().setWidth(108), padding: EdgeInsets.symmetric( horizontal: ScreenUtil().setWidth(34)), child: Stack( children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ ...widget.topNav.asMap().entries.map((entry){ return InkWell( onTap: (){ active = entry.key; widget.changeNav(active); setState(() { }); }, child: Container( margin: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(27)), child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Text( entry.value, style: TextStyle( fontSize: active == entry.key ? 38.w : 34.w, color: const Color.fromRGBO(51, 51, 51, 1), fontWeight: active == entry.key ? FontWeight.w600 : FontWeight.w400 ), ), SizedBox(height: ScreenUtil().setWidth(9),), if(active == entry.key) Image.asset( "assets/home_top_active.png", width: ScreenUtil().setWidth(25), ) ], ), ), ); }), ], ) ], ), ), ); } }