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.
aku_new_community/lib/pages/home/widget/animate_app_bar.dart

73 lines
2.2 KiB

4 years ago
import 'package:flutter/material.dart';
4 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';
4 years ago
import 'package:aku_community/provider/app_provider.dart';
import 'package:aku_community/utils/headers.dart';
4 years ago
class AnimateAppBar extends StatefulWidget with PreferredSizeWidget {
3 years ago
final ScrollController? scrollController;
final List<Widget>? actions;
AnimateAppBar({Key? key, this.scrollController, this.actions})
4 years ago
: super(key: key);
@override
_AnimateAppBarState createState() => _AnimateAppBarState();
@override
Size get preferredSize => Size.fromHeight(56);
}
class _AnimateAppBarState extends State<AnimateAppBar> {
Color _bgColor = Colors.transparent;
@override
void initState() {
super.initState();
3 years ago
widget.scrollController!.addListener(() {
4 years ago
setState(() {
3 years ago
_bgColor = widget.scrollController!.offset > 30
4 years ago
? Color(0xFFFFBD00)
3 years ago
: widget.scrollController!.offset < 0
4 years ago
? Colors.transparent
: Color(0xFFFFBD00)
3 years ago
.withOpacity((widget.scrollController!.offset / 30));
4 years ago
});
});
}
@override
Widget build(BuildContext context) {
final appProvider = Provider.of<AppProvider>(context);
4 years ago
return AppBar(
3 years ago
title: Text(S.of(context)!.tempPlotName),
4 years ago
backgroundColor: _bgColor,
leading: Container(
margin: EdgeInsets.only(left: 32.w),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
3 years ago
if (appProvider.location != null)
Text(
3 years ago
appProvider.location!['city'] as String? ?? '',
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 24.sp,
color: Color(0xff333333),
),
4 years ago
),
Text(
'${appProvider.weatherType} ${appProvider.weatherTemp}',
4 years ago
style: TextStyle(
fontSize: 20.sp,
color: Color(0xff333333),
),
)
]),
),
actions: widget.actions,
);
}
}