proxybuy-flutter/lib/widgets/profile_app_bar.dart

94 lines
2.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';
import 'package:lba/gen/assets.gen.dart';
import 'package:lba/res/colors.dart';
import 'package:lba/utils/theme_manager.dart';
class ProfileAppBar extends StatefulWidget implements PreferredSizeWidget {
final String title;
final bool showBackButton;
const ProfileAppBar({
super.key,
required this.title,
this.showBackButton = false,
});
@override
State<ProfileAppBar> createState() => _ProfileAppBarState();
@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight + 1);
}
class _ProfileAppBarState extends State<ProfileAppBar> {
@override
void didChangeDependencies() {
super.didChangeDependencies();
_updateSystemUI();
}
void _updateSystemUI() {
final brightness = Theme.of(context).brightness;
final isDark = brightness == Brightness.dark;
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: isDark ? Brightness.light : Brightness.dark,
statusBarBrightness: isDark ? Brightness.dark : Brightness.light,
),
);
}
@override
Widget build(BuildContext context) {
return Consumer<ThemeManager>(
builder: (context, themeManager, child) {
return AnimatedContainer(
duration: const Duration(milliseconds: 200),
curve: Curves.easeInOut,
decoration: BoxDecoration(
color: AppColors.surface,
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(18),
bottomRight: Radius.circular(18),
),
boxShadow: [
BoxShadow(
color: AppColors.textPrimary.withOpacity(0.05),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: AppBar(
surfaceTintColor: Colors.transparent,
backgroundColor: Colors.transparent,
elevation: 0,
centerTitle: true,
leading: widget.showBackButton
? IconButton(
icon: SvgPicture.asset(
Assets.icons.arrowLeft2.path,
color: AppColors.textPrimary,
),
onPressed: () => Navigator.of(context).pop(),
)
: null,
title: Text(
widget.title,
style: TextStyle(
color: AppColors.textPrimary,
fontSize: 17,
fontWeight: FontWeight.w600,
),
),
),
);
},
);
}
}