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/
|
# SERVER_URL = https://absensi-mamuju-tengah.airlangga-it.com/apiuser/
|
||||||
URL=https://absensi-mamuju-tengah.airlangga-it.com/absensi_server/
|
# 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 'dart:ui';
|
||||||
|
|
||||||
import 'package:absensi_karyawan/src/services/notification_services.dart';
|
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/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
@ -215,7 +215,7 @@ void onStart(ServiceInstance service) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _startBackgroundLocation() async {
|
Future<void> _startBackgroundLocation() async {
|
||||||
await BackgroundLocation.startLocationService(distanceFilter: 20);
|
// await BackgroundLocation.startLocationService(distanceFilter: 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _configureLocalTimeZone() async {
|
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: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/material.dart';
|
||||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
|
|
||||||
import '../../config/theme.dart';
|
import '../../config/theme.dart';
|
||||||
|
import '../../services/api_service.dart';
|
||||||
import '../../services/storage_service.dart';
|
import '../../services/storage_service.dart';
|
||||||
import '../../widget/dumb_widget/my_textformfield.dart';
|
import '../../widget/dumb_widget/my_textformfield.dart';
|
||||||
import '../../widget/smart_widget/bounce_scroller.dart';
|
import '../../widget/smart_widget/bounce_scroller.dart';
|
||||||
@ -47,11 +50,16 @@ class _ProfilKaryawanPageState extends State<ProfilKaryawanPage> {
|
|||||||
userDataModel = UserDataModel.fromJson(userData);
|
userDataModel = UserDataModel.fromJson(userData);
|
||||||
});
|
});
|
||||||
|
|
||||||
// dev.i("$url${userDataModel.image}");
|
dev.i("$url${userDataModel?.image}");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _showPasswordEdit() async {
|
Future<void> _showPasswordEdit() async {
|
||||||
// create dialog box
|
// create dialog box
|
||||||
|
// empty text field
|
||||||
|
_oldPasswordController.clear();
|
||||||
|
_newPasswordController.clear();
|
||||||
|
_confirmPasswordController.clear();
|
||||||
|
|
||||||
showDialog<void>(
|
showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
@ -76,18 +84,15 @@ class _ProfilKaryawanPageState extends State<ProfilKaryawanPage> {
|
|||||||
MyTextFormField(
|
MyTextFormField(
|
||||||
controller: _oldPasswordController,
|
controller: _oldPasswordController,
|
||||||
focusNode: _oldPasswordFocusNode,
|
focusNode: _oldPasswordFocusNode,
|
||||||
|
obscureText: !_isOldPasswordVisible,
|
||||||
labelText: "Password Lama",
|
labelText: "Password Lama",
|
||||||
hintText: "Password Lama",
|
hintText: "Password Lama",
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
_isOldPasswordVisible
|
Icons.visibility_off,
|
||||||
? Icons.visibility
|
|
||||||
: Icons.visibility_off,
|
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
null;
|
||||||
_isOldPasswordVisible = !_isOldPasswordVisible;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -97,18 +102,15 @@ class _ProfilKaryawanPageState extends State<ProfilKaryawanPage> {
|
|||||||
MyTextFormField(
|
MyTextFormField(
|
||||||
controller: _newPasswordController,
|
controller: _newPasswordController,
|
||||||
focusNode: _newPasswordFocusNode,
|
focusNode: _newPasswordFocusNode,
|
||||||
|
obscureText: !_isNewPasswordVisible,
|
||||||
labelText: "Password Baru",
|
labelText: "Password Baru",
|
||||||
hintText: "Password Baru",
|
hintText: "Password Baru",
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
_isNewPasswordVisible
|
Icons.visibility_off,
|
||||||
? Icons.visibility
|
|
||||||
: Icons.visibility_off,
|
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
null;
|
||||||
_isNewPasswordVisible = !_isNewPasswordVisible;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -117,20 +119,16 @@ class _ProfilKaryawanPageState extends State<ProfilKaryawanPage> {
|
|||||||
),
|
),
|
||||||
MyTextFormField(
|
MyTextFormField(
|
||||||
controller: _confirmPasswordController,
|
controller: _confirmPasswordController,
|
||||||
|
obscureText: !_isConfirmPasswordVisible,
|
||||||
focusNode: _confirmPasswordFocusNode,
|
focusNode: _confirmPasswordFocusNode,
|
||||||
labelText: "Konfirmasi Password",
|
labelText: "Konfirmasi Password",
|
||||||
hintText: "Konfirmasi Password",
|
hintText: "Konfirmasi Password",
|
||||||
suffixIcon: IconButton(
|
suffixIcon: IconButton(
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
_isConfirmPasswordVisible
|
Icons.visibility_off,
|
||||||
? Icons.visibility
|
|
||||||
: Icons.visibility_off,
|
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
null;
|
||||||
_isConfirmPasswordVisible =
|
|
||||||
!_isConfirmPasswordVisible;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -147,10 +145,58 @@ class _ProfilKaryawanPageState extends State<ProfilKaryawanPage> {
|
|||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
child: const Text('Ganti Password'),
|
child: const Text('Ganti Password'),
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
// if (_formKey.currentState!.validate()) {
|
// if (_formKey.currentState!.validate()) {
|
||||||
// unfocus all
|
// unfocus all
|
||||||
|
String passwordLama = _oldPasswordController.text;
|
||||||
|
String passwordBaru = _newPasswordController.text;
|
||||||
|
String konfirmasiPassword = _confirmPasswordController.text;
|
||||||
FocusScope.of(context).unfocus();
|
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
|
// 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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@ -321,7 +382,7 @@ class _DetailChild extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
icon,
|
icon,
|
||||||
color: ThemeInfo.myGrey2,
|
color: ThemeInfo.primary,
|
||||||
size: 40,
|
size: 40,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
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/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:logger/logger.dart';
|
import 'package:logger/logger.dart';
|
||||||
import 'package:platform_device_id/platform_device_id.dart';
|
import 'package:platform_device_id/platform_device_id.dart';
|
||||||
|
|
||||||
import '../config/theme.dart';
|
import '../config/theme.dart';
|
||||||
|
import '../models/base_response.dart';
|
||||||
|
import '../services/api_service.dart';
|
||||||
import '../services/storage_service.dart';
|
import '../services/storage_service.dart';
|
||||||
|
|
||||||
class SplashScreenPage extends StatefulWidget {
|
class SplashScreenPage extends StatefulWidget {
|
||||||
@ -28,11 +30,25 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
|
|||||||
Future.delayed(const Duration(seconds: 4), () async {
|
Future.delayed(const Duration(seconds: 4), () async {
|
||||||
// await _storage.remove('userData');
|
// await _storage.remove('userData');
|
||||||
var checkUser = await _storage.read('userData');
|
var checkUser = await _storage.read('userData');
|
||||||
// dev.i(checkUser);
|
dev.i(checkUser);
|
||||||
if (checkUser == null) {
|
if (checkUser == null) {
|
||||||
goToLogin();
|
goToLogin();
|
||||||
} else {
|
} else {
|
||||||
|
// 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();
|
goToHomepage();
|
||||||
|
} else {
|
||||||
|
goToLogin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Navigator.pushReplacementNamed(context, 'login');
|
// Navigator.pushReplacementNamed(context, 'login');
|
||||||
});
|
});
|
||||||
@ -116,7 +132,7 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
|
|||||||
right: 15,
|
right: 15,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
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(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 10,
|
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(
|
static Future<BaseResponse?> uploadLaporan(
|
||||||
String? imgPath, String namaLaporan, String ketLaporan) async {
|
String? imgPath, String namaLaporan, String ketLaporan) async {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -22,13 +22,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.9.0"
|
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:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -63,7 +63,7 @@ dependencies:
|
|||||||
google_maps_flutter:
|
google_maps_flutter:
|
||||||
|
|
||||||
# geolocator:
|
# geolocator:
|
||||||
background_location:
|
# background_location:
|
||||||
# background_locator:
|
# background_locator:
|
||||||
# location: ^5.0.0-dev.7
|
# location: ^5.0.0-dev.7
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user