finalize all except gps
This commit is contained in:
6
.env
6
.env
@ -1,2 +1,4 @@
|
||||
SERVER_URL = https://absensi-mamuju-tengah.airlangga-it.com/apiuser/
|
||||
URL=https://absensi-mamuju-tengah.airlangga-it.com/absensi_server/
|
||||
# SERVER_URL = https://absensi-mamuju-tengah.airlangga-it.com/apiuser/
|
||||
# URL=https://absensi-mamuju-tengah.airlangga-it.com/absensi_server/
|
||||
SERVER_URL = http://192.168.232.237/absensi_server/apiuser/
|
||||
URL=http://192.168.232.237/absensi_server/
|
||||
@ -3,7 +3,7 @@ import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:absensi_karyawan/src/services/notification_services.dart';
|
||||
import 'package:background_location/background_location.dart';
|
||||
// import 'package:background_location/background_location.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -215,7 +215,7 @@ void onStart(ServiceInstance service) async {
|
||||
}
|
||||
|
||||
Future<void> _startBackgroundLocation() async {
|
||||
await BackgroundLocation.startLocationService(distanceFilter: 20);
|
||||
// await BackgroundLocation.startLocationService(distanceFilter: 20);
|
||||
}
|
||||
|
||||
Future<void> _configureLocalTimeZone() async {
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
import 'package:absensi_karyawan/src/models/base_response.dart';
|
||||
import 'package:absensi_karyawan/src/models/user_data_model.dart';
|
||||
import 'package:animated_snack_bar/animated_snack_bar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
|
||||
import '../../config/theme.dart';
|
||||
import '../../services/api_service.dart';
|
||||
import '../../services/storage_service.dart';
|
||||
import '../../widget/dumb_widget/my_textformfield.dart';
|
||||
import '../../widget/smart_widget/bounce_scroller.dart';
|
||||
@ -47,11 +50,16 @@ class _ProfilKaryawanPageState extends State<ProfilKaryawanPage> {
|
||||
userDataModel = UserDataModel.fromJson(userData);
|
||||
});
|
||||
|
||||
// dev.i("$url${userDataModel.image}");
|
||||
dev.i("$url${userDataModel?.image}");
|
||||
}
|
||||
|
||||
Future<void> _showPasswordEdit() async {
|
||||
// create dialog box
|
||||
// empty text field
|
||||
_oldPasswordController.clear();
|
||||
_newPasswordController.clear();
|
||||
_confirmPasswordController.clear();
|
||||
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@ -76,18 +84,15 @@ class _ProfilKaryawanPageState extends State<ProfilKaryawanPage> {
|
||||
MyTextFormField(
|
||||
controller: _oldPasswordController,
|
||||
focusNode: _oldPasswordFocusNode,
|
||||
obscureText: !_isOldPasswordVisible,
|
||||
labelText: "Password Lama",
|
||||
hintText: "Password Lama",
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_isOldPasswordVisible
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isOldPasswordVisible = !_isOldPasswordVisible;
|
||||
});
|
||||
null;
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -97,18 +102,15 @@ class _ProfilKaryawanPageState extends State<ProfilKaryawanPage> {
|
||||
MyTextFormField(
|
||||
controller: _newPasswordController,
|
||||
focusNode: _newPasswordFocusNode,
|
||||
obscureText: !_isNewPasswordVisible,
|
||||
labelText: "Password Baru",
|
||||
hintText: "Password Baru",
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_isNewPasswordVisible
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isNewPasswordVisible = !_isNewPasswordVisible;
|
||||
});
|
||||
null;
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -117,20 +119,16 @@ class _ProfilKaryawanPageState extends State<ProfilKaryawanPage> {
|
||||
),
|
||||
MyTextFormField(
|
||||
controller: _confirmPasswordController,
|
||||
obscureText: !_isConfirmPasswordVisible,
|
||||
focusNode: _confirmPasswordFocusNode,
|
||||
labelText: "Konfirmasi Password",
|
||||
hintText: "Konfirmasi Password",
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(
|
||||
_isConfirmPasswordVisible
|
||||
? Icons.visibility
|
||||
: Icons.visibility_off,
|
||||
Icons.visibility_off,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_isConfirmPasswordVisible =
|
||||
!_isConfirmPasswordVisible;
|
||||
});
|
||||
null;
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -147,10 +145,58 @@ class _ProfilKaryawanPageState extends State<ProfilKaryawanPage> {
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('Ganti Password'),
|
||||
onPressed: () {
|
||||
onPressed: () async {
|
||||
// if (_formKey.currentState!.validate()) {
|
||||
// unfocus all
|
||||
String passwordLama = _oldPasswordController.text;
|
||||
String passwordBaru = _newPasswordController.text;
|
||||
String konfirmasiPassword = _confirmPasswordController.text;
|
||||
FocusScope.of(context).unfocus();
|
||||
// dev.i("ganti password");
|
||||
if (passwordLama == "" ||
|
||||
passwordBaru == "" ||
|
||||
konfirmasiPassword == "") {
|
||||
info('Error', 'Semua field harus diisi',
|
||||
AnimatedSnackBarType.error);
|
||||
// focus to first field
|
||||
FocusScope.of(context).requestFocus(_oldPasswordFocusNode);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (passwordBaru != konfirmasiPassword) {
|
||||
info(
|
||||
'Error',
|
||||
'Password baru dan konfirmasi password tidak sama',
|
||||
AnimatedSnackBarType.error);
|
||||
// focus to second field
|
||||
FocusScope.of(context).requestFocus(_newPasswordFocusNode);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
BaseResponse? response = await ApiServices.gantiPassword(
|
||||
passwordLama,
|
||||
passwordBaru,
|
||||
);
|
||||
|
||||
if (response == null) {
|
||||
info('Error', 'Terjadi Kesalahan Jaringan',
|
||||
AnimatedSnackBarType.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.status == false) {
|
||||
info('Error', response.message, AnimatedSnackBarType.error);
|
||||
return;
|
||||
}
|
||||
|
||||
info('Sukses Ganti Password', response.message,
|
||||
AnimatedSnackBarType.success);
|
||||
|
||||
pop();
|
||||
|
||||
// Navigator.of(context).pop();
|
||||
|
||||
// if
|
||||
},
|
||||
@ -161,6 +207,21 @@ class _ProfilKaryawanPageState extends State<ProfilKaryawanPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void info(String message, String title, AnimatedSnackBarType type) {
|
||||
AnimatedSnackBar.rectangle(
|
||||
title,
|
||||
message,
|
||||
type: type,
|
||||
brightness: Brightness.dark,
|
||||
).show(
|
||||
context,
|
||||
);
|
||||
}
|
||||
|
||||
void pop() {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@ -321,7 +382,7 @@ class _DetailChild extends StatelessWidget {
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: ThemeInfo.myGrey2,
|
||||
color: ThemeInfo.primary,
|
||||
size: 40,
|
||||
),
|
||||
const SizedBox(
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import 'package:background_location/background_location.dart';
|
||||
// import 'package:background_location/background_location.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:platform_device_id/platform_device_id.dart';
|
||||
|
||||
import '../config/theme.dart';
|
||||
import '../models/base_response.dart';
|
||||
import '../services/api_service.dart';
|
||||
import '../services/storage_service.dart';
|
||||
|
||||
class SplashScreenPage extends StatefulWidget {
|
||||
@ -28,11 +30,25 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
|
||||
Future.delayed(const Duration(seconds: 4), () async {
|
||||
// await _storage.remove('userData');
|
||||
var checkUser = await _storage.read('userData');
|
||||
// dev.i(checkUser);
|
||||
dev.i(checkUser);
|
||||
if (checkUser == null) {
|
||||
goToLogin();
|
||||
} else {
|
||||
goToHomepage();
|
||||
// goToHomepage();
|
||||
// change checkUSer to Map
|
||||
Map<String, dynamic> userData = checkUser;
|
||||
|
||||
BaseResponse? response = await ApiServices.cekUserPhoneID(userData);
|
||||
|
||||
if (response!.status == true) {
|
||||
// dev.i(response.data['data_user']);
|
||||
await _storage.write('userData', response.data['data_user']);
|
||||
// dev.i(response.data['data_jadwal']);
|
||||
|
||||
goToHomepage();
|
||||
} else {
|
||||
goToLogin();
|
||||
}
|
||||
}
|
||||
// Navigator.pushReplacementNamed(context, 'login');
|
||||
});
|
||||
@ -116,7 +132,7 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
|
||||
right: 15,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Dinas Pariwisata Dan Kebudayaan\nKabupaten Mamuju Tengah\n\nAirlangga IT',
|
||||
'Dinas Pariwisata Kepemudaan Dan Olahraga\nKabupaten Mamuju Tengah\n\nAirlangga IT',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
|
||||
@ -45,6 +45,65 @@ class ApiServices {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<BaseResponse?> cekUserPhoneID(
|
||||
Map<String, dynamic> datanya) async {
|
||||
try {
|
||||
String endpoint = 'cek_datanya';
|
||||
String deviceId = await storage.read("device_id");
|
||||
|
||||
Map<String, String> data = {
|
||||
"nik": datanya['nik'],
|
||||
"device_id": deviceId,
|
||||
};
|
||||
var response = await dio.post(endpoint, data: data);
|
||||
var responseReturn = response.data;
|
||||
// dev.i(responseReturn);
|
||||
return BaseResponse.fromJson(responseReturn);
|
||||
} on DioError catch (e) {
|
||||
dev.e(e);
|
||||
|
||||
await storage.remove('userData');
|
||||
return BaseResponse(
|
||||
status: false,
|
||||
message: e.response != null ? e.response!.data['message'] : e.message,
|
||||
);
|
||||
} catch (e) {
|
||||
await storage.remove('userData');
|
||||
dev.e(e);
|
||||
return null;
|
||||
}
|
||||
// return null;
|
||||
}
|
||||
|
||||
static Future<BaseResponse?> gantiPassword(
|
||||
String passwordLama, String passwordBaru) async {
|
||||
try {
|
||||
String endpoint = 'ganti_password';
|
||||
Map<String, dynamic> userData = await storage.read('userData');
|
||||
|
||||
Map<String, String> data = {
|
||||
"nik": userData['nik'],
|
||||
"password_lama": passwordLama,
|
||||
"password_baru": passwordBaru,
|
||||
"id_dinas": userData['id_dinas'],
|
||||
};
|
||||
|
||||
var response = await dio.post(endpoint, data: data);
|
||||
var responseReturn = response.data;
|
||||
|
||||
return BaseResponse.fromJson(responseReturn);
|
||||
} on DioError catch (e) {
|
||||
dev.e(e);
|
||||
return BaseResponse(
|
||||
status: false,
|
||||
message: e.response != null ? e.response!.data['message'] : e.message,
|
||||
);
|
||||
} catch (e) {
|
||||
dev.e(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<BaseResponse?> uploadLaporan(
|
||||
String? imgPath, String namaLaporan, String ketLaporan) async {
|
||||
try {
|
||||
|
||||
@ -22,13 +22,6 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.9.0"
|
||||
background_location:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: background_location
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.8.1"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@ -63,7 +63,7 @@ dependencies:
|
||||
google_maps_flutter:
|
||||
|
||||
# geolocator:
|
||||
background_location:
|
||||
# background_location:
|
||||
# background_locator:
|
||||
# location: ^5.0.0-dev.7
|
||||
|
||||
|
||||
Reference in New Issue
Block a user