diff --git a/assets/search.png b/assets/search.png new file mode 100644 index 0000000..b5bd0a4 Binary files /dev/null and b/assets/search.png differ diff --git a/lib/components/home_appbar.dart b/lib/components/home_appbar.dart index 613acdc..2733128 100644 --- a/lib/components/home_appbar.dart +++ b/lib/components/home_appbar.dart @@ -5,7 +5,8 @@ class HomeAppbar extends StatefulWidget { final List topNav; final void Function(int) changeNav; - const HomeAppbar({super.key, required this.topNav, required this.changeNav}); + final Widget right; + const HomeAppbar({super.key, required this.topNav, required this.changeNav, this.right = const SizedBox()}); @override State createState() => _HomeAppbarState(); @@ -20,55 +21,67 @@ class _HomeAppbarState extends State { return Container( padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top), color: Colors.transparent, - child: Container( - height: ScreenUtil().setWidth(108), - padding: EdgeInsets.symmetric( - horizontal: ScreenUtil().setWidth(34)), - child: Stack( - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, + child: Stack( + children: [ + Container( + height: ScreenUtil().setWidth(108), + padding: EdgeInsets.symmetric( + horizontal: ScreenUtil().setWidth(34)), + child: Stack( children: [ - ...widget.topNav.asMap().entries.map((entry){ - return InkWell( - onTap: (){ - active = entry.key; - widget.changeNav(active); - setState(() { + 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 - ), + }); + }, + 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), + ) + ], ), - 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, + ), + ) + ], ), ); } diff --git a/lib/pages/chat_page.dart b/lib/pages/chat_page.dart index 0b855ea..9cbf7b4 100644 --- a/lib/pages/chat_page.dart +++ b/lib/pages/chat_page.dart @@ -58,7 +58,19 @@ class _ChatPageState extends State { ), child: Column( children: [ - HomeAppbar(topNav: topNav, changeNav: changeNav,), + Container( + padding: EdgeInsets.symmetric(horizontal: 36.w), + child: HomeAppbar(topNav: topNav, changeNav: changeNav, right: InkWell( + onTap: (){ + print("12121"); + }, + child: Image.asset( + "assets/search.png", + width: 29.w, + height: 31.w, + ), + ),), + ), Container( width: 750.w, padding: EdgeInsets.only( diff --git a/lib/pages/live_page.dart b/lib/pages/live_page.dart index 637e5f1..fbd5efb 100644 --- a/lib/pages/live_page.dart +++ b/lib/pages/live_page.dart @@ -66,7 +66,29 @@ class _LivePageState extends State { ), child: Column( children: [ - HomeAppbar(topNav: topNav, changeNav: changeNav,), + HomeAppbar(topNav: topNav, changeNav: changeNav, right: InkWell( + onTap: (){ + print("12121"); + }, + child: Container( + width: 104.w, + height: 40.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(40.w)), + color: const Color.fromRGBO(108, 105, 244, 1) + ), + child: Center( + child: Text( + "申请红娘", + style: TextStyle( + fontSize: 20.w, + color: Colors.white, + fontWeight: FontWeight.w500 + ), + ), + ), + ), + ),), Container( width: 702.w, height: 91.w,