step 16 : get user location google map, refresh location google map absen selfie dan absen normal (bukan selfie)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:absensi_sas/app/constant.dart';
|
||||
import 'package:absensi_sas/provider/current_rekap_kehadiran_home_provider.dart';
|
||||
import 'package:absensi_sas/widget/custom_google_map_widget.dart';
|
||||
import 'package:dart_nominatim/dart_nominatim.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
@@ -322,7 +323,16 @@ class HomeScreen extends HookConsumerWidget {
|
||||
)
|
||||
: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
await requestLocationPermission();
|
||||
// await requestLocationPermission();
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => CustomGoogleMapWidget(
|
||||
positionLastLatitudeParam: positionLatitude,
|
||||
positionLastLongitudeParam: positionLongitude,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
shape: CircleBorder(),
|
||||
|
||||
@@ -30,7 +30,9 @@ import '../../provider/camera_controller_provider.dart';
|
||||
import '../../provider/current_check_distance_provider.dart';
|
||||
import '../../provider/current_check_jam_presensi_provider.dart';
|
||||
import '../../provider/current_user_provider.dart';
|
||||
import '../../provider/google_login_provider.dart';
|
||||
import '../../widget/custom_dialog_presensi_selfie_sukses.dart';
|
||||
import '../../widget/custom_google_map_widget.dart';
|
||||
import '../../widget/real_date.dart';
|
||||
import '../../widget/real_time.dart';
|
||||
import '../../widget/sankbar_widget.dart';
|
||||
@@ -55,6 +57,10 @@ class PresensiScreen extends HookConsumerWidget {
|
||||
|
||||
final positionLatitude = useState<String>("");
|
||||
final positionLongitude = useState<String>("");
|
||||
|
||||
final currLatProvider = ref.read(currentLatitudeProvider);
|
||||
final currLongProvider = ref.read(currentLongitudeProvider);
|
||||
|
||||
// final tTransactionCurrentDistance = useState<String>("NULL");
|
||||
|
||||
Location location = new Location();
|
||||
@@ -95,23 +101,34 @@ class PresensiScreen extends HookConsumerWidget {
|
||||
_locationData = await location.getLocation();
|
||||
|
||||
// Mendapatkan alamat dari posisi
|
||||
// final address = await positionToAddressGoogleApis(
|
||||
// LatLng(_locationData.latitude!, _locationData.longitude!));
|
||||
|
||||
final address = await positionToAddressGoogleApis(
|
||||
LatLng(_locationData.latitude!, _locationData.longitude!));
|
||||
LatLng(currLatProvider, currLongProvider));
|
||||
|
||||
if (positionLongitude.value.isEmpty && positionLatitude.value.isEmpty) {
|
||||
if (address != "") {
|
||||
isLoadingAddressUserLocation.value = false;
|
||||
|
||||
// ref.read(googleApisProvider.notifier).getAddressGoogleApis(
|
||||
// latitude: _locationData.latitude.toString(),
|
||||
// longitude: _locationData.longitude.toString(),
|
||||
// );
|
||||
|
||||
ref.read(googleApisProvider.notifier).getAddressGoogleApis(
|
||||
latitude: _locationData.latitude.toString(),
|
||||
longitude: _locationData.longitude.toString(),
|
||||
latitude: currLatProvider.toString(),
|
||||
longitude: currLongProvider.toString(),
|
||||
);
|
||||
|
||||
// String address =
|
||||
// "${placemark.thoroughfare}, ${placemark.locality}, ${placemark.administrativeArea}, ${placemark.country},";
|
||||
|
||||
positionLatitude.value = _locationData.latitude.toString();
|
||||
positionLongitude.value = _locationData.longitude.toString();
|
||||
// positionLatitude.value = _locationData.latitude.toString();
|
||||
// positionLongitude.value = _locationData.longitude.toString();
|
||||
|
||||
positionLatitude.value = currLatProvider.toString();
|
||||
positionLongitude.value = currLongProvider.toString();
|
||||
} else {
|
||||
isLoadingAddressUserLocation.value = false;
|
||||
SanckbarWidget(
|
||||
@@ -511,20 +528,34 @@ class PresensiScreen extends HookConsumerWidget {
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
getAddressFromLocation();
|
||||
// getAddressFromLocation();
|
||||
|
||||
// refresh location
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => CustomGoogleMapWidget(
|
||||
positionLastLatitudeParam:
|
||||
positionLatitude,
|
||||
positionLastLongitudeParam:
|
||||
positionLongitude,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// jika sudah dapat latitude dan logitude baru panggil check distance provider
|
||||
if (positionLatitude.value.isNotEmpty &&
|
||||
positionLongitude.value.isNotEmpty) {
|
||||
// panggil check distance provider
|
||||
ref
|
||||
.read(checkDistanceProvider.notifier)
|
||||
.checkDistance(
|
||||
selectedUser?.model.staffId ?? "",
|
||||
selectedUser?.model.companyId ?? "",
|
||||
positionLatitude.value,
|
||||
positionLongitude.value,
|
||||
);
|
||||
}
|
||||
// if (positionLatitude.value.isNotEmpty &&
|
||||
// positionLongitude.value.isNotEmpty) {
|
||||
// // panggil check distance provider
|
||||
// ref
|
||||
// .read(checkDistanceProvider.notifier)
|
||||
// .checkDistance(
|
||||
// selectedUser?.model.staffId ?? "",
|
||||
// selectedUser?.model.companyId ?? "",
|
||||
// positionLatitude.value,
|
||||
// positionLongitude.value,
|
||||
// );
|
||||
// }
|
||||
},
|
||||
child: Container(
|
||||
width: Constant.getActualXPhone(
|
||||
|
||||
@@ -30,7 +30,9 @@ import '../../provider/camera_controller_provider.dart';
|
||||
import '../../provider/current_check_distance_provider.dart';
|
||||
import '../../provider/current_check_jam_presensi_provider.dart';
|
||||
import '../../provider/current_user_provider.dart';
|
||||
import '../../provider/google_login_provider.dart';
|
||||
import '../../widget/custom_dialog_presensi_selfie_sukses.dart';
|
||||
import '../../widget/custom_google_map_widget.dart';
|
||||
import '../../widget/real_date.dart';
|
||||
import '../../widget/real_time.dart';
|
||||
import '../../widget/sankbar_widget.dart';
|
||||
@@ -40,8 +42,6 @@ import 'check_presensi_jam_provider.dart';
|
||||
import 'googleapis_provider.dart';
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'presensi_selfie_upload_area_web.dart';
|
||||
|
||||
class PresensiSelfieScreen extends HookConsumerWidget {
|
||||
const PresensiSelfieScreen({super.key});
|
||||
|
||||
@@ -55,6 +55,9 @@ class PresensiSelfieScreen extends HookConsumerWidget {
|
||||
ref.watch(currentCheckJamPresensiProvider);
|
||||
final selectedUser = ref.watch(currentUserProvider);
|
||||
|
||||
final currLatProvider = ref.read(currentLatitudeProvider);
|
||||
final currLongProvider = ref.read(currentLongitudeProvider);
|
||||
|
||||
final positionLatitude = useState<String>("");
|
||||
final positionLongitude = useState<String>("");
|
||||
|
||||
@@ -195,8 +198,11 @@ class PresensiSelfieScreen extends HookConsumerWidget {
|
||||
_locationData = await location.getLocation();
|
||||
|
||||
// Mendapatkan alamat dari posisi
|
||||
// final address = await positionToAddressGoogleApis(
|
||||
// LatLng(_locationData.latitude!, _locationData.longitude!));
|
||||
|
||||
final address = await positionToAddressGoogleApis(
|
||||
LatLng(_locationData.latitude!, _locationData.longitude!));
|
||||
LatLng(currLatProvider, currLongProvider));
|
||||
|
||||
// final address = await positionToAddress(
|
||||
// LatLng(-7.5666203, 110.8083376),
|
||||
@@ -207,16 +213,24 @@ class PresensiSelfieScreen extends HookConsumerWidget {
|
||||
if (address != "") {
|
||||
isLoadingAddressUserLocation.value = false;
|
||||
|
||||
// ref.read(googleApisProvider.notifier).getAddressGoogleApis(
|
||||
// latitude: _locationData.latitude.toString(),
|
||||
// longitude: _locationData.longitude.toString(),
|
||||
// );
|
||||
|
||||
ref.read(googleApisProvider.notifier).getAddressGoogleApis(
|
||||
latitude: _locationData.latitude.toString(),
|
||||
longitude: _locationData.longitude.toString(),
|
||||
latitude: currLatProvider.toString(),
|
||||
longitude: currLongProvider.toString(),
|
||||
);
|
||||
|
||||
// String address =
|
||||
// "${placemark.thoroughfare}, ${placemark.locality}, ${placemark.administrativeArea}, ${placemark.country},";
|
||||
|
||||
positionLatitude.value = _locationData.latitude.toString();
|
||||
positionLongitude.value = _locationData.longitude.toString();
|
||||
// positionLatitude.value = _locationData.latitude.toString();
|
||||
// positionLongitude.value = _locationData.longitude.toString();
|
||||
|
||||
positionLatitude.value = currLatProvider.toString();
|
||||
positionLongitude.value = currLongProvider.toString();
|
||||
} else {
|
||||
isLoadingAddressUserLocation.value = false;
|
||||
SanckbarWidget(
|
||||
@@ -660,7 +674,21 @@ class PresensiSelfieScreen extends HookConsumerWidget {
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
getAddressFromLocation();
|
||||
// getAddressFromLocation();
|
||||
|
||||
// refresh location
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => CustomGoogleMapWidget(
|
||||
positionLastLatitudeParam:
|
||||
positionLatitude,
|
||||
positionLastLongitudeParam:
|
||||
positionLongitude,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// jika sudah dapat latitude dan logitude baru panggil check distance provider
|
||||
// if (positionLatitude.value.isNotEmpty &&
|
||||
// positionLongitude.value.isNotEmpty) {
|
||||
|
||||
Reference in New Issue
Block a user