You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.9 KiB
88 lines
2.9 KiB
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
class HomeAppbar extends StatefulWidget {
|
|
|
|
final List<String> topNav;
|
|
final void Function(int) changeNav;
|
|
final Widget right;
|
|
const HomeAppbar({super.key, required this.topNav, required this.changeNav, this.right = const SizedBox()});
|
|
|
|
@override
|
|
State<HomeAppbar> createState() => _HomeAppbarState();
|
|
}
|
|
|
|
class _HomeAppbarState extends State<HomeAppbar> {
|
|
|
|
int active = 0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
|
|
color: Colors.transparent,
|
|
child: Stack(
|
|
children: [
|
|
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),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
|
|
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Positioned(
|
|
right: 0,
|
|
top: 0,
|
|
bottom: 0,
|
|
child: Center(
|
|
child: widget.right,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|