117 lines
3.7 KiB
Dart
117 lines
3.7 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';
|
|
import '../../l10n/app_localizations.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, AppLocalizations.of(context)!.yourCartTitle, 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(AppLocalizations.of(context)!.myCardsTab, 0),
|
|
_tabButton(AppLocalizations.of(context)!.myPostCardsTab, 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),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |