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
@@ -1,10 +1,9 @@
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:trip_overlay_plugin/trip_overlay_plugin.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
TripOverlayPlugin.initialize();
runApp(const MyApp());
}
@@ -16,34 +15,55 @@ class MyApp extends StatefulWidget {
}
class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown';
final _tripOverlayPlugin = TripOverlayPlugin();
bool _isOverlayActive = false;
@override
void initState() {
super.initState();
initPlatformState();
// Listen to overlay events
TripOverlayPlugin.onTripAccepted.listen((result) {
debugPrint('Trip accepted: ${result.tripId}');
});
TripOverlayPlugin.onTripRejected.listen((tripId) {
debugPrint('Trip rejected/expired: $tripId');
});
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
// We also handle the message potentially returning null.
try {
platformVersion =
await _tripOverlayPlugin.getPlatformVersion() ?? 'Unknown platform version';
} on PlatformException {
platformVersion = 'Failed to get platform version.';
@override
void dispose() {
TripOverlayPlugin.dispose();
super.dispose();
}
Future<void> _showOverlay() async {
final granted = await TripOverlayPlugin.isPermissionGranted();
if (!granted) {
await TripOverlayPlugin.requestPermission();
return;
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
final tripData = TripData(
tripId: 'TRIP_12345',
passengerName: 'Hamza A.',
pickupAddress: 'Amman, Jordan',
dropoffAddress: 'Irbid, Jordan',
distanceKm: 85.0,
estimatedFare: 25.0,
estimatedMinutes: 90,
pickupLat: 31.9539,
pickupLng: 35.9106,
);
final result = await TripOverlayPlugin.showOverlay(tripData);
setState(() {
_platformVersion = platformVersion;
_isOverlayActive = result;
});
}
Future<void> _hideOverlay() async {
await TripOverlayPlugin.hideOverlay();
setState(() {
_isOverlayActive = false;
});
}
@@ -52,10 +72,25 @@ class _MyAppState extends State<MyApp> {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
title: const Text('Trip Overlay Example'),
),
body: Center(
child: Text('Running on: $_platformVersion\n'),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Overlay Active: $_isOverlayActive'),
const SizedBox(height: 20),
ElevatedButton(
onPressed: _showOverlay,
child: const Text('Show Overlay'),
),
const SizedBox(height: 10),
ElevatedButton(
onPressed: _hideOverlay,
child: const Text('Hide Overlay'),
),
],
),
),
),
);