Skip to content

Commit

Permalink
updating the coordinate comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
a4ifka committed Apr 25, 2024
1 parent 2eb87c2 commit 9d2caf6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 39 deletions.
78 changes: 39 additions & 39 deletions lib/feature/presentation/pages/order_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_swipe_button/flutter_swipe_button.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:beFit_Del/feature/domain/entities/order_entity.dart';
import 'package:beFit_Del/feature/presentation/bloc/item_cubit/item_cubit.dart';
Expand Down Expand Up @@ -33,7 +34,7 @@ class _OrderDetailPageState extends State<OrderDetailPage> {
context.read<ItemCubit>().getOrderItems(order.id);
context.read<LocationCubit>().getPhoneLocation(order.address);
context.read<OrdersCostCubit>().getOrdersCost(isDelivered);

var key = '1';
BitmapDescriptor address = BitmapDescriptor.defaultMarker;
BitmapDescriptor home = BitmapDescriptor.defaultMarker;
BitmapDescriptor.fromAssetImage(
Expand Down Expand Up @@ -505,7 +506,7 @@ class _OrderDetailPageState extends State<OrderDetailPage> {
bottomNavigationBar: Container(
color: Color(0xFFFAF7F5),
child: Padding(
padding: EdgeInsets.only(left: 20, right: 20, bottom: 20),
padding: EdgeInsets.only(left: 10, right: 10, bottom: 20),
child: Container(
color: Color(0xFFFAF7F5),
height: 60,
Expand Down Expand Up @@ -534,50 +535,49 @@ class _OrderDetailPageState extends State<OrderDetailPage> {
)
: Align(
alignment: Alignment.bottomLeft,
child: SwipeableButtonView(
buttonText: "Доставлен",
buttontextstyle: const TextStyle(
child: SwipeButton(
height: 60,
elevationThumb: 2,
activeTrackColor: const Color(0xFF78C4A4),
activeThumbColor: Colors.white,
thumbPadding: EdgeInsets.all(8.0),
thumb: const Icon(
Icons.arrow_forward_ios_rounded,
color: Colors.grey,
),
child: const Text(
"Доставлен",
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontFamily: 'Nunito',
fontWeight: FontWeight.w600,
height: 0.07,
letterSpacing: 0.09,
),
buttonWidget: Container(
child: const Icon(
Icons.arrow_forward_ios_rounded,
color: Colors.grey,
),
),
activeColor: const Color(0xFF78C4A4),
isFinished: isFinished,
onWaitingProcess: () {
Future.delayed(Duration(seconds: 2), () {
final double radius = 150; // Радиус в метрах
final distance = Geolocator.distanceBetween(
locationList[0],
locationList[1],
locationList[2],
locationList[3]);
if (distance <= radius) {
context
.read<SetDeliveredCubit>()
.setOrderIsDelivered(orderId, true);
} else {
isFinished = false;
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content:
Text('Вы не в радиусе заказа!'),
backgroundColor: Colors.redAccent,
),
);
}
});
},
onFinish: () async {}),
),
),
onSwipe: () {
final double radius = 150; // Радиус в метрах
final distance = Geolocator.distanceBetween(
locationList[0],
locationList[1],
locationList[2],
locationList[3]);
if (distance <= radius) {
context
.read<SetDeliveredCubit>()
.setOrderIsDelivered(orderId, true);
} else {
isFinished = false;
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Вы не в радиусе заказа!'),
backgroundColor: Colors.redAccent,
),
);
}
},
)),
BlocListener<SetDeliveredCubit, SetDeliveredState>(
listener: (context, state) {
if (state is SetDeliveredLoaded) {
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.17"
flutter_swipe_button:
dependency: "direct main"
description:
name: flutter_swipe_button
sha256: eaddf7bf536bf099f0bcf05bfa861a9ab5b7fb3e9fbfdf48c13180bdc2500ec9
url: "https://pub.dev"
source: hosted
version: "2.1.1+1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies:
fl_chart: ^0.67.0
url_launcher: ^6.2.5
swipeable_button_view: ^0.0.2
flutter_swipe_button: ^2.1.1+1

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 9d2caf6

Please sign in to comment.