feat: implement core architecture, design system, localization, and trip features for both driver and rider apps.

This commit is contained in:
Hamza-Ayed
2026-07-19 16:21:58 +03:00
parent 959e2fa758
commit c4dfeb4c6f
207 changed files with 14017 additions and 5567 deletions
@@ -0,0 +1,194 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../core/l10n/app_localizations.dart';
import 'package:go_router/go_router.dart';
import '../../../core/design/tokens.dart';
import '../../../core/ui/tripz_scaffold.dart';
import '../../../core/ui/tripz_text_field.dart';
import '../cubit/destination_cubit.dart';
import '../data/models/place_model.dart';
import 'widgets/place_tile.dart';
/// شاشة البحث عن وجهة — full-screen مع autocomplete.
class DestinationScreen extends StatefulWidget {
const DestinationScreen({super.key});
@override
State<DestinationScreen> createState() => _DestinationScreenState();
}
class _DestinationScreenState extends State<DestinationScreen> {
final _controller = TextEditingController();
final _focusNode = FocusNode();
@override
void initState() {
super.initState();
_focusNode.requestFocus();
}
@override
void dispose() {
_controller.dispose();
_focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return TripzScaffold(
padding: false,
child: Column(
children: [
_SearchHeader(
controller: _controller,
focusNode: _focusNode,
l10n: l10n,
),
Expanded(
child: BlocBuilder<DestinationCubit, DestinationState>(
builder: (context, state) {
if (state.searching) {
return const Center(child: CircularProgressIndicator());
}
if (state.results.isEmpty && state.query.length >= 2) {
return Center(
child: Text(l10n.noResults, style: Theme.of(context).textTheme.bodyLarge),
);
}
return ListView.builder(
padding: EdgeInsets.zero,
itemCount: state.results.length,
itemBuilder: (context, index) {
final place = state.results[index];
return PlaceTile(
place: place,
onTap: () => context.pop<PlaceModel>(place),
);
},
);
},
),
),
SafeArea(
child: Padding(
padding: const EdgeInsets.all(T.pagePadding),
child: SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
onPressed: () => context.pop<PlaceModel>(null),
icon: const Icon(Icons.map_outlined),
label: Text(l10n.chooseOnMap),
),
),
),
),
],
),
);
}
}
class _SearchHeader extends StatelessWidget {
final TextEditingController controller;
final FocusNode focusNode;
final AppLocalizations l10n;
const _SearchHeader({
required this.controller,
required this.focusNode,
required this.l10n,
});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return Container(
color: cs.surface,
padding: const EdgeInsets.only(
left: T.pagePadding,
right: T.pagePadding,
top: T.s8,
bottom: T.s12,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
IconButton(
onPressed: () => Navigator.of(context).pop(),
icon: const Icon(Icons.arrow_back_rounded),
),
Expanded(
child: TripzTextField(
controller: controller,
focusNode: focusNode,
hint: l10n.searchPlaces,
prefix: const Icon(Icons.search_rounded),
onChanged: (v) => context.read<DestinationCubit>().onQueryChanged(v),
),
),
],
),
const SizedBox(height: T.s8),
Row(
children: [
Column(
children: [
Container(
width: 10,
height: 10,
decoration: BoxDecoration(
color: cs.primary,
shape: BoxShape.circle,
),
),
Container(width: 1.5, height: 24, color: cs.outlineVariant),
Container(
width: 10,
height: 10,
decoration: BoxDecoration(
color: cs.error,
shape: BoxShape.circle,
),
),
],
),
const SizedBox(width: T.s12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
l10n.pickupLocation,
style: Theme.of(context).textTheme.labelSmall?.copyWith(
color: cs.onSurfaceVariant,
),
),
const SizedBox(height: T.s4),
Text(
l10n.pickupSet,
style: Theme.of(context).textTheme.bodyMedium,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: T.s16),
Text(
l10n.dropoffLocation,
style: Theme.of(context).textTheme.labelSmall?.copyWith(
color: cs.onSurfaceVariant,
),
),
],
),
),
],
),
],
),
);
}
}
@@ -1,76 +1,260 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import '../../../core/l10n/app_localizations.dart';
import 'package:go_router/go_router.dart';
import 'package:intaleq_maps/intaleq_maps.dart';
import '../../auth/cubit/auth_cubit.dart';
import '../../auth/cubit/auth_state.dart';
import '../../../core/ui/tripz_button.dart';
import '../../../core/design/tokens.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 '../data/models/place_model.dart';
class HomeScreen extends StatelessWidget {
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
IntaleqMapController? _mapController;
@override
void initState() {
super.initState();
// فحص رحلة نشطة عند فتح الشاشة.
WidgetsBinding.instance.addPostFrameCallback((_) {
context.read<TripBloc>().add(const TripCheckActive());
});
}
@override
Widget build(BuildContext context) {
final center = const LatLng(31.9539, 35.9106); // عمّان
return Scaffold(
appBar: AppBar(
title: const Text('Tripz'),
actions: [
IconButton(
icon: const Icon(Icons.logout),
onPressed: () => context.read<AuthCubit>().logout(),
),
],
),
body: Stack(
children: [
FlutterMap(
options: MapOptions(initialCenter: center, initialZoom: 13),
children: [
// TODO: استبدال بلاطات انطلق (Martin) بدل OSM
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.mobileapp.store.ride',
),
MarkerLayer(markers: [
Marker(
point: center,
width: 40,
height: 40,
child: const Icon(Icons.location_pin, color: Colors.red, size: 40),
),
]),
],
),
Positioned(
left: 16,
right: 16,
bottom: 24,
child: Card(
child: Padding(
padding: const EdgeInsets.all(16),
child: BlocBuilder<AuthCubit, AuthState>(
builder: (context, state) {
final name = state.user?.name ?? state.user?.phone ?? '';
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('مرحباً $name',
style: Theme.of(context).textTheme.titleMedium),
const SizedBox(height: 12),
FilledButton.icon(
onPressed: () {},
icon: const Icon(Icons.local_taxi),
label: const Text('اطلب رحلة (قريباً)'),
),
],
);
final l10n = AppLocalizations.of(context)!;
final cs = Theme.of(context).colorScheme;
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(
body: Stack(
children: [
// الخريطة
BlocBuilder<HomeCubit, HomeState>(
builder: (context, state) {
final center = state.currentLocation ?? const LatLng(31.9539, 35.9106);
return IntaleqMap(
apiKey: '',
initialCameraPosition: CameraPosition(target: center, zoom: 15),
myLocationEnabled: true,
zoomControlsEnabled: false,
compassEnabled: false,
onMapCreated: (controller) => _mapController = controller,
markers: _buildMarkers(state),
onCameraMove: (position) {
context.read<HomeCubit>().updateCameraTarget(position.target);
},
);
},
),
// زر إعادة التوسيط
Positioned(
right: T.pagePadding,
bottom: 180,
child: FloatingActionButton.small(
heroTag: 'recenter',
backgroundColor: cs.surface,
onPressed: () {
final loc = context.read<HomeCubit>().state.currentLocation;
if (loc != null) {
_mapController?.animateCamera(CameraUpdate.newLatLngZoom(loc, 15));
}
},
child: Icon(Icons.my_location_rounded, color: cs.onSurface),
),
),
// الشريط السفلي
Positioned(
left: T.pagePadding,
right: T.pagePadding,
bottom: T.pagePadding,
child: Card(
elevation: 2,
child: Padding(
padding: const EdgeInsets.all(T.pagePadding),
child: BlocBuilder<HomeCubit, HomeState>(
builder: (context, state) {
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
BlocBuilder<AuthCubit, AuthState>(
builder: (context, authState) {
final name = authState.user?.name ?? '';
if (name.isNotEmpty) {
return Padding(
padding: const EdgeInsets.only(bottom: T.s12),
child: Text(
l10n.welcome(name),
style: Theme.of(context).textTheme.titleMedium,
),
);
}
return const SizedBox.shrink();
},
),
if (state.destination != null)
_DestinationPreview(
destination: state.destination!,
onTap: () => _openDestinationSearch(context),
onClear: () => context.read<HomeCubit>().clearTripData(),
)
else
TripzButton(
label: l10n.whereTo,
style: TripzButtonStyle.secondary,
icon: Icons.search_rounded,
onPressed: () => _openDestinationSearch(context),
),
if (state.destination != null) ...[
const SizedBox(height: T.s12),
TripzButton(
label: l10n.requestRide,
onPressed: () => _openRoutePreview(context, state),
),
],
],
);
},
),
),
),
),
),
],
// حالة التحميل
BlocBuilder<HomeCubit, HomeState>(
builder: (context, state) {
if (state.loading) {
return Container(
color: Colors.black26,
child: const Center(child: CircularProgressIndicator()),
);
}
return const SizedBox.shrink();
},
),
],
),
),
);
}
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) {
context.push<PlaceModel>('/destination').then((place) {
if (place != null && mounted) {
context.read<HomeCubit>().setDestination(place);
_openRoutePreview(context, context.read<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,
});
}
}
class _DestinationPreview extends StatelessWidget {
final PlaceModel destination;
final VoidCallback onTap;
final VoidCallback onClear;
const _DestinationPreview({
required this.destination,
required this.onTap,
required this.onClear,
});
@override
Widget build(BuildContext context) {
final cs = Theme.of(context).colorScheme;
return InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(T.r12),
child: Container(
padding: const EdgeInsets.all(T.s12),
decoration: BoxDecoration(
color: cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(T.r12),
),
child: Row(
children: [
Icon(Icons.location_on_outlined, color: cs.error, size: 20),
const SizedBox(width: T.s8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
destination.name,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(fontWeight: FontWeight.w500),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
if (destination.address != null)
Text(
destination.address!,
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: cs.onSurfaceVariant),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
IconButton(
onPressed: onClear,
icon: Icon(Icons.close_rounded, color: cs.onSurfaceVariant, size: 20),
visualDensity: VisualDensity.compact,
),
],
),
),
);
}
@@ -0,0 +1,307 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../core/l10n/app_localizations.dart';
import 'package:go_router/go_router.dart';
import 'package:intaleq_maps/intaleq_maps.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 'widgets/ride_class_card.dart';
/// شاشة معاينة المسار + اختيار فئة الرحلة + تأكيد الطلب.
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;
@override
void initState() {
super.initState();
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
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: Column(
children: [
// الخريطة مع المسار
Expanded(
flex: 2,
child: Stack(
children: [
IntaleqMap(
apiKey: '',
initialCameraPosition: CameraPosition(
target: LatLng(
(pickupLoc.latitude + destLoc.latitude) / 2,
(pickupLoc.longitude + destLoc.longitude) / 2,
),
zoom: 14,
),
myLocationEnabled: false,
zoomControlsEnabled: false,
compassEnabled: false,
onMapCreated: (c) => _mapController = c,
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: {
Polyline(
polylineId: const PolylineId('route'),
points: [pickupLoc, destLoc],
color: cs.primary,
width: 4,
),
},
),
Positioned(
top: MediaQuery.of(context).padding.top + T.s8,
left: T.s12,
child: FloatingActionButton.small(
heroTag: 'back',
backgroundColor: cs.surface,
onPressed: () => context.pop(),
child: const Icon(Icons.arrow_back_rounded),
),
),
Positioned(
top: MediaQuery.of(context).padding.top + T.s8,
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.s12, vertical: T.s8),
decoration: BoxDecoration(
color: cs.surface,
borderRadius: BorderRadius.circular(T.r12),
boxShadow: [T.shadowSm],
),
child: Text(
l10n.routeSummary(
state.quote!.distanceText ?? '',
state.quote!.durationText ?? '',
),
style: Theme.of(context).textTheme.labelLarge,
),
);
},
),
),
],
),
),
// قائمة فئات الرحلة
Expanded(
flex: 3,
child: Container(
color: cs.surface,
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),
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(
children: [
Padding(
padding: const EdgeInsets.fromLTRB(T.pagePadding, T.s16, T.pagePadding, T.s8),
child: Align(
alignment: AlignmentDirectional.centerStart,
child: Text(l10n.rideClasses, style: Theme.of(context).textTheme.titleMedium),
),
),
Expanded(
child: ListView.separated(
padding: const EdgeInsets.symmetric(horizontal: T.pagePadding),
itemCount: classes.length,
separatorBuilder: (_, __) => const SizedBox(height: T.s8),
itemBuilder: (context, index) {
final cls = classes[index];
return RideClassCard(
quoteClass: cls,
selected: state.selectedClass == cls.vehicleClass,
onTap: () => context.read<QuoteCubit>().selectClass(cls.vehicleClass),
);
},
),
),
SafeArea(
child: Padding(
padding: const EdgeInsets.all(T.pagePadding),
child: Column(
children: [
_PaymentRow(
method: state.paymentMethod,
onChanged: (m) => context.read<QuoteCubit>().setPaymentMethod(m),
),
const SizedBox(height: T.s12),
// زر طلب الرحلة — يستخدم TripBloc
BlocBuilder<TripBloc, TripState>(
builder: (context, tripState) {
final isLoading = tripState.requestStatus == TripRequestStatus.loading;
return SizedBox(
width: double.infinity,
child: 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);
},
),
],
),
);
}
}
@@ -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,102 @@
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.r12),
child: Container(
padding: const EdgeInsets.all(T.pagePadding),
decoration: BoxDecoration(
color: selected ? cs.primaryContainer : cs.surfaceContainerHighest,
borderRadius: BorderRadius.circular(T.r12),
border: Border.all(
color: selected ? cs.primary : Colors.transparent,
width: 2,
),
),
child: Row(
children: [
// أيقونة المركبة
Container(
width: 48,
height: 48,
decoration: BoxDecoration(
color: selected ? cs.primary : cs.surface,
shape: BoxShape.circle,
),
child: Icon(
Icons.directions_car_filled_rounded,
color: selected ? cs.onPrimary : cs.onSurfaceVariant,
size: 24,
),
),
const SizedBox(width: T.s12),
// اسم الفئة + السعة
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
quoteClass.name,
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 2),
Text(
l10n.capacity(quoteClass.capacity),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: cs.onSurfaceVariant,
),
),
],
),
),
// الوقت التقديري + السعر
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
quoteClass.estimatedTimeText,
style: Theme.of(context).textTheme.labelMedium?.copyWith(
color: cs.onSurfaceVariant,
),
),
const SizedBox(height: 2),
Text(
'${quoteClass.price} ${quoteClass.currency}',
style: Theme.of(context).textTheme.titleMedium?.copyWith(
fontWeight: FontWeight.w700,
color: selected ? cs.primary : cs.onSurface,
),
),
],
),
],
),
),
);
}
}
@@ -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),
),
),
],
),
),
),
);
}
}