chore: أرشفة تطبيقات ولوحات تريبز التي سيحلّ محلها كود سيرو

استكمال قرار 2026-07-27 (كوميت fff76c9 أرشف الباك إند):
  apps/rider          → apps/rider-archive-cubit
  apps/driver         → apps/driver-archive-cubit
  dashboards/admin-web    → dashboards/admin-web-archive
  dashboards/service-web  → dashboards/service-web-archive

إعادة تسمية بلا تعديل محتوى. rider/driver كانا إعادة بناء Cubit مبنية على
عقد NestJS المؤرشف. admin-web و service-web نموذجان بملف HTML واحد (164 و
128 سطراً) — يحلّ محلهما siro_admin و siro_service المكتملان.

يُحمل من المؤرشف ولا يُعاد اكتشافه: عقد map-saas المثبَّت بالتجربة في
apps/rider-archive-cubit/lib/core/api/ (x-api-key ترويسة، reverse مصفوفة،
route في points) ودرس مسار FCM.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Hamza-Ayed
2026-07-27 05:12:04 +03:00
co-authored by Claude Opus 5
parent fff76c949f
commit 9909d9b4c1
809 changed files with 0 additions and 0 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,528 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:intaleq_maps/intaleq_maps.dart';
import '../../../core/l10n/app_localizations.dart';
import '../../../core/design/tokens.dart';
import '../../auth/cubit/auth_cubit.dart';
import '../../auth/cubit/auth_state.dart';
import '../../trip/bloc/trip_bloc.dart';
import '../../trip/bloc/trip_state.dart';
import '../../trip/bloc/trip_event.dart';
import '../cubit/home_cubit.dart';
import '../cubit/saved_places_cubit.dart';
import '../data/models/place_model.dart';
import '../data/maps_repository.dart';
import '../../../core/storage/saved_places_store.dart';
import '../../../core/di.dart';
/// زر عائم دائري صغير — للقائمة وإعادة التوسيط فوق الخريطة.
class _MapCircleButton extends StatelessWidget {
const _MapCircleButton({required this.icon, required this.onPressed});
final IconData icon;
final VoidCallback onPressed;
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Container(
decoration: BoxDecoration(
color: cs.surface,
shape: BoxShape.circle,
boxShadow: const [T.shadowSm],
),
child: IconButton(
icon: Icon(icon, color: cs.onSurface),
onPressed: onPressed,
),
);
}
}
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
IntaleqMapController? _mapController;
bool _isSelectingOnMap = false;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
context.read<TripBloc>().add(const TripCheckActive());
context.read<SavedPlacesCubit>().load();
});
}
String _timeBasedGreeting(String? name, AppLocalizations l10n) {
final hour = DateTime.now().hour;
final isMorning = hour >= 5 && hour < 12;
final isAr = Localizations.localeOf(context).languageCode == 'ar';
final prefix = isMorning
? (isAr ? 'صباح الخير' : 'Good morning')
: (isAr ? 'مساء الخير' : 'Good evening');
final firstName = (name != null && name.trim().isNotEmpty)
? name.trim().split(' ').first
: '';
return firstName.isNotEmpty ? '$prefix، $firstName' : prefix;
}
String _whereToPrompt(String? name, AppLocalizations l10n) {
final firstName = (name != null && name.trim().isNotEmpty)
? name.trim().split(' ').first
: '';
if (firstName.isNotEmpty) {
final isAr = Localizations.localeOf(context).languageCode == 'ar';
return isAr ? 'إلى أين يا $firstName؟' : 'Where to, $firstName?';
}
return l10n.whereTo;
}
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final cs = Theme.of(context).colorScheme;
final isDark = Theme.of(context).brightness == Brightness.dark;
return BlocListener<TripBloc, TripState>(
listenWhen: (prev, cur) => prev.trip?.status != cur.trip?.status,
listener: (context, state) {
if (state.trip != null && !state.isCompleted) {
context.push('/trip-tracking');
}
},
child: Scaffold(
backgroundColor: cs.surface,
// الخريطة تملأ الشاشة حتى الحافة العلوية (docs/29 §3.6) — كل العناصر
// العائمة فوقها تعيش داخل SafeArea الخاصة بها لا الشاشة كلها.
extendBodyBehindAppBar: true,
body: Stack(
children: [
// ── الخريطة (75% من الشاشة) ──
Positioned(
top: 0,
left: 0,
right: 0,
height: MediaQuery.of(context).size.height * 0.75,
child: BlocConsumer<HomeCubit, HomeState>(
listenWhen: (prev, cur) =>
prev.currentLocation == null && cur.currentLocation != null,
buildWhen: (prev, cur) =>
prev.currentLocation != cur.currentLocation ||
prev.pickup != cur.pickup ||
prev.destination != cur.destination,
listener: (context, state) {
if (state.currentLocation != null && _mapController != null) {
_mapController!.animateCamera(
CameraUpdate.newLatLngZoom(state.currentLocation!, 16),
);
}
},
builder: (context, state) {
final center =
state.currentLocation ?? const LatLng(31.9539, 35.9106);
return IntaleqMap(
apiKey: '',
initialCameraPosition:
CameraPosition(target: center, zoom: 15),
mapType:
isDark ? IntaleqMapType.normal : IntaleqMapType.light,
myLocationEnabled: true,
myLocationButtonEnabled: false,
zoomControlsEnabled: false,
compassEnabled: false,
onMapCreated: (controller) {
_mapController = controller;
if (state.currentLocation != null) {
Future.delayed(const Duration(milliseconds: 300), () {
controller.animateCamera(
CameraUpdate.newLatLngZoom(
state.currentLocation!, 16),
);
});
}
},
markers: _buildMarkers(state),
onCameraMove: (position) {
context
.read<HomeCubit>()
.updateCameraTarget(position.target);
},
);
},
),
),
// زر القائمة أعلى-بداية
PositionedDirectional(
top: MediaQuery.of(context).padding.top + T.s8,
start: T.pagePadding,
child: _MapCircleButton(
icon: Icons.menu_rounded,
onPressed: () => _showLogoutDialog(context, l10n),
),
),
// زر إعادة التوسيط عائم أعلى البطاقة السفلية
PositionedDirectional(
end: T.pagePadding,
bottom: (_isSelectingOnMap ? 100 : MediaQuery.of(context).size.height * 0.28) + T.s16,
child: BlocBuilder<HomeCubit, HomeState>(
builder: (context, state) {
return _MapCircleButton(
icon: Icons.my_location_rounded,
onPressed: state.currentLocation == null
? () {}
: () => _mapController?.animateCamera(
CameraUpdate.newLatLngZoom(
state.currentLocation!, 16),
),
);
},
),
),
if (_isSelectingOnMap)
// علامة المركز (دبوس) لاختيار الموقع
Positioned(
top: (MediaQuery.of(context).size.height * 0.75) / 2 - 20,
left: MediaQuery.of(context).size.width / 2 - 20,
child: const Icon(Icons.location_on, size: 40, color: Colors.black),
),
// ── البطاقة السفلية: «إلى أين؟» والأماكن المحفوظة ──
if (!_isSelectingOnMap)
Positioned(
left: 0,
right: 0,
bottom: 0,
height: MediaQuery.of(context).size.height * 0.30,
child: Container(
width: double.infinity,
padding: const EdgeInsets.fromLTRB(
T.pagePadding, T.s24, T.pagePadding, T.s16),
decoration: BoxDecoration(
color: cs.surface,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(T.r24),
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.1),
blurRadius: 20,
offset: const Offset(0, -5),
)
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// التحية الزمنية مع اسم الراكب بتصميم أنيق
BlocBuilder<AuthCubit, AuthState>(
builder: (context, authState) {
final greeting = _timeBasedGreeting(authState.user?.name, l10n);
return Text(
greeting,
style: Theme.of(context)
.textTheme
.titleLarge
?.copyWith(
fontWeight: FontWeight.w800,
color: cs.onSurface,
letterSpacing: -0.5,
),
);
},
),
const SizedBox(height: T.s24),
// حقل «إلى أين؟»
BlocBuilder<AuthCubit, AuthState>(
builder: (context, authState) {
final searchPrompt = _whereToPrompt(authState.user?.name, l10n);
return Material(
color: cs.surfaceContainerLowest,
elevation: 2,
shadowColor: cs.shadow.withValues(alpha: 0.05),
borderRadius: BorderRadius.circular(T.r16),
child: InkWell(
borderRadius: BorderRadius.circular(T.r16),
onTap: () => _openDestinationSearch(context),
child: Container(
height: 60,
padding: const EdgeInsets.symmetric(horizontal: T.s16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(T.r16),
border: Border.all(
color: cs.outlineVariant.withValues(alpha: 0.5),
width: 1,
),
),
child: Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: cs.primaryContainer.withValues(alpha: 0.5),
shape: BoxShape.circle,
),
child: Icon(
Icons.search_rounded,
color: cs.primary,
size: 22,
),
),
const SizedBox(width: T.s16),
Expanded(
child: Text(
searchPrompt,
style: Theme.of(context)
.textTheme
.titleMedium
?.copyWith(
color: cs.onSurface,
fontWeight: FontWeight.w700,
fontSize: 18,
),
),
),
],
),
),
),
);
},
),
const Spacer(),
Divider(color: cs.outlineVariant.withValues(alpha: 0.3), height: 1),
const SizedBox(height: T.s12),
// الأماكن المحفوظة (سطر أفقي أنيق)
BlocBuilder<SavedPlacesCubit, SavedPlacesState>(
builder: (context, savedState) {
final items = savedState.places.take(3).toList();
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildQuickAction(context, Icons.home_rounded, l10n.homePlace, items.isNotEmpty ? items.first : null),
Container(width: 1, height: 32, color: cs.outlineVariant.withValues(alpha: 0.3)),
_buildQuickAction(context, Icons.work_rounded, l10n.workPlace, items.length > 1 ? items[1] : null),
Container(width: 1, height: 32, color: cs.outlineVariant.withValues(alpha: 0.3)),
_buildQuickAction(context, Icons.star_rounded, l10n.favorites, items.length > 2 ? items[2] : null),
],
);
},
),
const SizedBox(height: T.s8),
],
),
),
)
else
// زر تأكيد الوجهة في وضع اختيار الخريطة
Positioned(
left: 0,
right: 0,
bottom: 0,
child: Container(
padding: const EdgeInsets.fromLTRB(
T.pagePadding, T.s16, T.pagePadding, T.s32),
decoration: BoxDecoration(
color: cs.surface,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(T.r24),
),
boxShadow: const [T.shadowLg],
),
child: FilledButton(
onPressed: _confirmMapDestination,
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(T.r12),
),
),
child: Text('تأكيد الوجهة', style: Theme.of(context).textTheme.titleMedium?.copyWith(color: cs.onPrimary)),
),
),
),
],
),
),
);
}
void _onPlaceTap(BuildContext context, SavedPlace place) {
context.read<HomeCubit>().setDestination(PlaceModel(
name: place.name,
address: place.address,
lat: place.lat,
lng: place.lng,
));
final state = context.read<HomeCubit>().state;
if (state.pickup != null) {
_openRoutePreview(context, state);
}
}
Set<Marker> _buildMarkers(HomeState state) {
final markers = <Marker>{};
if (state.pickup != null) {
markers.add(Marker(
markerId: const MarkerId('pickup'),
position: LatLng(state.pickup!.lat, state.pickup!.lng),
icon: InlqBitmap.defaultMarkerWithHue(210),
anchor: const Offset(0.5, 1.0),
zIndex: 2,
));
}
if (state.destination != null) {
markers.add(Marker(
markerId: const MarkerId('destination'),
position: LatLng(state.destination!.lat, state.destination!.lng),
icon: InlqBitmap.defaultMarkerWithHue(0),
anchor: const Offset(0.5, 1.0),
zIndex: 1,
));
}
return markers;
}
void _openDestinationSearch(BuildContext context) {
final homeCubit = context.read<HomeCubit>();
final pickup = homeCubit.state.pickup;
final currentLocation = homeCubit.state.currentLocation;
context.push<dynamic>('/destination', extra: {
'currentLocation': currentLocation,
}).then((result) {
if (!mounted) return;
if (result is Map && result['pickFromMap'] == true) {
setState(() {
_isSelectingOnMap = true;
});
return;
}
final place = result as PlaceModel?;
if (place != null && pickup != null) {
homeCubit.setDestination(place);
// ignore: use_build_context_synchronously
context.push('/route-preview', extra: {
'pickup': pickup,
'destination': place,
});
}
});
}
Future<void> _confirmMapDestination() async {
final homeCubit = context.read<HomeCubit>();
final target = homeCubit.state.cameraTarget;
if (target == null) return;
// We reverse geocode the target to get the address name
final repo = getIt<MapsRepository>();
try {
final place = await repo.reverseGeocode(target.latitude, target.longitude);
setState(() {
_isSelectingOnMap = false;
});
homeCubit.setDestination(place);
if (homeCubit.state.pickup != null) {
_openRoutePreview(context, homeCubit.state);
}
} catch (_) {
// In case of error, still set it with empty name
setState(() {
_isSelectingOnMap = false;
});
homeCubit.setDestination(PlaceModel(
name: 'موقع محدد على الخريطة',
lat: target.latitude,
lng: target.longitude,
));
if (homeCubit.state.pickup != null) {
_openRoutePreview(context, homeCubit.state);
}
}
}
void _openRoutePreview(BuildContext context, HomeState state) {
if (state.pickup == null || state.destination == null) return;
context.push('/route-preview', extra: {
'pickup': state.pickup,
'destination': state.destination,
});
}
void _showLogoutDialog(BuildContext context, AppLocalizations l10n) {
final cs = Theme.of(context).colorScheme;
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text(l10n.logout),
content: Text(l10n.logout),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx),
child: Text(l10n.cancel),
),
FilledButton(
onPressed: () async {
Navigator.pop(ctx);
await context.read<AuthCubit>().logout();
if (context.mounted) context.go('/phone');
},
style: FilledButton.styleFrom(backgroundColor: cs.error),
child: Text(l10n.logout),
),
],
),
);
}
Widget _buildQuickAction(
BuildContext context, IconData icon, String label, SavedPlace? place) {
final cs = Theme.of(context).colorScheme;
return InkWell(
onTap: place != null ? () => _onPlaceTap(context, place) : null,
borderRadius: BorderRadius.circular(T.r12),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: T.s12, vertical: T.s8),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon,
color: place != null
? cs.primary
: cs.onSurfaceVariant.withValues(alpha: 0.5),
size: 28),
const SizedBox(height: T.s4),
Text(
label,
style: Theme.of(context).textTheme.labelMedium?.copyWith(
color: place != null
? cs.onSurface
: cs.onSurfaceVariant.withValues(alpha: 0.5),
fontWeight:
place != null ? FontWeight.w600 : FontWeight.normal,
),
),
],
),
),
);
}
}
@@ -0,0 +1,540 @@
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:intaleq_maps/intaleq_maps.dart';
import '../../../core/l10n/app_localizations.dart';
import '../../../core/design/tokens.dart';
import '../../../core/ui/tripz_button.dart';
import '../../trip/bloc/trip_bloc.dart';
import '../../trip/bloc/trip_state.dart';
import '../../trip/bloc/trip_event.dart';
import '../cubit/quote_cubit.dart';
import '../data/models/place_model.dart';
import '../data/models/route_model.dart';
import '../data/maps_repository.dart';
import '../../../core/di.dart';
import 'widgets/ride_class_card.dart';
List<LatLng> _decodePolyline(String encoded) {
return PolylineUtils.decode(encoded);
}
class RoutePreviewScreen extends StatefulWidget {
final PlaceModel pickup;
final PlaceModel destination;
const RoutePreviewScreen({
super.key,
required this.pickup,
required this.destination,
});
@override
State<RoutePreviewScreen> createState() => _RoutePreviewScreenState();
}
class _RoutePreviewScreenState extends State<RoutePreviewScreen> {
IntaleqMapController? _mapController;
RouteModel? _route;
List<LatLng> _polylinePoints = [];
bool _routeLoading = true;
String? _routeError;
final _promoController = TextEditingController();
@override
void initState() {
super.initState();
_fetchRoute();
WidgetsBinding.instance.addPostFrameCallback((_) {
context.read<QuoteCubit>().fetchQuote(
pickupLat: widget.pickup.lat,
pickupLng: widget.pickup.lng,
pickupAddress: widget.pickup.name,
dropoffLat: widget.destination.lat,
dropoffLng: widget.destination.lng,
dropoffAddress: widget.destination.name,
);
});
}
@override
void dispose() {
_promoController.dispose();
super.dispose();
}
Future<void> _fetchRoute() async {
setState(() {
_routeLoading = true;
_routeError = null;
});
try {
final repo = getIt<MapsRepository>();
final route = await repo.getRoute(
fromLat: widget.pickup.lat,
fromLng: widget.pickup.lng,
toLat: widget.destination.lat,
toLng: widget.destination.lng,
);
final points = await compute(_decodePolyline, route.polyline ?? '');
if (!mounted) return;
setState(() {
_route = route;
_polylinePoints = points;
_routeLoading = false;
});
_fitCamera();
} catch (e) {
if (!mounted) return;
setState(() {
_routeError = e.toString();
_routeLoading = false;
});
}
}
void _fitCamera() {
if (_mapController == null) return;
final bounds = _route?.getLatLngBounds();
if (bounds != null) {
_mapController!.moveCamera(CameraUpdate.newLatLngBounds(bounds));
} else {
_mapController!.moveCamera(CameraUpdate.newLatLngZoom(
LatLng(widget.pickup.lat, widget.pickup.lng),
15,
));
}
}
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final cs = Theme.of(context).colorScheme;
final pickupLoc = LatLng(widget.pickup.lat, widget.pickup.lng);
final destLoc = LatLng(widget.destination.lat, widget.destination.lng);
return BlocListener<TripBloc, TripState>(
listenWhen: (prev, cur) =>
prev.requestStatus != cur.requestStatus &&
cur.requestStatus == TripRequestStatus.searching,
listener: (context, state) {
context.pushReplacement('/trip-tracking');
},
child: Scaffold(
body: Stack(
children: [
// الخريطة بكامل الشاشة
if (_routeLoading)
const Center(child: CircularProgressIndicator())
else if (_routeError != null)
Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(l10n.errorGeneric),
const SizedBox(height: T.s12),
TripzButton(
label: l10n.retry,
onPressed: _fetchRoute,
),
],
),
)
else
IntaleqMap(
apiKey: '',
initialCameraPosition: CameraPosition(
target: LatLng(
(pickupLoc.latitude + destLoc.latitude) / 2,
(pickupLoc.longitude + destLoc.longitude) / 2,
),
zoom: 14,
),
mapType: Theme.of(context).brightness == Brightness.dark
? IntaleqMapType.normal
: IntaleqMapType.light,
myLocationEnabled: false,
zoomControlsEnabled: false,
compassEnabled: false,
onMapCreated: (c) {
_mapController = c;
_fitCamera();
},
markers: {
Marker(
markerId: const MarkerId('pickup'),
position: pickupLoc,
icon: InlqBitmap.defaultMarkerWithHue(210),
anchor: const Offset(0.5, 1.0),
),
Marker(
markerId: const MarkerId('destination'),
position: destLoc,
icon: InlqBitmap.defaultMarkerWithHue(0),
anchor: const Offset(0.5, 1.0),
),
},
polylines: {
// حماية محرك C++ من الانهيار إذا كانت النقاط أقل من 2
if (_polylinePoints.length >= 2)
Polyline(
polylineId: const PolylineId('route'),
points: _polylinePoints,
color: cs.primary,
width: T.polylineWidth,
),
},
),
// زر الرجوع العائم (Top Left)
Positioned(
top: MediaQuery.of(context).padding.top + T.s8,
left: T.s12,
child: FloatingActionButton.small(
heroTag: 'back',
backgroundColor: cs.surface.withValues(alpha: 0.9),
elevation: 4,
onPressed: () => context.pop(),
child: Icon(Icons.arrow_back_rounded, color: cs.onSurface),
),
),
// ملخص المسار العائم (Top Right)
Positioned(
top: MediaQuery.of(context).padding.top + T.s12,
right: T.s12,
child: BlocBuilder<QuoteCubit, QuoteState>(
builder: (context, state) {
if (state.quote == null) return const SizedBox.shrink();
return Container(
padding: const EdgeInsets.symmetric(
horizontal: T.s16, vertical: T.s12),
decoration: BoxDecoration(
color: cs.surface.withValues(alpha: 0.95),
borderRadius: BorderRadius.circular(T.r24),
boxShadow: const [T.shadowSm],
),
child: Text(
l10n.routeSummary(
state.quote!.distanceText ?? '',
state.quote!.durationText ?? '',
),
style: Theme.of(context).textTheme.labelLarge?.copyWith(
fontWeight: FontWeight.w700,
color: cs.onSurface,
),
),
);
},
),
),
// Bottom Sheet: فئات الرحلات
Align(
alignment: Alignment.bottomCenter,
child: Container(
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context).size.height * 0.55,
),
decoration: BoxDecoration(
color: cs.surface,
borderRadius: const BorderRadius.vertical(
top: Radius.circular(24),
),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.1),
blurRadius: 20,
offset: const Offset(0, -5),
)
],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// شريط السحب (Grab handle)
const SizedBox(height: T.s12),
Container(
width: 40,
height: 5,
decoration: BoxDecoration(
color: cs.outlineVariant.withValues(alpha: 0.5),
borderRadius: BorderRadius.circular(10),
),
),
const SizedBox(height: T.s12),
Expanded(
child: BlocBuilder<QuoteCubit, QuoteState>(
builder: (context, state) {
if (state.loading) {
return const Center(
child: CircularProgressIndicator());
}
if (state.error != null) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(l10n.errorGeneric,
style: Theme.of(context)
.textTheme
.bodyLarge
?.copyWith(color: cs.error)),
const SizedBox(height: T.s12),
TripzButton(
label: l10n.retry,
onPressed: () => context
.read<QuoteCubit>()
.fetchQuote(
pickupLat: widget.pickup.lat,
pickupLng: widget.pickup.lng,
pickupAddress: widget.pickup.name,
dropoffLat: widget.destination.lat,
dropoffLng: widget.destination.lng,
dropoffAddress:
widget.destination.name,
),
),
],
),
);
}
final classes = state.quote?.classes ?? [];
if (classes.isEmpty) {
return Center(child: Text(l10n.noResults));
}
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.symmetric(
horizontal: T.pagePadding),
child: Text(
l10n.rideClasses,
style: Theme.of(context)
.textTheme
.titleLarge
?.copyWith(
fontWeight: FontWeight.w800,
letterSpacing: -0.5,
),
),
),
const SizedBox(height: T.s12),
Expanded(
child: ListView.separated(
padding: const EdgeInsets.symmetric(
horizontal: T.pagePadding),
itemCount: classes.length,
separatorBuilder: (_, __) =>
const SizedBox(height: T.s12),
itemBuilder: (context, index) {
final cls = classes[index];
return RideClassCard(
quoteClass: cls,
selected: state.selectedClass ==
cls.vehicleClass,
onTap: () => context
.read<QuoteCubit>()
.selectClass(cls.vehicleClass),
);
},
),
),
// شريط الدفع وكود الخصم
Container(
padding: const EdgeInsets.fromLTRB(
T.pagePadding, T.s12, T.pagePadding, T.s8),
decoration: BoxDecoration(
color: cs.surface,
border: Border(
top: BorderSide(
color: cs.outlineVariant
.withValues(alpha: 0.3),
),
),
),
child: Column(
children: [
_PaymentRow(
method: state.paymentMethod,
onChanged: (m) => context
.read<QuoteCubit>()
.setPaymentMethod(m),
),
const SizedBox(height: T.s12),
_PromoRow(
controller: _promoController,
onApply: (code) => context
.read<QuoteCubit>()
.setCouponCode(code),
),
],
),
),
// زر طلب الرحلة
SafeArea(
top: false,
child: Padding(
padding: const EdgeInsets.fromLTRB(
T.pagePadding, 0, T.pagePadding, T.s12),
child: BlocBuilder<TripBloc, TripState>(
builder: (context, tripState) {
final isLoading =
tripState.requestStatus ==
TripRequestStatus.loading;
return TripzButton(
label: isLoading
? l10n.loading
: l10n.requestRide,
onPressed:
(state.selectedClass != null &&
!isLoading)
? () =>
_requestTrip(context, state)
: null,
);
},
),
),
),
],
);
},
),
),
],
),
),
),
],
),
),
);
}
void _requestTrip(BuildContext context, QuoteState state) {
if (state.selectedClass == null) return;
context.read<TripBloc>().add(TripRequested(
pickupLat: widget.pickup.lat,
pickupLng: widget.pickup.lng,
pickupAddress: widget.pickup.name,
dropoffLat: widget.destination.lat,
dropoffLng: widget.destination.lng,
dropoffAddress: widget.destination.name,
vehicleClass: state.selectedClass!,
paymentMethod: state.paymentMethod,
couponCode: state.couponCode,
));
}
}
class _PaymentRow extends StatelessWidget {
final String method;
final ValueChanged<String> onChanged;
const _PaymentRow({required this.method, required this.onChanged});
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final cs = Theme.of(context).colorScheme;
return Container(
padding: const EdgeInsets.symmetric(
horizontal: T.pagePadding, vertical: T.s12),
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(T.r12),
),
child: Row(
children: [
Icon(
method == 'wallet'
? Icons.account_balance_wallet_outlined
: Icons.money_rounded,
color: cs.onSurfaceVariant,
),
const SizedBox(width: T.s12),
Text(l10n.paymentMethod,
style: Theme.of(context).textTheme.bodyMedium),
const Spacer(),
DropdownButton<String>(
value: method,
underline: const SizedBox.shrink(),
isDense: true,
items: [
DropdownMenuItem(value: 'cash', child: Text(l10n.cash)),
DropdownMenuItem(
value: 'wallet', child: Text(l10n.walletPayment)),
],
onChanged: (v) {
if (v != null) onChanged(v);
},
),
],
),
);
}
}
class _PromoRow extends StatefulWidget {
final TextEditingController controller;
final ValueChanged<String?> onApply;
const _PromoRow({required this.controller, required this.onApply});
@override
State<_PromoRow> createState() => _PromoRowState();
}
class _PromoRowState extends State<_PromoRow> {
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final cs = Theme.of(context).colorScheme;
return Container(
padding:
const EdgeInsets.symmetric(horizontal: T.pagePadding, vertical: T.s8),
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(T.r12),
),
child: Row(
children: [
Icon(
Icons.local_offer_outlined,
color: cs.onSurfaceVariant,
),
const SizedBox(width: T.s12),
Expanded(
child: TextField(
controller: widget.controller,
decoration: InputDecoration(
hintText: l10n.couponCode,
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
),
style: Theme.of(context).textTheme.bodyMedium,
),
),
TripzButton(
label: l10n.confirm,
style: TripzButtonStyle.text,
fullWidth: false,
onPressed: () {
final code = widget.controller.text.trim();
widget.onApply(code.isEmpty ? null : code);
},
),
],
),
);
}
}
@@ -0,0 +1,74 @@
import 'package:flutter/material.dart';
import '../../../../core/design/tokens.dart';
import '../../data/models/place_model.dart';
/// عنصر نتائج البحث عن مكان.
class PlaceTile extends StatelessWidget {
final PlaceModel place;
final VoidCallback? onTap;
final IconData? icon;
const PlaceTile({
super.key,
required this.place,
this.onTap,
this.icon,
});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
final displayIcon = icon ?? Icons.location_on_outlined;
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: T.pagePadding,
vertical: T.s12,
),
child: Row(
children: [
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
shape: BoxShape.circle,
),
child: Icon(displayIcon, size: 20, color: cs.onSurfaceVariant),
),
const SizedBox(width: T.s12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
place.name,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
fontWeight: FontWeight.w500,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
if (place.address != null && place.address!.isNotEmpty) ...[
const SizedBox(height: 2),
Text(
place.address!,
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: cs.onSurfaceVariant,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
],
),
),
Icon(Icons.chevron_right_rounded, color: cs.onSurfaceVariant),
],
),
),
);
}
}
@@ -0,0 +1,116 @@
import 'package:flutter/material.dart';
import '../../../../core/l10n/app_localizations.dart';
import '../../../../core/design/tokens.dart';
import '../../data/models/quote_model.dart';
/// بطاقة فئة رحلة واحدة في قائمة الاختيار.
class RideClassCard extends StatelessWidget {
final QuoteClassModel quoteClass;
final bool selected;
final VoidCallback? onTap;
const RideClassCard({
super.key,
required this.quoteClass,
this.selected = false,
this.onTap,
});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
final l10n = AppLocalizations.of(context)!;
return InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(T.r16),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: T.s16, vertical: T.s12),
decoration: BoxDecoration(
color: selected ? cs.primaryContainer.withValues(alpha: 0.2) : Colors.transparent,
borderRadius: BorderRadius.circular(T.r16),
border: Border.all(
color: selected ? cs.primary : cs.outlineVariant.withValues(alpha: 0.3),
width: selected ? 2 : 1,
),
),
child: Row(
children: [
// أيقونة المركبة
Container(
width: 56,
height: 56,
decoration: BoxDecoration(
color: selected ? cs.primary.withValues(alpha: 0.1) : cs.surfaceContainerHighest,
shape: BoxShape.circle,
),
child: Center(
child: Icon(
Icons.directions_car_filled_rounded,
color: selected ? cs.primary : cs.onSurfaceVariant,
size: 32,
),
),
),
const SizedBox(width: T.s16),
// اسم الفئة + السعة
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
quoteClass.name,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w700,
color: cs.onSurface,
),
),
const SizedBox(height: 2),
Row(
children: [
Icon(Icons.person_outline_rounded,
size: 14, color: cs.onSurfaceVariant),
const SizedBox(width: 4),
Text(
l10n.capacity(quoteClass.capacity),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: cs.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
),
],
),
],
),
),
// الوقت التقديري + السعر
Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${quoteClass.price} ${quoteClass.currency}',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w800,
color: selected ? cs.primary : cs.onSurface,
),
),
const SizedBox(height: 2),
Text(
quoteClass.estimatedTimeText,
style: Theme.of(context).textTheme.labelSmall?.copyWith(
color: cs.onSurfaceVariant,
fontWeight: FontWeight.w600,
),
),
],
),
],
),
),
);
}
}
@@ -0,0 +1,126 @@
import 'package:flutter/material.dart';
import '../../../../core/l10n/app_localizations.dart';
import '../../../../core/design/tokens.dart';
/// طبقة البحث عن سائق — نبض + مؤقت + زر إلغاء.
class SearchingOverlay extends StatefulWidget {
final int elapsed;
final VoidCallback? onCancel;
const SearchingOverlay({
super.key,
required this.elapsed,
this.onCancel,
});
@override
State<SearchingOverlay> createState() => _SearchingOverlayState();
}
class _SearchingOverlayState extends State<SearchingOverlay>
with SingleTickerProviderStateMixin {
late AnimationController _pulseController;
late Animation<double> _pulseAnimation;
@override
void initState() {
super.initState();
_pulseController = AnimationController(
vsync: this,
duration: const Duration(seconds: 2),
)..repeat(reverse: true);
_pulseAnimation = Tween<double>(begin: 0.8, end: 1.2).animate(
CurvedAnimation(parent: _pulseController, curve: Curves.easeInOut),
);
}
@override
void dispose() {
_pulseController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
final cs = Theme.of(context).colorScheme;
final minutes = widget.elapsed ~/ 60;
final seconds = widget.elapsed % 60;
final timeStr = '${minutes.toString().padLeft(2, '0')}:${seconds.toString().padLeft(2, '0')}';
return Material(
color: Colors.black54,
child: Center(
child: Container(
margin: const EdgeInsets.all(T.pagePadding * 2),
padding: const EdgeInsets.all(T.pagePadding * 1.5),
decoration: BoxDecoration(
color: cs.surface,
borderRadius: BorderRadius.circular(T.r16),
boxShadow: [T.shadowLg],
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// نبض البحث
ScaleTransition(
scale: _pulseAnimation,
child: Container(
width: 80,
height: 80,
decoration: BoxDecoration(
color: cs.primaryContainer,
shape: BoxShape.circle,
),
child: Icon(
Icons.directions_car_filled_rounded,
size: 40,
color: cs.onPrimaryContainer,
),
),
),
const SizedBox(height: T.s16),
// نص البحث
Text(
l10n.searchingDriver,
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w600,
),
textAlign: TextAlign.center,
),
const SizedBox(height: T.s8),
// المؤقت
Text(
timeStr,
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
color: cs.primary,
fontWeight: FontWeight.w700,
fontFeatures: const [FontFeature.tabularFigures()],
),
),
const SizedBox(height: T.s20),
// زر الإلغاء
SizedBox(
width: double.infinity,
child: OutlinedButton(
onPressed: widget.onCancel,
style: OutlinedButton.styleFrom(
foregroundColor: cs.error,
side: BorderSide(color: cs.error),
),
child: Text(l10n.cancelSearch),
),
),
],
),
),
),
);
}
}