66 lines
2.3 KiB
Dart
66 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:sliding_up_panel/sliding_up_panel.dart';
|
|
|
|
import 'package:anyway/core/constants.dart';
|
|
import 'package:anyway/domain/entities/trip.dart';
|
|
import 'package:anyway/presentation/utils/trip_location_utils.dart';
|
|
import 'package:anyway/presentation/widgets/trip_details_panel.dart';
|
|
import 'package:anyway/presentation/widgets/trip_map.dart';
|
|
|
|
class TripDetailsPage extends StatefulWidget {
|
|
const TripDetailsPage({super.key, required this.trip});
|
|
|
|
final Trip trip;
|
|
|
|
@override
|
|
State<TripDetailsPage> createState() => _TripDetailsPageState();
|
|
}
|
|
|
|
class _TripDetailsPageState extends State<TripDetailsPage> {
|
|
late Future<bool> _locationPrefFuture;
|
|
late Future<TripLocaleInfo> _localeFuture;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_locationPrefFuture = _loadLocationPreference();
|
|
_localeFuture = TripLocationUtils.resolveLocaleInfo(widget.trip);
|
|
}
|
|
|
|
Future<bool> _loadLocationPreference() async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
return prefs.getBool('useLocation') ?? true;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: FutureBuilder<TripLocaleInfo>(
|
|
future: _localeFuture,
|
|
builder: (context, snapshot) {
|
|
final locale = snapshot.data;
|
|
final title = locale?.cityName ?? 'Trip overview';
|
|
return Text(title);
|
|
},
|
|
),
|
|
),
|
|
body: FutureBuilder<bool>(
|
|
future: _locationPrefFuture,
|
|
builder: (context, snapshot) {
|
|
final enableLocation = snapshot.data ?? false;
|
|
return SlidingUpPanel(
|
|
borderRadius: const BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24)),
|
|
parallaxEnabled: true,
|
|
maxHeight: MediaQuery.of(context).size.height * TRIP_PANEL_MAX_HEIGHT,
|
|
minHeight: MediaQuery.of(context).size.height * TRIP_PANEL_MIN_HEIGHT,
|
|
panelBuilder: (controller) => TripDetailsPanel(trip: widget.trip, controller: controller),
|
|
body: TripMap(trip: widget.trip, showRoute: true, interactive: true, borderRadius: 0, enableMyLocation: enableLocation),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|