All checks were successful
Build and release APK / Build APK (pull_request) Successful in 5m25s
79 lines
2.4 KiB
Dart
79 lines
2.4 KiB
Dart
import 'package:anyway/layout.dart';
|
|
import 'package:anyway/structs/preferences.dart';
|
|
import 'package:anyway/structs/trip.dart';
|
|
import 'package:anyway/utils/fetch_trip.dart';
|
|
import 'package:auto_size_text/auto_size_text.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
class NewTripButton extends StatefulWidget {
|
|
final Trip trip;
|
|
|
|
const NewTripButton({required this.trip});
|
|
|
|
@override
|
|
State<NewTripButton> createState() => _NewTripButtonState();
|
|
}
|
|
|
|
class _NewTripButtonState extends State<NewTripButton> {
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListenableBuilder(
|
|
listenable: widget.trip,
|
|
builder: (BuildContext context, Widget? child) {
|
|
if (widget.trip.landmarks.isEmpty){
|
|
return Container();
|
|
}
|
|
return SizedBox(
|
|
width: 200,
|
|
child: ElevatedButton(
|
|
onPressed: () async {
|
|
Future<UserPreferences> preferences = loadUserPreferences();
|
|
Trip trip = widget.trip;
|
|
fetchTrip(trip, preferences);
|
|
Navigator.of(context).push(
|
|
MaterialPageRoute(
|
|
builder: (context) => BasePage(mainScreen: "map", trip: trip)
|
|
)
|
|
);
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
Icons.add,
|
|
),
|
|
Expanded(
|
|
child: Padding(
|
|
padding: EdgeInsets.only(left: 10, top: 5, bottom: 5, right: 5),
|
|
child: FutureBuilder(
|
|
future: widget.trip.cityName,
|
|
builder: (context, snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
return AutoSizeText(
|
|
'New trip to ${snapshot.data.toString()}',
|
|
style: TextStyle(fontSize: 18),
|
|
maxLines: 2,
|
|
);
|
|
} else {
|
|
return AutoSizeText(
|
|
'New trip to ...',
|
|
style: TextStyle(fontSize: 18),
|
|
maxLines: 2,
|
|
);
|
|
}
|
|
},
|
|
)
|
|
)
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
);
|
|
}
|
|
}
|
|
|