Files
CityCards_Customer_Flutter/lib/cart/views/my_cart_view_page.dart
2026-02-26 15:54:57 +05:30

116 lines
3.6 KiB
Dart

import 'package:citycards_customer/common_packages/app_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../common_packages/back_widget.dart';
import '../blocs/myPassCart/my_pass_cart_bloc.dart';
import '../blocs/myPassCart/my_pass_cart_event.dart';
import '../blocs/myPostcardsCart/my_postcards_cart_bloc.dart';
import 'my_pass_cart_page_view.dart';
import 'my_postcard_cart_page_view.dart';
class MyCartPage extends StatefulWidget {
const MyCartPage({super.key});
@override
State<MyCartPage> createState() => _MyCartPageState();
}
class _MyCartPageState extends State<MyCartPage> {
int selectedTab = 0;
@override
void initState() {
super.initState();
context.read<MyPassCartBloc>().add(const CheckLoginAndFetchEvent());
context.read<MyPostCardsCartBloc>().add(CheckLoginAndFetchPostcardsCart());
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CommonAppBar(
isWhiteLogo: false,
isProfilePage: false,
showCart: false,
showDivider: true,
),
backWidget(context, "Your Cart", Colors.black),
SizedBox(height: 24.h),
Container(
padding: EdgeInsets.all(4.w),
decoration: BoxDecoration(
color: const Color(0xffFEE7E7),
borderRadius: BorderRadius.circular(30.r),
),
child: Row(
children: [
_tabButton("My Passes", 0),
_tabButton("My Post Cards", 1),
],
),
),
SizedBox(height: 8.h),
],
),
),
Expanded(
child: IndexedStack(
index: selectedTab,
children: const [
MyPassesCartPage(),
MyPostCardsCartPage(),
],
),
),
],
),
),
);
}
Expanded _tabButton(String title, int index) {
final bool isSelected = selectedTab == index;
return Expanded(
child: GestureDetector(
onTap: () => setState(() => selectedTab = index),
child: Container(
padding: EdgeInsets.symmetric(vertical: 12.h),
decoration: BoxDecoration(
color: isSelected ? Colors.white : Colors.transparent,
borderRadius: BorderRadius.circular(30.r),
boxShadow: isSelected
? [
BoxShadow(
color: Colors.black.withOpacity(0.06),
blurRadius: 6,
offset: const Offset(0, 2),
)
]
: [],
),
child: Center(
child: Text(
title,
style: TextStyle(
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
fontSize: 13.sp,
color: const Color(0xff2A2A2A),
),
),
),
),
),
);
}
}