264 lines
10 KiB
Dart
264 lines
10 KiB
Dart
import 'package:citycards_customer/itinerary_creation/bloc/get_itinerary_cities_bloc.dart';
|
|
import 'package:citycards_customer/itinerary_creation/bloc/itinerary_steps_selection_bloc.dart';
|
|
import 'package:citycards_customer/itinerary_creation/views/itinerary_creation_steps/current_location_selection.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
import '../../core/route_constants.dart';
|
|
import '../../localPreference/local_preference.dart';
|
|
import '../../networkApiServices/api_urls.dart';
|
|
import '../../profile/bloc/profile/profile_bloc.dart';
|
|
import '../../profile/bloc/profile/profile_state.dart';
|
|
import 'itinerary_creation_steps/museums_rating_selection_view.dart';
|
|
import 'itinerary_creation_steps/city_selection_view.dart';
|
|
import 'itinerary_creation_steps/date_selection_view.dart';
|
|
import 'itinerary_creation_steps/dietary_selection_view.dart';
|
|
import 'itinerary_creation_steps/energy_selection_view.dart';
|
|
import 'itinerary_creation_steps/cultural_landmark_rating_view.dart';
|
|
import 'itinerary_creation_steps/itinerary_completion_view.dart';
|
|
import 'itinerary_creation_steps/kids_selection_view.dart';
|
|
import 'itinerary_creation_steps/scenic_viewpoints_rating_view.dart';
|
|
import 'itinerary_creation_steps/shopping_rating_view.dart';
|
|
import 'itinerary_creation_steps/wildlife_rating_view.dart';
|
|
|
|
class ItineraryCreationPage extends StatefulWidget {
|
|
const ItineraryCreationPage({super.key});
|
|
|
|
@override
|
|
State<ItineraryCreationPage> createState() => _ItineraryCreationPageState();
|
|
}
|
|
|
|
class _ItineraryCreationPageState extends State<ItineraryCreationPage> {
|
|
final PageController _pageController = PageController();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
resizeToAvoidBottomInset: true,
|
|
backgroundColor: Color(0xFFFFF5F5),
|
|
appBar: AppBar(
|
|
backgroundColor: Color(0xFFFFF5F5),
|
|
elevation: 0,
|
|
leading: BlocBuilder<ItineraryStepNavigationBloc, ItineraryStepNavigationState>(
|
|
builder: (context, state) {
|
|
return GestureDetector(
|
|
onTap: () {
|
|
if (state.selectedIndex == 0) {
|
|
Navigator.of(context).pop();
|
|
} else {
|
|
context.read<ItineraryStepNavigationBloc>().add(
|
|
ItineraryStepNavigationPreviousEvent(),
|
|
);
|
|
}
|
|
},
|
|
child: Row(
|
|
children: [
|
|
SizedBox(width: 8.w),
|
|
Icon(Icons.arrow_back, color: Colors.black87),
|
|
SizedBox(width: 4.w),
|
|
Text(
|
|
"Back",
|
|
style: TextStyle(
|
|
color: Colors.black87,
|
|
fontSize: 14.sp,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
leadingWidth: 100.w,
|
|
|
|
// ✅ ADD THIS
|
|
actions: [
|
|
Padding(
|
|
padding: EdgeInsets.only(right: 16.w),
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.of(context, rootNavigator: true)
|
|
.pushNamed(RouteConstants.profile);
|
|
},
|
|
child: BlocBuilder<ProfileBloc, ProfileState>(
|
|
builder: (context, state) {
|
|
String? imagePath;
|
|
if (state is ProfileLoaded) {
|
|
imagePath = state.profile.profileImage;
|
|
}
|
|
final String? imageUrl =
|
|
(imagePath != null && imagePath.isNotEmpty)
|
|
? "${ApiUrls.baseUrl}$imagePath"
|
|
: null;
|
|
|
|
return CircleAvatar(
|
|
radius: 18.r,
|
|
backgroundColor: const Color(0xffFFDFDF),
|
|
backgroundImage:
|
|
(imageUrl != null && imageUrl.isNotEmpty)
|
|
? NetworkImage(imageUrl)
|
|
: null,
|
|
child: (imageUrl == null || imageUrl.isEmpty)
|
|
? Image.asset("assets/images/profile_default_img.png")
|
|
: null,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
body: BlocListener<
|
|
ItineraryStepNavigationBloc,
|
|
ItineraryStepNavigationState
|
|
>(
|
|
listener: (context, state) {
|
|
_pageController.animateToPage(
|
|
state.selectedIndex,
|
|
duration: const Duration(milliseconds: 300),
|
|
curve: Curves.easeInOut,
|
|
);
|
|
},
|
|
child: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
// City Logo + Magic Itinerary Title
|
|
FutureBuilder<String?>(
|
|
future: LocalPreference.getSelectedCityLogo(),
|
|
builder: (context, snapshot) {
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
if (snapshot.connectionState == ConnectionState.done &&
|
|
snapshot.hasData &&
|
|
snapshot.data != null &&
|
|
snapshot.data!.isNotEmpty)
|
|
Padding(
|
|
padding: EdgeInsets.only(bottom: 6.h),
|
|
child: CachedNetworkImage(
|
|
imageUrl: ApiUrls.baseUrl + snapshot.data!,
|
|
height: 45.h,
|
|
fit: BoxFit.contain,
|
|
color: Colors.black87,
|
|
placeholder: (context, url) => SizedBox(
|
|
height: 45.h,
|
|
child: Center(
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: 2,
|
|
color: Color(0xFFF95F62),
|
|
),
|
|
),
|
|
),
|
|
errorWidget: (context, url, error) => Icon(
|
|
Icons.location_city,
|
|
size: 40.sp,
|
|
color: Color(0xFFF95F62),
|
|
),
|
|
),
|
|
),
|
|
Text(
|
|
"Magic Itinerary ✨",
|
|
style: TextStyle(
|
|
color: Color(0xFFF95F62),
|
|
fontSize: 24.sp,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
SizedBox(height: 12.h),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
|
|
// Progress Bar
|
|
Padding(
|
|
padding: EdgeInsets.only(
|
|
left: 20.w,
|
|
right: 20.w,
|
|
bottom: 8.h,
|
|
),
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(10),
|
|
child: BlocBuilder<
|
|
ItineraryStepNavigationBloc,
|
|
ItineraryStepNavigationState
|
|
>(
|
|
builder: (context, state) {
|
|
return LinearProgressIndicator(
|
|
value: state.selectedIndex / 5,
|
|
borderRadius: BorderRadius.circular(10),
|
|
backgroundColor: Colors.white,
|
|
color: const Color(0xFFF95F62),
|
|
minHeight: 6.h,
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
|
|
// Step X of 10 — below the progress bar
|
|
BlocBuilder<
|
|
ItineraryStepNavigationBloc,
|
|
ItineraryStepNavigationState
|
|
>(
|
|
builder: (context, state) {
|
|
return Padding(
|
|
padding: EdgeInsets.only(bottom: 12.h),
|
|
child: RichText(
|
|
text: TextSpan(
|
|
style: TextStyle(
|
|
color: Color(0xFF4A5565),
|
|
fontSize: 14.sp,
|
|
),
|
|
children: [
|
|
TextSpan(text: "Step "),
|
|
TextSpan(
|
|
text: "${state.selectedIndex}",
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
TextSpan(text: " of "),
|
|
TextSpan(
|
|
text: "5",
|
|
style: TextStyle(fontWeight: FontWeight.bold),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
|
|
Expanded(
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 20.w),
|
|
child: PageView(
|
|
controller: _pageController,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
children: [
|
|
DateSelectionView(),
|
|
// CurrentLocationSelection(),
|
|
// BlocProvider(
|
|
// create: (context) => GetItineraryCitiesBloc(),
|
|
// child: CitySelectionView(),
|
|
// ),
|
|
EnergySelectionView(),
|
|
KidsSelectionView(),
|
|
DietarySelectionView(),
|
|
ArtGallerySelectionView(),
|
|
// ScenicViewpointsRatingView(),
|
|
// HistoricalSiteRatingView(),
|
|
// WildlifeRatingView(),
|
|
// ShoppingRatingView(),
|
|
ItineraryCompletionView(),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |