location picker and ui fixes
All checks were successful
Build and release APK / Build APK (pull_request) Successful in 5m25s
All checks were successful
Build and release APK / Build APK (pull_request) Successful in 5m25s
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:anyway/modules/new_trip_button.dart';
|
||||
import 'package:anyway/structs/landmark.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geocoding/geocoding.dart';
|
||||
@@ -6,7 +7,8 @@ import 'package:anyway/layout.dart';
|
||||
import 'package:anyway/utils/fetch_trip.dart';
|
||||
import 'package:anyway/structs/preferences.dart';
|
||||
import "package:anyway/structs/trip.dart";
|
||||
|
||||
import 'package:anyway/modules/new_trip_location_search.dart';
|
||||
import 'package:anyway/modules/new_trip_map.dart';
|
||||
|
||||
|
||||
class NewTripPage extends StatefulWidget {
|
||||
@@ -20,74 +22,31 @@ class _NewTripPageState extends State<NewTripPage> {
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
final TextEditingController latController = TextEditingController();
|
||||
final TextEditingController lonController = TextEditingController();
|
||||
Trip trip = Trip();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// floating search bar and map as a background
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('New Trip'),
|
||||
),
|
||||
body: Form(
|
||||
key: _formKey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
children: <Widget>[
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(hintText: 'Lat'),
|
||||
controller: latController,
|
||||
validator: (String? value) {
|
||||
if (value == null || value.isEmpty || double.tryParse(value) == null){
|
||||
return 'Please enter a floating point number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
TextFormField(
|
||||
decoration: const InputDecoration(hintText: 'Lon'),
|
||||
controller: lonController,
|
||||
|
||||
validator: (String? value) {
|
||||
if (value == null || value.isEmpty || double.tryParse(value) == null){
|
||||
return 'Please enter a floating point number';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
),
|
||||
Divider(height: 15, color: Colors.transparent),
|
||||
ElevatedButton(
|
||||
child: const Text('Create trip'),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState!.validate()) {
|
||||
List<double> startPoint = [
|
||||
double.parse(latController.text),
|
||||
double.parse(lonController.text)
|
||||
];
|
||||
Future<UserPreferences> preferences = loadUserPreferences();
|
||||
Trip trip = Trip();
|
||||
trip.landmarks.add(
|
||||
Landmark(
|
||||
location: startPoint,
|
||||
name: "Start",
|
||||
type: start,
|
||||
uuid: "pending"
|
||||
)
|
||||
);
|
||||
fetchTrip(trip, preferences);
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => BasePage(mainScreen: "map", trip: trip)
|
||||
)
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
body: Stack(
|
||||
children: [
|
||||
NewTripMap(trip),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: NewTripLocationSearch(trip),
|
||||
),
|
||||
)
|
||||
)
|
||||
Align(
|
||||
alignment: Alignment.bottomRight,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(15),
|
||||
child: NewTripButton(trip: trip)
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,82 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sliding_up_panel/sliding_up_panel.dart';
|
||||
|
||||
import 'package:anyway/structs/trip.dart';
|
||||
|
||||
import 'package:anyway/modules/landmarks_overview.dart';
|
||||
import 'package:anyway/modules/map.dart';
|
||||
import 'package:anyway/modules/greeter.dart';
|
||||
|
||||
|
||||
|
||||
class NavigationOverview extends StatefulWidget {
|
||||
final Trip trip;
|
||||
|
||||
NavigationOverview({
|
||||
required this.trip,
|
||||
});
|
||||
|
||||
@override
|
||||
State<NavigationOverview> createState() => _NavigationOverviewState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
class _NavigationOverviewState extends State<NavigationOverview> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SlidingUpPanel(
|
||||
panel: _floatingPanel(),
|
||||
// collapsed: _floatingCollapsed(),
|
||||
body: MapWidget(trip: widget.trip),
|
||||
// renderPanelSheet: false,
|
||||
// backdropEnabled: true,
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.8,
|
||||
padding: EdgeInsets.all(10),
|
||||
// panelSnapping: false,
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
blurRadius: 20.0,
|
||||
color: Colors.black,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _floatingCollapsed(){
|
||||
return Greeter(
|
||||
trip: widget.trip
|
||||
);
|
||||
}
|
||||
|
||||
Widget _floatingPanel(){
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(15),
|
||||
child:
|
||||
Center(
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 5,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
borderRadius: BorderRadius.all(Radius.circular(12.0)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
Greeter(trip: widget.trip),
|
||||
LandmarksOverview(trip: widget.trip)
|
||||
]
|
||||
)
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
84
frontend/lib/pages/trip.dart
Normal file
84
frontend/lib/pages/trip.dart
Normal file
@@ -0,0 +1,84 @@
|
||||
import 'package:anyway/modules/save_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:sliding_up_panel/sliding_up_panel.dart';
|
||||
|
||||
import 'package:anyway/structs/trip.dart';
|
||||
import 'package:anyway/modules/landmarks_list.dart';
|
||||
import 'package:anyway/modules/greeter.dart';
|
||||
import 'package:anyway/modules/map.dart';
|
||||
|
||||
|
||||
|
||||
class TripPage extends StatefulWidget {
|
||||
final Trip trip;
|
||||
|
||||
TripPage({
|
||||
required this.trip,
|
||||
});
|
||||
|
||||
@override
|
||||
State<TripPage> createState() => _TripPageState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
class _TripPageState extends State<TripPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SlidingUpPanel(
|
||||
panelBuilder: (sc) => _panelFull(sc),
|
||||
// collapsed: _floatingCollapsed(),
|
||||
body: MapWidget(trip: widget.trip),
|
||||
// renderPanelSheet: false,
|
||||
// backdropEnabled: true,
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.8,
|
||||
padding: EdgeInsets.only(left: 10, right: 10, top: 25, bottom: 10),
|
||||
// panelSnapping: false,
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
blurRadius: 20.0,
|
||||
color: Colors.black,
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _panelFull(ScrollController sc) {
|
||||
return ListenableBuilder(
|
||||
listenable: widget.trip,
|
||||
builder: (context, child) {
|
||||
if (widget.trip.uuid != 'pending' && widget.trip.uuid != 'error') {
|
||||
return ListView(
|
||||
controller: sc,
|
||||
padding: EdgeInsets.only(bottom: 35),
|
||||
children: [
|
||||
Greeter(trip: widget.trip),
|
||||
...landmarksList(widget.trip),
|
||||
Padding(padding: EdgeInsets.only(top: 10)),
|
||||
Center(child: saveButton(widget.trip)),
|
||||
],
|
||||
);
|
||||
} else if(widget.trip.uuid == 'pending') {
|
||||
return Greeter(trip: widget.trip);
|
||||
} else {
|
||||
return Column(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
color: Colors.red,
|
||||
size: 60,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16),
|
||||
child: Text('Error: ${widget.trip.errorDescription}'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user