137 lines
4.2 KiB
Dart
137 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import '../core/route_constants.dart';
|
|
import '../home/widgets/search_city_bottomsheet.dart';
|
|
|
|
class CommonAppBar extends StatelessWidget {
|
|
const CommonAppBar({
|
|
super.key,
|
|
required this.isWhiteLogo,
|
|
required this.isProfilePage,
|
|
this.showCart = true,
|
|
required this.showDivider,
|
|
this.imageUrl,
|
|
this.isSelectCity = false, // ✅ NEW PARAMETER (default false)
|
|
});
|
|
|
|
final bool isWhiteLogo;
|
|
final bool isProfilePage;
|
|
final bool? showCart;
|
|
final bool showDivider;
|
|
final String? imageUrl;
|
|
final bool isSelectCity; // ✅ NEW
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
/// LEFT SIDE
|
|
Row(
|
|
children: [
|
|
/// ✅ Logo handling
|
|
imageUrl != null && imageUrl!.isNotEmpty
|
|
? Image.network(
|
|
imageUrl!,
|
|
scale: 4,
|
|
errorBuilder: (context, error, stackTrace) {
|
|
return Image.asset(
|
|
isWhiteLogo
|
|
? "assets/logo/logo_city_cards_white.png"
|
|
: "assets/logo/logo_city_cards.png",
|
|
scale: 4,
|
|
);
|
|
},
|
|
)
|
|
: Image.asset(
|
|
isWhiteLogo
|
|
? "assets/logo/logo_city_cards_white.png"
|
|
: "assets/logo/logo_city_cards.png",
|
|
scale: 4,
|
|
),
|
|
|
|
/// ✅ Show dropdown ONLY if isSelectCity == true
|
|
if (isSelectCity)
|
|
IconButton(
|
|
onPressed: () {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
backgroundColor: Colors.transparent,
|
|
builder: (_) => const CitySelectionBottomSheet(),
|
|
);
|
|
},
|
|
icon: Icon(
|
|
Icons.arrow_drop_down,
|
|
color: isWhiteLogo
|
|
? Colors.white
|
|
: const Color(0xffF95F62),
|
|
size: 30,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
|
|
/// RIGHT SIDE
|
|
Row(
|
|
children: [
|
|
if (showCart!)
|
|
InkWell(
|
|
onTap: () {
|
|
Navigator.of(
|
|
context,
|
|
rootNavigator: true,
|
|
).pushNamed(RouteConstants.cartPage);
|
|
},
|
|
child: Container(
|
|
padding: const EdgeInsets.all(10),
|
|
decoration: const BoxDecoration(
|
|
color: Colors.white,
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: Image.asset(
|
|
"assets/icons/shopping_cart.png",
|
|
height: 20.h,
|
|
),
|
|
),
|
|
),
|
|
|
|
SizedBox(width: 8.w),
|
|
|
|
if (!isProfilePage)
|
|
GestureDetector(
|
|
onTap: () {
|
|
Navigator.of(
|
|
context,
|
|
rootNavigator: true,
|
|
).pushNamed(RouteConstants.profile);
|
|
},
|
|
child: CircleAvatar(
|
|
backgroundColor: const Color(0xffFFDFDF),
|
|
child: Image.asset(
|
|
"assets/images/profile_default_img.png",
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
|
|
/// DIVIDER
|
|
if (showDivider)
|
|
Column(
|
|
children: [
|
|
SizedBox(height: 12.h),
|
|
const Divider(height: 1, color: Color(0xFFD9D9D9)),
|
|
SizedBox(height: 22.h),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|