loaded map data
This commit is contained in:
parent
9b38337f94
commit
ed4f91ce98
|
|
@ -25,7 +25,10 @@ class MyApp extends StatelessWidget {
|
|||
create: (context) => di.sl<UserBloc>(), //..add(CheckUser()),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => di.sl<OrderBloc>()..add(const GetOrders(FilterProductParams())),
|
||||
create: (context) => di.sl<OrderBloc>()
|
||||
..add(const GetOrders(
|
||||
FilterProductParams(state: GoodsState.Received),
|
||||
)),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) => di.sl<OrderDetailBloc>(),
|
||||
|
|
|
|||
|
|
@ -1 +1,9 @@
|
|||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
enum NavigationTab { home, histories, profile }
|
||||
|
||||
enum GoodsState {
|
||||
Reserved,
|
||||
Received,
|
||||
Delivered,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,12 @@ class OrderRemoteDataSourceImpl implements OrderRemoteDataSource {
|
|||
|
||||
@override
|
||||
Future<OrderResponseModel> getOrders(FilterProductParams params, String token) async {
|
||||
Uri uri = Uri.parse(
|
||||
'$baseUrl/Goods?pageNumber=${params.offset}&pageSize=${params.limit}${params.state != null ? '&state=${params.state!.name}' : ''}',
|
||||
);
|
||||
|
||||
final response = await client.get(
|
||||
Uri.parse('$baseUrl/Goods?pageNumber=${params.offset}&pageSize=${params.limit}'),
|
||||
uri,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'accept': '*/*',
|
||||
|
|
|
|||
|
|
@ -1,19 +1,25 @@
|
|||
import 'package:cargo/core/core.dart';
|
||||
|
||||
class FilterProductParams {
|
||||
final int offset;
|
||||
final int limit;
|
||||
final GoodsState? state;
|
||||
|
||||
const FilterProductParams({
|
||||
this.offset = 1,
|
||||
this.limit = 10,
|
||||
this.state,
|
||||
});
|
||||
|
||||
FilterProductParams copyWith({
|
||||
int? offset,
|
||||
int? limit,
|
||||
GoodsState? state,
|
||||
}) {
|
||||
return FilterProductParams(
|
||||
offset: offset ?? this.offset,
|
||||
limit: limit ?? this.limit,
|
||||
state: state ?? this.state,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,23 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||
import '../../application/order_bloc/order_bloc.dart';
|
||||
import '../../configs/configs.dart';
|
||||
import '../../core/core.dart';
|
||||
import '../../domain/entities/order/filter_params_model.dart';
|
||||
import '../widgets/widgets.dart';
|
||||
|
||||
class HistoriesScreen extends StatelessWidget {
|
||||
class HistoriesScreen extends StatefulWidget {
|
||||
const HistoriesScreen({super.key});
|
||||
|
||||
@override
|
||||
State<HistoriesScreen> createState() => _HistoriesScreenState();
|
||||
}
|
||||
|
||||
class _HistoriesScreenState extends State<HistoriesScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
context.read<OrderBloc>().add(const GetOrders(FilterProductParams()));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
App.init(context);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import 'package:cargo/application/application.dart';
|
||||
import 'package:cargo/configs/configs.dart';
|
||||
import 'package:cargo/domain/domain.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
import '../../application/order_detail_bloc/order_detail_bloc.dart';
|
||||
import '../../core/core.dart';
|
||||
import '../../domain/entities/order/order.dart';
|
||||
import '../widgets/map/clustering.dart';
|
||||
import '../widgets/widgets.dart';
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
|||
),
|
||||
backgroundColor: AppColors.primary,
|
||||
title: Text(
|
||||
'Sargyt №ABC456789',
|
||||
'Sargyt ${widget.order.name}',
|
||||
style: AppText.h2!.copyWith(color: Colors.white),
|
||||
),
|
||||
),
|
||||
|
|
@ -43,7 +43,7 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
|||
/// map
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
height: AppDimensions.normalize(120),
|
||||
height: AppDimensions.normalize(130),
|
||||
child: const ClusteringPage(),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
import '../../../application/order_detail_bloc/order_detail_bloc.dart';
|
||||
|
||||
class ClusteringPage extends StatefulWidget {
|
||||
static const String route = 'clusteringPage';
|
||||
|
||||
|
|
@ -12,6 +15,141 @@ class ClusteringPage extends StatefulWidget {
|
|||
State<ClusteringPage> createState() => _ClusteringPageState();
|
||||
}
|
||||
|
||||
class _ClusteringPageState extends State<ClusteringPage> {
|
||||
final PopupController _popupController = PopupController();
|
||||
|
||||
late List<Marker> markers;
|
||||
late List<Polyline> polylines;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
markers = [];
|
||||
polylines = [];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: BlocBuilder<OrderDetailBloc, OrderDetailState>(
|
||||
builder: (context, state) {
|
||||
if (state is RoutesLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
} else if (state is RoutesLoaded) {
|
||||
markers = state.routes.map((route) {
|
||||
return Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(route.lat, route.long),
|
||||
child: const Icon(Icons.pin_drop),
|
||||
);
|
||||
}).toList();
|
||||
|
||||
// Update polylines
|
||||
polylines = [
|
||||
Polyline(
|
||||
points: state.routes.map((route) {
|
||||
return LatLng(route.lat, route.long);
|
||||
}).toList(),
|
||||
borderStrokeWidth: 6.6,
|
||||
color: Colors.blue,
|
||||
borderColor: Colors.green,
|
||||
),
|
||||
];
|
||||
|
||||
return PopupScope(
|
||||
popupController: _popupController,
|
||||
child: FlutterMap(
|
||||
options: MapOptions(
|
||||
initialCenter:
|
||||
markers.isNotEmpty ? markers.first.point : const LatLng(0, 0), // Default to (0, 0) if no markers
|
||||
initialZoom: 4.5,
|
||||
maxZoom: 45,
|
||||
onTap: (_, __) => _popupController.hideAllPopups(),
|
||||
),
|
||||
children: <Widget>[
|
||||
TileLayer(
|
||||
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
subdomains: const ['a', 'b', 'c'],
|
||||
),
|
||||
MarkerClusterLayerWidget(
|
||||
options: MarkerClusterLayerOptions(
|
||||
spiderfyCircleRadius: 80,
|
||||
spiderfySpiralDistanceMultiplier: 2,
|
||||
circleSpiralSwitchover: 12,
|
||||
maxClusterRadius: 120,
|
||||
rotate: true,
|
||||
size: const Size(40, 40),
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.all(50),
|
||||
maxZoom: 15,
|
||||
markers: markers,
|
||||
polygonOptions: const PolygonOptions(
|
||||
borderColor: Colors.blueAccent,
|
||||
color: Colors.black12,
|
||||
borderStrokeWidth: 3,
|
||||
),
|
||||
popupOptions: PopupOptions(
|
||||
popupSnap: PopupSnap.markerTop,
|
||||
popupController: _popupController,
|
||||
popupBuilder: (_, marker) => Container(
|
||||
width: 200,
|
||||
height: 100,
|
||||
color: Colors.white,
|
||||
child: GestureDetector(
|
||||
onTap: () => debugPrint('Popup tap!'),
|
||||
child: const Text(
|
||||
'Container popup for marker',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
builder: (context, markers) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
color: Colors.blue,
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
markers.length.toString(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
PolylineLayer(
|
||||
polylineCulling: true,
|
||||
polylines: polylines,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else if (state is RoutesError) {
|
||||
return Center(
|
||||
child: Text('Error loading routes: ${state.failure}'),
|
||||
);
|
||||
} else {
|
||||
return const Center(child: Text('No data'));
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* class ClusteringPage extends StatefulWidget {
|
||||
static const String route = 'clusteringPage';
|
||||
|
||||
const ClusteringPage({super.key});
|
||||
|
||||
@override
|
||||
State<ClusteringPage> createState() => _ClusteringPageState();
|
||||
}
|
||||
|
||||
class _ClusteringPageState extends State<ClusteringPage> {
|
||||
final PopupController _popupController = PopupController();
|
||||
|
||||
|
|
@ -47,111 +185,6 @@ class _ClusteringPageState extends State<ClusteringPage> {
|
|||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
const Marker(
|
||||
alignment: Alignment.center,
|
||||
height: 30,
|
||||
width: 30,
|
||||
point: LatLng(49.8566, 3.3522),
|
||||
child: Icon(Icons.pin_drop),
|
||||
),
|
||||
];
|
||||
|
||||
super.initState();
|
||||
|
|
@ -245,19 +278,7 @@ class _ClusteringPageState extends State<ClusteringPage> {
|
|||
polylineCulling: true,
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: [
|
||||
// const LatLng(51.5, -0.09),
|
||||
// const LatLng(49.8566, 3.3522),
|
||||
// const LatLng(49.8566, 1.3522),
|
||||
// const LatLng(47.8566, 1.3522),
|
||||
// const LatLng(47.8566, 5.3522),
|
||||
// const LatLng(44.8566, 5.3522),
|
||||
// const LatLng(49.8566, 12.3522),
|
||||
// const LatLng(49.8864, 13.4522),
|
||||
// const LatLng(49.8966, 13.6522),
|
||||
const LatLng(37.90970, 58.39795),
|
||||
const LatLng(37.90491, 58.39742)
|
||||
],
|
||||
points: [const LatLng(37.90970, 58.39795), const LatLng(37.90491, 58.39742)],
|
||||
borderStrokeWidth: 6.6,
|
||||
color: Colors.red,
|
||||
borderColor: Colors.green,
|
||||
|
|
@ -270,3 +291,4 @@ class _ClusteringPageState extends State<ClusteringPage> {
|
|||
);
|
||||
}
|
||||
}
|
||||
*/
|
||||
Loading…
Reference in New Issue