update app bar

hmxc
张萌 4 years ago
parent 8ea4aaae04
commit 7e0c0d50e6

@ -4,6 +4,7 @@ import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/const/resource.dart';
import 'package:akuCommunity/pages/activities_page/activities_page.dart';
import 'package:akuCommunity/pages/convenient_phone/convenient_phone_page.dart';
import 'package:akuCommunity/pages/home/widget/animate_app_bar.dart';
import 'package:akuCommunity/pages/industry_committee/industry_committee_page.dart';
import 'package:akuCommunity/pages/life_pay/life_pay_page.dart';
import 'package:akuCommunity/pages/message_center_page/message_center_page.dart';
@ -48,6 +49,9 @@ class _HomePageState extends State<HomePage>
@override
bool get wantKeepAlive => true;
ScrollController _scrollController;
Color _bgColor;
List<AkuShopModel> _shopList = [];
List<dynamic> data;
@ -102,6 +106,8 @@ class _HomePageState extends State<HomePage>
akuShop(value);
});
// akuShop(page);
_scrollController = ScrollController();
}
Future<void> akuShop(String response) async {
@ -142,6 +148,8 @@ class _HomePageState extends State<HomePage>
);
}
@override
Widget build(BuildContext context) {
super.build(context);
@ -149,47 +157,21 @@ class _HomePageState extends State<HomePage>
designSize: Size(750, 1334), allowFontScaling: true);
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
title: 'TEST'.text.make(),
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: true,
leading: Container(
margin: EdgeInsets.only(left: 32.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'深圳',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 24.sp,
color: Color(0xff333333),
),
),
Text(
'阴 27℃',
style: TextStyle(
fontSize: 20.sp,
color: Color(0xff333333),
),
)
]),
appBar: AnimateAppBar(
scrollController: _scrollController,
actions:[
_buildColButton(
icon: AntDesign.scan1,
title: '扫一扫',
onTap: () => Get.to(ScanPage()),
),
actions: [
_buildColButton(
icon: AntDesign.scan1,
title: '扫一扫',
onTap: () => Get.to(ScanPage()),
),
_buildColButton(
icon: AntDesign.bells,
title: '消息',
onTap: () => Get.to(MessageCenterPage()),
),
16.wb,
],
_buildColButton(
icon: AntDesign.bells,
title: '消息',
onTap: () => Get.to(MessageCenterPage()),
),
16.wb,
],
),
body: RefreshConfiguration(
child: SmartRefresher(
@ -200,6 +182,7 @@ class _HomePageState extends State<HomePage>
enablePullUp: true,
enablePullDown: false,
child: CustomScrollView(
controller: _scrollController,
slivers: [
SliverToBoxAdapter(
child: Column(

@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:velocity_x/velocity_x.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class AnimateAppBar extends StatefulWidget with PreferredSizeWidget {
final ScrollController scrollController;
final List<Widget> actions;
AnimateAppBar({Key key, this.scrollController, this.actions})
: super(key: key);
@override
_AnimateAppBarState createState() => _AnimateAppBarState();
@override
// TODO: implement preferredSize
Size get preferredSize => Size.fromHeight(56);
}
class _AnimateAppBarState extends State<AnimateAppBar> {
Color _bgColor = Colors.transparent;
@override
void initState() {
super.initState();
widget.scrollController.addListener(() {
setState(() {
_bgColor = widget.scrollController.offset > 30
? Color(0xFFFFBD00)
: widget.scrollController.offset < 0
? Colors.transparent
: Color(0xFFFFBD00)
.withOpacity((widget.scrollController.offset / 30));
});
});
}
@override
Widget build(BuildContext context) {
return AppBar(
title: 'TEST'.text.make(),
backgroundColor: _bgColor,
elevation: 0,
centerTitle: true,
leading: Container(
margin: EdgeInsets.only(left: 32.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'深圳',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 24.sp,
color: Color(0xff333333),
),
),
Text(
'阴 27℃',
style: TextStyle(
fontSize: 20.sp,
color: Color(0xff333333),
),
)
]),
),
actions: widget.actions,
);
}
}

@ -94,6 +94,8 @@ class _PersonalIndexState extends State<PersonalIndex>
SliverAppBar _sliverAppBar(double height) {
final userProvider = Provider.of<UserProvider>(context);
return SliverAppBar(
pinned: true,
toolbarHeight: 0,
elevation: 0,
stretch: true,
floating: true,

Loading…
Cancel
Save