Author SHA1 Message Date
fbachus 6c19d981ad Revert "build(mobile): deactivate sqlite debugging lib used for desktop"
keep development branch in a state to run on desktop

This reverts commit 5ead82b9c6.
2026-08-01 00:07:46 +02:00
5 changed files with 27 additions and 96 deletions
+10 -4
View File
@@ -5,7 +5,14 @@ import 'dart:core';
import 'dart:convert';
import 'transport_helper.dart';
import 'utilities.dart';
String timeOf(DateTime fullDT) {
// doing it this way so we always get two digits on the hour
String full = fullDT.toString();
List<String> splits = full.split(" ")[1].split(":");
String time = '${splits[0]}:${splits[1]}';
return time;
}
class ApiHandler {
// TODO: Split next line for better Error Handling
@@ -72,7 +79,7 @@ class ApiHandler {
static Future<List<Departure>> departures(
String stationId, {
int? maxDepartures = -1,
DateTime? datetime,
DateTime? time,
int? duration = 0,
}) async {
String urlPath = '/api/fahrinfo/latest/departureBoard';
@@ -81,9 +88,8 @@ class ApiHandler {
Uri url = Uri.https(baseUrl, urlPath, {
'accessId': accessID,
'id': stationString,
'date': dateOf(datetime ?? DateTime.now()),
'time': timeOf(
datetime ?? DateTime.now(),
time ?? DateTime.now(),
), //time from which departures will be shown
'duration': duration.toString(), //interval time in minutes
'maxJourneys': maxDepartures.toString(),
+11 -69
View File
@@ -3,17 +3,13 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'api_handler.dart';
import 'transport_helper.dart';
import 'dart:async';
import 'dart:io';
import 'package:sqflite_common_ffi/sqflite_ffi.dart'; //for testing on desktop
import 'utilities.dart';
void main() async {
await dotenv.load();
const String dbName = "oeffimasterTransportDb";
if (Platform.isLinux) {
databaseFactory = databaseFactoryFfi; // for debugging and desktop test
}
DbHelper.initDb(dbName);
runApp(const MyApp());
}
@@ -181,7 +177,7 @@ class _ChooseStationPageState extends State<ChooseStationPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Start a Journey')),
appBar: AppBar(title: const Text('RoutePicker')),
body: Center(
child: Column(
children: [
@@ -195,7 +191,7 @@ class _ChooseStationPageState extends State<ChooseStationPage> {
builder: (BuildContext context, SearchController controller) {
return SearchBar(
controller: controller,
hintText: 'Search your start Station',
hintText: 'Search for a Station',
padding: const WidgetStatePropertyAll<EdgeInsets>(
EdgeInsets.symmetric(horizontal: 16.0),
),
@@ -296,7 +292,7 @@ class _ChooseDeparturePageState extends State<ChooseDeparturePage> {
void loadDepartures(Station startStation) async {
departureList = await ApiHandler.departures(
startStation.id,
datetime: widget.arrival?.arrivalTime ?? DateTime.now(),
time: widget.arrival?.arrivalTime ?? DateTime.now(),
);
setState(() {});
}
@@ -324,27 +320,12 @@ class _ChooseDeparturePageState extends State<ChooseDeparturePage> {
return Scaffold(
appBar: AppBar(
title: Text(
'Departures for ${widget.startStation.name}',
'RoutePicker for ${widget.startStation.name} // ${widget.journeyId}',
),
),
body: Center(
child: Column(
children: [
Builder(
builder: (context) {
if (widget.arrival != null) {
return ListTile(
title: Text(
'arrive at ${widget.arrival?.arrivalTime}',
),
);
} else {
return ListTile(
title: Text(''),
);
}
},
),
Expanded(
child: SizedBox(
height: 400,
@@ -455,7 +436,7 @@ class _ChooseArrivalPageState extends State<ChooseArrivalPage> {
return Scaffold(
appBar: AppBar(
title: Text(
'Arrivals for ${widget.departure.vehicleName}',
'Arrivals for ${widget.departure.vehicleName}// ${widget.journeyId}',
),
),
body: Center(
@@ -560,16 +541,7 @@ class _JourneyDetailPageState extends State<JourneyDetailPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: ListTile(
title: Text(
'${widget.singleJourney.startStation}${widget.singleJourney.endStation}',
),
subtitle: Text(
'${widget.singleJourney.duration.toString().split(".")[0]}h',
),
),
),
appBar: AppBar(title: Text('Connection Details \n$duration')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -584,7 +556,7 @@ class _JourneyDetailPageState extends State<JourneyDetailPage> {
margin: const EdgeInsets.only(bottom: 60.0),
child: ElevatedButton(
onPressed: () {
Navigator.push(
Navigator.pop(
context,
MaterialPageRoute(
builder: (context) => JourneyOverviewPage(),
@@ -614,39 +586,9 @@ class SegmentList extends StatelessWidget {
return ListView(
children: [
for (Segment seg in journey.segments)
Card(
child: Column(
mainAxisSize: .min,
children: [
Container(
padding: EdgeInsets.only(left: 10, top: 10),
child: Row(
children: [
Text(
seg.vehicle.name,
textScaler: TextScaler.linear(1.1),
),
Icon(Icons.arrow_right_alt),
Text('${seg.start.direction}'),
],
),
),
ListTile(
leading: Text(
timeOf(seg.start.departureTime),
textScaler: TextScaler.linear(1.4),
),
title: Text(seg.start.stationName),
),
ListTile(
leading: Text(
timeOf(seg.end.arrivalTime),
textScaler: TextScaler.linear(1.4),
),
title: Text(seg.end.stationName),
),
],
),
title: Text(seg.start.direction),
subtitle: Text(seg.start.departureTime.toString()),
),
],
);
@@ -699,7 +641,7 @@ class _JourneyOverviewPageState extends State<JourneyOverviewPage> {
height: 100.0,
child: FittedBox(
fit: BoxFit.contain,
alignment: Alignment.center,
alignment: Alignment.centerLeft,
child: Text("Your Journeys"),
),
),
+4 -6
View File
@@ -1,5 +1,4 @@
import 'package:sqflite/sqflite.dart';
import 'utilities.dart';
// import './state_helper.dart';
// import './db_helper.dart';
@@ -95,15 +94,13 @@ class Journey {
Map<String, Object?> journeyMaps,
List<Segment> segmentMaps,
) {
Journey journey = Journey(
return Journey(
id: journeyMaps["id"] as int,
startStation: journeyMaps["startstation"] as String?,
endStation: journeyMaps["endstation"] as String?,
segments: segmentMaps,
duration: Duration(minutes: 0),
);
journey.sync();
return journey;
}
// from trip API request
@@ -137,8 +134,8 @@ class Journey {
if (segments.isNotEmpty) {
startStation = segments.first.start.stationName;
endStation = segments.last.end.stationName;
duration = segments.last.end.arrivalTime.difference(
segments.first.start.departureTime,
duration = segments.first.start.departureTime.difference(
segments.last.end.arrivalTime,
);
} else {
// if the journey has no segments yet, at least the startStation should remain,
@@ -226,6 +223,7 @@ class Journey {
static Future<Journey> fromMapWrapper(Map<String, Object?> journeyMap) async {
Future<List<Segment>> segs = _dbGetJourneySegments(journeyMap["id"] as int);
Journey res = Journey.fromMap(journeyMap, await segs);
res.sync();
return res;
}
-13
View File
@@ -1,13 +0,0 @@
String timeOf(DateTime fullDT) {
// doing it this way so we always get two digits on the hour
String full = fullDT.toString();
List<String> splits = full.split(" ")[1].split(":");
String time = '${splits[0]}:${splits[1]}';
return time;
}
String dateOf(DateTime fullDT) {
String full = fullDT.toString();
String date = full.split(" ")[0];
return date;
}
-2
View File
@@ -37,8 +37,6 @@ dependencies:
flutter_dotenv: ^6.0.1
http: ^1.6.0
sqflite: ^2.4.2+1
sqlite3: ^3.3.0
sqflite_common_ffi: ^2.4.0+3
dev_dependencies:
flutter_test:
sdk: flutter